hImg= new Image();
hImgA= new Image();
mImg = new Image();
mImgA = new Image();
iImg = new Image();
iImgA = new Image();
gImg = new Image();
gImgA = new Image();
pImg = new Image();
pImgA = new Image();
rImg = new Image();
rImgA = new Image();
aImg = new Image();
aImgA = new Image();
cImg = new Image();
cImgA = new Image();

function openWin(URL,W,H){
	window.open(URL,"","width="+W+",height="+H+",status=No,resizable=No,scrollbars=Yes")
}


function LoadImages(active){
	if (document.images){
		if (active=="home"){
			hImg.src = "images/homeactive.gif";
			hImgA.src = "images/homeactive.gif";
		} else {
			hImg.src = "images/home.gif";
			hImgA.src = "images/homeactive.gif";
		}
		if (active=="measuring"){
			mImg.src = "images/measuringactive.gif";
			mImgA.src = "images/measuringactive.gif";
		} else {
			mImg.src = "images/measuring.gif";
			mImgA.src = "images/measuringactive.gif";
		}
		if (active=="installation"){
			iImg.src = "images/installationactive.gif";
			iImgA.src = "images/installationactive.gif";
		} else {
			iImg.src = "images/installation.gif";
			iImgA.src = "images/installationactive.gif";
		}
		if (active=="glossary"){
			gImg.src = "images/glossaryactive.gif";
			gImgA.src = "images/glossaryactive.gif";
		} else {
			gImg.src = "images/glossary.gif";
			gImgA.src = "images/glossaryactive.gif";
		}
		if (active=="policies"){
			pImg.src = "images/policiesactive.gif";
			pImgA.src = "images/policiesactive.gif";
		} else {
			pImg.src = "images/policies.gif";
			pImgA.src = "images/policiesactive.gif";
		}
		if (active=="privacy"){
			rImg.src = "images/privacyactive.gif";
			rImgA.src = "images/privacyactive.gif";
		} else {
			rImg.src = "images/privacy.gif";
			rImgA.src = "images/privacyactive.gif";
		}
		if (active=="aboutus"){
			aImg.src = "images/aboutusactive.gif";
			aImgA.src = "images/aboutusactive.gif";
		} else {
			aImg.src = "images/aboutus.gif";
			aImgA.src = "images/aboutusactive.gif";
		}
		if (active=="contactus"){
			cImg.src = "images/contactusactive.gif";
			cImgA.src = "images/contactusactive.gif";
		} else {
			cImg.src = "images/contactus.gif";
			cImgA.src = "images/contactusactive.gif";
		}
	}
}

function DisplayImages(active){
	if (active=="home")
		window.document.getElementById("homeImg").src = "images/homeactive.gif";
	else
		window.document.getElementById("homeImg").src = "images/home.gif";
	if (active=="measuring")
		window.document.getElementById("measuringImg").src = "images/measuringactive.gif";
	else
		window.document.getElementById("measuringImg").src = "images/measuring.gif";
	if (active=="installation")
		window.document.getElementById("installationImg").src = "images/installationactive.gif";
	else
		window.document.getElementById("installationImg").src = "images/installation.gif";
	if (active=="glossary")
		window.document.getElementById("glossaryImg").src = "images/glossaryactive.gif";
	else
		window.document.getElementById("glossaryImg").src = "images/glossary.gif";
	if (active=="policies")
		window.document.getElementById("policiesImg").src = "images/policiesactive.gif";
	else
		window.document.getElementById("policiesImg").src = "images/policies.gif";
	if (active=="privacy")
		window.document.getElementById("privacyImg").src = "images/privacyactive.gif";
	else
		window.document.getElementById("privacyImg").src = "images/privacy.gif";
	if (active=="aboutus")
		window.document.getElementById("aboutusImg").src = "images/aboutusactive.gif";
	else
		window.document.getElementById("aboutusImg").src = "images/aboutus.gif";
	if (active=="contactus")
		window.document.getElementById("contactusImg").src = "images/contactusactive.gif";
	else
		window.document.getElementById("contactusImg").src = "images/contactus.gif";
}





// validation function
function validate(frm){
	if (frm.R_IEmail)
		if (!CheckEmail(frm.R_IEmail)) return false;

	    if (document.frm.R_ICEmail)
		if (document.frm.R_ICEmail.value != document.frm.R_IEmail.value){
				alert("please check your email address");
				frm.R_ICEmail.focus();
				return false;
				}
	for (i=0; i<frm.elements.length; i++){
		fld = frm.elements[i];
		if (fld.name.indexOf('R_') >= 0){
			if (fld.type=="text" || fld.type=="password")
				alertText = "Please Enter "+fld.title
			else if (fld.type=="select-one")
				alertText = "Please Select "+fld.title
			if (fld.value==""){
				alert(alertText);
				fld.focus();
				return false;
			}
		}
	}
	if (!CheckPassword()) return false;
	if (frm.R_Email)
		if (!CheckEmail(frm.R_Email)) return false;
	if (frm.R_YourEmail)
		if (!CheckEmail(frm.R_YourEmail)) return false;
	if (frm.R_ZipCode)
		if (!CheckZipCode(frm.R_ZipCode)) return false;
	if (frm.R_Terms){
		if (frm.R_Terms.checked==false){
			alert("Please confirm that you are agree with our Terms of Use");
			return false;
		}
	}
	return true;
}

function openwin(URL,H,W){
	var mms = window.open(URL, '', 'width='+W+',height='+H+',status=No,resizable=No,scrollbars=No,top=200,left=200');
	mms.focus();
}

function CheckPassword(){
	if (document.frm.R_Password)
	if (document.frm.R_Password.value != document.frm.R_CPassword.value){
		alert("Password and Confirm Password are not same");
		document.frm.R_CPassword.focus();
		return false;
	}
	return true;
}

function CheckEmail(e){
	var str=e.value;
	var filter=/^.+@.+\..{2,3}$/
	if (filter.test(str))
		result=true;
	else{
	    alert("Your email address does not appears to be valid, Please write a valid email address in Email");
	    e.focus();
		result=false;
	}
	return (result);
}

function CheckZipCode(z){
	if (!IsNumeric(z.value)){
		alert("Please enter numeric value in "+z.title);
		z.focus();
		return false;
	}
	return true;
}

function IsNumeric(sText){
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++){ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1){
			IsNumber = false;
		}
	}
	return IsNumber;
}