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 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 getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function checkAnketa(f) {
	var check = false;
	var len = f.answer_id.length;

	for(var i = 0; i < len; i++)
		if(f.answer_id[i].checked == true)
   			check = true;

	if(!check) {
		alert("Niste izbrali odgovora!");
		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 makeBackup(url){
	$('backupdiv').innerHTML = '<img src="../images/ajax-loader.gif" style="position:absolute; margin-top:-10px;">';
	new Ajax.Request(url, {asynchronous: true, method: 'post', parameters:'', onSuccess:handlerFunc2, onFailure:errFunc});
}
function previewBackup(id){
	new Ajax.Updater('previewBackup', './?mod=backup&action=preview&backup_id='+id+'', {onComplete:function(){ new Effect.Highlight('previewBackup');},asynchronous:true, evalScripts:true})

}
var errFunc = function(t) {
		    alert('Error ' + t.status + ' -- ' + t.statusText);
		}
function handlerFunc() {
	$('loaderDiv').innerHTML = '';
	$('loaderDiv').style.visibility = 'hidden';
}
function handlerFunc2() {
	$('backupdiv').innerHTML = 'Varnostna kopija shranjena.';
	new Effect.Pulsate('backupdiv');

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

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

	with(f) {
		if(isEmpty(prejemnik_email)) {
			error += "Prejemnikov email prosim!\n";
		}
		else {
			if(!isEmail(prejemnik_email)) {
				error += "Prejemnikov email ni pravilen (format)!\n"
			}
		}

		if(isEmpty(posiljatelj_email)) {
			error += "Pošiljateljev (vaš) email prosim!\n";
		}
		else {
			if(!isEmail(posiljatelj_email)) {
				error += "Posiljateljev (vaš!) email ni pravilen (format)!\n"
			}
		}

		if(isEmpty(ht_code)) {
			error += "Anti spam kodo prosim!?\n";
		}
	}

	if(error != '') {
		alert("HočemTo opozorilo: \n\n" + error);
		return false;
	}

	return true;
}

//v2.1.0 by PVII-www.projectseven.com
function P7_colH2(){ 
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ 
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ 
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ 
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}
