// JS Flash Detection
// Flash detection
var requiredVersion7 = 7;
var requiredVersion4 = 4;
var useRedirect 	= false; 
var flash2Installed = false;    
var flash3Installed = false;     
var flash4Installed = false;     
var flash5Installed = false; 
var flash6Installed = false;
var flash7Installed = false;
var flash8Installed = false;
var flash9Installed = false;
var flash10Installed = false;   
var maxVersion = 10;  
var actualVersion = 0;     
var hasRightVersion7 = false;     
var hasRightVersion4 = false; 
var jsVersion = 1.0;

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
jsVersion = 1.1;

if(isIE && isWin)
{ 
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
	document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
	document.write('flash10Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))) \n');
	document.write('</SCR' + 'IPT\> \n'); // break up end tag so it does n0t end our script
}

if (navigator.plugins)
{ 
	if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"])
	{
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		flash2Installed = flashVersion == 2;     
		flash3Installed = flashVersion == 3;
		flash4Installed = flashVersion == 4;
		flash5Installed = flashVersion == 5;
		flash6Installed = flashVersion == 6;
		flash7Installed = flashVersion == 7;
		flash8Installed = flashVersion == 8;
		flash9Installed = flashVersion == 9;
		flash10Installed = flashVersion == 10;
	}
}

for (var i = 2; i <= maxVersion; i++) {if (eval("flash" + i + "Installed") == true) actualVersion = i;}

if (navigator.userAgent.indexOf("WebTV") != -1) {actualVersion = 2;}      


// Set 2 flags
hasRightVersion7 = (actualVersion >= requiredVersion7);	
hasRightVersion4 = (actualVersion >= requiredVersion4);	


// Javascript-to-Flash functions from http://www.moock.org/webdesign/flash/fscommand/
var movieName = "testcommand";

function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window[movieName]
  }	else {
    return document[movieName]
  }
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
    return theMovie.PercentLoaded() == 100;
  } else {
    return false;
  }
}


function playmovie() {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).Play();
  }
}

function stopmovie() {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).StopPlay();
  }
}


function go(theFrame) {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).GotoFrame(theFrame);
  }
}

function golabel() {
  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).TGotoLabel("_level0/","do_sound");
  }
}




// Control what is visible (state: 0=out, 1=over, 2=click)
function control_home_promos(nav_item, state)
{
	// Remember: Home has no selected state
	
	// Trigger a sound
	if (state == 1 && hasRightVersion4 && isWin)
	{
		golabel();
	}
	




}




/*
	tableruler()
	written by Chris Heilmann for alistapart.
	enables a rollover of rows for each table with the classname "hlrows"
*/

function tableruler(table_name)
{
	if (document.getElementById && document.createTextNode)
	{
		var tables=document.getElementsByTagName('table');
		
		for (var i=0;i<tables.length;i++)
		{
			if(tables[i].className == table_name)
			{
				var trs=tables[i].getElementsByTagName('tr');
				
				for(var j=0;j<trs.length;j++)
				{
					if(trs[j].parentNode.nodeName=='TBODY')
					{
						trs[j].onmouseover=function(){this.className='ruled';return false}
						trs[j].onmouseout=function(){this.className='';return false}
					}
				}
			}
		}
	}
}


function open_win (pop_url, pop_width, pop_height, pop_scrollable, pop_resizeable, pop_status, pop_toolbar, pop_titlebar)
{
	// Window position
	winLeft = Math.floor((screen.width - pop_width) / 2);
	winTop =  Math.floor((screen.height - pop_height) / 2);
	
	
	// Window arguments
	var wargs_a = "width=" + pop_width + ",height=" + pop_height + ",resizable=" + pop_resizeable + ",scrollbars=" + pop_scrollable;
	var wargs_b = ",menubar=" + pop_toolbar + ",status=" + pop_status + ",titlebar=" + pop_titlebar + ",toolbar=" + pop_toolbar + ",z-lock=1,";
	var wargs_c = "location=" + pop_toolbar + ",personalbar=" + pop_titlebar + ",";
	var wargs_d = "screenX=" + winLeft + ",screenY=" + winTop + ",left=" + winLeft + ",top=" + winTop;
	var wargs = wargs_a + wargs_b + wargs_c + wargs_d;
	

	// Random name generator
	var rand_num = Math.floor(Math.random()*10000);
	//alert (rand_num);
	
	// Open the window
	var ext_window = window.open(pop_url, '1b' + rand_num, wargs);
	ext_window.focus()
}



// Old school image preloader

function MM_swapImgRestore() 
{
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("http://www.lincolnharbor.net#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




// Random image selection with cookie
function image_random(random_image)
{
	document.write ('<a href="register_to_win/"><img src="home/imagefolder/home_header_' + random_image + '.gif" ');
	document.write ('width="568" height="264" border="0" alt="" /></a>\n');
}

// COOKIE CONTROLS FOR RANDOMLY-SELECTED FACTOIDS

// Set cookie
function cookie_set (name, value)
{
	var path = "/";
	
	// Set the cookie
	document.cookie = name + "=" + escape (value) + "; path=" + path;
}


// Get a random number between lo and hi that is different from the current value
function rand_val(lo, hi, current_val)
{
	do {rand_num = Math.round(Math.random(1)*10);}
	while (rand_num < lo || rand_num > hi || rand_num == current_val);
	
	return rand_num
}


// Set the value of the cookie
function cookie_val(val)
{
	// Set a cookie different that the current cookie
	smile_cookie_01_val = rand_val(0, 2, val)		
	
	cookie_set("smile_cookie_01", smile_cookie_01_val)
}


// The following cookie functions are used to control the intro image
// Check for session cookie
function cookie_get(name) 
{ 
	// Check for cookie 
	var index = document.cookie.indexOf(name + "=");
    if (index == -1) return null;

	// Extract the cookie
	index = document.cookie.indexOf("=", index) + 1;
	var endstr = document.cookie.indexOf(";", index);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(index, endstr));
}

// Set the cookie
function cookie_init()
{
	// Declare a cookie var
	smile_cookie_01_val = cookie_get("smile_cookie_01");
	
	// Set the document.cookie to cookie var
	cookie_val(smile_cookie_01_val);
	
	// Set the img_rand var to a new value
	img_rand = smile_cookie_01_val;
	
}

// Set the value
img_rand = 0;
cookie_init();


