// JavaScript Document
var star_on = "images/template/yellowstar.jpg";
var star_off = "images/template/whitestar.jpg";
var num_stars = 0;

function SE( id )
{
	return document.getElementById( id );
}

function doRate( id )
{
	SE( "rating" ).value = id;
}

function doHighlight( id )
{
	for ( var x = 1 ; x < id + 1 ; x++ )
	{
		if ( SE( "Rate_" + x ) )
		{
			SE( "Rate_" + x ).src = star_on;
		}
		else
		{
			break;
		}
	}
	for ( var i = id + 1 ; i < num_stars + 1 ; i++ )
	{
		if ( SE( "Rate_" + i ) )
		{
			SE( "Rate_" + i ).src = star_off;
		}
		else
		{
			break;
		}
	}
}

function doMsOut( )
{
	var svdrtng = 1*SE( "rating" ).value;
	doHighlight( svdrtng );
}

function BuildStars( qty )
{
	if ( qty == "" )
	{
		qty = 5;
	}
	num_stars = qty;
	
	for ( var x = 1 ; x < qty+1 ; x++ )
	{
		document.write( '<img src="' + star_off + '" onMouseOver="doHighlight(' + x + ')" onMouseOut="doMsOut()" onClick="doRate(' + x + ')" id="Rate_' + x + '" style="cursor:pointer; cursor:hand; display:inline;">' );
	}
	
	document.write( '<span style="padding-left:10px; font-size:10px;">(Please Select One)</span> <input type="hidden" id="rating" name="rating" value="0">' );
}
