function removeValid(oBj){
 
var oBjV=oBj.value;
var oId=document.getElementById(oBj.id);
oId.style.border='1px solid #afafaf';
	
}
function checkForm(){
	
	var name=document.getElementById('name').value;
	var email=document.getElementById('email').value;
	var phone=document.getElementById('phone').value;
	var message=document.getElementById('message').value;
	
	var alertMSG = '';
	
	if (name.length<1){
	     
		document.getElementById('name').style.border='1px solid #ff0000';
		
		alertMSG += '* Name is eampty\n';
		}
		
		if (phone.length<1){
		
			document.getElementById('phone').style.border='1px solid #ff0000';
			alertMSG += '* Invalid phone number\n'
			}
			if (email.length<1){
				
				document.getElementById('email').style.border='1px solid #ff0000';
				alertMSG += '* Invalid email address\n'
				} 
				
				
			if(alertMSG) alert('Please fix the following fields:\n'+alertMSG);
	
	
	if (name.length<1){
	
		}else if (phone.length<1){
		
			}else if (email.length<1){
				
			        }else if (echeck(email)==false){

		document.getElementById('email').style.border='1px solid #ff0000';
		alertMSG += '* Invalid email address\n';
		
	} else{
	 
	  url='sendForm.asp?name='+name+'&message='+message+'&email='+email+'&phone='+phone;
 
try {
     req = new XMLHttpRequest(); 
     } catch(e) {
       try {
       req = new ActiveXObject("Msxml2.XMLHTTP");  
       } catch (e) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP");  
         } catch (E) {
          req = false;
         } 
       } 
     }
     req.onreadystatechange
        = function() {
			
		if(req.readyState == 4) {
      if(req.status == 200) {
		   clearForm();
	 tb_show('', 'formSent.asp?height=80&width=200')
         } else {
        
         output  = errorMessage+"\n"+responseText;
         }
		 
      }	
			};
			 
			 myRand=parseInt(Math.random()*999999999999999); // cache buster 
	 if (url.match('=')){
		var modurl=url+"&rand="+myRand; 
	 }else{
		var modurl=url+"?rand="+myRand;  
	 }
     req.open("GET",modurl,true);
    
      req.send(null); 
	
	}
	

	 
 
	
	
	 
	
}
function clearForm(){
	document.getElementById('name').value='';
	document.getElementById('email').value='';
	document.getElementById('phone').value='';
	document.getElementById('message').value='';
	
}
  
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   	   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		      return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   	    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   	    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		        return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		  	    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		       return false
		 }

 		 return true					
	}