	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 ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID ")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function contactus()
{
var name=document.formcontactus.name.value;
name= name.replace(/\s+$/g,'');
if(name.length==0)
{
alert("Please Enter your name");
document.formcontactus.name.value="";
document.formcontactus.name.focus();
return false;
}
var emailID=document.formcontactus.email;
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
var y=document.formcontactus.mob_no.value;
if(y.length==0)
{
   		alert ( "Please Enter mob_no." );
		document.formcontactus.y.focus();
		document.formcontactus.y.value="";
        return false;
}

//var y = document.formcontactus.mob_no.value;
if(isNaN(y)||y.indexOf(" ")!=-1)
{
alert("Enter numeric value")
return false; 
}
if (y.charAt(0)!="9")
{
alert("it should start with 9 ");
return false
}
if (y.length>10||y.length<10)
{
alert("enter 10 digits");
return false;
}




var message=document.formcontactus.message.value;
message= message.replace(/\s+$/g,'');
if(message.length==0)
{
   alert ( "Please enter your message." );
		document.formcontactus.message.focus();
		document.formcontactus.message.value="";
        return false;
}


}
////////////////// Reset Contact form
function reset_contact(){
document.formcontactus.name.value="";
document.formcontactus.email.value="";
document.formcontactus.comments.value="";
document.formcontactus.security_code.value="";
document.formcontactus.name.focus();
}
//////////////////////////////
function basket_check()
{
			var name=document.basketform.name.value;
			name= name.replace(/\s+$/g,'');
			if(name.length==0)
			{
			alert("Please Enter your name");
			document.basketform.name.value="";
			document.basketform.name.focus();
			return false;
			}
			var phone=document.basketform.phone.value;
			phone= phone.replace(/\s+$/g,'');
			if(phone.length==0)
			{
			alert("Please Enter your Phone No.");
			document.basketform.phone.value="";
			document.basketform.phone.focus();
			return false;
			}
			var emailID=document.basketform.email;
				if ((emailID.value==null)||(emailID.value=="")){
					alert("Please Enter your Email ID")
					emailID.focus()
					return false
				}
				if (echeck(emailID.value)==false){
					emailID.value=""
					emailID.focus()
					return false
				}
			var company=document.basketform.company.value;
			company= company.replace(/\s+$/g,'');
			if(company.length==0)
			{
			alert("Please Enter your company name");
			document.basketform.company.value="";
			document.basketform.company.focus();
			return false;
			}
			var address=document.basketform.address.value;
			address= address.replace(/\s+$/g,'');
			if(address.length==0)
			{
			   alert ( "Please enter your address." );
					document.basketform.address.focus();
					document.basketform.address.value="";
					return false;
			}
			var comment=document.basketform.comment.value;
			comment= comment.replace(/\s+$/g,'');
			if(comment.length==0)
			{
			   alert ( "Please enter your commnets." );
					document.basketform.comment.focus();
					document.basketform.comment.value="";
					return false;
			}
}
///////////////////////
function enquiry_check()
{
			var name=document.enquiry_form.name.value;
			name= name.replace(/\s+$/g,'');
			if(name.length==0)
			{
			alert("Please Enter your name");
			document.enquiry_form.name.value="";
			document.enquiry_form.name.focus();
			return false;
			}
			var phone=document.enquiry_form.phone.value;
			phone= phone.replace(/\s+$/g,'');
			if(phone.length==0)
			{
			alert("Please Enter your Phone No.");
			document.enquiry_form.phone.value="";
			document.enquiry_form.phone.focus();
			return false;
			}
			var emailID=document.enquiry_form.email;
				if ((emailID.value==null)||(emailID.value=="")){
					alert("Please Enter your Email ID")
					emailID.focus()
					return false
				}
				if (echeck(emailID.value)==false){
					emailID.value=""
					emailID.focus()
					return false
				}
			var company=document.enquiry_form.company.value;
			company= company.replace(/\s+$/g,'');
			if(company.length==0)
			{
			alert("Please Enter your company name");
			document.enquiry_form.company.value="";
			document.enquiry_form.company.focus();
			return false;
			}
			var address=document.enquiry_form.address.value;
			address= address.replace(/\s+$/g,'');
			if(address.length==0)
			{
			   alert ( "Please enter your address." );
					document.enquiry_form.address.focus();
					document.enquiry_form.address.value="";
					return false;
			}
			var security_code=document.enquiry_form.security_code.value;
			security_code= security_code.replace(/\s+$/g,'');
			if(security_code.length==0)
			{
			alert("Please Enter Security code");
			document.enquiry_form.security_code.value="";
			document.enquiry_form.security_code.focus();
			return false;
			}
}
///////////////
function reset_form()
{
document.basketform.name.value="";
document.basketform.phone.value="";
document.basketform.email.value="";
document.basketform.company.value="";
document.basketform.address.value="";
document.basketform.comment.value="";
document.basketform.name.focus();		
}
///////////////////////////////////////////// Validate Newsletter subscription
function nevigate(url)
{
	
var searchkey=document.searchfrm.searchkey.value;
searchkey= searchkey.replace(/\s+$/g,'');
if(searchkey=='Search key')
{
alert("Please enter search key value.")
document.searchfrm.searchkey.focus();
document.searchfrm.searchkey.value="";
return false;
}
if(searchkey.length==0)
{
alert("Please enter search key value. ")
document.searchfrm.searchkey.focus();
document.searchfrm.searchkey.value="";
return false;
}else{
document.searchfrm.action=url;
document.searchfrm.submit();	
}
}
//////
function validate2()
{
var len=document.basketform.basket.length;
k=0;
for(i=0;i<len;i++)
		{
			if (document.basketform.basket[i].checked==true)
			{
				k++;
			}
		}
	 if (k==0)
	 {
	 	alert("You have not yet selected any product");
		document.basketform.basket[0].focus();
	 	return false;
	 }
}
