//==================================
//  toggle star color on mouseover
//==================================
function changestar0(imgobject) { imgobject.src = "/img/rating-0.jpg"; }
function changestar1(imgobject) { imgobject.src = "/img/rating-1.jpg"; }
function changestar2(imgobject) { imgobject.src = "/img/rating-2.jpg"; }

//==================================
//  ajax: send http
//==================================
function setvote(template, vote, textelem)
{
	request = (typeof(XMLHttpRequest) != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
	request.open("GET", "/templates/voter.php?a=" + template + "&b=" + vote, false);
	request.send(null);

	if ( !request.getResponseHeader("Date") )
	{
		var cached = request;
		request = (typeof(XMLHttpRequest) != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
		var ifModifiedSince = cached.getResponseHeader("Last-Modified");
		ifModifiedSince = (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
		request.open("GET", "/templates/voter.php?a=" + template + "&b=" + vote, false);
		request.setRequestHeader("If-Modified-Since", ifModifiedSince);
		request.send(null);
		if ( request.status == 304 ) request = cached;
	}
	textelem.innerHTML = 'Vote cast';
}

//==================================
//  ajax: count download
//==================================
function setdownloadcount(template, vote)
{
	request = (typeof(XMLHttpRequest) != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
	request.open("GET", "/templates/counter.php?a=" + template, false);
	request.send(null);

	if ( !request.getResponseHeader("Date") )
	{
		var cached = request;
		request = (typeof(XMLHttpRequest) != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
		var ifModifiedSince = cached.getResponseHeader("Last-Modified");
		ifModifiedSince = (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
		request.open("GET", "/templates/counter.php?a=" + template, false);
		request.setRequestHeader("If-Modified-Since", ifModifiedSince);
		request.send(null);
		if ( request.status == 304 ) request = cached;
	}
}