$(document).ready(function() {
	/* target="_blank" */
	$('a.external').click( function() {
		window.open(this.href);
		return false;
	});

	$(".vote-star").click(function(){
		var forumID = $(this).attr('title').split(" ")[0];
		var sterne = $(this).attr('title').split(" ")[1];
		$.getJSON("ajax/vote.cfm",{ thread: forumID, stern: sterne }, function(data){
		/* @data liefert
				error (string: true/false),
				[errormsg] (string),
				pixelwidth (int),
				forumid (int),
				votes (int)
		*/
			if (data.error == "false") {
				$("#stars-voted-" + forumID).css("width",data.pixelwidth + "px");
				//$("#stars-votes-" + forumID).text(data.votes);
			} else {
				alert(data.errormsg);
			}
		});
		return false;
	});
});

var px = 4;//mehr=schneller
var timer;

function scrollDenDiv(val){
	clearTimeout(timer);
	d=document.getElementById('scroll_div');
	y=d.scrollTop;
	if(val==1)y-=px;
	if(val==2)y+=px;
	if(y<=d.scrollHeight-d.offsetHeight+px&&y>=0-px){
		d.scrollTop=y;
		timer=setTimeout('scrollDenDiv('+val+')',50);
	}
	if(y<0||y>d.scrollHeight-d.offsetHeight){
		clearTimeout(timer);
	}
}

function decryptThis(s) {
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(2));
	}
	return r;
}

function decrypt_mail(element, email, params) {
	if (!params) var params = '';
	element.href = 'mailto:' + decryptThis(email) + params;
}


