// JavaScript Document

   
function validate_quickcontact(thisform)
{
	with (thisform)
	{
	//	if(fname.value=="Name")fname.value="";	
	if (emptyvalidation(r_name,"Woops! You forgot to fill in your Name")==false) 
		{
		r_name.focus();
		return false;	
		}
		if (emptyvalidation(r_phone,"Woops! You forgot to fill in your Phone No")==false) 
		{
		r_phone.focus();
		return false;	
		}
		var ph = thisform.r_phone.value;
		var res=IsPhoneNumber(ph);
		if(res==false)
		{
			alert("Enter Phone Number");
			r_phone.focus();
			r_phone.select();
			return false;		
		}
	/*if(email.value=="Email")email.value=""; */	
	if (emptyvalidation(r_email,"Woops! You forgot to fill in your Email Address")==false) 
		{
		r_email.focus();
		return false;	
		}	
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = thisform.r_email.value;
  
	if(reg.test(address) == false) 
	{ 
      alert('Woops! You have entered an invalid Email Address');
	  r_email.focus();
	  r_email.select();
      return false;
   }
	if (emptyvalidation(r_comments,"Woops! You forgot to fill in your Comments")==false) 
		{
		r_comments.focus();
		return false;	
		}
		if (emptyvalidation(code,"Enter the characters as seen on the image above")==false) 
		{
		code.focus();
		return false;	
		}
		
	}
	thisform.submit();
}
var strString;
function IsPhoneNumber(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.- []()";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (var i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
		 //alert("Enter a phone number");
         blnResult = false;
         }
      }
   return blnResult;
   }	
function emptyvalidation(entered, alertbox)
{
	with (entered)
	{
		while (value.charAt(0) == ' ')
			value = value.substring(1);
		while (value.charAt(value.length - 1) == ' ')
			value = value.substring(0, value.length - 1);
		if (value==null || value=="")
		{
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}
