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) {}
}


if(window.addEventListener) window.addEventListener('load', ReplaceSearch, false); // gecko, safari, konqueror and standard
else if(document.addEventListener) document.addEventListener('load', ReplaceSearch, false); // opera 7
else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', ReplaceSearch);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			ReplaceSearch();
		}
	} else {
		window.onload = function() {
			ReplaceSearch();
		}
	}
}



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) {}
}


// Position Tool Tip
function MoreInfo(iconId,iconName,boxName)
{	
	try {
		var icon = document.getElementById(iconId);
		if (icon) {
			var iconPos = findPos(icon);
			var toolipID = iconId.replace(iconName,boxName);
			
			var box = document.getElementById(toolipID);
			box.style.left = iconPos[0]+'px';
			box.style.top = iconPos[1]+'px';
			box.style.display = "block";
			
			icon.onmouseout = function()
			{
				box.style.display = "none";
			};
		}
	}catch(e) {}
}

function findPos(obj) {
	try {
		var curleft = curtop = 0;
		if (obj && obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		}
		return [curleft,curtop];
	} catch(e) {} 
}

// Show or Hide Floating Content
function ShowHide(boxId,ShowHide)
{
	try {
		if(ShowHide == 'show'){
			document.getElementById(boxId).style.display = "block";
		}
		else if(ShowHide == 'hide'){
			document.getElementById(boxId).style.display = "none";
		}
	}catch(e) {}
}


// 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) {}
}


function initiateSplash() {
	try{
		var cookie = readCookie("PopUp");
		if(cookie == null){
		showOverlay();
		}
	
	} catch(e) {}
}
	
function showOverlay() {
	try {
		document.getElementById("overlay_img").style.display="block";
		document.getElementById("black_overlay").style.display="block";
		
	} catch(e) {}
}	
function hideOverlay() {
	try {
		document.getElementById("overlay_img").style.display="none";
		document.getElementById("black_overlay").style.display="none";
		
		createCookie("PopUp", false, 14);
	} catch(e) {}
}
function downloadPDF(path) {
	try {
		window.open(path, "_blank");
		hideOverlay();
		window.location.assign("/thankyou");
		
	} catch(e) {}

}
