sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
			hideSelects();
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" over\\b"), "");
			showSelects();
		}
	}
}
if (window.attachEvent) window.attachEvent('onload', sfHover);


function hideSelects(){
	var oSelects=document.getElementById("content").getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className+=" invisible";
}
function showSelects(){
	var oSelects=document.getElementById("content").getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className=oSelects[i].className.replace(" invisible","");
}


function getsite()
{
var OutLink = "";
for(i=0; i<document.forms.sites_select.country.length; i++) 
	{
	if (document.forms.sites_select.country[i].selected)
		{
		OutLink = document.forms.sites_select.country[i].value;
		}
	}
if (OutLink  != '')
	{
	window.open(OutLink, "Optrex")
	}
}

// Form Validation
function bad_email(s) {

	var j = 0;
	for (i = 0; i < s.length; i++) {
		if (s.charAt(i) == "@") {
			j++;
		}
		if (s.charAt(i) == ".") {
			j++;
		}
	}
	if (j < 2) {
		return true;
	} else {
		return false;
	}	
}

function validate(myform) 
{
	if (myform.phone1.value == "") {
		alert("Please enter your complete phone number");
		myform.phone1.focus();
		return false;
	}
	
	if (myform.phone2.value == "") {
		alert("Please enter your complete phone number");
		myform.phone2.focus();
		return false;
	}
	
	if (myform.phone3.value == "") {
		alert("Please enter your complete phone number");
		myform.phone3.focus();
		return false;
	}
	
	if (myform.email.value == "") {
		alert("Please enter your email address");
		myform.email.focus();
		return false;
	}
	
	if (bad_email(myform.email.value)) {
		alert("Please enter a valid email address");
		myform.email.focus();
		return false;
	}
	
	return true;
}


function emailalerts(myform)
{
	if (myform.email.value == "") {
		alert("Please enter your email address");
		myform.email.focus();
		return false;
	}
	
	if (bad_email(myform.email.value)) {
		alert("Please enter a valid email address");
		myform.email.focus();
		return false;
	}
}


function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function closeWindow() {
	window.close();
}


function reloadParent() {
	window.opener.location.reload();
}


/* Fix IE6/7 ActiveX activation */
function ieFlash(path, fwidth, fheight, nojs) {
	document.write('<object type="application/x-shockwave-flash" data="'+ path +'" width="' + fwidth +'" height="' + fheight +'">');
	document.write('<param name="movie" value="'+ path +'" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write(nojs);
	document.write('</object>');
}

/* For movies with preloads */
function ieFlashNC(path, fwidth, fheight, nojs) {
	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="'+ fwidth +'" height="' + fheight +'">');
	document.write('<param name="movie" value="'+ path +'" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<![CDATA[<embed src="'+ path +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ fwidth +'" height="'+ fheight +'"></embed>]]>');
	document.write(nojs);
	document.write('</object>');
}
