var img_empty = site_root_path + 'images/star-empty.gif';
var img_full = site_root_path + 'images/star-full.gif';
var objImgSel = null;

function updateRating(objImg) {
	var cur_id = objImg.id.split('-')[1];
	
	for(var i=1; i<=5; i++) {
		if( i<=cur_id ) {
			document.getElementById('rt-'+i.toString()).src = img_full;
		} else {	
			document.getElementById('rt-'+i.toString()).src = img_empty;
		}
	}
	document.getElementById('rt-text').innerHTML = objImg.alt;
	document.getElementById('rt-value').value = cur_id;
}

function clearRating() {
	if( objImgSel !== null ) {
		updateRating(objImgSel);
	} else {
		for(var i=1; i<=5; i++) {
			document.getElementById('rt-'+i.toString()).src = img_empty;
		}
		document.getElementById('rt-text').innerHTML = '';
	}
}

function fixRating(objImg, fieldId) {
	var cur_id = objImg.id.split('-')[1];
	var objRateField = document.getElementById(fieldId);
	
	objImgSel = objImg;
	objRateField.value = cur_id;
}

function submitRating(objImg) {
	var cur_id = objImg.id.split('-')[1];
	document.getElementById('rt-value').value = cur_id;
	document.forms['ratingform'].submit();
}
function submitComment(id) {
//	var cur_id = objImg.id.split('-')[1];
//	document.getElementById('rt-value').value = cur_id;
//alert(document.forms['ratingform'].comments.value);
  if (document.getElementById('rt-value').value=='' || document.forms['ratingform'].comments.value=='' ){
   	showElement('rate_validate')
   	return;
    }

	document.forms['ratingform'].submit();
}

function showElement(element){
	handle = document.getElementById(element);
	handle.style.visibility = 'visible';
	handle.style.display = 'block';
}

function hideElement(element){
	handle = document.getElementById(element);
	handle.style.visibility = 'hidden';
	handle.style.display = 'none';
}