function StarOver(ev,iStars,sStarID,version) {

	var e = navigator.appName.indexOf("Microsoft")>-1 ? event.srcElement : ev.target;

	if (!version)
		version = "1";

	if (version == "1") {

		if (e.tagName == "IMG")
		{
			var iStarsToFill = e.id.replace(/\D/gi,"")*1;
			for (var i=1;i<=iStars;i++)
			{
				if (i <= iStarsToFill)
					document.getElementById(sStarID+i).src = document.getElementById(sStarID+i).src.replace(/\-empty\-/gi,"-full-");
				else
					document.getElementById(sStarID+i).src = document.getElementById(sStarID+i).src.replace(/\-full\-/gi,"-empty-");
			}
		}

	} else if (version == "2") {
		
		if ($(e.parentNode).hasClass("star")) {
			var iStarsToFill = e.id.replace(/\D/gi,"")*1;
			for (var i=1;i<=iStars;i++)
			{
				if (i <= iStarsToFill)
					document.getElementById(sStarID+i).className = document.getElementById(sStarID+i).className.replace(/\-empty/gi,"-full");
				else
					document.getElementById(sStarID+i).className = document.getElementById(sStarID+i).className.replace(/\-full/gi,"-empty");
			}

			AddFlopMessage(iStarsToFill);
		}
	} else if (version == "3") {
		
		if ($(e.parentNode).hasClass("star")) {
			var iStarsToFill = e.id.replace(/\D/gi,"")*1;
			
			for (var i=1;i<=iStars;i++)
			{
				if (i <= iStarsToFill)
					document.getElementById(sStarID+i).className = document.getElementById(sStarID+i).className.replace(/\-empty/gi,"-full");
				else
					document.getElementById(sStarID+i).className = document.getElementById(sStarID+i).className.replace(/\-full/gi,"-empty");
			}
		}
	}
}

function AddFlopMessage(iStars) {

	if (iStars <= 2.5 * 2) {
		$("#hit-tooltip").css("display","none");
		$("#flop-tooltip").css("display","block");

		$("#aFlop").css("color","#323232");
		$("#aHit").css("color","#acacac");

	} else {
		
		var sMessageToolTip = "Add it to your Watched Movies Catalouge";
		$("#hit-tooltip").css("left","36px").find(".center").css("width","206px");
		$("#hit-tooltip").find(".arrow").css("left","189px");

		if (iStars >= 4.5 * 2) {
			$("#hit-tooltip").css("left","0px").find(".center").css("width","277px");
			$("#hit-tooltip").find(".arrow").css("left","225px");

			sMessageToolTip += " and Become a Fan";
		}
		$("#hit-tooltip").find(".text").html(sMessageToolTip);

		$("#flop-tooltip").css("display","none");
		$("#hit-tooltip").css("display","block");


		$("#aFlop").css("color","#acacac");
		$("#aHit").css("color","#323232");
	}
}


function StarOut(ev,iStars,sStarID,iStarsToFill, version) {

	var e = navigator.appName.indexOf("Microsoft")>-1 ? event.srcElement : ev.target;

	if (!version)
		version = "1";

	if (version == "1") {

		if (e.tagName == "IMG")
		{
			for (var i=1;i<=iStars;i++)
			{
				if (i <= iStarsToFill)
					document.getElementById(sStarID+i).src = document.getElementById(sStarID+i).src.replace(/\-empty\-/gi,"-full-");
				else
					document.getElementById(sStarID+i).src = document.getElementById(sStarID+i).src.replace(/\-full\-/gi,"-empty-");
			}
		}
	} else if (version == "2") {

		if ($(e.parentNode).hasClass("star")) {
			for (var i=1;i<=iStars;i++)
			{
				if (i <= iStarsToFill)
					document.getElementById(sStarID+i).className = document.getElementById(sStarID+i).className.replace(/\-empty/gi,"-full");
				else
					document.getElementById(sStarID+i).className = document.getElementById(sStarID+i).className.replace(/\-full/gi,"-empty");
			}
		}

		AddFlopMessage(iStars);
		$("#flop-tooltip").css("display","none");
		$("#hit-tooltip").css("display","none");
		

	}
}

function StarSelect(ev,sIdToChange,sMessage,version,params) {

	if (!protectMembers()) return false;

	var e = navigator.appName.indexOf("Microsoft")>-1 ? event.srcElement : ev.target;

	if (!version)
		version = "1";

	if (version == "1") {

		if (e.tagName == "IMG")
		{
			iAnswerSelected = e.id.replace(/\D/gi,"")*1;
			 $.ajax({
			   type: "POST",
			   url: ROOT_URL+"pro-movies.asp?rnd="+new Date().getTime(),
			   data: {act:"updateViewStatus",id:movieId,viewStatus:1,rate:iAnswerSelected},
			   success: function(msg){
					if (iAnswerSelected >= 6)
					{
						document.getElementById("Wizard_Answer1").style.color = '#cdcdcd';
						document.getElementById("Wizard_Answer2").style.color = '';
					} else {
						document.getElementById("Wizard_Answer2").style.color = '#cdcdcd';
						document.getElementById("Wizard_Answer1").style.color = '';
					}
					document.getElementById(sIdToChange).innerHTML = sMessage;
					document.getElementById("Wizard_Watched").onmouseover = document.getElementById("Wizard_Watched").onclick = null;
					document.getElementById("StarsContainer").onmouseout = null;
					
					var imgAllStars = e.parentNode.parentNode.getElementsByTagName("IMG");
					for (var i=0;i<imgAllStars.length;i++)
					{
						if (imgAllStars[i].className.indexOf("star") > -1)
						{
							imgAllStars[i].style.cursor="default";
						}
					}
			   }
			});
		}

	} else if (version == "2") {

		if ($(e.parentNode).hasClass("star")) {
			
			iAnswerSelected = e.id.replace(/\D/gi,"")*1;
			

			 $.ajax({
			   type: "POST",
			   url: ROOT_URL+"pro-movies.asp?rnd="+new Date().getTime(),
			   data: {act:"updateViewStatus",id:movieId,viewStatus:1,rate:iAnswerSelected},
			   success: function(msg){

					document.getElementById(sIdToChange).innerHTML = sMessage;
					/*document.getElementById("Wizard_Watched").onmouseover = document.getElementById("Wizard_Watched").onclick = null;
					document.getElementById("StarsContainer").onmouseout = null;*/

					$("#flop-tooltip").css("display","none");
					$("#hit-tooltip").css("display","none");
					$("#aFlop").removeClass("color8");
					$("#aHit").removeClass("color8");

					$("#StarsContainer").find(".star").css("cursor","default");


					ShowStars(iAnswerSelected,params.objectName);
					
			   }
			});

		}

	} else if (version == "3") {

		if ($(e.parentNode).hasClass("star")) {

			/*document.getElementById("Wizard_Watched2").onmouseout = null;
			document.getElementById("Wizard_Watched2").onclick = null;
			document.getElementById("starscontainer2").onmouseover = null;*/			
			
			iAnswerSelected = (e.id+"").replace(/\D/gi,"")*1;
			

			$.ajax({
				type: "POST",
				url: ROOT_URL+"pro-movies.asp?rnd="+new Date().getTime(),
				data: {act:"updateViewStatus",id:movieId,viewStatus:1,rate:iAnswerSelected},
				success: function(msg) {
					ShowStars(iAnswerSelected,params.objectName);	
				}
			});

		}

	}
}

function NovShowStarsDialog(bToShow) {
	if (bToShow) {
		$("#StarsDialogNov").css("display","block");
		$("#list-action-staractivator").addClass("hover");
	} else {
		$("#StarsDialogNov").css("display","none");
		$("#list-action-staractivator").removeClass("hover");
	}
}
