/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function redirect (loc) {
	var temp = "go_now(\""+loc+"\")";
 
    setTimeout(temp,5000);
}
function go_now (loc)   { window.location.href = loc; }

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
	if (docHt < 350) {
		iframeEl.style.height = docHt + 350 + "px";
	}
	else
	{
		if (docHt) iframeEl.style.height = docHt + 30 + "px";
	}
	loc=iframeWin.location.href.toString();
	poundLocation = loc.indexOf("#");
	if(poundLocation>0){
		loc=loc.substring(poundLocation, loc.length);		
		iframeWin.location.href=loc;
	}
 
  }
}

function setIframeFixedHeight(iframeName,a) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show	
	iframeEl.style.height = a + "px";	
  }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;
    return false;
  }
  else return true;
}

function goSetHeight() {
  if (parent == window) return;
  else parent.setIframeHeight('frmCentral');
}

function goSetFixedHeight(a) {
  if (parent == window) return;
  else parent.setIframeFixedHeight('frmCentral',a);
}

var str=""
function setMessage()
{
    if (str == "")
    {
        for (var ii = 0; ii < 120; ii += 10) {str = str + "          "}
        str = str + " <<-- Novosti Oglasi -->>  "
    }
    else
    {
        str = str.substring(2, str.length)
    }
    window.status = str
    JSCTimeOutID = window.setTimeout('setMessage()',100)
}

function refreshFrame()
{
	
		document.frames['frmCentral'].window.location.reload();
	
}

//-----------------------------------------------------------------------------
//ToggleRowDisplay & init implementiraju prikaz vece slike u tekucem oglasu

function DisplayImage( objTargetButton , picId){
   var tabPar, picIdPar;
   var lBtn = document.forms[0].btnToggleL;
   var lBtn1 = document.forms[0].btnToggleL1;
   var lBtn2 = document.forms[0].btnToggleL2;
   var lBtn3 = document.forms[0].btnToggleL3;
   var imgLrg = document.getElementById("imgLarge");
   var tabBdy = document.getElementById("idTableBody");
   var searchPar = location.search.replace(/(\?|\&)tbody\=[^\&]*/i,"");
   if(searchPar>""){
     tabPar = "&tbody=";
   } else {
     tabPar = "?tbody=";
   }

   if(objTargetButton.value==null){
   	objTargetButton.value="+";
	}		
		
   if(objTargetButton.value=="+"){
     tabPar += "expand";
   } else {
     tabPar += "collapse";
   }   
   picIdPar = "&picId="+picId;
//   if(lBtn1.name == objTargetButton.name){
//   	alert("BtnId 1: "+lBtn1.id+"btn name:" + lBtn1.name);
//   }
//   if(lBtn2.name == objTargetButton.name){
//   	alert("BtnId 2");
//   }
//   if(lBtn.name == objTargetButton.name){
//   	alert("BtnId 0");
//   }
imgLrg.src = picId;
tabBdy.style.display="block";
   //location = location.href.split("?")[0]+searchPar+tabPar+picIdPar;
}
function ToggleRowDisplay( objTargetButton ){
   var tabPar;
   var searchPar = location.search.replace(/(\?|\&)tbody\=[^\&]*/i,"");
   if(searchPar>""){
     tabPar = "&tbody=";
   } else {
     tabPar = "?tbody=";
   }

   if(objTargetButton.value==null){
   	objTargetButton.value="+";
	}		
		
   if(objTargetButton.value=="+"){
     tabPar += "expand";
   } else {
     tabPar += "collapse";
   }   
   location = location.href.split("?")[0]+searchPar+tabPar;
}
function init(){
  if(location.search){
    var tabPar = location.search.split("tbody=");	
    if(tabPar.length>1){
      tabPar = (tabPar[1]+"&").split("&")[0];
      var tabBtn = document.forms[0].btnToggleL;
	  var tabBtn2 = document.forms[0].btnToggleS;
      var tabBdy = document.getElementById("idTableBody");
      if(tabPar.toLowerCase()=="expand"){
        tabBtn.value="-";
		tabBtn.alt="Klikni za smanjenje"
		tabBtn.title="Klikni za smanjenje"
		tabBtn2.value="-";
		tabBtn2.alt="Klikni za smanjenje"
		tabBtn2.title="Klikni za smanjenje"
		tabBtn2.src="images/small.gif"
        tabBdy.style.display="block";
      }
    }
  }
}
//-----------------------------------------------------------------------------

function setCentralBanner(bannerRef, bannerImg){
	if(parent != null){
		var objAnchor =parent.document.getElementById('centralBannerLink');
		objAnchor.href=bannerRef;
		var objAnchorImg =parent.document.getElementById('centralBannerImage');
		objAnchorImg.src=bannerImg;
	}
	
}