var baseurl = '';

document.onload = set_baseurl();

function set_baseurl() {
        baseurl = document.getElementsByTagName('base')[0].href;
}



function changeDisplay(id) {
	if ($(id).style.display == "none") {
		Effect.BlindDown(id, {duration: 0.5});
	} else {
		Effect.BlindUp(id, {duration: 0.5});
	}
}



function requestBody(body, callback_f)
{
	var opt = {
		method: 'post',
		postBody: body,
		onSuccess: function(t) {
			eval("callback_f(t);");
		},
		on404: function(t) {
			alert('Error 404: location "' + t.statusText + '" was not found.');
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request(ajaxurl, opt);
}


function show(elem) {
       $(elem).style.display = 'block';
}

function hide(elem) {
       $(elem).style.display = 'none';
}

function clear(elem) {
	$(elem).innerHTML = "";
}


function riseAgreement(message, url){
	Dialog.confirm("<b>" + message + "</b>", {windowParameters: {className:'alphacube', width:350},
	okLabel: "Taip", cancelLabel: "Ne", cancel:function(win) {return false;}, ok:function(win) {window.location = url; return true;} });
}

function goURI(href)
{
       window.location.href=href;
}

function voteItem(itemId, value, countId)
{
       var url       = baseurl + "ajax/lt/items/vote/";
       var post      = "item=" + itemId + "&value=" + value;
       new Ajax.Request(url, {
              method: 'post',
              postBody: post,
              onSuccess: function(t) {
                     $(countId).innerHTML = parseInt($(countId).innerHTML) + 1;
              }
       });
}


