var pn_value;
var visits;
/* onload handler setter */
var window_onload = new Array;
var onloadRef = window.onload;

/*
    window.ie - will be set to true if the current browser is internet explorer (any).
	window.ie6 - will be set to true if the current browser is internet explorer 6.
	window.ie7 - will be set to true if the current browser is internet explorer 7.
 	window.khtml - will be set to true if the current browser is Safari/Konqueror.
	window.gecko - will be set to true if the current browser is Mozilla/Gecko.
*/

if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.khtml = true;
else if (document.getBoxObjectFor != null) window.gecko = true;

window.onload = function() {
 	if (onloadRef != null) {
		onloadRef();
	}
	// for (var i =  window_onload.length; i >= 0; i--){ //Why is this running backwards?
	for (var i = 0; i < window_onload.length; i++) {
		//alert(window_onload);
		eval(window_onload[i]);
	}
	//window_onload[i] = "";
};

function onload_register(func) {
	window_onload.push(func);
	/*
	var notIn = false;
	//alert("onload_register: "+ func);
	alert(window_onload);
	for (var i = 0; i < window_onload.length; i++) {
        if (window_onload[i] == func) {
            notIn = true;
			i = window_onload.length + 2; // GET OUT
        }
    }
	if (!notIn){
		//alert("onload_register: "+ func);
		window_onload.push(func);
	}
	*/
}
/* end onload handler */




//collect the value of the page name and use it to make the cookie unique.
function getName(){
	var dl = window.location;
	//if the browser has no file name, then name it the index page.
	if(document.location.pathname.indexOf(".htm") <= -1 && document.location.pathname.indexOf(".aspx") <= -1){
		var pname = dl+"/index.html";
	}else{
		var pname = window.location.toString();
	}
	var pn_split = pname.split("/");
	var pn_string = pn_split[pn_split.length - 1].toString();
	var pns_split = pn_string.split(".");
	var pn_id = pns_split[0].toString();
	pn_value = pn_id.toLowerCase();
	(pn_value);
	return pn_value;
}
DaysToLive = 1;
function GetCookie(name) {
	// Start by assuming no cookie exists.
	//javascript:alert("name : "+name);
	var cookiecontent = '0';
	if(document.cookie.length > 0) {
	 // Determine begin position of the cookie with the specified name.
	 var cookiename = name + '=';
	 var cookiebegin = document.cookie.indexOf(cookiename);
	 // Initialize the end position at zero.
	 var cookieend = 0;
	 // If a cookie with the specified name is actually available ...
		if(cookiebegin > -1) {
			 // Offset the begin position of the cookie by the lengh of the cookie name.
			 cookiebegin += cookiename.length;
			 // Determine the end position of the cookie.
			 cookieend = document.cookie.indexOf(";",cookiebegin);
			 if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
				 // Put the cookie into our own variable "cookiecontent".
			 cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
	}
	// Increment cookie content by 1 and store in variable "value".
	var value = parseInt(cookiecontent) + 1;
	// Put the incremented value as a new cookie on the visitor's hard drive.
	PutCookie(name,value);
	// Return the incremented value to the calling line of code.
	return value;
}
	
	// This function puts the cookie on the visitor's hard drive.
function PutCookie(n,v) {
	// Begin by assuming no expiration date is applicable.
	var exp = '';
	if(DaysToLive > 0) {
		 var now = new Date();
		 var then = now.getTime() + (DaysToLive * 24 * 60 * 60 * 1000);
		 now.setTime(then);
		 exp = '; expires=' +
		 now.toGMTString();
	}
	document.cookie = n + "=" + v + '; path=/' + exp;

}

// the variable to hold the flash name
var flashName;
var seedID = Math.floor(Math.random()*11111);
/*Turn on rendering div*/



//JESSE COPY THIS FUNCTION  ----------------------------------------------------------------------------------------------------------------------------------------
function showFlash(argSwf, argElement, argFlashVars, overrideLowBand) {
	
	if (argElement == "model_image") {
		var clone = $(argElement).getFirst().clone().injectAfter('colors');
		clone.addClass('print');
	}
	// cache buster for IE7 redraw issues 
	if (argElement == "promos") {
		argSwf += "?r="+new Date().getTime();
	}
	var individualID = Math.floor(Math.random()*11111);
	/*
	    Prepare to load in the Flash rendering engine.
	    Uses Unobtrusive Flash Objects by Bobby van der Sluis
	    http://www.bobbyvandersluis.com/ufo/
	*/
        
        if(overrideLowBand){
			userData.bandwidth = "high";

	//Bake the userData cookie
	Cookie.set('userdata', Json.toString(userData), {duration: 365, path: "/"});
	}

        var isSafari = "";
 	navigator.userAgent.indexOf("Safari")>= 0 ? isSafari = true : isSafari = false;

	var isLTOpera92 = "";
 	navigator.userAgent.indexOf("Opera") >= 0 && parseFloat(navigator.appVersion) < 9.2 ? isLTOpera92 = true : isLTOpera92 = false;

	//Should Flash even be shown? (does user want it / can their browser support Flash 8 functionality)


	if ((userData.bandwidth != "low" && isLTOpera92 == false) || overrideLowBand ) {
	var site_config = {
	    	'host':location.host,
	    'src':location.href,
	    'title':document.title,
	    	'isSafari':isSafari,
	'isLTOpera92':isLTOpera92,
	    	'EOF':'EOF'
	};
	
	var flash_vars = '';
	for (k in site_config) {
		if (k != "toJSONString") {
			flash_vars += "&"+k+"="+encodeURIComponent(site_config[k]);
		}
	}
	//alert(location.href.substr(location.href.indexOf("?")+1, location.href.length));
	//alert(location.href.indexOf("?"));
	// deep link
	if (location.href.indexOf("?") != -1) {
		flash_vars += "&"+location.href.substr(location.href.indexOf("?")+1);
	}
	// add local connect sound vars 
	flash_vars += "&localconnect_seed="+seedID;
	flash_vars += "&localconnect_id="+individualID;
	
	//flash_vars += "&argMLC=" + hbx.mlc;
	if ($(argElement)) {
		var render_foo = document.getElementById(argElement);
		render_foo.style.display = 'block';
	}
	// set the name fo the flash based on the div 
	flashName = argElement+'_flash';
	if (argFlashVars != null) {
		flash_vars += argFlashVars;
	}

	var debug_html = getParameter('flash');
	var flash_version;
	if (debug_html == "false" && debug_html != "") {
		flash_version = 10;
	} else {
		flash_version = 8;
	}


	var FO = {
		movie:argSwf, 
		width:"100%", 
		height:"100%", 
		name:flashName, 
		id:flashName, 
		allowscriptaccess:"always", 
		bgcolor:"#FFFFFF", 
		scale:"noscale", 
		wmode:"transparent", 
		play:"true", 
		quality:"high", 
		menu:"false", 
		majorversion:flash_version, 
		build:"0", xi:"false", 
		flashvars:flash_vars
		};
	UFO.create(FO, argElement);
                } else {
		$(argElement).style.visibility = 'visible';
                }

                if (!(hasFlashMin())){
			$(argElement).setHTML("<a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW' title='Get Flash'><img src='/Hansons/images/no_flash.png' /></a>");
		}

}


//JESSE END COPY THIS FUNCTION  ----------------------------------------------------------------------------------------------------------------------------------------









//----------------------------------------------------------------------------------------------------------------------START CODE BRICK FOR JOHN 
//--------------------------THE PATH TO THE no_flash.png NEEDS TO BE UPDATED TO ACCOMODATE FOR YOU SERVER PATHS        --------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>Look down   ||  <img src='/Hansons/images/no_flash.png' />.
function fCheckUserSettings(){
	
	if (!(hasFlashMin())){
			$('media').setHTML("<a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW' title='Get Flash'><img src='/Hansons/images/no_flash.png' /></a>");
		}
	
}

// External Interface hack for IE out of memory error
function nullFlashLoopFunction() { __flash_savedUnloadHandler = null; }
window.onbeforeunload = nullFlashLoopFunction;

function hasFlashMin(){
	var debug_html = getParameter('flash');
	var flash_version;
	if(debug_html == "false" && debug_html !=  ""){
		flash_version = 10;
	}else{
		flash_version = 8;
	}
	return(UFO.hasFlashVersion(flash_version,0));
}
//----------------------------------------------------------------------------------------------------------------------END CODE BRICK FOR JOHN








<!--
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function Hansons_DoFSCommand(command, args) {
	var HansonsObj = isInternetExplorer ? document.all.Hansons : document.Hansons;
	if (command == "media") {
	 alert("fsCommand called");
	 var visibleChange = new Fx.Style('myElement', 'visiblility', {duration:500});
		visibleChange.start(false);
		alert("close div");
	 }
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub Hansons_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call Hansons_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
//-->


var userData = new Object;
function getUserData(){

	cookieUserData = Cookie.get('userdata');

	if(cookieUserData) {
		//Decompress JSON values of userData
		userData = eval('(' + cookieUserData + ')');
	}

	if(Cookie.get('zipcode')) {
		userData.zipcode = Cookie.get('zipcode');
	}

	//Bake the userData cookie
	Cookie.set('userdata', Json.toString(userData), {duration: 365, path: "/"});


}


/*Universal function to get parameter from url srting */
function getParameter(aP){var qS = new String(location.search.substring(1,location.search.length));var p = qS.split("&");var val = "";if(aP){for(i=0;i<p.length;i++){if(p[i].split( "=" )[0] == aP){val = p[i].split( "=" )[1];}}return val;}}
