window.onload = function() {
	setCookie();
}


function setCookie(){
//let's set/get a cookie so that we can track all of the users events on this site
expireDate = new Date;

expireDate.setMonth(expireDate.getMonth()+6);
user = "pass";
if(document.cookie != ""){
user = document.cookie.split("=")[1];
//detect for flash Version
//allowDetect();

}else{

allowDetect();
}
}

function Cookie(user, expire){

document.cookie = "tbwaUser=" +user+ ";expires=" + expire;

setCookie();
}


function allowDetect(){

//function for detecting Flash Version
function pluginInfo() {
//set min version need for this site
versionNeeded = 7;

//set the URL to go to if they fail the test
directToFail = '/upgradeflash.html';




if(window.navigator.plugins){
	var PI = window.navigator.plugins;
		for(var i =0; i < PI.length; i++){
			if(window.navigator.plugins[i].name.indexOf('Flash') != -1){
			var vers = window.navigator.plugins[i].description.charAt(16);
 			}
		}
return vers;

}else {
//the browser cannot understand the request for plug-in info
return 'fail';
}
 
}

// Detect WIN/IE Configuration and throw VB at it to get the flash version
if(navigator.appVersion.indexOf("MSIE") != -1){var IE = true}else{ var IE = false;}
if(navigator.appVersion.toLowerCase().indexOf("win") != -1){var WIN = true}else{ var WIN = false;}

// This is a js1.1 code block, so make note that js1.1 is supported.
jsVersion = 1.1;

// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
if(IE && WIN){
	winVB();
}

function winVB(){


  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('winV = 0 \n');
  document.write('on error resume next \n');
  
  document.write('For i = 2 to 8 \n');
  document.write('\tIf Not (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then\n');  
  document.write('Else \n'); 
  document.write('winV = i \n');
  document.write('End If \n');
  document.write('Next \n');

  document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script


}

if(pluginInfo() == 'fail'){alert('This page requires a Flash '+versionNeeded+' plug-in.');window.location = directToFail;}//this means that we failed the first test, and cannot read the plug-in info
else{ //passed that basic test, now we get the returns of which version the user has
var flashVersion;
	if(pluginInfo()){ flashVersion = pluginInfo();}else{flashVersion = winV;}
//finally, if the result is >= the desired plug-in, we pass. Else, we fail
if(flashVersion >= versionNeeded){Cookie(user, expireDate);}else{alert('This page requires a Flash '+versionNeeded+' plug-in. You have version '+flashVersion);window.location = directToFail;}
}

}//end Allow detect