var xmlrequest;

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";

if (navigator.plugins && navigator.plugins.length) {
	x = navigator.plugins["Shockwave Flash"];
	if (x) {
		flashinstalled = 2;
		if (x.description) {
			y = x.description;
			flashversion = y.charAt(y.indexOf(".")-1);
		}
	} else flashinstalled = 1;
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
	x = navigator.mimeTypes["application/x-shockwave-flash"];
	if (x && x.enabledPlugin) {
		flashinstalled = 2;
	} else flashinstalled = 1;
} else MSDetect = "true";

if(flashinstalled != 2 && MSDetect=="true"){
	for(var i=9; i>0; i--){
		flashversion = 0;
		try {
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
			flashversion = i;
			break;
		}
		catch(e){
		}
	}
	if(flashversion > 0) flashinstalled=2;
}

function displayNav (thisurl) {

	if (flashinstalled == 2 && flashversion >= 7) {

		var theUrl = "firstcut.swf?thisurl="+thisurl;
		var theHeight = "600";
		var sAlign = "";

		var theWidth = "100%";
	
		theHtml  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
		theHtml += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ';
		theHtml += 'width="'+theWidth+'" height="'+theHeight+'" id="video-object">';
		theHtml += '	<param name="allowScriptAccess" value="sameDomain" />';
		theHtml += '	<param name="movie" value="'+theUrl+'" />';
		theHtml += '	<param name="loop" value="false" />';
		theHtml += '	<param name="menu" value="false" />';
		theHtml += '	<param name="quality" value="autohigh" />';
		theHtml += '	<param name="scale" value="noscale" />';
		theHtml += '	<param name="salign" value="'+sAlign+'" />';
		theHtml += '	<param name="wmode" value="transparent" />';
		theHtml += '	<embed src="'+theUrl+'" loop="false" menu="false" quality="autohigh" ';
		theHtml += 'scale="noscale" salign="'+sAlign+'" wmode="transparent" width="'+theWidth+'" height="'+theHeight+'" ';
		theHtml += 'id="video-embed" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" ';
		theHtml += 'pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		theHtml += '</object>';
	
	} else {
	
		theHtml  = '<h1><a href="./">First Cut Film Series</a></h1>';
		theHtml += '<div id="nav"><ul>';
		theHtml += '	<li><a href="contact.php" class="contact">Contact</a></li>';
		theHtml += '	<li><a href="bios.php" class="bios">Bios</a></li>';
		theHtml += '	<li><a href="about.php" class="about">About</a></li>';
		theHtml += '	<li><a href="faqs.php" class="faqs">FAQs</a></li>';
		theHtml += '	<li><a href="home.php" class="home">Home</a></li>';
		theHtml += '	<li><a href="login.php" class="apply">Apply</a></li>';
		theHtml += '	<li><a href="guidelines.php" class="guidelines">Guidelines</a></li>';
		theHtml += '	<li><a href="timeline.php" class="timeline">Timeline</a></li>';
		theHtml += '</ul></div>';
	
	}
	document.getElementById('flash').innerHTML = theHtml;

}

function openPage (thisurl) {

	if (thisurl == "home") {

		document.getElementById("content").innerHTML = "";
		document.body.className = thisurl;

	} else {

		var geturl = "output/"+thisurl+".php";
			
		xmlrequest = false;
		if (window.XMLHttpRequest) { // branch for native XMLHttpRequest object
			try {
				xmlrequest = new XMLHttpRequest();
			} catch(e) {
				xmlrequest = false;
			}
		} else if (window.ActiveXObject) { // IE/Windows ActiveX version
			try {
				xmlrequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					xmlrequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {
					xmlrequest = false;
				}
			}
		}
		if (xmlrequest) {
			xmlrequest.onreadystatechange = function() { displayPage(thisurl); };
			xmlrequest.open("GET",geturl,true);
			xmlrequest.send("");
		} else {
			if (thisurl == "home") {
				document.location = "./";
			} else document.location = thisurl+".php";
		}

	}

}

function displayPage (thisurl) {
	if (xmlrequest.readyState == 4 && xmlrequest.responseText) { // xmlrequest.status == 200 ?
		document.getElementById("content").innerHTML = xmlrequest.responseText;
		document.body.className = thisurl;
			
	} // else silently ignore errors
}