var xmlHttp
function addtofavorite(str,logged)
{
if(logged == "true")
{
 holderid = str;
xmlHttp=GetXmlHttpObject()
document.getElementById("imgHolder"+holderid).src = "images/icons/preloader.gif";
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 var url="../audio/addtofavorite.php"
 url=url+"?q="+str
 url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
else
{
	window.location.href = "../login.php";
}

}
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	if(xmlHttp.responseText == "fail") {
	document.getElementById("imgHoldertxt"+holderid).innerHTML = "add to favorite&nbsp;&nbsp;|&nbsp;&nbsp;";
document.getElementById("imgHolder"+holderid).src = "images/icons/star_g.gif";
	} else if(xmlHttp.responseText == "succ") {
		document.getElementById("imgHoldertxt"+holderid).innerHTML = "remove favorite&nbsp;&nbsp;|&nbsp;&nbsp;";
	document.getElementById("imgHolder"+holderid).src = "images/icons/star_b.gif";
 }	
 } 
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}