// JavaScript Document
function checkForm()
{   
    if(document.emailfriend.recipient.value == ""){
        alert("Please Enter Recipient's Name.");
       //document.emailfriend.errrecipient.value="Please enter the recipients name";
        document.emailfriend.recipient.focus();    
        return false;    
    }
	if(document.emailfriend.recipientEmail.value == ""){
       alert("Please enter Recipient Email.");
        document.emailfriend.recipientEmail.focus();       
        return false;
    }
   //else document.emailfriend.errrecipient.value="";
    
   /* if(document.emailfriend.recipientEmail.value == ""){
       alert("Please enter Recipient Email.");
        //alert("Hi");
        document.emailfriend.recipientEmail.focus();
        //document.emailfriend.errrecipientEmail.value="Please enter the recipients email address";        
        return false;
    }
    //else document.emailfriend.errrecipientEmail.value="";
    
    
    if(echeck(document.emailfriend.recipientEmail.value=="")){
        // do nothing
    }else{
		alert('Invalid Email Address');
        document.emailfriend.recipientEmail.focus();
        //document.emailfriend.errrecipientEmail.value="Invalid Email Address";
        return false;
    }*/
    
    
    
    if(document.emailfriend.sender.value == ""){
        alert("Please enter your  name.");
        document.emailfriend.sender.focus();
        //document.emailfriend.errsender.value="Please enter your name";
        return false;
    }
	if(document.emailfriend.senderEmail.value == ""){
		alert('Invalid Email Address');
        document.emailfriend.senderEmail.focus();
        return false;
    }
	
    //else document.emailfriend.errsender.value="";
    
/*    if(document.emailfriend.senderEmail.value == ""){
		alert('Invalid Email Address');
        //document.emailfriend.errsenderEmail.value="Please enter your email address";
        document.emailfriend.senderEmail.focus();
        return false;
    }
    //else document.emailfriend.errsenderEmail.value="";
    
    if(echeck(document.emailfriend.senderEmail.value)){
        // do nothing
    }else{
		alert('Invalid Email Address');
        document.emailfriend.senderEmail.focus();
        //document.emailfriend.errsenderEmail.value="Invalid Email Address";
        return false;
    }*/
    ReferObj.slideit();	
	divObj=document.getElementById('progressmeter')
    divObj.style.display=""
    // All ok Send it using AJAX
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
          alert ("Browser does not support HTTP Request")
          return
    }
    var url="./email_send.php"
    url=url+"?recipientEmail="+document.emailfriend.recipientEmail.value
    url=url+"&recipient="+document.emailfriend.recipient.value
    //url=url+"&pId="+document.emailfriend.pId.value
    url=url+"&message="+document.emailfriend.message.value
    url=url+"&sender="+document.emailfriend.sender.value
    url=url+"&senderEmail="+document.emailfriend.senderEmail.value
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    xmlHttp.onreadystatechange = emailreferer       
    return false;
	
}

function GetXmlHttpObject()
{
    var objXMLHttp=null
        if (window.XMLHttpRequest)
            {
            objXMLHttp=new XMLHttpRequest()
            }
        else if (window.ActiveXObject)
            {
            objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
            }
        return objXMLHttp
} 
function emailreferer()
{
	
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {    			
    		divObj=document.getElementById('progressmeter')
		    divObj.style.display="none"
            
            divObj=document.getElementById('MsgSentStatus')			
            divObj.style.display=""
			
            self.setTimeout('refreshsuccessmsg()', 3000);
   }   
}
function refreshsuccessmsg()
{   
    divId="MsgSentStatus"
    divObj.style.display="none"        
}