function showPopZem (popid){
	o = document.getElementById("pop"+popid);
	if(o.style.display=="none"){
		o.style.display = "block";
	}else{
		o.style.display = "none";
	}
}
function addBookmark() {
	if (document.all){
		window.external.AddFavorite(document.location.href , document.title);
	} else {
		window.sidebar.addPanel(document.title, document.location.href,""); 
	}
}

function check_decimal(val){
	return val.match(/\d*\.?\d*/);
}

function formatNumber(val){ 
	var sVal=''; 
	var nVal = val.length; 
	var sChar=''; 
	for(i=0;i<nVal;i++){ 
		sChar = val.charAt(i); 
		nChar = sChar.charCodeAt(0); 
		if ((nChar >=48) && (nChar <=57)) { 
			sVal += val.charAt(i); } 
	} 
	var samount = new String(sVal); 
	for (var i = 0; i < Math.floor((samount.length-(1+i))/3); i++){ 
		samount = samount.substring(0,samount.length-(4*i+3)) + "." + samount.substring(samount.length-(4*i+3)); 
	} 
	return samount; 
}

function chSearch(site){
	o = document.getElementById("iskt");
	s = document.getElementById("sSearch");
	a = document.getElementById("aSearch");
	fs = document.getElementById("topSearch");
	fa = document.getElementById("podrobno");
	if(o.className=="aSearch"){
		o.className = "";
		s.style.display = "none";
		a.style.display = "";
		fa.elements[0].focus();
		setPref("search_type","1",site);
	}else{
		o.className = "aSearch";
		a.style.display = "none";
		s.style.display = "";
		fs.elements[0].focus();
		setPref("search_type","2",site);
	}
}
function setPref(pref,val,site){
	url = "/p/js/set_preference.php";
	var postData = "site="+site+"&set="+pref+"&value="+val;
	var request = YAHOO.util.Connect.asyncRequest('POST', url, setpref_cback, postData);
}
var handleSetpref = function(o){
	if(o.responseText !== undefined){
		if(o.responseText!=""){
			
		}
	}
};
var setpref_cback = { success:handleSetpref, failure:handleFailure };

function minBox(id,site){
	o =  document.getElementById(id);
	field = id.replace(/r_/ig, "");
	url = "/p/js/set_preference.php";
	if(o.className=="rbox"){
		var postData = "site="+site+"&set="+field+"&value=0";
	}else if(o.className=="rboxMin"){
		var postData = "site="+site+"&set="+field+"&value=1";
	}else if(o.className=="rboxMin2"){
		var postData = "site="+site+"&set="+field+"&value=1";
	}
	if(postData){
		o.className = o.className+ " rboxL";
		var request = YAHOO.util.Connect.asyncRequest('POST', url, minbox_cback, postData);
	}
}
function minBoxDone(id){
	o =  document.getElementById("r_"+id);
	if(o.className=="rbox rboxL"){
		o.className = "rboxMin";
	}else if(o.className=="rboxMin rboxL"){
		o.className = "rbox";
	}else if(o.className=="rboxMin2 rboxL"){
		window.location.reload();
	}
}
var handleMinbox = function(o){
	if(o.responseText !== undefined){
		if(o.responseText!=""){
			minBoxDone(o.responseText);
		}
	}
};
var minbox_cback = { success:handleMinbox, failure:handleFailure };

function phpadbanner(zone,rnd){
	if (!document.phpAds_used) document.phpAds_used = ',';
	document.write ("<" + "script language='JavaScript' type='text/javascript' src='http://bandera.kabi.si/adjs.php?n="+rnd+"&amp;what=zone:"+zone+"&amp;block=1&amp;exclude=" + document.phpAds_used);
	if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
	document.write ("'><" + "/script>");
	
}

var top8_urls = new Array();
function top8(url,user_id){
	//top8_urls[top8_urls.length] = "/p/js/top8.php?id="+top8_urls.length+"&url="+URLEncode(url)+"&user_id="+user_id+"&lang="+banana_lang+"&link_prefix="+linkovi_prefix+"&oglasi_alias="+oglasi_alias+"&oglas_alias="+oglas_alias;
	top8_urls[top8_urls.length] = new Array(top8_urls.length,URLEncode(url),user_id);

	if(top8_urls.length==8){
		populateTop8();
	}
}
ktid = new Array();
function populateTop8(){
	//var url = "/p/js/top8.php?";
	var url = "http://admin.nepremicnine.info/js/top8n.php?";
	for (i in top8_urls) {
		//top8_get(top8_urls[i]);
		url += "id"+i+"="+top8_urls[i][0]+"&url"+i+"="+top8_urls[i][1]+"&user_id"+i+"="+top8_urls[i][2]+"&";
	}
	url+="lang="+banana_lang+"&link_prefix="+linkovi_prefix+"&oglasi_alias="+oglasi_alias+"&oglas_alias="+oglas_alias;
	top8_get(url);
}
function kajax_do (url,o) {
    var jselemenat = document.createElement('script');
    jselemenat.type = 'text/javascript';
    jselemenat.src = url;
    o.appendChild (jselemenat);
}
// YUI
function top8_get(url){
	var request = YAHOO.util.Connect.asyncRequest('GET', url, top8_cback);
}
var handleTop8 = function(o){
	if(o.responseText !== undefined){
		if(o.responseText!=""){
			//eval(o.responseText);
			vars = o.responseText.split(/\n/i);
			for(icnt=0; icnt<=7; icnt++){
				showTop8(vars[(8*icnt)],vars[(8*icnt+1)],vars[(8*icnt+2)],vars[(8*icnt+3)],vars[(8*icnt+4)],vars[(8*icnt+5)],vars[(8*icnt+6)],vars[(8*icnt+7)]);
			}
		}
	}
};
var handleFailure = function(o){
	if(o.responseText !== undefined){
		
	}
};
var top8_cback =
{
  success:handleTop8,
  failure:handleFailure,
  argument:['foo','bar']
};
	
var top8_br = 0;
var pt8_time_id = new Array();
function showTop8(url,img,agencija,tip,regija,podrocje,velikost,rbr){
	top8_br+=1;
	var id = "t8_"+rbr;
	top8c = document.getElementById("top8");
	ac = document.createElement('a');
	ac.href = url;
	ac.id = id;
	ac.className = "item";
	ac.style.opacity=0;
	ac.style.filter = "alpha(opacity:0)";	
	top8c.appendChild(ac);
	
	slika = document.createElement('img');
	slika.src=img;
	slika.alt=agencija;
	ac.appendChild(slika);
	
	dtekst = document.createElement('div');
	dtekst_b = document.createElement('strong');
	dtekst_b2 = document.createElement('strong');
	dtekst_b3 = document.createElement('strong');
	dtekst_t = document.createTextNode(regija);
	dtekst_t2 = document.createTextNode(podrocje);
	dtekst_t3 = document.createTextNode(velikost);
	dtekst_b.appendChild(dtekst_t);
	dtekst_b2.appendChild(dtekst_t2);
	dtekst_b3.appendChild(dtekst_t3);
	ac.appendChild(dtekst);
	dtekst.appendChild(dtekst_b);
	dtekst.appendChild(dtekst_b2);
	dtekst.appendChild(dtekst_b3);
	dtekst.style.opacity=0.9;
	dtekst.style.filter = "alpha(opacity:90)";	
	
	i = document.createElement('i');
	b = document.createElement('b');
	i_t = document.createTextNode(agencija);
	b_t = document.createTextNode(agencija);
	ac.appendChild(i);
	ac.appendChild(b);
	i.appendChild(i_t);
	b.appendChild(b_t);
	
	spen = document.createElement('span');
	ac.appendChild(spen);
	spen_t = document.createTextNode(tip);
	spen.appendChild(spen_t);
	
	pt8_time_id[id] = window.setTimeout("pokaziTop8('"+id+"')",5);
}
function pokaziTop8(id){
	o = document.getElementById(id);
	alfa = o.style.opacity*100;
	novialfa = alfa +5;
	if(alfa<100){
		o.style.opacity=novialfa/100;
		o.style.filter = "alpha(opacity:"+novialfa+")";
		pt8_time_id[id] = window.setTimeout("pokaziTop8('"+id+"')",5);
	}else{
		if(window.pt8_time_id[id]){
			clearTimeout(pt8_time_id[id]);
		}
	}
}

function URLEncode(string)
{
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = string;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				encoded += ch;
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} 

	return encoded;
};
function formInputClear(forma,formel,tekst){
	if(document.getElementById(forma).elements[formel].value==tekst){
		document.getElementById(forma).elements[formel].value="";
	}
}
function formInputFill(forma,formel,tekst){
	if(document.getElementById(forma).elements[formel].value==""){
		document.getElementById(forma).elements[formel].value=tekst;
	}
}

var nep_lang;
function neps_selChange(action,lang){
	nep_lang = lang;
	//document.getElementById("iskLoading").style.display="block";
	
	
    url = "/p/js/neps.php?action="+action+"&jezik="+lang;
    url+=getNepsSelValues(action);
    
	i = document.getElementById("podrobno");
	i.style.opacity=0.5;
	i.style.filter = "alpha(opacity:50)";	
	var request2 = YAHOO.util.Connect.asyncRequest('GET', url, sel_change_cback);
    
}

function getNepsSelValues(action){
		o = document.getElementById("podrobno");
		url = "";
		if(o.elements["neps_drzava_id-d"]){
	    	url+="&drzava="+o.elements["neps_drzava_id-d"].value;
	    }
	    if(o.elements["neps_regija_id-r"]){
	    	url+="&regija="+o.elements["neps_regija_id-r"].value;
	    }
	    if(o.elements["neps_podrocje_id-p"]){
	    	url+="&podrocje="+o.elements["neps_podrocje_id-p"].value;
	    }
	    if(o.elements["neps_vrsta_objekta_id-v"]){
	    	url+="&vrsta_objekta="+o.elements["neps_vrsta_objekta_id-v"].value;
	    }
	    if(o.elements["neps_tip_id-t"]){
	    	url+="&tip_objekta="+o.elements["neps_tip_id-t"].value;
	    }
	    if(o.elements["neps_naselje_id-n"]){
	    	url+="&naselje="+o.elements["neps_naselje_id-n"].value;
	    }
	    if(o.elements["neps_stanje_id-z"]){
	    	url+="&stanje="+o.elements["neps_stanje_id-z"].value;
	    }
	    if(o.elements["neps_transakcija_id-k"]){
	    	url+="&transakcija="+o.elements["neps_transakcija_id-k"].value;
	 	}
    return url;
}
function countSearchResult(){
	url = "/p/js/neps_countSearch.php?lang="+nep_lang;
	url+=getNepsSelValues();
	document.getElementById("sDisp").style.display="none";
	var request2 = YAHOO.util.Connect.asyncRequest('GET', url, sel_count_result_cback);
}
var handleSelCh = function(o){
	if(o.responseText !== undefined){
		if(o.responseText!=""){
			vars = o.responseText.split(/\n/i);
			f_v = "no";
			var skip;
			var cc = 0;
			i = 0;
			if(vars.length>0){
				for (i in vars) {
					if (vars[i].toString()==vars[i]){
						var tmp_vars = vars[i];
						if(tmp_vars.length>2){
							if (tmp_vars.substr(0,9)=="neps_type") {
								key = "neps_"+vars[i].replace(/neps_type:/ig, "");
								cc = 0;
								ff_v = document.getElementById('podrobno');
								if(ff_v.elements[key]){
									f_v = ff_v.elements[key];
									f_v_a = f_v.value;
									f_v.options.length = 1;
									f_v.disabled = true;
								}else{
									f_v = "no";
								}
							}else{
								if(f_v!="no"){
									vals = vars[i].split(/§§/i);
									if(vals[1]){
										cc = cc+1;
										f_v.disabled = false;
										f_v.options[cc]=new Option(vals[0], vals[1]);
										if(f_v_a==vals[1]){
											f_v.options[cc].selected=true;
										}
									}
								}
							}
						}
					}
				}
				i = document.getElementById("podrobno");
				i.style.opacity=1.0;
				i.style.filter = "alpha(opacity:100)";	
				//countSearchResult();
			}
		}
	}
};

var handleSelCountResult = function(o){
	if(o.responseText !== undefined){
		if(o.responseText!=""){
			setSearchDisplay(o.responseText);
			document.getElementById("iskLoading").style.display="none";
		}
	}
}
function setSearchDisplay(txt){
	o = document.getElementById("sDisp");
	t = document.createTextNode(txt);
	while (o.firstChild) {
		o.removeChild(o.firstChild);
	}
	o.appendChild(t);
	o.style.display="";
}
var sel_change_cback = { success:handleSelCh, failure:handleFailure};
var sel_count_result_cback = { success:handleSelCountResult, failure:handleFailure};

navHover = function() { 
	if(document.getElementById("nav")){
		var lis = document.getElementById("nav").getElementsByTagName("LI"); 
		for (var i=0; i<lis.length; i++) { 
			lis[i].onmouseover=function() { 
				this.className+=" iehover"; 
			} 
			lis[i].onmouseout=function() { 
				this.className=this.className.replace(new RegExp(" iehover\\b"), ""); 
			} 
		} 
	}
} 
		
if (window.attachEvent) window.attachEvent("onload", navHover);


function changeRule(theNumber,neww) {
	var theRules = new Array();
	if (document.styleSheets[0].cssRules) {
		theRules = document.styleSheets[0].cssRules;
	} else if (document.styleSheets[0].rules) {
		theRules = document.styleSheets[0].rules;
	}
	theRules[theNumber].style.width = neww+"px";
}

function ColumnGrabberMouseDown(event) {
	if (!event) event = window.event;
	if (this.inDrag) this.onmouseup(event); 
	this.inDrag = true;
	
	xpos = findPosX(this);
	w = parseFloat(getStyle(this,"width"));
	this.start_clientX = xpos+w-event.clientX;
	
	this.onmousemove(event); 
	
	return true;
}
function ColumnGrabberMouseMove(event) {
	if (!event) event = window.event; 
	if (this.inDrag) {	
		num = parseFloat(this.id.substr(3));
		
		xpos = findPosX(this);
		w = parseFloat(getStyle(this,"width"));
		
		neww = event.clientX-xpos+this.start_clientX;
		razlika = w - neww;
		el_next = document.getElementById("rth"+(num+1));
		
		wnext = parseFloat(getStyle(el_next,"width"));
		
		wnextw = wnext+razlika;
		if(wnextw>20 && neww>20){
			changeRule((num-1), neww);
			changeRule(num, wnextw);
		}
	}
}

function ColumnGrabberMouseUp() {
	if (this.inDrag) { 
		this.inDrag = false;
	}
}


function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	
	else if (obj.x)
		curleft += obj.x;
	return curleft;
	
}
function getStyle(oElm, strCssRule){ 
	var strValue = ""; 
	if(document.defaultView && document.defaultView.getComputedStyle){ 
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); 
	} else if(oElm.currentStyle){ 
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){ 
			return p1.toUpperCase(); 
		}); 
		strValue = oElm.currentStyle[strCssRule]; 
	} 
	strValue = strValue.replace(/([0-9]*)px/ig, "$1");
	var browserName=navigator.appName;
	if(browserName=="Opera"){
		strValue = 	 parseFloat(strValue)-5;
	}
	return strValue; 
}

function installTableResize(){
	for(i=1; i<=6; i++){
		grabber = document.getElementById("rth"+i);
		grabber.onmousedown = ColumnGrabberMouseDown; 
		grabber.onmouseup = ColumnGrabberMouseUp; 
		grabber.onmousemove = ColumnGrabberMouseMove;
		
	}
}
function oznaciVse(forma,polje,val){
	f = document.forms[forma];
	for (i = 0; i < f.elements.length; i++) {
		if(f.elements[i].name.substring(0,polje.length)==polje){
			f.elements[i].checked = val ; 
		}
	}
}


function showNepPop(ivent){
	o = document.getElementById("nepMeni");
	if(ivent==1){
		o.style.display = "block";
		if(window.stid){
			clearTimeout(stid);	
		}
		tid = window.setTimeout("pokaziPMeni()",500);
	}else if(ivent==2){
		if(o.style.opacity==0){
			if(window.tid){
				clearTimeout(tid);	
			}
			sakrijPMeni();
		}else{
			stid = window.setTimeout("sakrijPMeni()",1000);
		}
	}
}
function snp(ivent){
	if(ivent==1){
		if(window.stid){
			clearTimeout(stid);	
		}
	}else if(ivent==2){
		stid = window.setTimeout("sakrijPMeni()",500);
	}
}
function pokaziPMeni(pmeni_id){
	o = document.getElementById("nepMeni");
	palfa = o.style.opacity*100;
	if(!palfa){
		palfa = 0;
	}
	novialfa = palfa + 20;

	if(palfa<95){
		o.style.opacity=novialfa/100;
		o.style.filter = "alpha(opacity:"+novialfa+")";
		tid = window.setTimeout("pokaziPMeni()",10);
	}else{
		if ( window.tid ) {	
			clearTimeout(tid);
		}
	}
}
function sakrijPMeni(pmeni_id){
	o = document.getElementById("nepMeni");
	o.style.opacity=0;
	o.style.filter = "alpha(opacity:0)";	
	o.style.display="none";
}

function produziPmeni(pmeni_id){
	if ( window.stid ) {		
		clearTimeout(stid);
	}
	stid = window.setTimeout("sakrijPMeni()",1000);
}
function change_regija(drzava_id) {
	a= document.submit_ad_form.regija;
	if(a){
		a.selectedIndex=0;
		var i= 0;
		if (drzave[drzava_id]){
			for(var x in drzave[drzava_id]) {
				a.options[i]=new Option(drzave[drzava_id][x], x);
				i++;
			}
			a.length=i;
			a.disabled= false;
		}else{
			a.length=0;
			a.disabled= true;
		}
		
		if (a.options[0]){
			if(document.submit_ad_form.podrocje){
				change_podrocje(a.options[0].value);
			}
		}else{
			if(document.submit_ad_form.podrocje){
				change_podrocje(null);	
			}
		}
	}
}

function change_podrocje(regija_id) {
	a= document.submit_ad_form.podrocje;
	a.selectedIndex=0;
	var i= 0;
	if (regije[regija_id]){
		for(var x in regije[regija_id]) {
			a.options[i]=new Option(regije[regija_id][x], x);
			i++;
		}
		a.length=i;
		a.disabled= false;
	}else{
		a.disabled= true;
		a.length=0;
	}
}

function change_tipi(vrsta_id) {
	a= document.submit_ad_form.tip;
	a.selectedIndex=0;
	var i= 0;
	if (vrste[vrsta_id]){
		for(var x in vrste[vrsta_id]) {
			a.options[i]=new Option(vrste[vrsta_id][x], x);
			i++;
		}
		a.length=i;
		a.disabled= false;
	}else{
		a.disabled= true;
		a.length=0;
	}
}
function showProdajalec(){
	o = document.getElementById("oglasProdajalec");
	o2 = document.getElementById("prodajalecH2");
	if(o.style.display=="none" || o.style.display!="block"){
		o.style.display = "block";
		o2.style.color = "#1480B0";
		o2.style.background = "#D2E9FF";
		o2.style.borderColor = "#98C7E5";
	}else{
		o.style.display = "none";
		o2.style.color = "#fff";
		o2.style.background = "#fff";
		o2.style.borderColor = "#fff";
	}
}