// JavaScript Document
function ClickStar(Index,span,hiddenfield,spanNumber){
	Index=Index+2;
	var activespan=document.getElementById("dgRating__ctl"+Index+"_"+span+spanNumber);
	var activeclass=activespan.className
	var currentclass="";
	for (var i=1;i<=3;i++){
		currentclass=document.getElementById("dgRating__ctl"+Index+"_"+span+i).className
		document.getElementById("dgRating__ctl"+Index+"_"+hiddenfield).value=spanNumber;
		if (i<=spanNumber){
			document.getElementById("dgRating__ctl"+Index+"_"+span+i).className=currentclass.replace(' star-red','') +' star-red';
		}
		else{
			document.getElementById("dgRating__ctl"+Index+"_"+span+i).className=currentclass.replace(' star-red','');
		}
		
	}
}

function RolloverStar(Index,span,hiddenfield,spanNumber){
	Index=Index+2;
	var activespan=document.getElementById("dgRating__ctl"+Index+"_"+span+spanNumber);
	var activeclass=activespan.className
	var hiddenvalue=document.getElementById("dgRating__ctl"+Index+"_"+hiddenfield).value;
	var currentclass="";
		if ((hiddenvalue==0) && (activeclass=='star-empty' || activeclass=='star-filled')){
			for (var i=1;i<=spanNumber;i++){
				currentclass=document.getElementById("dgRating__ctl"+Index+"_"+span+i).className
				document.getElementById("dgRating__ctl"+Index+"_"+span+i).className=currentclass +' star-red';
			}
		}
}

function RolloutStar(Index,span,hiddenfield,spanNumber){
	Index=Index+2;
	var activespan=document.getElementById("dgRating__ctl"+Index+"_"+span+spanNumber);
	var activeclass=activespan.className
	var hiddenvalue=document.getElementById("dgRating__ctl"+Index+"_"+hiddenfield).value;
	var currentclass="";
		if (activeclass.indexOf('star-red')>=0 && hiddenvalue==0){
			for (var i=1;i<=3;i++){
				currentclass=document.getElementById("dgRating__ctl"+Index+"_"+span+i).className
				document.getElementById("dgRating__ctl"+Index+"_"+span+i).className=currentclass.replace(' star-red','');
			}
		}
}

function ValidateChoices(){
	var msg="";
	if (document.getElementById("lstChoice1").selectedIndex==0 || document.getElementById("lstChoice2").selectedIndex==0 || document.getElementById("lstChoice3").selectedIndex==0){
		msg="- Please choose your top 3 favorite Candidates for President\n";
	}
	else{
		var choice1=document.getElementById("lstChoice1").options[document.getElementById("lstChoice1").selectedIndex].value;
		var choice2=document.getElementById("lstChoice2").options[document.getElementById("lstChoice2").selectedIndex].value;
		var choice3=document.getElementById("lstChoice3").options[document.getElementById("lstChoice3").selectedIndex].value;
		if (choice1==choice2 || choice1==choice3 || choice2==choice3){
			msg="- Please choose 3 different Candidates\n";	
		}
	}
	return msg;
	}

function ValidateRating(itemscount){
	var filled=true;
	for (var i=2;i<itemscount+2;i++){
		if((document.getElementById("dgRating__ctl"+i+"_RateIntegrity").value==0) || (document.getElementById("dgRating__ctl"+i+"_RateCompetence").value==0) || (document.getElementById("dgRating__ctl"+i+"_RatePersonality").value==0) || (document.getElementById("dgRating__ctl"+i+"_RateCommitment").value==0)){
			filled=false;
			break;
		}
	}
	return filled;
}
function ValidateVotes(itemscount){
	var msg="";
	var msg1="";
	msg1=ValidateChoices();
	if (ValidateRating(itemscount)==false)
		msg="- Please rate all candiates\n"
	msg=msg+msg1;
	if (msg!=""){
		alert(msg)
		return false;
		}
	else
		return true;	
}
