/*****************************************************************************************************/
/*                                                                                                   */
/*                                      'VOTING' CONTROL PANEL                                       */          
/*                                                                                                   */
/*****************************************************************************************************/

var VotingObject = new Object();


function initVotingPanel(){
	if (document.forms['voting_form'] == null){
		return;	
	}

	//daca nu s-a votat inca acest tutorial
	if (document.forms['voting_form'].voting.value == "true"){
		for (var i=1; i<=10; i++){
			var star = document.getElementById("star_"+i);
			star.style.cursor = "pointer";
			star.onmouseover = function(){
				var star_nr = parseInt(this.id.split("_")[1]);
				//coloram toate stelutele pana la cea curenta
				for (var j=1; j<=star_nr; j++){
					var star = document.getElementById("star_"+j);
					star.src = star.src.split("_")[0] +  "_" + star.src.split("_")[1] + "_" + "full_" + star.src.split("_")[3];
				}

				
				//decoloram toate stelutele incepand de la cea curenta
				for (var j=star_nr+1; j<=10; j++){
					var star = document.getElementById("star_"+j);
					star.src = star.src.split("_")[0] +  "_" + star.src.split("_")[1] + "_" + "empty_" + star.src.split("_")[3];
				}
			}

			star.onclick = function(){
				document.forms['voting_form'].mark.value = 	parseInt(this.id.split("_")[1]);
				document.forms['voting_form'].submit();
			}
		}
		

		document.getElementById('stars_container').onmouseout = function(){
			//decoloram toate stelutele incepand de la cea curenta
			for (var j=1; j<=10; j++){
				var star = document.getElementById("star_"+j);
				star.src = star.src.split("_")[0] +  "_" + star.src.split("_")[1] + "_" + "empty_" + star.src.split("_")[3];
			}	
		}
	

	}

	

}



