
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 WriteFlashWithID(strID,SWFPath,SWFWidth,SWFHeight,SWFParams) {
	try {
		var str = '\n';
		var NewParams = '';
		str+='	<object name="' + strID + '" id="' + strID + '" 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 WriteFlash(SWFPath,SWFWidth,SWFHeight,SWFParams,objID,elmID,imgPath,altText) {
	try {
		var playerVersion = swfobject.getFlashPlayerVersion(); // returns a JavaScript object
		if (swfobject.hasFlashPlayerVersion("9.0.0")) {
			var str = '\n';
			var NewParams = '';
			str+='	<object type="application\/x-shockwave-flash" id="' + objID + '" data="' + SWFPath + '" width="' + SWFWidth + '" height="' + SWFHeight + '">\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.getElementById(elmID).innerHTML = str;
		} else {
			document.getElementById(elmID).innerHTML = '<a href="\/"><img id="'+elmID+'" src="'+imgPath+'" width="'+SWFWidth+'" height="'+SWFHeight+'" alt="'+altText+'" \/><\/a>';
		}
	} catch(e) {}
}


function ShowHideTabs(liElm,dlElm){
	try{
		var lis = document.getElementById("Tabs").getElementsByTagName("li");
		var dls = document.getElementById("TabsCol").getElementsByTagName("dl");
		var selIndex;
		for(var i=0; i<lis.length; i++){
			lis[i].className = "";
			if(lis[i] == liElm){
				selIndex = i;
			}
		}
		for(var j=0; j<dls.length; j++){
			dls[j].style.display = "none";
		}

		liElm.className="Sel";
		dls[selIndex].style.display = "block";

		return false;
	}catch(e){}
}


function DrawFlashVideo(VidFile, autoStart, elmID, width, height) {
	try{
		if(autoStart == undefined){
			autoStart = false;
		}
		if(elmID == undefined){
			elmID = "FLVVideo";
		}
		var playerVersion = swfobject.getFlashPlayerVersion(); // returns a JavaScript object
		if (swfobject.hasFlashPlayerVersion("9.0.0")) {
			swfobject.embedSWF("/files/flash/flvplayer.swf", elmID, width, height, "9.0.0", false, {file:VidFile, width:width, height:height, autostart:autoStart, stretching:"exactfit"}, {allowfullscreen:true,wmode:"transparent"}, false );

		}else{}
	} catch(e) {}
}


function SetupVideo(videoPlayer, vidID, title, vidPath, summary){
	try{
		if(videoPlayer != null){
			videoPlayer.sendEvent('STOP','true');
			videoPlayer.style.visibility = "hidden";
		}
		DrawOverlay('FadePage','FadeContent',false);
		document.getElementById("OverlayTitle").innerHTML = "<a href=\"#\" onclick=\"CloseOverlay(FLVVideo); return false;\">X</a>"+title;
		document.getElementById("Overlay").innerHTML = "<div id=\""+vidID+"\"></div><div id=\"Summary\"></div>";
		document.getElementById("Summary").innerHTML = summary;
		DrawFlashVideo(vidPath, true, vidID, 640, 480);
		
		window.setTimeout('addListeners(\''+vidID+'\')',1000);

	} catch(e) {}
}	



function addListeners(vidID){
	try{
		var videoPlayer = document.getElementById(vidID);
		videoPlayer.addModelListener("STATE", "stateListener");

	} catch(e) {}
}

function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
	try{
		currentState = obj.newstate; 
		previousState = obj.oldstate;
		if (currentState == "COMPLETED") {
			CloseOverlay(document.getElementById("FLVVideo"));
		}

	} catch(e) {}
}




function DrawOverlay(elemID,ContentID,noCenter) {
    try {
		var x;
		var y;
		var obj = document.getElementById(elemID);
		var contentObj = document.getElementById(ContentID);
		
		windowProperties = GetWindowProperties();

		if(windowProperties[1] >= windowProperties[3] && navigator.appName != "Microsoft Internet Explorer"){
			obj.style.width = windowProperties[2]-17 + "px";
		} else {
			obj.style.width = windowProperties[2] + "px";
		}
		
		if(windowProperties[1] < windowProperties[3]){
			obj.style.height = windowProperties[3] + "px";
		} else {
			obj.style.height = windowProperties[1] + "px";
		}
		obj.style.display = "block";
		contentObj.style.display = "block";
		
		if(!noCenter){
			CenterOverlay(elemID,ContentID);
		}
		
	} catch(e) {}
}

function CenterOverlay(elemID,ContentID) {
	try{
		windowProperties = GetWindowProperties();
		
		elementStyle = document.getElementById("FadeContent").style;
		elementStyle.display = "block";
		overlayWidth = document.getElementById("FadeContent").clientWidth;
		overlayHeight = document.getElementById("FadeContent").clientHeight;
		overlayH = Math.round(((windowProperties[2] - overlayWidth)/2));
		overlayV = Math.round(windowProperties[3]*.1);
		overlayV2 = Math.round(windowProperties[4]+(windowProperties[3]*.1));
		if(overlayV < 10){
			overlayV = overlayV2;
		}
		if(overlayV < windowProperties[4]){
			overlayV = windowProperties[4]+(windowProperties[3]*.1); 
		}
		if(overlayH < 10){
			overlayH = 10;
		}
		
		elementStyle.left = overlayH+"px";
		elementStyle.top = overlayV+"px";
		
		if(overlayHeight >= windowProperties[3]){
			DrawOverlay(elemID,ContentID,'true');
		}

	}catch(e){}
}

function GetWindowProperties() {
	try{
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { 
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;
		if (self.innerHeight) {	
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		
		if(typeof(window.pageYOffset) == 'number') {
			yOffset = window.pageYOffset;
		} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
			yOffset = document.body.scrollTop;
		} else if(document.documentElement) {
			yOffset = document.documentElement.scrollTop;
     	 	}
     	 	
		return Array(xScroll,yScroll,windowWidth,windowHeight,yOffset);
		
	}catch(e){}
}



function CloseOverlay(videoPlayer){

    try {
		var obj = document.getElementById("FadePage");
		var contentObj = document.getElementById("FadeContent");

		obj.style.display = "none";
		contentObj.style.display = "none";

		if(videoPlayer != null){
			videoPlayer.style.visibility = "visible";
		}

		document.getElementById("Overlay").getElementsByTagName("object")[0].sendEvent('STOP','true');

	}catch(e){}
}

