/* 

File Name:wldcontact.js 
Created By: Gajanan Late
Date:6/6/2004
Usage: File validates the user deatails pertaining contact information.File is used in contact_us.jsp.

*/



//Method is callled on submit action of the form.
function validateForm()
    {
		//var flag=false;
		var  formelement=document.form1.femail;
		var urlvalidation='www,com';
		var urlstring=document.form1.furl.value;
		var newString="";
		 var dotIndex="";
		 var nextdotIndex="";
//Checking for user's name 
	if (document.form1.fname.value=="")
	     {
			alert('Please enter your name');
			document.form1.fname.focus();
			return false;
         }

if (document.form1.furl.value!="")
 {  
	var dotcount;
	dotcount = 0;
	var charEle;
//		alert(document.form1.furl.value.length);
  for(var i=0; i<document.form1.furl.value.length; i++)
	 {
		charEle = document.form1.furl.value.substring(i, i+1)
		if (charEle == '.')
		{
			dotcount++;
		}
	}
	if (dotcount < 2)
	{
		alert('Incorrect URL. Please try again');
		document.form1.furl.focus();
		return false;
	}
 }
else
{
   alert('Please enter URL');
   document.form1.furl.focus();
   return false;
 
 }

	//checking for email entered by user.
 if(document.form1.femail.value!="")
	  { 
//	var pattern = ".+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)"
//	var pattern = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"

		 if(chkEmail(document.form1.femail, "email") == false )
			 return false;
    } 
	else
	{
		alert('Please enter Email Address.');
		document.form1.femail.focus();
		return false;
	}



 //checking for telephone numbers entered by user.
    if(document.form1.ftel.value !="")
	{
      if (isNaN(document.form1.ftel.value))
	   {
	      alert('Please enter a numeric country code');
		  document.form1.ftel.focus();
         //document.form1.ftel2.focus();
		// document.form1.ftel3.focus();
		  return false;
  	  }
 }
 else
 {
	alert('Please enter country code.');
	document.form1.ftel.focus();
	// document.form1.ftel2.focus();
	// document.form1.ftel2.focus();
	return false;
}


 if(document.form1.ftel2.value !="")
	{
 if (isNaN(document.form1.ftel2.value))
   {
	 
	 alert('Please enter a numeric  city code');
	 //document.form1.ftel.focus();
	 document.form1.ftel2.focus();
	// document.form1.ftel3.focus();
	return false;
	
  }
}
else
 {
   alert('Please enter City Code');
   //document.form1.ftel.focus();
   document.form1.ftel2.focus();
  // document.form1.ftel2.focus();
   return false;
 }


 if(document.form1.ftel3.value!="")
{
 if (isNaN(document.form1.ftel3.value))	 									
	 { 
	  
	   alert('Please enter numeric phone no ');
	 //document.form1.ftel.focus();
	 //document.form1.ftel2.focus();
	  document.form1.ftel3.focus();
	  return false;
	
  }

}
else
 {
	alert('Please enter Phone Number');
	//document.form1.ftel.focus();
	//document.form1.ftel2.focus();
	document.form1.ftel3.focus();
	return false;
 }
///Checking for whether user has entered his query / comments................................
	if (document.form1.fcomm.value=="")
	     {
			alert('Please write your Comment/Query. ');
			document.form1.fcomm.focus();
			return false;
		
         }
	return true;

	}//Method Ends Here.
