// JavaScript Document

var psMax;	// Isthe maximum number of stars
var pholder; // Is the holding pattern for clicked state
var ppreSet; // Is the ppreSet value onces a selection has been made
var prated=0;

// Rollover for image Stars //
function precioRating(num,flag){
	psMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			psMax++;	
		}
	}

	if(!prated){
		s = num.id.replace("_"+flag, ''); // Get the selected star
		a = 0;
		for(i=1; i<=psMax; i++){		
			if(i<=s){
				document.getElementById("_"+flag+i).className = "on";
				//document.getElementById("rateStatus").innerHTML = num.title;	
				pholder = a+1;
				a++;
			}else{
				document.getElementById("_"+flag+i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function precioOff(me,flag){
	if(!prated){
		if(!ppreSet){	
			for(i=1; i<=psMax; i++){		
				document.getElementById("_"+flag+i).className = "";
				//document.getElementById("rateStatus").innerHTML = me.parentNode.title;
			}
		}else{
			rating(ppreSet);
			//document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML;
		}
	}
}

// When you actually rate something //
function precioRateIt(me){
	if(!prated){
		//document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML + " :: "+me.title;
		ppreSet = me;
		prated++;
		//sendRate(me);
		rating(me);
	}
}

function precioRate(num,flag){
	s = num.id.replace("_"+flag, '');
	if (!prated)
	{
		document.getElementById("comentario_precio_valor").value = s;	
	}
	ppreSet = num;
	prated=1;	
}

