/* ================================================================================================== */
/* Search Functions */

function ClearSearch() {
	try {
		var element = window.document.getElementById('SearchKeywords');
		if(element.value=='Search'){
			element.value='';
		}else{}
	} catch(e) {}
}

function WriteSearch() {
	try {
		var element = window.document.getElementById('SearchKeywords');
		if(element.value==''){
			element.value='Search';
		}else{}
	} catch(e) {}
}

ReplaceSearch = function() {
	try {
		var elements = window.document.getElementById('SearchKeywords');
		if(window.addEventListener){	
			elements.addEventListener('focus', ClearSearch, true);
			elements.addEventListener('blur', WriteSearch, true);	
		}else{
			elements.attachEvent("onfocus",ClearSearch);
			elements.attachEvent("onblur",WriteSearch);
		}
	} catch(e) {}
}

/* END Search Functions */
/* ================================================================================================== */



/* ================================================================================================== */
/* Jump Menu Functions */

// Use this function to jump user to another page
function JumpRedirect(strAddress) {
	try {
		if (strAddress != "") {
			//alert(strAddress);
			window.location.href=strAddress;
		}
	} catch(e) {}
}

// Add jump menu script -- uses JumpRedirect()
AttachJump = function() {
	try {
		var element = document.getElementById('JumpMenu');
		element.onchange = function(){JumpRedirect(element.value);}
	} catch(e) {}
}

/* END Jump Menu Functions */
/* ================================================================================================== */



/* ================================================================================================== */
/* Cookie Functions */

function createCookie(name,value,days) {
	try {
		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=/";
	} catch(e) {}
}

function readCookie(name) {
	try {
		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;
	} catch(e) {}
}

function eraseCookie(name) {
	try {
		createCookie(name,"",-1);
	} catch(e) {}
}

// Managing style cookies, attaching to links

function SetStyleCookie(name,value,days) {
	try {
		eraseCookie(name);
		//alert('cookie erased');
		createCookie(name,value,days);
	} catch(e) {}
}

// Font Size cookies

function ResetSize() {
	try {
		SetStyleCookie('size','',30);
	} catch(e) {}
}

function LargeStyle() {
	try {
		SetStyleCookie('size','large',30);
	} catch(e) {}
}

function LargerStyle() {
	try {
		SetStyleCookie('size','larger',30);
	} catch(e) {}
}

AttachCookieLinks = function() {
	try {
		var Link1 = window.document.getElementById('DefaultSize');
		if(window.addEventListener){	
			Link1.addEventListener('click', ResetSize, true);
		}else{
			Link1.attachEvent("onclick",ResetSize);
		}
		var Link2 = window.document.getElementById('Large');
		if(window.addEventListener){	
			Link2.addEventListener('click', LargeStyle, true);
		}else{
			Link2.attachEvent("onclick",LargeStyle);
		}
		var Link3 = window.document.getElementById('Larger');
		if(window.addEventListener){	
			Link3.addEventListener('click', LargerStyle, true);
		}else{
			Link3.attachEvent("onclick",LargerStyle);
		}
	} catch(e) {}
}

/* END Cookie Functions */
/* ================================================================================================== */



/* ================================================================================================== */
/* Read Query String */

function ReadQuery () {
	try {
		var queryValue = location.search;
		if (queryValue.match("WillExpire") != null) {
			var lastChar = queryValue.indexOf("&");
			if (lastChar == -1) {
				lastChar = queryValue.length;
			}
			alert("Your password will expire in "+queryValue.substring(12,lastChar)+" days. You can change your password using My Information - Change Password.");
		}
	} catch(e) {}
}

/* END Query String */
/* ================================================================================================== */



/* ================================================================================================== */
/* Attaching functions to events */

if(window.addEventListener) { // gecko, safari, konqueror and standard
	window.addEventListener('load', ReplaceSearch, false);
	window.addEventListener('load', AttachCookieLinks, false);
	window.addEventListener('load', AttachJump, false);
	window.addEventListener('load', ReadQuery, false);
} else if(document.addEventListener) {  // opera 7
	document.addEventListener('load', ReplaceSearch, false);
	document.addEventListener('load', AttachCookieLinks, false);
	document.addEventListener('load', ReadQuery, false);
	document.addEventListener('load', AttachJump, false);
} else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', ReplaceSearch);
	window.attachEvent('onload', AttachCookieLinks);
	window.attachEvent('onload', AttachJump);
	window.attachEvent('onload', ReadQuery);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			ReplaceSearch();
			AttachCookieLinks();
			AttachJump();
			ReadQuery();
		}
	} else {
		window.onload = function() {
			ReplaceSearch();
			AttachCookieLinks();
			AttachJump();
			ReadQuery();
		}
	}
}

/* End Attach */
/* ================================================================================================== */



/* ================================================================================================== */
/* Write Flash Objects */

function WriteFlash(SWFPath,SWFWidth,SWFHeight,SWFParams) {
	try {
		var str = '\n';
		var NewParams = '';
		str+='	<object type="application\/x-shockwave-flash" data="' + SWFPath + '" width="' + SWFWidth + '" height="' + SWFHeight + '" title="">\n';
		str+='		<param name="wmode" value="transparent">\n';
		str+='		<param name="movie" value="' + SWFPath + '">\n';
		if(typeof(SWFParams) != "undefined"){
			var SWFParamsArray = SWFParams.split(';');
			for (var i=0; i<SWFParamsArray.length; i++) {
				var EachParam = SWFParamsArray[i].split(',');
				NewParams+='		<param name="' + EachParam[0] + '" VALUE="' + EachParam[1] + '">\n';
			}
			str+=NewParams;
		}
		str+='	<\/object>\n';
		document.write(str);
	} catch(e) {}
}

function WriteFlashVid(VidFile,ThumbFile) {
	try {
		var s1 = new SWFObject("/files/flash/flvplayer.swf","single","320","240","7");
		s1.addParam("allowfullscreen","true");
		s1.addVariable("file",VidFile);
		s1.addVariable("image",ThumbFile);
		s1.addVariable("width","320");
		s1.addVariable("height","240");
		s1.addVariable("autostart","true");
		s1.addVariable("overstretch","none");
		s1.addParam("wmode","transparent");
		s1.write("VideoBlock");
	} catch(e) {}
}

/* End Flash */
/* ================================================================================================== */