/*
 * BS | nbsp GmbH | JS-Funktionen für Artikelbewertung
 * ****************************************************************
 */

function callbackRating() {
    if(xmlhttp.readyState != 4) {
        //alert('Seite wird geladen ...');
    }
    if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		document.getElementById('ratingsend').innerHTML 	= '';
		document.getElementById('starsoverall').innerHTML 	= xmlhttp.responseText;
    }
}

function doRate(rating,doc){
	
	var params = "rating="+rating+"&doc="+doc;

	//Abfrage Starten
	xmlhttp.open("POST", siteurl+'/index.cfm?event=articles.dorate', true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.onreadystatechange = callbackRating
	//Verbindung beenden
	xmlhttp.send(params);	
}

function setStars(starno){
	
	var i;
	for (i=1;i<(starno+1);i++)
	{
		document.getElementById('star'+i).src = '/img/icons/star_on.png';		
	}
	for (j=i;j<6;j++)
	{
		document.getElementById('star'+j).src = '/img/icons/star_off.png';
	}
	document.getElementById('rating').value = starno;
	
}

/*
 * BS | nbsp GmbH | JS-Funktionen für Artikel-Kommentierung
 * ****************************************************************
 */

function callbackComment() {
    if(xmlhttp.readyState != 4) {
        //alert('Seite wird geladen ...');
    }
	

    if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		
		var response = xmlhttp.responseText;
		var aResponse = response.split("|",3);
		var elementname = 'comment_'+aResponse[0];
		var buttonname = 'morebutton_'+aResponse[0];
		var full = aResponse[2];
		
		if(full == 0){
			document.getElementById(buttonname).innerHTML = '<a class="more" href="javascript:getComment('+aResponse[0]+',1)" onclick="">Aufklappen</a>';

		}else{
			document.getElementById(buttonname).innerHTML = '<a class="more" href="javascript:getComment('+aResponse[0]+',0)" onclick="">Einklappen</a>';
		}		
		document.getElementById(elementname).innerHTML = aResponse[1];
    
    }
}

function getComment(commentid,full){
	
	var params = "commentid="+commentid+"&full="+full;

	//Abfrage Starten
	xmlhttp.open("POST", siteurl+'/index.cfm?event=articles.getcomment', true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.onreadystatechange = callbackComment
	//Verbindung beenden
	xmlhttp.send(params);	
}


