this.maxStars = 5;
this.starCount = 0;
var msgDiv = document.getElementById('ratingMsg');
var starHole = 'http://'+getHost()+'/image/star_empty.png';
var starFull = 'http://'+getHost()+'/image/star.png';


this.greyStars = greyStars;
this.colorStars = colorStars;
this.setStars = setStars;
this.showStars = showStars;

function setStars(starNum, formName) {
	this.starCount = starNum;
	this.showStars(starNum);
	var content1='<table border="0" align="center" cellspacing="0" cellpadding="0"><tr>';
	for(var i=0;i<this.maxStars; i++)		
		if (i < starNum)
			content1 = content1 + '<td><img src="http://'+getHost()+'/image/star.png" style="border: 0px"></td>';
		else
			content1 = content1 + '<td><img src="http://'+getHost()+'/image/star_empty.png" style="border: 0px"></td>';
			
	content1 = content1 + '</tr></table>';
	document.getElementById('ratingDiv').innerHTML= content1 ;
	document.forms[formName]['rating'].value = this.starCount;
	var form = document.forms[formName];
	postFormByForm(form,true,blankF);
	//document.forms[this.formName]['rating'].value = this.starCount;		
}

function drawStars(starNum) {
	this.starCount=starNum;
	this.showStars(starNum);
}

function showStars(starNum) {
	this.greyStars();
	this.colorStars(starNum);	
}

function greyStars() {
	for (var i=0; i < this.maxStars; i++)
		if (i <= this.starCount)
			document.getElementById('star' + (i+1)).src = starHole; 
		else
			document.getElementById('star' + (i+1)).src = starHole;
}

function colorStars(starNum) {
	for (var i=0; i < starNum; i++)
		document.getElementById('star' + (i+1)).src = starFull;
}

function reply_comment(id)
{
	var text_id = 'text_' + id;
	var comment = document.getElementById(text_id).value;
	if( comment.replace(/^\s*|\s*$/g,'') == ""){
		alert('please insert comment'); return;}
	var form = document.forms['form_'+id];
	postFormByForm(form,true,button_dim('button_'+id));
	document.getElementById(text_id).disabled = true;
	loadComment();
}

function deleteCommentAndShow(id)
{
	var delForm = document.createElement("form");
	var action = 'http://'+getHost()+'/deletecomment.do';
	delForm.setAttribute('action',action);
	delInput = document.createElement("input");
	delInput.setAttribute('type','hidden');
	delInput.setAttribute('name','cmt');
	delInput.setAttribute('value',id);
	delForm.appendChild(delInput);
	postFormByForm(delForm, true, loadComment());
	setTimeout('loadComment()', 2000);
}

function addFav(id)
{
	var f = document.createElement("form");
	var action = 'http://'+getHost()+'/addfav.do';
	f.setAttribute('action',action);
	delInput = document.createElement("input");
	delInput.setAttribute('type','hidden');
	delInput.setAttribute('name','chid');
	delInput.setAttribute('value',id);
	f.appendChild(delInput);
	postFormByForm(f, true, blankF);
	var addfav = document.getElementById('addfav_div');
	addfav.style.display = '';
	setTimeout('document.getElementById(\'addfav_div\').style.display = \'none\'', 2000)
	
}

function getHost() {
	var url = window.location.href;
	var nohttp = url.split('//')[1];
	var hostPort = nohttp.split('/')[0]
	return (hostPort);
}

