// JavaScript Document

winHeight = 450;
winHeightBig = 613;
winWidth = 720;
winWidthBig = 980;
winName = 'BGI';




function popup(pageToLoad, winName, width, height, id) {

	myid = id;
	window.location = pageToLoad;
	
/*
	windowName = (Math.round((Math.random()*99999)+1));
	xposition=0; yposition=0;
	isOpen = false;
	redirectPage = pageToLoad;
	
	if (parseInt(navigator.appVersion) >= 4){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	
	args = "width=" + width + "," + "height=" + height + "," + "location=0," + "menubar=0," + "resizable=1," + "scrollbars=0," + "status=0," + "titlebar=0," + "toolbar=0," + "hotkeys=0," + "screenx=" + xposition + "," + "screeny=" + yposition + "," + "left=" + xposition + "," + "top=" + yposition;           
	popup[windowName] = window.open(pageToLoad,"popup_win",args);
	
	//call window that checks if the pop up actually opened.
	callWindow(id)
	
	*/
	
}
	
function callWindow(id) {

	
	//wait 2 seconds and call a function in the pop up window.
	setTimeout('theCaller()', 2000);

	//wait 4 seconds and call a local function that handles logic if pop up doesn't exist.
	setTimeout('windowCheck('+id+')', 3000);


}

function theCaller() {

	try {
		popup[windowName].checkIfOpen()

	} 
	
	catch(errorObject) {
		windowCheck(myid)
	}
}

//window.onError=silentErrorHandler()

function silentErrorHandler() {
	//windowCheck();
	return true
}

function windowCheck(id) {

	
 	if (isOpen) {
 		//nothing opened, they must have a pop up stopeper so lets redirect them to a warning page or the page that was suppose to open in the pop up.
 		//window.location = 'nopopup.cfm?id='+myid;
	} 
	else {
		window.location = 'nopopup.cfm?id='+myid;
		//window.location = '_thankyou.cfm';
	}



}




function openFlashSite(lang, id) {
	//add width detection to this function
	//alert('forefront.cfm?'+stats);
	//alert(id);
	
	stats = "browser_name="+ navigator.appName +"&width="+screen.width+"&height="+screen.height+"&flash_version="+flashVersion;
	document.getElementById("id").value = id;
	document.getElementById("languageID").value = lang;
	document.getElementById("browser_name").value = navigator.appName;
	document.getElementById("width").value = screen.width;
	document.getElementById("height").value = screen.height;
	document.getElementById("flash_version").value = flashVersion;
	
	document.getElementById("launchSite").submit();
	/*
	if (id == undefined) {
		id = 0;
	}
	if (screen.width > 800) {
		//alert('/forefront/forefront.cfm?id='+id+'&languageID='+lang+'&'+stats);
 		popup('/forefront/forefront.cfm?id='+id+'&languageID='+lang+'&'+stats,winName,winWidthBig,winHeightBig, id);
	} else {
		popup('/forefront/forefront.cfm?id='+id+'&languageID='+lang+'&'+stats,winName,winWidth,winHeight, id);
	}
	
	*/
	
	//window.location = '/forefront/forefront.cfm';
	
	
}

//flash detector for content
var contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i = 0; i < words.length; ++i)
		{
		if (isNaN(parseInt(words[i])))
		continue;
		var pluginVersion = words[i]; 
		}
	var flashCanPlay = pluginVersion >= contentVersion;
}

else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('flashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}


///////////////////////////////////////////////////
//tracking js
///////////////////////////////////////////////////

var flashVersion = 0;
var agent = navigator.userAgent.toLowerCase(); 

// NS3 needs flashVersion to be a local variable
if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
  flashVersion = 0;
}

// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
if (navigator.plugins != null && navigator.plugins.length > 0) {
	var flashPlugin = navigator.plugins['Shockwave Flash'];
	if (typeof flashPlugin == 'object') { 
		if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
		else if (flashPlugin.description.indexOf('6.') != -1) flashVersion = 6;
		else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
		else if (flashPlugin.description.indexOf('4.') != -1) flashVersion = 4;
		else if (flashPlugin.description.indexOf('3.') != -1) flashVersion = 3;
	}
}

// IE4+ Win32:  attempt to create an ActiveX object using VBScript
else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
    document.write('<scr' + 'ipt language="VBScript"\> \n');
	document.write('on error resume next \n');
	document.write('dim obFlash \n');
	document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
	document.write('if IsObject(obFlash) then \n');
	document.write('flashVersion = 7 \n');
	document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
	document.write('if flashVersion < 7 and IsObject(obFlash) then \n');
	document.write('flashVersion = 6 \n');
	document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
	document.write('if flashVersion < 6 and IsObject(obFlash) then \n');
	document.write('flashVersion = 5 \n');
	document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
	document.write('if flashVersion < 5 and IsObject(obFlash) then \n');
	document.write('flashVersion = 4 \n');
	document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") end if \n');
	document.write('if flashVersion < 4 and IsObject(obFlash) then \n');
	document.write('flashVersion = 3 \n');
	document.write('end if \n');
	document.write('</scr' + 'ipt\> \n');
}
	
// WebTV 2.5 supports flash 3
else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

// older WebTV supports flash 2
else if (agent.indexOf("webtv") != -1) flashVersion = 2;

// Can't detect in all other cases
else {
	flashVersion = flashVersion_DONTKNOW;
}

stats = "browser_name="+ navigator.appName +"&width="+screen.width+"&height="+screen.height+"&flash_version="+flashVersion;

//alert(stats);
//window.location = url;