function addOnloadEvent(func) {
    var oldonload = window.onload; 
    if (typeof window.onload != 'function') { 
        window.onload = func; 
    } else { 
        window.onload = function() { 
            if (oldonload) { 
                oldonload(); 
            } 
            func(); 
        } 
    } 
}

function readCookie(strName) {    var strNameEq = strName + "=";    var arrayCookies = document.cookie.split(';');    var strCookie;    for (var i=0; i < arrayCookies.length; i++) {        strCookie = arrayCookies[i];        while (strCookie.charAt(0) == ' ') {            strCookie = strCookie.substring(1, strCookie.length);        }        if (strCookie.indexOf(strNameEq) == 0) {            return strCookie.substring(strNameEq.length, strCookie.length);        }    }    return null;}function writeCookie(strFieldName, strData, lngExpires, strPath, strDomain, blnSecure)	{
	var strCookieData = '';
	var dtToday = new Date();
	var dtExpires_date = new Date(dtToday.getTime());
	dtToday.setTime(dtToday.getTime());

	if (lngExpires) {
		lngExpires = lngExpires*1000*60*60*24;
	} else {
		lngExpires=0;
	}

	dtExpires_date = new Date(dtToday.getTime() + (lngExpires));

	strCookieData += strFieldName + '=' + escape(strData);
	strCookieData += (((parseInt(lngExpires) > 0)&&(!isNaN(lngExpires))) ? ';expires=' + dtExpires_date.toGMTString() : '');
	strCookieData += (((strPath != '') && (strPath != null)) ? ';path=' + strPath : '/');
	strCookieData += (((strDomain != '') && (strDomain != null)) ? ';domain=' + strDomain : '');
	strCookieData += ((blnSecure == true) ? ';secure' : '');

	document.cookie = strCookieData;
}

/*<replaced with content of site_tracking.js 080728.09 DRP>
if ((document.referrer.indexOf("thunderbird.edu") == -1) && (document.referrer.indexOf("t-bird.edu") == -1) && (document.referrer != "") && (document.cookie.indexOf("referrer=") == -1)) {
	document.cookie = "referrer=" + escape(document.referrer) + "; path=/"
} 
*/
//----------------------------------------------------------------------------
/*
>>>>>Set cookies to retain referrer information for campaign so that
>>>>>user may browse the site after coming in from a campaign link
>>>>>and we still are able to tell that they found us via such a link
*/
//----------------------------------------------------------------------------
//>>>>>init inline\\global vars
var strDL=String(document.location);//<<--capture campaign details from DocumentLocation (if present)
var strDR=String(document.referrer)!=''?String(document.referrer):'www.thunder.edu';//<<--capture DocumentReferrer
var strCD='';strCD=FXstrStoreCampaignData(strDR,strDL);//<<--condition Campaign Details proper
var strQS='';
//----------------------------------------------------------------------------
//>>>>>querystring storage
if(strDR.indexOf('?')>-1)//>>>>>found querystring arguments
	{strQS=strDR.split('?')[1];}//<<--capture the querystring section
else//>>>>>do nothing
	{;}
//</if>
//>>>>>see if user is coming in from outside our domain, if so...
if ((strDR.indexOf("thunderbird.edu")== -1)&& (strDR.indexOf("t-bird.edu")== -1)&& (strDR != ""))//>>>>>store in cookie for later retrieval
	{
	FXvoidSetCookie('referrer', strCD, 90, '/', null, false);
	//>>>>>store either data or nullstring to init cookie
	FXvoidSetCookie('querystring', strQS, 90, '/', null, false);
	}
else//>>>>>do nothing, continue
	{;}
//</if>
//>>>>>see if cookie is set, if not, go ahead and set to default
if ((document.cookie.indexOf("referrer=")== -1))//>>>>>store default cookie
	{
	FXvoidSetCookie('referrer', strCD, 90, '/', '.thunderbird.edu', false);
	//>>>>>store either data or nullstring to init cookie
	FXvoidSetCookie('querystring', strQS, 90, '/', '.thunderbird.edu', false);
	}
else//>>>>>do nothing, continue
	{;}
//</if>
//----------------------------------------------------------------------------
function FXvoidSetCookie(strFieldName, strData, lngExpires, strPath, strDomain, blnSecure)
	{
	//>>>>>configure and set cookie
	var strCookieData='';
	var dtToday=new Date();
	var dtExpires_date=new Date(dtToday.getTime());
	dtToday.setTime(dtToday.getTime());
	//
	if (lngExpires)//>>>>>configure expiration proper
		{lngExpires=lngExpires*1000*60*60*24;}//<<--set time, it's in milliseconds lngExpires=days
	else//>>>>>default
		{lngExpires=0;}
	//</if>
	dtExpires_date=new Date(dtToday.getTime()+(lngExpires));//<<--update
	//>>>>>build cookie
	strCookieData+=strFieldName+'=' +escape(strData);//<<--protect data and system
	strCookieData+=(((parseInt(lngExpires)>-1)&&(!isNaN(lngExpires)))?';expires='+dtExpires_date.toGMTString(): '');
	strCookieData+=(((strPath!='')&&(strPath!=null))?';path='+strPath:'/');
	strCookieData+=(((strDomain!='')&&(strDomain!=null))?';domain='+strDomain:';domain='+document.domain.toLowerCase().replace('www.',''));
	strCookieData+=((blnSecure==true)?';secure':'');
	//>>>>>store cookie
	document.cookie=strCookieData;
	}//</FXvoidSetCookie()>
//----------------------------------------------------------------------------
function FXstrStoreCampaignData(strReferrer,strLocation)
	{
	//>>>>>capture referer and campaign data
	var strData=FXstrIsNull(String(strLocation),'?cd=&cs=&s=');
	var strCampaingData=FXstrIsNull(String(strReferrer),'ThunderEdU');
	var arrCampaingData=new Array();
	var arrPairs=new Array();//<<--shape pairs
	var intLoop=0;
	var intLoopSize=0;
	var enumKey=0;
	var enumValue=1;
	var intFieldCount=0;
	var arrStrFields=new Array('cs','cd','s','search');//<<--these are the campaign detail fields
	/*
	>>>>>because the cookie field lenght can only be so long, and various search-engine results produce
	>>>>>some decently long URL, we must condition the data just to the referring host.
	>>>>>to preseve the querystring data in case it is needed(which it should not)it will be
	>>>>>stored in another cookie not in this one
	*/
	//>>>>>conditioning
	if(strCampaingData.indexOf('?')>-1)//>>>>>found querystring arguments
		{strCampaingData=strCampaingData.split('?')[0];}//<<--remove the querystring
	else//>>>>>continue
		{;}
	//</if>
	//
	if(strData.indexOf('cs=')==-1)//>>>>>campaign details will not be found, append default data
		{
		//
		if(strData.indexOf('?')==-1)//>>>>>initial querystring
			{strData+='?';}
		else//>>>>>append to current querystring
			{strData+='&';}
		//
		strData+='cs=&cd=&s=';//<<--default nullvalues data
;		}
	else//>>>>>continue
		{;}
	//</if>
	//
	try{strData=strData.split('?')[1];}//<<--take the querystring
	catch(error){;}
	//</try>
	//
	if(strCampaingData.indexOf('?')>-1)//>>>>>append fields
		{strCampaingData+='&';}
	else//>>>>>add fields
		{strCampaingData+='?';}
	//</if>
	//
	arrPairs=strData.split('&');//<<--shape pairs
	intLoopSize=arrPairs.length;
	intSizeLoop=arrStrFields.length;
	//>>>>>fetch any campaign data
	//
	for(intLoop=0;intLoop<intSizeLoop;intLoop++)//>>>>>load found values for each field
		{arrCampaingData[arrStrFields[intLoop]]=FXstrParseArray(arrPairs,arrStrFields[intLoop]);}
	//</for>
	//
	for(intLoop=0;intLoop<intSizeLoop;intLoop++)//>>>>>append to output what we find
		{
		//
		try
			{
			//
			if(arrCampaingData[arrStrFields[intLoop]]!='')//>>>>>store
				{
				if(intFieldCount>0){strCampaingData+='&';}/*<<--insert delimiter*/else{;}//<<--do nothing
				//</if>
				strCampaingData+=arrStrFields[intLoop];
				strCampaingData+='='+arrCampaingData[arrStrFields[intLoop]];
				intFieldCount++
				}
			else//>>>>>do nothing and continue
				{;}
			//</if>
			}
		catch(error){alert(arrStrFields[intLoop]+'=\\ERR::'+error.description);}//<<--do nothing
		//</try>
		}
	//</for>
	//
	if(strCampaingData.indexOf('cs=')==-1)//>>>>>campaign details will not be found, append default data
		{strCampaingData+='cs=&cd=&s=';}//<<--default nullvalues data
	else//>>>>>continue
		{;}
	//</if>
	return(strCampaingData.replace('&&','&'));
	}//</FXstrStoreCampaignData()>
//----------------------------------------------------------------------------
function FXstrParseArray(arrPairs,strLookFor)
	{
	//>>>>>parse through array and return value for key if found else nullstring
	var enumKey=0;
	var enumValue=1;
	var intLoop=0;
	var intLoopSize=arrPairs.length;
	var strKey='';
	var strValue='';
	var strReturn='';
	//
	for(intLoop=0;intLoop<intLoopSize;intLoop++)
		{
		strKey=arrPairs[intLoop].split('=')[enumKey];
		strValue=arrPairs[intLoop].split('=')[enumValue];
		//
		if(strKey.toLowerCase()==strLookFor.toLowerCase())//>>>>>found key
			{strReturn=strValue;}
		else//>>>>>do nothing and continue
			{;}
		//
		}
	//</for>
	//
	return(strReturn);
	}//</FXstrParseArray()>
//----------------------------------------------------------------------------
function FXstrIsNull(strInput, strDefault)//<<--return the default if input is null
	{return(((strInput!='')&&(strInput!=null)&&(strInput!=undefined)&&(strInput!='undefined'))?strInput:strDefault);}
//----------------------------------------------------------------------------

