function checkvalid(frm)
{
    with (frm)
    {
		if(!checkValidNull(vFullName,MSG_JS_ENTER_FULL_NAME))
        	return false;
		/*if(!checkValidNull(vPhone,MSG_JS_ENTER_PHONE))
        	return false;*/
		if(!checkValidNull(vEmail,MSG_JS_ENTER_EMAIL))
        	return false;
		if(vEmail.value != ''){
			if(!isValidEmail(vEmail.value))	
			{
				vEmail.focus();
				return false;
			}
		}
		if(!checkValidNull(vSubject,MSG_JS_ENTER_SUBJECT))
        	return false;
		if(!checkValidNull(tComment,MSG_JS_ENTER_COMMENTS))
        	return false;

		sendContactDetails(vFullName.value,vPhone.value,vEmail.value,vSubject.value,tComment.value);
    }
}

function sendContactDetails(name,phone,email,subject,comment){
	var url = SITE_AJAX_URL+"sendContactDetails.php?vFullName="+escape(name)+"&vPhone="+escape(phone)+"&vEmail="+escape(email)+"&vSubject="+escape(subject)+"&tComment="+escape(comment);
/*	alert(url);
	return false;*/
	if (window.XMLHttpRequest)
  	{
  		http=new XMLHttpRequest()
  		http.open("GET",url,true)
	  	http.onreadystatechange=getContactResponse;
	  	http.send(null)
  	}
	// code for IE
	else if (window.ActiveXObject)
  	{
  		http=new ActiveXObject("Microsoft.XMLHTTP")
    	if (http)
    	{
    		http.open("GET",url,true)
    		http.onreadystatechange=getContactResponse;
    		http.send()
    	}
  	}
}
function getContactResponse()
{
	if (http.readyState == 4) 
	{	
      	isWorking = false;

    	if (http.responseText.indexOf('invalid') == -1) 
		{
    		var xmlDocument = http.responseXML; 
			var succ = xmlDocument.getElementsByTagName('succ').item(0).firstChild.data;
			clearField(document.getElementById('frmconatactus'));
			if(succ == '1'){
				if(document.getElementById("showLoading"))	
					document.getElementById("showLoading").style.display ='';
				document.getElementById("errormsg").style.display ='';
				document.getElementById("errormsg").innerHTML = document.getElementById("success").value;
				
				if(document.getElementById("showLoading"))	
					document.getElementById("showLoading").style.display ='none';
				return false;
			}else{
				if(document.getElementById("showLoading"))	
					document.getElementById("showLoading").style.display ='';

				document.getElementById("errormsg").style.display ='';
				document.getElementById("errormsg").innerHTML = document.getElementById("fail").value;
				
				if(document.getElementById("showLoading"))	
					document.getElementById("showLoading").style.display ='none';
				return false;
			}
		}
	}	
}
function checkValidPhoneFaxDigit(events) 
{
var unicodes=events.charCode? events.charCode :events.keyCode;
/*alert(unicodes);
return false;*/
	if (unicodes!=8)
	{ //backspace
	        if( (unicodes>46 && unicodes<59) || unicodes == 46 || unicodes == 45 || unicodes == 40 || unicodes == 41 || unicodes == 43 || unicodes == 32 || unicodes == 9)
	            return true;
			else
				return false; 
	}
}
