var xmlHttppm;
function sendPM()
{ 
var pm_touser=document.getElementById("pm_touser").value;
var pm_sub=document.getElementById("pm_sub").value;
var pm_mat=document.getElementById("pm_matter").value;
var pm_date=document.getElementById("pm_date").value;
var pm_fruser=document.getElementById("pm_fruser").value;	
var home_link=document.getElementById("pm_home_link").value;
xmlHttppm=GetXmlHttpObject()
if (xmlHttppm==null)
{
alert ("Browser does not support HTTP Request")
return 
}
if((pm_touser=="")||(pm_sub=="")||(pm_mat==""))
{
alert("Must fill all fields");
return ;
}
else
{
var url=home_link+"plugins/site/themes/default/addpm.php"
url=url+"?to="+pm_touser+"&sub="+pm_sub+"&mat="+pm_mat+"&d="+pm_date+"&fr="+pm_fruser;
xmlHttppm.open("GET",url,true)
xmlHttppm.onreadystatechange=stateChangedpm ;
xmlHttppm.send(null);
}
}

function stateChangedpm() 
{ 
if (xmlHttppm.readyState==4 )
{ 

if(xmlHttppm.responseText=='1')
{
document.getElementById("pm_sub").value='';
document.getElementById("pm_matter").value='';
alert('Your PM send successfully.');
}
else if(xmlHttppm.responseText=='0')
{
document.getElementById("pm_touser").value='';
alert('Please choose a valid username to send your PM .');
}
} 
}


function GetXmlHttpObject()
{
	var xmlHttppm=null;
	
try
 {
	 // Firefox, Opera 8.0+, Safari
 xmlHttppm=new XMLHttpRequest();
 }
catch (e)
 {
	
 //Internet Explorer
 try
  {
  xmlHttppm=new ActiveXObject("Msxml2.XMLHTTP");
 
  }
 catch (e)
  {
	  
  xmlHttppm=new ActiveXObject("Microsoft.XMLHTTP");
  
  }
 }
 
 
return xmlHttppm;
}

function cancelPM()
{ 
document.getElementById("pm_touser").value='';
document.getElementById("pm_sub").value='';
document.getElementById("pm_matter").value='';
document.getElementById("pm_toname").value='';	

}

