// JavaScript Document
var name,content,email;
function displayMessage(url)
{
	
window.open(url,null,
    "height=600,width=1000,status=yes,toolbar=no,menubar=no,location=no,resizeable=yes,scrollbars=1");

}

function isEmail(v)
{
    
          var regExpr=new RegExp("^([a-zA-Z0-9_.-]+[@][a-zA-z0-9]+[.](([a-zA-z]{3})|([a-zA-z]{2})|([a-zA-z]{2}[.][a-zA-z]{2})))$");
    		if( !v.match(regExpr))
            		{
					   
            				return false;
            		}
					return true;

 
}


function createRequestObject() { 
    var ro; 
    var browser = navigator.appName; 
    if(browser == "Microsoft Internet Explorer"){ 
        ro = new ActiveXObject("Microsoft.XMLHTTP"); 
    }else{ 
        ro = new XMLHttpRequest(); 
    } 
    return ro; 
} 
var http = createRequestObject(); 



function mysendmail()
{
	
	 name=document.getElementById('name').value;
	 email=document.getElementById('email').value;
	 content=document.getElementById('content').value;
	
	if(!name)
	{
	alert("Invalid Name!");
	document.getElementById('name').focus();
	return false;
	}
	
	if((!email)||(!isEmail(email)))
	{
	alert("Invalid Email Address!");
	document.getElementById('email').focus();
	return false;
	}
	
	if(!content)
	{
	alert("Invalid Message!");
	document.getElementById('content').focus();
	return false;
	}
	var opaque=0.5;
	var hnd=document.getElementById('messageholder');
	hnd.style.visibility="visible";
	hnd.style.opacity=opaque;                          
	hnd.style.MozOpacity=opaque;
	hnd.style.filter='alpha(opacity='+50+')';     
	hnd.style.zIndex=19;        
	hnd.style.backgroundColor="#000000";
	
	opaque=1;
	
	var hnd=document.getElementById('box');
	hnd.style.opacity=opaque;                          
	hnd.style.MozOpacity=opaque;
	hnd.style.filter='alpha(opacity='+100+')'; 
	
	setTimeout('postrequest()',1000);
	
}
function postrequest()
{
	
	
	 var url ='mail.php?name='+name+"&email="+email+"&query="+content;
// alert(url);

    http.open('post', url,false); 

    http.onreadystatechange = handleResponse; 
	 
    http.send(null); 	
	
}



function handleResponse()
{ 
  
    if(http.readyState == 4)
	{ 
	  
        var response = http.responseText;
		var opaque=0;
	var hnd=document.getElementById('messageholder');
	hnd.style.visibility="hidden";
	hnd.style.opacity=opaque;                          
	hnd.style.MozOpacity=opaque;
	hnd.style.filter='alpha(opacity='+0+')';     
	hnd.style.zIndex=-1;        
	hnd.style.backgroundColor="#000000";
	
	var hnd=document.getElementById('box');
	hnd.style.opacity=opaque;                          
	hnd.style.MozOpacity=opaque;
	hnd.style.filter='alpha(opacity='+100+')'; 
	
	alert(response);
	
	document.getElementById('name').value="";
	document.getElementById('email').value="";
	document.getElementById('content').value="";
	
	
	}
}