function showTooltip(name, e) {
	var elem = $(name + 'Tooltip');
	elem.style.visibility = 'visible';

	if(e.clientX > screen.width) {
		elem.style.left = screen.width + 'px';
	} else {
		elem.style.left = e.clientX + 20 + 'px';
	}

	elem.style.top = e.clientY + 'px';
}

function hideTooltip(name) {
	$(name + 'Tooltip').style.visibility = 'hidden';
}

function switchMenu(obj) {
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'block') ? 'block' : 'none';
}

function checkNewPageForm(f) {
	var error = '';

	with(f) {
		if(isEmpty(page_name)) {
			error += "Niste vnesli ime spletne strani!\n";
		}

		if(isEmpty(page_title)) {
			error += "Niste vnesli naslov (title) spletne strani!\n";
		}
	}

	if(error != '') {
		alert("Opozorilo:\n\n" + error);
		return false;
	}

	return true;
}

function redirect(url) {
	location.href = url;
}

function isEmpty(elem) {
	return (elem.value == '');
}

function isEmail(email) {
	if(email && typeof email == 'object') email = email.value;

	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(email);
}

function OpenWindow(url, width, height, top, left) {
	if(top == undefined) top = 0;
	if(left == undefined) left = 0;
	if(width == undefined) width = 820;
	if(height == undefined) height = 880;

	var win = window.open(url, "",'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+ height +',top='+top+',left='+left);
}

function popUp(url, width, height, top, left) {
	OpenWindow(url, width, height, top, left);
}

function customWindow(url) {
	OpenWindow(url, 660, 500, 0, 0);
}

function AjaxGetter(url) {
	$('loaderDiv').style.visibility = 'visible';
	$('loaderDiv').innerHTML = "<div class='loader_div'><img src='images/ajax-loader.gif' align='absmiddle'></div>";
	new Ajax.Request(url, {asynchronous:true, method: 'get', onSuccess:handlerFunc});

}

function handlerFunc() {
	$('loaderDiv').innerHTML = '';
	$('loaderDiv').style.visibility = 'hidden';
}

