// JavaScript Document

function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function resetName(name,value){
	document.homeform.name.focus();	
	document.homeform.name.value = "";	
}

function resetCompany(company,value){
	document.homeform.company.focus();	
	document.homeform.company.value = value;	
}

function resetLocation(location,value){
	document.homeform.location.focus();	
	document.homeform.location.value = value;	
}

function resetEmail(email,value){
	document.homeform.email.focus();	
	document.homeform.email.value = value;	
}

function resetPhone(phone,value){
	document.homeform.phone.focus();	
	document.homeform.phone.value = value;	
}

function resetEnquiry(enquiry,value){
	document.homeform.enquiry.focus();	
	document.homeform.enquiry.value = value;	
}


//################# rightform ##################
function resetNameR(name,value){
	document.rightform.name.focus();	
	document.rightform.name.value = value;	
}

function resetPhoneR(phone,value){
	document.rightform.phone.focus();	
	document.rightform.phone.value = value;	
}

function resetAddressR(address,value){
	document.rightform.address.focus();	
	document.rightform.address.value = value;	
}

function resetEmailR(email,value){
	document.rightform.email.focus();	
	document.rightform.email.value = value;	
}

function echeck(str) {
				var at="@"
				var dot="."
				var lat=str.indexOf(at)
				var lstr=str.length
				var ldot=str.indexOf(dot)
				if (str.indexOf(at)==-1){
				   alert("Invalid E-mail Address")
				   return false
				}
				if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
				   alert("Invalid E-mail Address")
				   return false
				}
				if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
					alert("Invalid E-mail Address")
					return false
				}
				 if (str.indexOf(at,(lat+1))!=-1){
					alert("Invalid E-mail Address")
					return false
				 }
				 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
					alert("Invalid E-mail Address")
					return false
				 }
				 if (str.indexOf(dot,(lat+2))==-1){
					alert("Invalid E-mail Address")
					return false
				 }
				 if (str.indexOf(" ")!=-1){
					alert("Invalid E-mail Address")
					return false
				 }
				 return true
	}

function ValidateForm(){
	var emailID=document.homeform.Email;
	if (document.homeform.name.value == "")
		{
		alert ("You must enter your name.")
		document.homeform.name.focus();
		return false;
		}
	if (document.homeform.name.value == "name")
		{
		alert ("You must enter your name.")
		document.homeform.name.focus();
		return false;
		}
	var emailID=document.homeform.email
		if ((emailID.value==null)||(emailID.value=="")){
			alert("You must enter your Email Address")
			emailID.focus()
			return false
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false
		}
	if (document.homeform.phone.value == "")
		{
		alert ("You must enter your phone number.")
		document.homeform.phone.focus();
		return false;
		}
	if (document.homeform.phone.value == "phone")
		{
		alert ("You must enter your phone number.")
		document.homeform.phone.focus();
		return false;
		}
	if (document.homeform.captchacode.value == "")
		{
		alert ("You must enter the security code.")
		document.homeform.captchacode.focus();
		return false;
		}
return true
}

function ValidateRightForm(){
	var emailID=document.rightform.Email;
	if (document.rightform.name.value == "")
		{
		alert ("You must enter your name.")
		document.rightform.name.focus();
		return false;
		}
	if (document.rightform.name.value == "name")
		{
		alert ("You must enter your name.")
		document.rightform.name.focus();
		return false;
		}
	if (document.rightform.phone.value == "")
		{
		alert ("You must enter your phone number.")
		document.rightform.phone.focus();
		return false;
		}
	if (document.rightform.phone.value == "phone number")
		{
		alert ("You must enter your phone number.")
		document.rightform.phone.focus();
		return false;
		}
	var emailID=document.rightform.email
		if ((emailID.value==null)||(emailID.value=="")){
			alert("You must enter your Email Address")
			emailID.focus()
			return false
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false
		}
	if (document.rightform.captchacode.value == "")
		{
		alert ("You must enter the security code.")
		document.rightform.captchacode.focus();
		return false;
		}
return true
}
