

function ds_getleft(el) {
	var tmp = el.offsetLeft;
	el = el.offsetParent
	while(el) {
		tmp += el.offsetLeft;
		el = el.offsetParent;
	}
	return tmp;
}
function ds_gettop(el) {
	var tmp = el.offsetTop;
	el = el.offsetParent
	while(el) {
		tmp += el.offsetTop;
		el = el.offsetParent;
	}
	return tmp;
}
 


function displaySubs(){
 value=document.getElementById("email").value;
 ime=document.getElementById("ime").value;
 var counter = 0;                
  var radio_choice;  
    while (counter < document.main_form.pr.length) {                    
    if (document.main_form.pr[counter].checked) {                        radio_choice = (document.main_form.pr[counter].value);                    }                    counter++;                }  
 
 if(!ime) imes="a"; else imes=ime;
    var url="write_email.php?email="+value+"&odpr="+radio_choice+"&ime="+imes;
   
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();// Mozilla/Safari
    }else if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");// IE
    }

    xmlHttp.onreadystatechange=AJAXresponse;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null)
//}
}
function AJAXresponse(){

    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
   document.getElementById("result").innerHTML=xmlHttp.responseText;
}
    else{
        document.getElementById("result").innerHTML = '<img src=images/16.gif width="26" height="26" alt="">';
    }
}



function display(polje, id, fajl){
if(fajl=="test2.php" || fajl=="test3.php") test=fajl; else test="test1.php"; 
 jQuery('#'+polje).html('<select><option>Učitavam<option></select>');
    var url="http://www.biznis-portal.rs/"+test+"?polje="+polje+"&id="+id;
   jQuery('#'+polje).load(url);
  	return false;
  
   }
function display1(polje, id, idd,fajl){
if(fajl=="test2.php" || fajl=="test3.php") test=fajl; else test="test1.php"; 
 jQuery('#'+polje).html('<select><option>Učitavam<option></select>');
  var url="http://www.biznis-portal.rs/"+test+"?polje="+polje+"&id="+id+"&idd="+idd;
   jQuery('#'+polje).load(url);
  	return false;
 
   }

function izbmesta(id,page)
{

if(id.length==0)
{
window.location = page+"/";
}
else
window.location = page+"/"+id+".html";

}
function izbopstine(id,page)
{
if(id.length==0)
{
window.location = page+".html";
}
else
window.location = page+"/"+id+".html";

}
var path2;
 function podkat(path,t){

  path2=path;

  
  the_left = ds_getleft(t);
	the_top = ds_gettop(t) + t.offsetHeight;
  element=document.getElementById("resulti");
  element.style.display="block";
	element.style.top=the_top-290 + 'px';
	element.style.left=the_left-300 + 'px';
/*	
jQuery('#resulti').html('<img src='+path2+'/images/16.gif width="26" height="26" alt="">');
    var url=path+"/pod_kat.php";
   jQuery('#resulti').load(url);
  	return false;
  	*/
}
function hide()
{
document.getElementById("resulti").style.display="none";
}
function whichElement(e)
{
var targ;

if (!e)
  {
  var e=window.event;
  }
if (e.target)
  {
  targ=e.target;
  }
else if (e.srcElement)
  {
  targ=e.srcElement;
  }
if (targ.nodeType==3) // defeat Safari bug
  {
  targ = targ.parentNode;
  }
var tname;
tname=targ.tagName;

if(tname=="DIV" || tname=="IMG" || tname=="BODY" || tname=="A" || tname=="UL" || tname=="TABLE"  || tname=="TD"){
document.getElementById("livesearch").style.display="none";
}


}





 function show_resulti(ivent){
	o = document.getElementById("resulti");
	if(ivent==1){
		o.style.display = "block";
		if(window.stid){
			clearTimeout(stid);	
		}
		tid = window.setTimeout("prikazi()",500);
	}else if(ivent==2){
		if(o.style.opacity==0){
			if(window.tid){
				clearTimeout(tid);	
			}
			zatvori();
		}else{
			stid = window.setTimeout("zatvori()",1000);
		}
	}
}
 function pokreni_ponovo(ivent){
	if(ivent==1){
		if(window.stid){
			clearTimeout(stid);	
		}
	}else if(ivent==2){
		stid = window.setTimeout("zatvori()",500);
	}
}
function prikazi(pmeni_id){
	o = document.getElementById("resulti");
	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("prikazi()",10);
	}else{
		if ( window.tid ) {	
			clearTimeout(tid);
		}
	}
}
function zatvori(pmeni_id){
	o = document.getElementById("resulti");
	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("zatvori()",1000);
}



function aktiviraj(path,odpr,sid){
 document.getElementById("link").style.display="block";
    var url=path+"/glas.php?id="+odpr+"&sid="+sid;
   
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();// Mozilla/Safari
    }else if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");// IE
    }

    xmlHttp.onreadystatechange=AJAXresponseS;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null)
//}

}
function AJAXresponseS(){

    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
   document.getElementById("results").innerHTML=xmlHttp.responseText;
}  else{
        document.getElementById("results").innerHTML = '<span style="font-weight:bold;">Glasam...</span>';
    }
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function galerija(id,vr,slika){

   	//var arrayPageSize = getPageSize();
   	//document.getElementById("fade").style.height = (arrayPageSize[1] + 'px');
    /*
    if(n==2)
    document.getElementById("result").innerHTML=document.getElementById("result");
    else
    {*/
  
    var url="http://www.biznis-portal.rs/slike.php?id="+id+"&nid="+vr+"&slika="+slika;
   
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();// Mozilla/Safari
    }else if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");// IE
    }

    xmlHttp.onreadystatechange=AJAXresponsev;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null)
//}
}
function AJAXresponsev(){

    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
   document.getElementById("resultr").innerHTML=xmlHttp.responseText;
}
    else{
        document.getElementById("resultr").innerHTML = '<div style="width:490px;height:500px;font-size:14px;font-weight:bold;">Učitavam...</div>';
    }
}


///////////////// pretraga ///////////
	function test() {
  el=document.getElementById("kontejner");
	var tmp = el.offsetLeft;
	el = el.offsetParent
	while(el) {
		tmp += el.offsetLeft;
		el = el.offsetParent;
	}
	return tmp;
}
 function ds_getleft(el) {
	var tmp = el.offsetLeft;
	el = el.offsetParent
	while(el) {
		tmp += el.offsetLeft;
		el = el.offsetParent;
	}
	return tmp;
}
function ds_gettop(el) {
	var tmp = el.offsetTop;
	el = el.offsetParent
	while(el) {
		tmp += el.offsetTop;
		el = el.offsetParent;
	}
	return tmp;
}
				function showResult(t,str,path)
{ 
 var tap = 0;

for( i = 0; i < document.trazim.drzava.length; i++ )
{
if( document.trazim.drzava[i].checked == true )
tap = document.trazim.drzava[i].value;
}

//alert(tap)
 
//tap=document.getElementById("tap").value;

document.getElementById("livesearch").style.display="block";
  polje_left = test();
	the_left = ds_getleft(t);
	the_top = ds_gettop(t) + t.offsetHeight;
	element=document.getElementById("livesearch");

	element.style.top=the_top + 'px';
	element.style.left=the_left + 'px';
	
if (str.length<2)
  { 
  document.getElementById("livesearch").innerHTML="";
  document.getElementById("livesearch").style.border="0px";
  return;
  }
  document.getElementById("livesearch").style.border="1px solid black";
  var url=path+"/search.php?str="+str+"&tap="+tap;
   
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();// Mozilla/Safari
    }else if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");// IE
    }

    xmlHttp.onreadystatechange=AJAXresponse;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null)

/*jQuery('#livesearch').html('load...');
  var url="<?=base_url()?>index.php/racun_za_usluge/livesearch/"+str+"/"+kolona+"/"+tabela;
 jQuery('#livesearch').load(url);
 */
}
function AJAXresponse(){
 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
   document.getElementById("livesearch").innerHTML=xmlHttp.responseText;
// ddrivetip(xmlHttp.responseText);
}
    else{
        document.getElementById("livesearch").innerHTML = 'load...';
    }
}
function dodeli(pojam)
{ 
  document.getElementById("pojam").value=pojam;
  document.getElementById("livesearch").style.display="none";
}

