// JavaScript Document
// preset values
// (c) mercl.com 2006
//
// check platform
var os_platform = navigator.userAgent.toLowerCase();
var mac = os_platform.indexOf("mac");
if (mac > -1) {
	mac = true;
} else {
	mac = false;
};
//
var project_title = new Array();
var thmb = new Array();
var file = new Array();
//Main navigation arrays
var main_navtitle = new Array();
var main_nav_url = new Array();
var flash_player_version = 6;
//
var project_folder, thumb_width, thumb_height, pagetitle, display_format, plugin, popup, info_arr;
//
plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
// ----------------------------
// Popup
function openpopup(file_info) {
	info_arr = file_info.split(",");
	ext = file_info.split(".");
	ext = ext[1].substring(0,3);
	// header properties
	var mh = parseInt(info_arr[3])+55;
	var mw = parseInt(info_arr[2])+40;
	// head section
	popup = window.open('', 'popwin','toolbar=no, location=no, scrollbars=yes, scrolling=yes, resizable=yes, width='+mw+', height='+mh+'');
	popup.document.write('<html><head><title>Night Owl<\/title><link href="inc/style.css" rel="stylesheet" type="text/css"><\/head>');
	popup.document.write('<body topmargin="10" marginheight="10" leftmargin="10" rightmargin="10">');
	popup.document.write('<h3>'+info_arr[1]+'<\/h3>');
	// content
	if (ext == "gif" || ext == "jpg" || ext == "png") {
		popup.document.write('<img src="'+project_folder+info_arr[0]+'" border="0"><br>');
		popup.document.write('<div align="center"><a href="javascript:close();">close<\/a><\/div>');
	// video display AVI
	} else if (ext == "avi" || ext == "wmv") {
		if (mac == true) {
			popup.document.write('<p>if you\'re viewing from a mac, you\'ll need to download the WMV/Avi file directly to you computer<br><br>please <a href="'+project_folder+info_arr[0]+'">click here to download<\/a><\/p>');
		} else {
			popup.document.write('<object id="winMedia" width="'+info_arr[2]+'" height="'+info_arr[3]+'"');
			popup.document.write(' classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"');
			popup.document.write(' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"');
			popup.document.write(' standby="Loading Windows Media Player components..."');
			popup.document.write(' type="application/x-oleobject"');
			popup.document.write(' width="'+info_arr[2]+'" height="'+info_arr[3]+'" id="'+info_arr[1]+'"');
			popup.document.write('<src="'+project_folder+info_arr[0]+'">\n');
			popup.document.write('<param name="FileName" value="'+project_folder+info_arr[0]+'">\n');
			popup.document.write('<param name="AutoStart" value="True">\n');
			popup.document.write('<\/object>');
		}
	// Qtime
	} else if (ext == "mov") {
		popup.document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+info_arr[2]+'" height="'+info_arr[3]+'"');
		popup.document.write(' codebase="http://www.apple.com/qtactivex/qtplugin.cab"');
		popup.document.write('<param name="src" value="'+project_folder+info_arr[0]+'">\n');
		popup.document.write('<param name="autoplay" value="true">\n'); 
		popup.document.write('<param name="controller" value="true">\n');
		popup.document.write('<param name="loop" value="false">\n');
		popup.document.write('<embed src="'+project_folder+info_arr[0]+'" quality="high"');
		popup.document.write(' width="'+info_arr[2]+'" height="'+info_arr[3]+'"');
		popup.document.write(' autoplay="true" controller="true" loop="false" pluginspage="http://www.apple.com/quicktime/download/"');
		popup.document.write('</embed>\n');
		popup.document.write('</object>');
	}
	popup.document.write('<\/body><\/html>');
	popup.moveTo(popup_xpos,popup_ypos);
	popup.focus();
};
function close_popup() {
	popup.close();
}
// flash player check
function writePlayer() {	
	if (plugin) {
		plugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= flash_player_version;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0) {
		document.write('<script language=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+flash_player_version+'")))\n');
		document.write('if ( plugin <= 0 ) then plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+flash_player_version+'")))\n');
		document.write('<\/script\> \n');
	}
};
writePlayer();
// function
function writeRest(ourSwf,ourWidth,ourHeight,ourBg,msgOrPage,noFlashMsg) {
	if (plugin) {
	 document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	 document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"');
	 document.write(' id=flash width='+ourWidth+' height='+ourHeight+'>\n');
	 document.write('<param name=movie value="'+ourSwf+'">\n');
	 document.write('<param name=quality value=high>\n'); 
	 document.write('<param name=bgcolor value='+ourBg+'>\n'); 
	 document.write('<embed src="'+ourSwf+'" quality=high');
	 document.write(' swLiveConnect=FALSE WIDTH='+ourWidth+' HEIGHT='+ourHeight+' bgcolor='+ourBg);
	 document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n');
	 document.write('</embed>\n');
	 document.write('</object>');
	} else { 
	// if the right flash player version has not been found:
		if (msgOrPage == 1) {
			document.write('<meta http-equiv="Refresh" content="1; URL='+noFlashMsg+'">'); 
		} else if (msgOrPage == 2) { 
			popup(noFlashMsg,'noflash',350,350);
		} else if (msgOrPage == 3) { 
			document.write('<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">'+noFlashMsg+'<\/a>');
		}
	}	
};
