var cid;
var wr;

function SendReq(queryString) {
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {  // Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {  // IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', wr+'/favorites_server.php', true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			UpdatePage(self.xmlHttpReq.responseText);
		}
	}
	self.xmlHttpReq.send(queryString);
}

function ToggleFavorite(sid, awr) {
	cid = sid;
	wr = awr;
	qstr = 'sid=' + sid;
	SendReq(qstr);
}

function UpdatePage(str){
	if (str=="1")
		document.getElementById('fav_'+cid).style.background = "url("+wr+"/_images/favorite_on.gif)";
	else
		document.getElementById('fav_'+cid).style.background = "url("+wr+"/_images/favorite_off.gif)";
}


