var hidden=1;

function getPage(param, id) {
	new Ajax.Request('/getPage', { method: 'post', parameters: param,
  	onSuccess: function(transport, json){
		if(id!='none') $(id).update(transport.responseText);
  	}
	});		
};

function commentsToggle(image,extra) {
	$('comments').toggle();
	$('commentsBox').toggle();
	if(hidden==1) {
		getPage('mode=comments&id='+image+'&extra='+extra,'commentsList');
		hidden=0;
		$('commentText').focus();
	} else {
		hidden=1;
	}
};

function vote(image, vote) {
	getPage("mode=vote&id="+image+"&vote="+vote,'none');
	location.reload(true);
};

function postComment(param,id) {
	getPage(param+"&mode=comment&id="+id,'none');
	var t=setTimeout("getPage('mode=comments&id="+id+"','commentsList')",500);
	$('commentText').value="";
}

function commentField(theForm) {
	if(theForm.value.length > 160) {
		theForm.value=theForm.value.substring(0,160);
	}
	var lengthValue=(160-theForm.value.length);
	if(lengthValue<10) lengthValue="00"+lengthValue;
	else if(lengthValue<100) lengthValue="0"+lengthValue
	$('commentTextCount').innerHTML=' '+lengthValue;
}

function nsfw(value) {
	if(value=='yes') getPage("mode=nsfw&nsfw=yes","none");
	else getPage("mode=nsfw&nsfw=no","none");
	var t=setTimeout("location.reload(true);",500);
}

var addthis_config = {
	ui_cobrand: "hc.fi",
	ui_header_color: "#ffffff",
	ui_header_background: "#444444",
	services_compact: 'email, print, facebook, twitter, favorites, linkedin, myspace, more',
	services_exclude: 'amazonwishlist, ask, ballhype, buzz, kaboodle, fark, kirtsy, newsvine, propeller, reddit, slashdot, stylehive, technorati, thisnext, tipd, yardbarker'
}

