var starsMin;
var starsMax;
var starsStep;
var starsDefault;

function starsCreate(min, max, step, start, container)
{
	starsMin=min;
	starsMax=max;
	starsStep=step;
	starsDefault=start;
	var table=document.createElement('table');
	var tr=document.createElement('tr');
	for ( i=min ; i<=max ; i+=step )
	{
		var img=document.createElement('img');
		img.setAttribute('id', 'star_' + i);
		img.setAttribute('onmouseover', 'starsOnMouseOver(this);');
		img.onmouseover=function() { starsOnMouseOver(this); }
		img.setAttribute('onclick', 'starsOnClick(this);');
		img.onclick=function() { starsOnClick(this); }
		img.style.cursor="pointer";
		img.style.display="block";
		img.style.fontSize="0";
		img.style.height="16px";
		img.style.width="16px";
		img.style.margin="0";
		img.style.padding="0";
		img.style.float="left";
		img.style.border="none";
		//container.appendChild(img);
		var td=document.createElement('td');
		td.appendChild(img);
		td.style.padding="0";
		tr.appendChild(td);
	}
	table.appendChild(tr);
	container.appendChild(table);
	starsMark(start);
	container.setAttribute('onmouseout', 'starsOnMouseOut(this);');
	container.onmouseout=function() { starsOnMouseOut(this); }
}

function starsCreateIE(min, max, step, start, container)
{
	starsMin=min;
	starsMax=max;
	starsStep=step;
	starsDefault=start;
	document.write('<div onmouseout="starsOnMouseOut(this);"><table><tr>');
	for ( i=min ; i<=max ; i+=step )
		document.write('<td><img id="star_' + i + '" onmouseover="starsOnMouseOver(this);" onclick="starsOnClick(this);" alt="' + i + '"/></td>');
	document.write('</tr></table></div>');
	starsMark(start);
}

function starsGetNote(star)
{
	var re=new RegExp('star_([0-9]+)');
	var note=re.exec(star.id);
	return note[1];
}

function starsMark(lim)
{
	for ( i=starsMin ; i<=lim ; i+=starsStep )
		document.getElementById('star_' + i).src="starsMarked.gif";
	for ( i=parseInt(lim)+starsStep ; i<=starsMax ; i+=starsStep )
		document.getElementById('star_' + i).src="starsUnmarked.gif";
}

function starsOnClick(star)
{
	var note=starsGetNote(star);
	document.formOcena.ocena.value=note;
	document.formOcena.submit();
}

function starsOnMouseOut(star)
{
	starsMark(starsDefault);
}

function starsOnMouseOver(star)
{
	starsMark(starsGetNote(star));
}
