function validateForm(form)
{       if (!checkNotEmpty(form.name))
        {
           form.name.focus();
           return false;
           
        }      
        else if (!checkEmail(form.email))
        {
           form.email.focus();
           return false;
           
        }
        else
        { 
           return true;
        }
}


function checkPhoneNumber(phoneNumberFormField) 
{
        var theNumber = phoneNumberFormField.value
	var valid = true
	var GoodChars = "0123456789()-+ "
	var i = 0
	if ((theNumber ==null)||(theNumber=="")) 
        {
		// Return false if number is empty
                //alert("Invalid phone number")		
                //phoneNumberFormField.focus()
                return false
	}
	for (i =0; i <= theNumber.length -1; i++) 
        {
		if (GoodChars.indexOf(theNumber.charAt(i)) == -1) 
                {
                   // Note: Remove the comments from the following line to see this
                   // for loop in action.
                   // alert(theNumber.charAt(i) + " is no good.")
                   //alert("Invalid phone number") 
                   //phoneNumberFormField.focus()   
                   return false
		} // End if statement
	} // End for loop
	return true
}

function checkNotEmpty(formField)
{
   if ((formField.value==null)||(formField.value==""))
   {
	alert("Invalid input for "+formField.name)
	formField.focus()
        return false
   }
   return true;
}

function checkEmail(formField)
{
                var str = formField.value
                var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
                {
		   alert("Invalid E-mail ID")                   
                   formField.focus() 
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID") 
                   formField.focus()
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
		    alert("Invalid E-mail ID") 
                    formField.focus()
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID") 
                    formField.focus()
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID") 
                    formField.focus()
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID") 
                    formField.focus()
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID") 
                    formField.focus()
		    return false
		 }

 		 return true		
}

function checkCheckbox(checkbox)
{
   if(checkbox.checked == true)
   {
      return true;
   }
   else
   {
      alert("Please read & accept the Terms & Conditions first!")
      checkbox.focus();
      return false;
   }
}
