﻿// JScript File

selectStar = function(pStar, hiddenContainerId, labelContainerId, starId) {
	var starBase = pStar.id.substring(0,pStar.id.length-1);
	if (starBase.endsWith("1")) {
	  starBase = starBase.substring(0, starBase.length-1);
	} 

	if (hiddenContainerId != null) {
	  document.getElementById(hiddenContainerId).value = starId; 
	}
  if (labelContainerId != null) {
	  document.getElementById(labelContainerId).innerHTML = starId; 
	}
	//window.stars[starBase] = starId; 

};

hoverStar = function(pStar, labelContainerId, starId) {
	var starBase = pStar.id.substring(0,pStar.id.length-1);
	if (starBase.endsWith("1")) {
	  starBase = starBase.substring(0, starBase.length-1);
	} 
	for (var i = 1; i <= 10; i++) {
		document.getElementById(starBase + i).className = document.getElementById(starBase + i).className.replace("-selected", "");
	}
	for (var i = 1; i <= starId; i++) {
		document.getElementById(starBase + i).className = document.getElementById(starBase + i).className + '-selected';
	}

	if (labelContainerId != null) {
	  document.getElementById(labelContainerId).innerHTML = starId; 
	}
};

clearStars = function(pStar, hiddenContainerId, labelContainerId) {
	var starBase = pStar.id.substring(0,pStar.id.length-1);
	if (starBase.endsWith("1")) {
	  starBase = starBase.substring(0, starBase.length-1);
	} 
	var number = 0;
	if (hiddenContainerId != null) {
	  number = document.getElementById(hiddenContainerId).value; 
	}
		
	for (var i = 1; i <= 10; i++) {
		document.getElementById(starBase + i).className = document.getElementById(starBase + i).className.replace("-selected", "");
	}
	for (var i = 1; i <= number; i++) {
		document.getElementById(starBase + i).className = document.getElementById(starBase + i).className + '-selected';
	}
	if (labelContainerId != null) {
	  if (number == 0) {
	    document.getElementById(labelContainerId).innerHTML = ''; 
	  }
	  else {
	    document.getElementById(labelContainerId).innerHTML = number; 
	  }
	}
	
};

