/* Javascript Flash Player/Displayer.  
	

*/

/*  MovieDiv is where the second movie is.  SplashDiv is the div container that plays the flash.
*/


/*  Flash detection software.  Returns flashinstalled == 2 if flash is installed, and returns
flashversion as value of flash. Returns 1 if unsure.  Returns 0 if definitely not installed. */
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;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
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";


	
var flashloadfine = false;

/*	The flash should call "splashLoaded()" on the first frame.  This tells the
	Javascript that the flash loaded, and so the user must have at least had the chance to see it.
*/
function splashLoaded() {
	flashloadfine = true;	
}


/*	The flash should call 'closePolarVideo()' when the video is requested to be closed.
	Clicking on the box in general should cause this same effect.
*/
function closePolarVideo() {
	if (flashloadfine) {
		document.getElementById("flash_content").style.display='none';
			document.body.style.overflow='auto';
			document.body.style.width='auto';
			document.body.style.height='auto';
		document.getElementById("flash_content").innerHTML = '&nbsp;';
		setCookie('firstviz','true','');
		if (document.getElementById("portfolioSelect")) {
			document.getElementById("portfolioRollOut").style.display='';
			document.getElementById("portfolioSelect").style.display='';
		}
	} else {
		document.getElementById("flash_content").style.display='none';
	}
	return;
}
function openPolarVideo() {
	if ((flashinstalled < 2) && (!MSDetect)) {
		document.getElementById("flash_content").style.display='none';
	} else {
		document.getElementById("flash_content").style.display='block';
		document.getElementById("flash_content").innerHTML = '<embed wmode="transparent" src="/polardesign-v02.swf" quality="high" bgcolor="#ffffff" name="flash-page-001" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" style="width: 100%; height: 100%;"></embed>';
			document.body.style.overflow='hidden';
			document.body.style.width='100%';
			document.body.style.height='100%';
		if (document.getElementById("portfolioSelect")) {
			document.getElementById("portfolioRollOut").style.display='none';
			document.getElementById("portfolioSelect").style.display='none';
		}
	}
	return;
}

function loadNoSplash() {
	setCookie('firstviz','true','');
	document.getElementById("flash_content").style.display='none';
}







/* Cookie Creation and checking
*/

function setRewCookie() {
	document.cookie = 'visited=true; expires=Mon, 31 Dec 2010 23:59:59 UTC; path=/';
	return;
}
function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie = c_name + "=" + escape(value) +
	                  ((expiredays == null) || (expiredays == '') ? "" : ";expires=" + exdate.toGMTString());

}

function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start != -1) { 
			c_start = c_start + c_name.length+1 ;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		} 
	}
	return "";
}

function rewCookieTest() {
	if(getCookie('firstviz') == 'true') { return true; }
	else { return false; }
}




