/**
 * @author dave
 */
// func to display video and hide content
// ------- Private vars -------
var jsReady = false;

// ------- functions called by ActionScript -------
// called to check if the page has initialized and JavaScript is available
function isReady()
{
    return jsReady;
}

// called by the onload event of the <body> tag
function pageInit()
{
    // Record that JavaScript is ready to go.
    jsReady = true;
}

function playVideo(){
	//processAjax("video.html");
	document.getElementById("logo-container").innerHTML = "<img src=\"images/4alarmstudio_logo_static.gif\"/>";
	
	var soVideo = new SWFObject("flash/4AlarmVideo.swf", "video", "862", "360", "8", "#000000");
	soVideo.addParam("wmode", "transparent");
	soVideo.addParam("allowScriptAccess", "sameDomain");
	soVideo.write("videoOverlayTarget");
	
	document.getElementById("videoOverlay").style.display = 'block';	
	document.getElementById("leftColumn").style.display = 'none';	
	document.getElementById("rightColumn").style.display = 'none';
}

function closeVideo(){
	document.getElementById("videoOverlayTarget").innerHTML = "";
	document.getElementById("videoOverlay").style.display = 'none';	
	document.getElementById("leftColumn").style.display = 'block';	
	document.getElementById("rightColumn").style.display = 'block';	
	
	var so = new SWFObject("flash/logo.swf", "logo", "136", "107", "0", "#000000");
	so.addParam("wmode", "transparent");
	so.addParam("allowScriptAccess", "sameDomain");
	so.write("logo-container");
}

function displayPortfolio ( fullSource, brand, program, agency ) {
	//alert("Load: " + brand);
	//document.getElementById("portfolio-feature").innerHTML = "<img src=\"" + fullSource + "\" />";	
	thisMovie("portfolioDisplay").updatePortfolio(fullSource);	
	document.getElementById("portfolio-header").innerHTML = "BRAND: " + brand + " &nbsp;&nbsp; PROGRAM: " + program + " &nbsp;&nbsp; AGENCY: " + agency + "";
}

function displayCaseStudy(fullSource, brand, program, agency, content){
	//processAjax(content + ".html");
	thisMovie("portfolioDisplay").updatePortfolio(fullSource);	
	document.getElementById("portfolio-header").innerHTML = "BRAND: " + brand + " &nbsp;&nbsp; PROGRAM: " + program + " &nbsp;&nbsp; AGENCY: " + agency + "";
	document.getElementById("portfolio-content").innerHTML = content;
}

/*
function sendToActionScript(value) {
	thisMovie("ExternalInterfaceExample").sendToActionScript(value);
}
*/

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
         return window[movieName];
     } else {
         return document[movieName];
     }
}
     
function processAjax(url) {		
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
		req.onreadystatechange = targetDiv;
		try {
			req.open("GET", url, true);
		} catch (e) {
			//alert(e);
		}
		req.send(null);
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = targetDiv;
			req.open("GET", url, true);
			req.send();		
		}
	}
}


function targetDiv() {
	if (req.readyState == 4) { // Complete
		if (req.status == 200) { // OK response
			document.getElementById("videoOverlay").innerHTML = req.responseText;
		} else {
			//alert("Problem: " + req.statusText);
		}
	}
} 