// JavaScript Document

//Procedure calls
function checkenquiry(frm) {
	if(emptyfield(frm._name, "Please enter your name")==false) return;
	if(emptyfield(frm._company, "Please enter your company name")==false) return;	
	if(emptyfield(frm._email, "Please enter your email address")==false) return;	
	if(checkEmail(frm._email)==false) return;
	if(emptyfield(frm._enquiry, "Please enter your enquiry")==false) return;	

	frm.submit();	
}

function MM_openBrWindow(theURL) {
  window.open(theURL,"productdetail","status=yes,scrollbars=no,resizable=yes,width=600,height=450");
}

// Common functions
function validNum(check, err_msg){
   str=new String(check.value)
   if(isNaN(str) == true ){
      alert(err_msg)
	  check.focus();
	  return false;
   }
 }

function emptyfield(check,err_msg){
   if (check.value == ""){
      alert(err_msg);
	  check.focus();
	  return false;
   }
}

function checkEmail(check){
   email = new String(check.value);
   errmsg="Invalid Email Address";
     if (email.indexOf("@") == -1){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 else
	 {
	   idx1=email.indexOf("@");
	 }
	 if(email.indexOf(".") == -1){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 else{
	    idx2=email.indexOf(".");
	 }
	 str1=email.substring(0,idx1);
	 if(str1.length < 2){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 str2=email.substring(idx1,idx2);
	 if(str2.length < 2){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 str3=email.substring(idx2,email.length-1);
	 if(str3.length < 2){
		alert(errmsg);
		check.focus();
		return false;
	 } 
}
