var xmlHttp
function GetXmlHttpObject(){ 
	var objXMLHttp=null
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject){
		try{
			objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(e){
		}
	}
	return objXMLHttp
}

function sentEmail(url)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var friendName = document.sendFriendEmail.friendName.value;
	var friendEmail = document.sendFriendEmail.friendEmail.value;
	var yourName = document.sendFriendEmail.yourName.value;
	var yourEmail = document.sendFriendEmail.yourEmail.value;
    var comments = document.sendFriendEmail.comments.value;
	var ad_id=document.sendFriendEmailS.ad_id.value;

	
	
var passData = 'friendName='+escape(friendName)+'&friendEmail='+escape(friendEmail)+'&yourName='+escape(yourName)+'&yourEmail='+escape(yourEmail)+'&comments='+escape(comments)+'&ad_id='+escape(ad_id);
	
	 document.sendFriendEmail.friendName.value='';
	 document.sendFriendEmail.friendEmail.value='';
     document.sendFriendEmail.yourName.value='';
	 document.sendFriendEmail.yourEmail.value='';
     document.sendFriendEmail.comments.value='';
	 
	
	var url=url+"sendemail.php";
	/*url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=dispEMail 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)*/

	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange =  dispEMail;      
	xmlHttp.send(passData);
}

function sentEmailSeller(url)
{
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var yourName = document.sendFriendEmailS.yourName.value;
	var yourEmail = document.sendFriendEmailS.yourEmail.value;
    var comments = document.sendFriendEmailS.comments.value;
	
	
	var ad_id=document.sendFriendEmailS.ad_id.value;
	
	
var passData = 'yourName='+escape(yourName)+'&yourEmail='+escape(yourEmail)+'&comments='+escape(comments)+'&ad_id='+escape(ad_id);

	document.sendFriendEmailS.yourName.value ='';
	document.sendFriendEmailS.yourEmail.value ='';
    document.sendFriendEmailS.comments.value ='';
	
	
	var url=url+"sendselleremail.php";
	/*url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=dispEMail 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)*/

	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange =  dispEMailS;      
	xmlHttp.send(passData);
}


function dispEMail(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		//alert(xmlHttp.responseText);
		if(xmlHttp.responseText==0)
		{
		document.getElementById("success").style.display = "block";
		document.getElementById("outmostDiv").style.display = "none";
		}else
		{
		document.getElementById("successContent").innerHTML=xmlHttp.responseText 
		}
		
	} 
	
}




function dispEMailS(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		//alert(xmlHttp.responseText);
		if(xmlHttp.responseText==0)
		{
		document.getElementById("successS").style.display = "block";
		document.getElementById("outmostDivS").style.display = "none";
		}else
		{
		document.getElementById("successContentS").innerHTML=xmlHttp.responseText 
		}
		
	} 
	
}