voteState = false;
question_de = 'Wie bewerten Sie diesen Beitrag?';
question_en = 'How would you rate this article?';
thanks_de = 'Vielen Dank!';
thanks_en = 'Thank you!';


function initRating() {

	var templ = '';

	if(language[1]=='d') {
		templ+= "<div class=\"ratingQuestion\">" + question_de + "</div><br/>";
	} else {
		templ+= "<div class=\"ratingQuestion\">" + question_en + "</div><br/>";
	}


	for(i=1;i<=10;++i) {
		templ+= "<a id=\"votelink" + i + "\" href=\"javascript:vote(" + i + ");\" onmouseover=\"ratingOver(" + i + ")\" onmouseout=\"ratingOut()\">";
		templ+= "<img id=\"voteimg" + i + "\" src=\"/cso/images/cso_vote.gif\" class=\"ratingQuestion\"  border=\"0\" />";
		templ+= "</a>";
	}

	templ+= "<div class=\"ratingQuestionStepsLeft\">1</div>";
	templ+= "<div class=\"ratingQuestionStepsRight\">10</div>";

	var rDiv = document.getElementById('rating');
	if(rDiv!=null) {
		rDiv.innerHTML = templ;
	}
}

function ratingOver(imgno) {

	if(!voteState) {
		for(i=1;i<=imgno;++i) {
			document.getElementById("voteimg" + i).src = '/cso/images/cso_voteover.gif';
		}
	}
}

function ratingOut() {

	if(!voteState) {
		for(i=1;i<=10;++i) {
			document.getElementById("voteimg" + i).src = '/cso/images/cso_vote.gif';
		}
	}
}

function vote(vt) {

	if(!voteState) {
		$.get(csoPath + '/rating.php5?vote=' + vt + '&page=' + bcPath, {}, function(data){

		});
		
		voteState = true;

		if(language[1]=='d') {
			votedMessage = thanks_de;
		} else {
			votedMessage = thanks_en;
		}
		msgDiv = document.createElement("div");
		msgDiv.className = 'ratingQuestionMsg';
		msgDiv.appendChild(document.createTextNode(votedMessage));
		document.getElementById('rating').appendChild(msgDiv);

	}
}

function sortList(element) {

	var v = element.options[element.selectedIndex].value;
	parent.location.href='?sort=' + v;
}
