


// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf(")")==-1)return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}




function checkForm(enquiry_form)

{		
	//var form = enquiry_form;


	//first name
	
	if(enquiry_form.clientfirstname.value=="")
	{
		alert("Please Enter Your First Name") ;
		enquiry_form.clientfirstname.focus() ;
		return false;
	}	
	
	//last name
	
	if(enquiry_form.clientlastname.value=="")
	{
		alert("Please Enter Your Last Name") ;
		enquiry_form.clientlastname.focus() ;
		return false;
	}	
	
	//Email
	
	if (!enquiry_form.clientemail.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/))
		{
			alert("Please enter a valid E-mail ID!");
			enquiry_form.clientemail.focus();
			enquiry_form.clientemail.value = '';
			return false;
		}
	
	//Telephone	
		
	if ((enquiry_form.clientphoneno.value==null)||(enquiry_form.clientphoneno.value=="")){
		alert("Please Enter Your Phone Number");
		enquiry_form.clientphoneno.focus();
		return false
	}	
	
	if (checkInternationalPhone(enquiry_form.clientphoneno.value)==false){
		alert("Please Enter a Valid Phone Number");
		enquiry_form.clientphoneno.focus();
		enquiry_form.clientphoneno.value = '';
		return false
	}
	
	//City
	
	if(enquiry_form.clientcity.value=="")
	{
		alert("Please Select Your City") ;
		enquiry_form.clientcity.focus() ;
		return false;
	}	
	
	//State
	
	if(enquiry_form.clientstate.value=="")
	{
		alert("Please Select Your State") ;
		enquiry_form.clientstate.focus() ;
		return false;
	}	
	
	//Country
	
	if(enquiry_form.clientcountry.value=="")
	{
		alert("Please Select Your Country") ;
		enquiry_form.clientcountry.focus() ;
		return false;
	}	
	
	//Massage
		
	if(enquiry_form.clientmassage.value=="")
	{
		alert("Please Enter Your Massage here") ;
		enquiry_form.clientmassage.focus() ;
		return false;
	}	
		
	
	return;

}




