/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    try {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e2) {
      xmlHttp = false;
    }
  }
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function SetValue(id, value){
  var url = '/dinamic/articles?action=save_vote&id='+id+'&value='+value;
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updateVote;
  xmlHttp.send(null);
}
function updateVote() {
	if (xmlHttp.readyState == 4) {
		var response = xmlHttp.responseText;
		document.getElementById("curr_rate").innerHTML = response;
	}
}
//Highlight stars START
var timer;
$(document).ready(function(){

	$("a[tag='star']").each(function() {

		$(this).mouseover(function () {
			var max_rel = $(this).attr('rel');
			clearTimeout(timer);
			$("a[tag='star']").each(function() {
				if($(this).attr('rel') <= max_rel){
					this.style.backgroundImage="url(/images/site/zv2.gif)";
				}
				else{
					this.style.backgroundImage="url(/images/site/zv1.gif)";
				}
			});
		});

		$(this).mouseout(function () {
			var max_rel = $(this).attr('rel');
			clearTimeout(timer);
			$("a[tag='star']").each(function() {
				if($(this).attr('rel') < max_rel){
					this.style.backgroundImage="url(/images/site/zv2.gif)";
				}
				else{
					this.style.backgroundImage="url(/images/site/zv1.gif)";
				}
			});
		});

	});


	$("#all_stars").each(function() {
		$(this).mouseout(function () {
			timer = setTimeout(function(){
				$("a[tag='star']").each(function() {
					this.style.backgroundImage="url(/images/site/zv1.gif)";
				});
			}, 500);
		});
	});

});
//Highlight stars END
