/* Rate System by Germancjk */
function sendRate(id,num) {
	try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: No se ha podido cargar la pagina.");}
	document.getElementById("rating" + id).innerHTML = '<img src="/js/loading.gif" width="16" height="16" alt="Cargando..." />';
	xmlhttp.onreadystatechange = function(){
		if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
			document.getElementById("rating" + id).innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open("GET", "/ajax/rating.php?num=" + num + "&id=" + id);
	xmlhttp.send(null);
	
	return false;
}

/*
Author: Addam M. Driver
Date: 10/31/2006

Modify by: Germancjk
Date: 10/06/2011
*/

var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state

// Rollover for image Stars //
function rating(idg,num){
	sMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}
	
	s = num.id.replace(idg+"_", ''); // Get the selected star
	a = 0;
	for(i=1; i<=sMax; i++){		
		if(i<=s){
			document.getElementById(idg+"_"+i).className = "on";
			// document.getElementById("rateStatus_"+idg).innerHTML = num.title;
			holder = a+1;
			a++;
		}else{
			document.getElementById(idg+"_"+i).className = "";
		}
	}
}

// For when you roll out of the the whole thing //
function off(idg,me,num){
	for(i=1; i<=sMax; i++){		
		document.getElementById(idg+"_"+i).className = "";
		// document.getElementById("rateStatus_"+idg).innerHTML = me.parentNode.title;
	}

	// added germancjk
	// send the object of default rate
	var g = document.getElementById(idg+"_"+num);
	rating(idg,g);
}

// When you actually rate something //
function rateIt(idg,me,num,id){
	// sendRate(me);
	sendRate(id,num);
	rating(idg,me,num);
}

// Send the rating information somewhere using Ajax or something like that.
/*
function sendRate(sel){
	// alert("Votaste: "+sel.title);
}
*/

function agregar(){
//IE
if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
var url="http://www.juegos-vestir.org/"; //
var titulo="Juegos de Vestir"; //
window.external.AddFavorite(url,titulo);
}
//Para Firefox
else {
if(navigator.appName == "Netscape")
//
window.sidebar.addPanel("Juegos de Vestir", "http://www.juegos-vestir.org","");
}
}
