/* Functions for the review elements hover and submit events */

//Changes the hover of the links to pointer. So that users without javascript won't see the links as links.
function showReviewLinks(uniqueID) {
	try {
		document.getElementById('reviewStars' + uniqueID).className = 'stars showLinks';	//changing class
	} catch (err) {
	}
}

//review stars' hover
function reviewStarsHover(uniqueID, stars) {	//hovers the stars before index	
	if (uniqueID != null && uniqueID != '' && stars != null && stars > 0) {
		for (var i=1; i<=5; ++i) {					//hiding the star hovers and showing original stars
			if (i <= stars)
				document.getElementById('star' + uniqueID + '_' + i).className = 'starFull';	//full star
			else
				document.getElementById('star' + uniqueID + '_' + i).className = 'starEmpty';	//empty star
		}
	}
}
//review stars back to original
function reviewStarsHoverOff(uniqueID) {	//hovers off. span with id elementID, has the starvalue
	var starValue = 0;
	if (uniqueID != null && uniqueID != '') {
		try {
			starValue = document.getElementById('starValue' + uniqueID).className;	//getting the original star value
		} catch (err) {
		}
		
		for (var i=1; i<=5; ++i) {					//hiding the star hovers and showing original stars
			if (i <= starValue)
				document.getElementById('star' + uniqueID + '_' + i).className = 'starFull';	//full star
			else
				document.getElementById('star' + uniqueID + '_' + i).className = 'starEmpty';	//empty star
		}
	}
}
 
//submit vote
function reviewSubmit(uniqueID, starValue) {	//submits the review element form
	if (uniqueID != null && uniqueID != '' && starValue != null && starValue > 0 && starValue <= 5) {
		try {
			document.getElementById('voteValue' + uniqueID).value = starValue;	//setting the input field value
		} catch (err) {
		}
		
		document.getElementById('reviewForm' + uniqueID).submit();		//submitting the form
	}
}

