// JScript source code

function check_phone_value(strPhone,alerttxt){
    var digits = "0123456789";
    var phoneNumberDelimiters = "()- ";
    var validWorldPhoneChars = phoneNumberDelimiters + "+";
    var minDigitsInIPhoneNumber = 0;

    s=stripCharsInBag(strPhone,validWorldPhoneChars);

    if ((isInteger(s) && s.length >= minDigitsInIPhoneNumber)==false)
	{    alert(alerttxt); }

    return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function check_correct_value(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
	{alert(alerttxt);return false}
else {return true}
}
}

function checks_has_value(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
	{alert(alerttxt);return false}
else {return true}
}
}

function validate_form(thisform)
{
with (thisform)
{
if (checks_has_value(form_name,"Please fill out your Name")==false)
	{form_name.focus();return false}
	
//if (checks_has_value(form_home_phone,"Please enter your contact phone number")==false)
//	{form_home_phone.focus();return false}
	
if (check_phone_value(form_home_phone.value,"Please Enter a Valid Phone Number\n Valid characters are as follows:\n0-9\n()\n- +")==false)
    {form_home_phone.focus();return false;}

//if (checks_has_value(form_work_phone,"Please enter your contact phone number")==false)
//	{form_work_phone.focus();return false}
	
if (check_phone_value(form_work_phone.value,"Please Enter a Valid Phone Number\n Valid characters are as follows:\n0-9\n()\n- +")==false)
    {form_work_phone.focus();return false;}
	
//if (checks_has_value(form_mobile_phone,"Please enter your contact phone number")==false)
//	{form_mobile_phone.focus();return false}
	
if (check_phone_value(form_mobile_phone.value,"Please Enter a Valid Phone Number\n Valid characters are as follows:\n0-9\n()\n- +")==false)
    {form_mobile_phone.focus();return false;}
	
if (check_correct_value(form_email,"Please enter the Email Address correctly")==false)
	{form_email.focus();return false}	

}
}