var hasCleared = false;
function clearOnce(textbox)
{
if(!hasCleared)
{
	textbox.value = "";
	hasCleared = true;
}
return true;
}

function rollover(img, on)
{

	off = img.src;
	id = img.id;
	subnav = id+"_subnav";
	offfull = img.src;
	onfull = on;
	if(off.lastIndexOf('/') != -1) // if there is a path, strip it
		{
			 off = off.substring(off.lastIndexOf('/')+1);
		}
	if(on.lastIndexOf('/') != -1) // if there is a path, strip it
		{
			 on = on.substring(on.lastIndexOf('/')+1);
		}
	if(on != off)
		{	
			off_ex = off.substring(off.lastIndexOf('.')) // extract extension
			off = off.substring(0,off.lastIndexOf('.')); //strip extension
			on_ex = on.substring(on.lastIndexOf('.')) // extract extension
			on = on.substring(0,on.lastIndexOf('.')); //strip extension
			eval(off + " = new Image(); ");
			eval(off + ".src = '" + offfull +"'");
			eval(on + " = new Image(); ");
			eval(on + ".src = '" + onfull +"'");
			var image_on = eval(on + ".src");
			var image_off = eval(off + ".src");
			img.onmouseover = function() { img.src = image_on;}
			img.onmouseout = function() { img.src = image_off;}
			
		} 
		
}

function expandProductsBenefits() {
	document.getElementById("products_benefits_dropdown").style.display = "block";
}

function closeProductsBenefits() {
	document.getElementById("products_benefits_dropdown").style.display = "none";	
}

function expandContactBox() {
	if(document.getElementById("contact_box_ext").style.display == "block") {
		document.getElementById("contact_box_ext").style.display = "none";
	}
	else {
		document.getElementById("contact_box_ext").style.display = "block";
	}
	
	
}

function validate() {
	
		
	var valid = true;
		
		if(document.inquire.name.value == "") {
			valid = false;
			document.getElementById("name").style.background = "#CCCCCC";
		}
		else {
			
			document.getElementById("name").style.background = "#FFFFFF";
		}
			
		if(document.inquire.email.value == "") {
			valid = false;
			document.getElementById("email").style.background = "#CCCCCC";
		}
		else {
			document.getElementById("email").style.background = "#FFFFFF";
		}
		
		if(document.inquire.phone.value == "") {
			valid = false;
			document.getElementById("phone").style.background = "#CCCCCC";
		}
		else {
			document.getElementById("phone").style.background = "#FFFFFF";
		}
				
		if(!valid) {
			alert("Please provide values for all grayed fields");
		}
		else {
			processForm();	
		}
		
	}
	
	
function processForm() {	
	var req;
	var params;
	
	params = "name=" + document.inquire.name.value + "&";
	params += "email=" + document.inquire.email.value + "&";
	params += "company=" + document.inquire.company.value + "&";
	params += "phone=" + document.inquire.phone.value + "&";		
	params += "notes=" + document.inquire.notes.value;

	if(window.XMLHttpRequest){
	//For Firefox, Safari, Opera
	req = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
	//For IE 5
	req = new ActiveXObject("Microsoft.XMLHTTP");
	} else if(window.ActiveXObject){
	//For IE 6+
	req = new ActiveXObject("Msxml2.XMLHTTP");
	}
	else{
	//Error for an old browser
	}
	
	req.open("POST","../process_demo_form.php");
	
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.setRequestHeader("Content-length", params.length);
	req.setRequestHeader("Connection", "close");
	
	req.onreadystatechange = function() {//Call a function when the state changes.
		if(req.readyState == 4 && req.status == 200) {
			//call message recieved box.
			document.getElementById("contact_box_content").style.display = "none";
			document.getElementById("contact_box_confirmation").style.display = "block";
		}
	}
	
	req.send(params);
}

function expandCSImage() {
	if(document.getElementById("costsavings_popup").style.display == "block") {
		document.getElementById("costsavings_popup").style.display = "none";
	}
	else {
		document.getElementById("costsavings_popup").style.display = "block";
		document.getElementById("costsavings_popup").style.zIndex = "400";
	}
	
	
}

function expandProdImage() {
	if(document.getElementById("products_popup").style.display == "block") {
		document.getElementById("products_popup").style.display = "none";
	}
	else {
		document.getElementById("products_popup").style.display = "block";
		//document.getElementById("products_popup").style.zIndex = 400;
	}
	
	
}

function expandCloudImage() {
	if(document.getElementById("cloudcomp_popup").style.display == "block") {
		document.getElementById("cloudcomp_popup").style.display = "none";
	}
	else {
		document.getElementById("cloudcomp_popup").style.display = "block";
	}		
}

function expandSolutionsImage() {
	if(document.getElementById("solutions_expand_image").style.display == "block") {
		document.getElementById("solutions_expand_image").style.display = "none";
	}
	else {
		document.getElementById("solutions_expand_image").style.display = "block";
	}		
}

function expandSolutionsImage2() {
	if(document.getElementById("solutions_expand_2").style.display == "block") {
		document.getElementById("solutions_expand_2").style.display = "none";
	}
	else {
		document.getElementById("solutions_expand_2").style.display = "block";
	}		
}

function expandIOImage1() {
	if(document.getElementById("io_expand_1").style.display == "block") {
		document.getElementById("io_expand_1").style.display = "none";
	}
	else {
		document.getElementById("io_expand_1").style.display = "block";
	}		
}

function expandIOImage2() {
	if(document.getElementById("io_expand_2").style.display == "block") {
		document.getElementById("io_expand_2").style.display = "none";
	}
	else {
		document.getElementById("io_expand_2").style.display = "block";
	}		
}

function InsertFlashMovie(path, width, height)
{
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+path+'"><param name="quality" value="high"><param name="wmode" value="transparent"><EMBED SRC="'+path+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  WIDTH="'+width+'" HEIGHT="'+height+'" WMODE="TRANSPARENT" MENU="FALSE" BGCOLOR="BLACK"></EMBED></object>');
}

function openvideo1(){
	$.nyroModalManual({content:'<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/kBg_8SWQmQE&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/kBg_8SWQmQE&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>'});
}

function openvideo2(){
	$.nyroModalManual({content:'<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/TPp12dXfc54&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/TPp12dXfc54&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>'});
}

function openvideo3(){
	$.nyroModalManual({content:'<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/DIHGcwa7q4A&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/DIHGcwa7q4A&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>'});
}

function openvideo4(){
	$.nyroModalManual({content:'<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/Uo-IjV1k5M4&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Uo-IjV1k5M4&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>'});
}


