// Flash Detection ************************************************************************

var g_plugin = 0;
function detectFlash(myVersion){
	var topVersion = 20; 
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] &&    
	    navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
	
		var version_check = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0); 
		var flash_ver = parseInt(version_check.description.substring(version_check.description.indexOf(".")-2))

		if (navigator.plugins && navigator.plugins["Shockwave Flash"] && flash_ver >= myVersion)g_plugin = 1;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
		&& (navigator.appVersion.indexOf("Windows") != -1)) {
			document.write('<SC' + 'RIPT LANGUAGE=VBScript> \n');
			document.write('on error resume next \n');
			document.write('g_plugin = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + myVersion + '")))\n');
			for(var i=(myVersion+1); i<=topVersion; i++){
				document.write('if (g_plugin <= 0) then g_plugin = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + i + '")))\n');
			}
			document.write('</SC' + 'RIPT\> \n');
	}	
	if ( g_plugin != 0 ){
		return true;
	} else {
		return false;
	}
}

// Cookie functions *******************************************************

// set days = 0 for expiration on session end

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}


function clearSearch(myForm) {if (myForm.defaultValue==myForm.value) myForm.value = "";}
function showSearch(myForm) {if (myForm.value=="") myForm.value = myForm.defaultValue;}


function showNoFlashClass(){
	if(document.getElementById){if(document.getElementById('flashArea'))document.getElementById('flashArea').className='noFlash';}
	document.write('<p class="noscriptFlashDisclaimer">To view the Flash Movie, you must have Adobe Flash Player installed. Adobe Flash Player can be downloaded from the link below. The text version is also available from link below.</p>');
}

function showNoFlashClass2(){
	if(document.getElementById){if(document.getElementById('flashArea'))document.getElementById('flashArea').className='noFlash';}
	document.write('<p class="noscriptFlashDisclaimer">To view the Flash Movie, you must have Adobe Flash Player installed. Adobe Flash Player can be downloaded from the link below.</p>');
}


function emailObf(myElementID){
	if(document.getElementById){  
		addEvent2(document.getElementById(myElementID),"click", function(){doMail(document.getElementById(myElementID), 'REMOVETHISTEXT')});
	}
}

function doMail(theLink, key){

    //Get the HREF tag. This includes the anti-spam 'key'
    var before = theLink.getAttribute('href');

    //If the anti-spam key is not found in the link, exit the function without doing anything
    //If the link is clicked more than once, this prevents the Javascript from throwing an error
    if(before.indexOf(key) == -1) return false;

    //Our new variable "addy" is a combination of the text that
    //comes BEFORE the key [0] and AFTER the key [1]
    var addy = before.split(key)[0] + before.split(key)[1];

    //Substitute the original link with the new link ("addy")
    theLink.href = addy;

}


function writeCssImport2(strCssPath){
	document.write('<' + 'style type="text/css"><' + '!-- @' + 'impo' + 'rt ur' + 'l(' + strCssPath + '); --' + '><' + '/style>');
}

function writeCssImport(strCssPath){
	myStyle = document.createElement("style");
	myStyle.setAttribute("id", "altStyle");
	myStyle.setAttribute("type", "text/css");
	document.getElementsByTagName('head')[0].appendChild(myStyle);
	myStyle_content = document.createTextNode("<" + "!-- @" + "import ur" + "l(" + strCssPath + "); --" + ">");
	document.getElementById('altStyle').appendChild(myStyle_content);
}



/* SSL Detection 
/* Cookie Array:  Create Cookie Name as Key and ResponseHeader Name as value
====================================================================================*/
var arrCookie = new Array()
arrCookie["REFERRER"]="referer";
arrCookie["FROM"]="From";
arrCookie["HTTP_X_FORWARDED_FOR"]="X-Forwarded-For";
arrCookie["HTTP_VIA"]="Via";
arrCookie["HTTP_SESSION_STEP_UP"]="____";
arrCookie["HTTP_SESSION_INITIAL_CIPHER_NAME"]="____";
arrCookie["HTTP_SESSION_INITIAL_CIPHER_KEY_SIZE"]="____";
arrCookie["HTTP_SESSION_INITIAL_CIPHER_USE_SIZE"]="____";
arrCookie["HTTP_SESSION_CIPHER_NAME"]="SSL-Cipher";
arrCookie["HTTP_SESSION_CIPHER_USE_SIZE"]="____";

setResponseHeadersAsCookies();

function setResponseHeadersAsCookies() {

	xmlhttp=null;
	if(window.XMLHttpRequest)xmlhttp=new XMLHttpRequest(); // code for Firefox, Mozilla, IE7, etc.
	if(window.ActiveXObject)xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5

	if (xmlhttp!=null){
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 4){
				for(var key in arrCookie) {
					strResponseHeaderValue = xmlhttp.getResponseHeader(arrCookie[key]);					
					if(strResponseHeaderValue){
						if(!readCookie(key))createCookie(key,strResponseHeaderValue,0);
					}
				}
			}
		}
		xmlhttp.open('GET', location.href, true); 
		xmlhttp.send(null);
	}

	if((!readCookie("REFERRER"))&&(document.referrer!=""))createCookie("REFERRER",document.referrer,0); //Fix for referrer
	
}