// JavaScript Document
function IsEmpty(a) {
   if ((a.value.length==0) ||
   (a.value==null)) {
      return true;
   }
   else { return false; }
}	


function checkemail ( form )
{
	   	   
	   	if (!ValidateEmailform(form)) {
		 // document.getElementById('email').className = "inputtxterror";
     	 return false; 
		} else {
		//	document.getElementById('email').className = "inputtxtok";
	   	   return true;
		}
   

}
	
	function isPhoneNumber(s) 
{
 
     // Check for correct phone number
     rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);
     if (!rePhoneNumber.test(s.value)) {
          alert("Phone Number Must Be Entered As: (555) 555-1234");
          s.focus(); 
          return false;
     }
 
       return true;
}


function echeck(str) {
/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid  E-mail address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid  E-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid  E-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid  E-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid  E-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid  E-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid  E-mail address")
		    return false
		 }

 		 return true					
	}

function ValidateEmailform(form){
	emailID = form.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 
 function ValidateMailphone(form) {
	 var mesg ="";

	 if  (ValidateEmailform(form) )  {
		 if (IsEmpty(form.name) ) {
			var mesg ="";

			document.getElementById('name').className = "inputtxterror";
			mesg += 'Please enter your  name' + '\n\n';
		 } else {
			document.getElementById('name').className = "inputtxtok";
		 }
		 if (IsEmpty(form.phone) ) {
			document.getElementById('phone').className = "inputtxterror";
			mesg += 'Please enter your  phone number' + '\n\n';
		 } else {
			document.getElementById('phone').className = "inputtxtok";
		 }
		 if (mesg != "") {
	   		   alert(mesg);
	  		 return false
		 } else {
			return true
		}
	 } else {
	 return false
	 }
 }
		 


// Radio Button Validation
// copyright Stephen Chapman, 15th Nov 2004,14th Sep 2005
// you may copy this function but please keep the copyright notice with it
function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}
                  

