/*
* Projekt: Ekonomska Kranj
* Glavni JS Filet
*/

function pause(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 

var lastid = 0;

function show(id){
	if(lastid!=id){
	document.getElementById('link'+id).className='active';
	document.getElementById('submenu'+id).style.visibility='visible';
	lastid = id;
	}
}


function hide(id,c){

//pause(100);

document.getElementById('submenu'+id).style.visibility='hidden';
	if(id!=c){
		document.getElementById('link'+id).className='';
	}
	lastid = 0;

}


function p(n) {
	document.getElementById("menu"+n).className = "menu" + n + "_s";
	document.getElementById("submenu"+n).style.visibility = 'visible';
}

function s(n) {
	document.getElementById("menu"+n).className = "menu"+n;
	document.getElementById("submenu"+n).style.visibility = 'hidden';
}

function pp(n) {
	document.getElementById("level3").style.display = "block";
	document.getElementById("menu"+n).className = "menu" + n + "_s";
	document.getElementById("subsub"+n).style.visibility = 'visible';
}

function ss(n) {
	document.getElementById("level3").style.display = "none";
	document.getElementById("menu"+n).className = "menu"+n;
	document.getElementById("subsub"+n).style.visibility = 'hidden';
	document.getElementById("submenu"+n).style.visibility = 'hidden';
}

function swap(el){
	if (el == "gim"){
	document.getElementById("ps").style.display = 'none';
	document.getElementById("gim").style.display = 'block';
	document.getElementById("switch1").style.display = 'block';
	document.getElementById("switch2").style.display = 'none';
	
	}
	if (el == "ps"){
	document.getElementById("gim").style.display = 'none';
	document.getElementById("ps").style.display = 'block';
	document.getElementById("switch2").style.display = 'block';
	document.getElementById("switch1").style.display = 'none';
	
	}
}

function get_radio_value(){
	for (var i=0; i < document.anketa.odg.length; i++){
		if (document.anketa.odg[i].checked){
			return(document.anketa.odg[i].value);
		}
	}
}

function postPollVote(anketa,pageType){
	odg = get_radio_value();
	url = "&pt2="+pageType+"&poll="+anketa+"&vote="+odg;
	openURL(url,1,'');
	document.getElementById('rezultati').style.display='block';
	document.getElementById('glasovanje').style.display='none';
	document.getElementById('pek').style.display='block';
}

var xmlHttp;
var lastpage = 0;
function openURL(str,mode,element){
	xmlHttp=GetXml()
	if (xmlHttp==null){
		//alert ("Browser does not support HTTP Request")
		return
	} 
	var url="hint.php"
	url=url+"?sid="+Math.random();
	url=url+str
	temp = changeCont;
	xmlHttp.onreadystatechange=temp;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	elem = element;
}

function changeCont(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		nekaj = xmlHttp.responseText;
		if(elem!=""){
			document.getElementById(elem).innerHTML=nekaj;
		}
	}
}

function GetXml(){ 
	var objXMLHttp=null
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

function getCal(mesec,leto,pt){
	xmlHttp=GetXml()
	if (xmlHttp==null){
		//alert ("Browser does not support HTTP Request")
		return
	} 
	var url="koledarh.php"
	url=url+'?pt='+pt;
	url=url+'&m='+mesec;
	url=url+'&y='+leto;
	url=url+"&sid="+Math.random();
	//url=url+str
	temp = changeCont;
	xmlHttp.onreadystatechange=temp;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	elem = 'koledarcont';
}

	  // JS function for uncrypting spam-protected emails:
	function UnCryptMailto(s) {	//
		var n=0;
		var r="";
		for(var i=0; i < s.length; i++) {
			n=s.charCodeAt(i);
			if (n>=8364) {n = 128;}
			r += String.fromCharCode(n-(1));
		}
		return r;
	}
  // JS function for uncrypting spam-protected emails:
	function linkTo_UnCryptMailto(s)	{	//
		location.href=UnCryptMailto(s);
	}	
