var minus = siterelpath + 'images/misc/content/minus.jpg';
var plus  = siterelpath + 'images/misc/content/plus.jpg';
var previousReply;

function showHidden ( id_comments, button, other )	{

	var comment = document.getElementById( id_comments );
	var view = comment.style.display;
	
	if (view == "block")	{
		button.src = plus;
		comment.style.display = "none";
	}
	if (view == "none")	{
		button.src = minus;
		comment.style.display = "block";
	}
	
}

function article ( id )	{

	var art = document.getElementById( 'article_' + id );
	var wra = document.getElementById( 'wrapper_' + id );
	var button = document.getElementById( 'button_' + id );
	var view = art.style.display;
	
	if (view == "inline")	{
		button.src = plus;
		art.style.display = "none";
		wra.style.display = "inline";
	}
	if (view == "none")	{
		button.src = minus;
		art.style.display = "inline";
		wra.style.display = "none";
	}
	
}

function mask ( id, iNoArticles )	{
	
	var iCommentblock = 0;
	var oCom = 0;
	var oImg = 0;
	var oEle = 0;
	
	showReply(0);
	
	for (iCommentblock = 1; iCommentblock <= iNoArticles; iCommentblock++) {
		oCom = document.getElementById( 'comment_' +  iCommentblock);
		oImg = document.getElementById( 'image_' +  iCommentblock);

		if (oCom != null && iCommentblock != id && oImg != null) {
			oCom.style.display = 'none';
			oImg.src = plus; 
		}
	}	
	
}

function showReply ( id )	{

	if ( previousReply ) {
		var old_reply = document.getElementById( previousReply );
		old_reply.style.display = 'none';
	}
	previousReply = 'reply_' + id;
	var reply = document.getElementById( 'reply_0' );
	var my_reply = document.getElementById( 'reply_' + id );
	
	reply.style.display = 'none';
	my_reply.style.display = 'block';

}

function expandAll( iNoArticles ) {

	var iCommentblock = 0;
	var sDisplay = "";
	var sIcon = "";
	var oCom = 0;
	var oImg = 0;
	var oEle = 0;
	
	showReply(0);

	if(document.getElementById('expandall').innerHTML == 'alle ausklappen') {
		document.getElementById('expandall').innerHTML = 'alle einklappen';
		//document.getElementById('expandall2').innerHTML = 'alle einklappen';
		sDisplay = "block";
		sIcon = minus;
	} else {
		document.getElementById('expandall').innerHTML = 'alle ausklappen';
		//document.getElementById('expandall2').innerHTML = 'alle ausklappen';
		sDisplay = "none";
		sIcon = plus;
	}
	
	for (iCommentblock = 1; iCommentblock <= iNoArticles; iCommentblock++) {
		oCom = document.getElementById( 'comment_' +  iCommentblock);
		oImg = document.getElementById( 'image_' +  iCommentblock);
		
		if (oCom != null) {
			oCom.style.display = sDisplay;
			oImg.src = sIcon;
		} 
	}	

}

function toggleElement(id){
	return ( document.getElementById(id).style.display && document.getElementById(id).style.display == 'none'? document.getElementById(id).style.display = 'block' : document.getElementById(id).style.display = 'none' ) == 'none' ? false : true;
} 

/* voting comments is disabled. crash with mootools-tab */
/* voting in comments */
/*
function vote(tablefield_ID, related_ID, user_ID, voting) {
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'storeVote', tablefield_ID, related_ID, user_ID, voting, showVoted);
}

function showVoted(r) {
	var svoting = "";
	
	if (eval(r.brefresh)) {
		$('starAverage' + r.related_id).title = r.faveragevoting;
		$('starAverageCur' + r.related_id).style.width = Math.ceil(r.faveragevoting*12) + "px";
		if(r.ivotecount == 0) {
			svoting = "n/a (0 votes)";
		} else if (r.ivotecount == 1) {
			svoting = r.faveragevoting + " (1 vote)";
		} else {
			svoting = r.faveragevoting + " (" + r.ivotecount + " votes)";
		}
		$('starAverageVote' + r.related_id).innerHTML = svoting;
		$S('starCur' + r.related_id).width=Math.round(r.ivoting*12)+'px';
		$('starCur' + r.related_id).title = r.ivoting;
		star.nval = r.ivoting;
	}
//	alert(r.sreturn);
}
*/
/* AJAX Star Rating : v1.0.3 : 2008/05/06 */
/* http://www.nofunc.com/AJAX_Star_Rating/ */
/* heavily adapted by CONTENS */
/*
function $(v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); }
function $S(o) { return((typeof(o)=='object'?o:$(o)).style); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function abPos(o) { var o=(typeof(o)=='object'?o:$(o)), z={X:0,Y:0}; while(o!=null) { z.X+=o.offsetLeft; z.Y+=o.offsetTop; o=o.offsetParent; }; return(z); }
function XY(e,v) { var o=agent('msie')?{'X':event.clientX+document.documentElement.scrollLeft,'Y':event.clientY+document.documentElement.scrollTop}:{'X':e.pageX,'Y':e.pageY}; return(v?o[v]:o); }

star={};

star.mouse = function(e,o) { 
	if(star.stop || isNaN(star.stop)) {
		
		star.stop=0;
		star.nval=$('starCur'+o.id.substr(4)).title;
		 
		document.onmousemove = function(e) {
			
			var n = star.num;
			var p = abPos($('star'+n));
			var x = XY(e);
			var oX = x.X-p.X;
			var oY = x.Y-p.Y;
			star.num = o.id.substr(4);

			if(oX<1 || oX>60 || oY<0 || oY>11) {
				star.stop = 1;
				star.revert();
			} else {
				$S('starCur'+n).width = (Math.ceil(oX/12))*12+'px';
				$('starCur'+n).title = Math.ceil(oX/12);
                switch($('starCur'+n).title) {
                    case "1": $('starUserRating'+n).innerHTML = "<span style='color:#E42C0C'>Unsatisfactory</span>"; break;
                    case "2": $('starUserRating'+n).innerHTML = "<span style='color:#E42C0C'>Average</span>"; break;
                    case "3": $('starUserRating'+n).innerHTML = "<span style='color:#E42C0C'>Good</span>"; break;
                    case "4": $('starUserRating'+n).innerHTML = "<span style='color:#E42C0C'>Very Good</span>"; break;
                    case "5": $('starUserRating'+n).innerHTML = "<span style='color:#E42C0C'>Excellent</span>"; break;
                }
			}
		
		};
	}
};

star.update=function(e,o,tablefield_ID,related_ID,user_ID) {

	var n = star.num;
	var v = parseFloat($('starCur'+n).title);

	n = o.id.substr(4);

	vote(tablefield_ID,related_ID,user_ID,v);

};

star.revert=function() {
	
	var n = star.num;

	$S('starCur'+n).width=Math.round((isNaN(star.nval)?0:star.nval)*12)+'px';
	$('starCur'+n).title = star.nval;
	$('starUserRating'+n).innerHTML = "Your Rating:";

	document.onmousemove='';

};

star.num=0;*/
