function showcomments( artid ) {
	elm = document.getElementById("comments_" + artid);
	if(!elm) return true; 

	if(elm.innerHTML == "" || elm.innerHTML == "<!-- comments -->") {
		new ajax( '/comments.php', { postBody: 'article='+artid, update: $('comments_'+artid), onComplete: displayComments(artid) });
	} else {
		return displayComments(artid);
	}

	return false;
}

function loadtaste( username ) {
	elm = document.getElementById("lasttaste");
	if(!elm) return true;
	if(username.length > 0) {
		$('lasttaste').innerHTML="<img src='/images/loading.gif'>";
		$('lasttaste').style.display='block';
		bla = new ajax('/lasttaste.php', { postBody: 'username='+username, update: $('lasttaste') });
	}
}

function displayComments( artid ) {
	elm = document.getElementById("comments_" + artid);
	if(!elm) return true; 

	if(elm.style.display != 'block') {
		elm.style.display = 'block';
	} else {
		elm.style.display = 'none';
	}
	return false;
}

function submitform(formname) {
	eval("form = document.forms."+formname+";");
	if(!form) return true;
	div = document.getElementById("comments_" + form.article.value);
	if(!div) {
		form.article.value += "index.html";
		div = document.getElementById("comments_" + form.article.value);
	} 
	if(!div)
		return true;

	// calc radio input
	var antispam = 0;
	if(form.antispam[0].checked) antispam = form.antispam[0].value;
	if(form.antispam[1].checked) antispam = form.antispam[1].value;
	if(form.antispam[2].checked) antispam = form.antispam[2].value;

	new ajax( '/comments.php', {
		postBody: 'article=' + form.article.value + '&mode=' + form.mode.value + '&name=' + escape(form.name.value) + '&comment=' + escape(form.comment.value) + '&email=' + escape(form.email.value) + '&antispam=' + escape(antispam),
		update: $('comments_' + form.article.value) 
		});

	return false;
}

var kscroll;

function init() {
	kscroll = new fx.Scroll();	
}

function scrollto(elm) {
	kscroll.scrollTo(elm);
	return false;
}
