/////////////////////////////////////////////////////////////////////////////////
//
// UOZG Javascript
//
// (c)2008 by Abacus, info ath abacus doth hr
//
// v1.27 14.05.2010. IGolovic
//
/////////////////////////////////////////////////////////////////////////////////

//-------------------------------------------------------------------------------
//
// globalne varijable
//
//-------------------------------------------------------------------------------

var xMENU='NAS';
var xWSPCID=601;
var xNS=(navigator.appName.indexOf("Netscape") != -1);
var xDOC=document;
var xAJAXURI;

///////////////////////////////////////////////////////////////////////////////////
//
// status
//
///////////////////////////////////////////////////////////////////////////////////

window.defaultStatus='Udruženje obrtnika grada Zagreba';
window.name='OBRTZG';

function S(pMSG) {
  if (pMSG!='') { pMSG='Udruženje obrtnika grada Zagreba: '+pMSG }
  window.status=pMSG;
  return(true);
}


///////////////////////////////////////////////////////////////////////////////////
//
// AJAX
//
///////////////////////////////////////////////////////////////////////////////////

function ajaxEvaluate (pTXT) {
  var rSCRIPT = new RegExp('(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 'img');
  var tSCRIPT = '';
  while (tSCRIPT = rSCRIPT.exec(pTXT)) { eval(tSCRIPT[1]) }
}

function getDataReturnText (pURL, pTAG) { 
  var XMLHttpRequestObject = false; 
  if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  }

  if(XMLHttpRequestObject) {
    XMLHttpRequestObject.open('GET',pURL+'&SESSION='+xKEY+'&DUMMY='+new Date().getTime());    

    XMLHttpRequestObject.onreadystatechange = function() 
    { 
      if (XMLHttpRequestObject.readyState == 4 && 
        XMLHttpRequestObject.status == 200) { 
          ajaxCallback(XMLHttpRequestObject.responseText, pTAG);
          delete XMLHttpRequestObject;
          XMLHttpRequestObject = null;
      } 
    } 

    XMLHttpRequestObject.send(null); 
  }
}


function ajaxCallback (pTXT,pTAG) {
  ajaxEvaluate(pTXT);
  if (pTAG==undefined) { 
    pTAG='BODY';
    if (xAJAXURI) { }
  }
  rNAVIG=/<NAVIGATOR>((\n|\r|.)*?)<\/NAVIGATOR>/mi;
  var tNAVIG=rNAVIG.exec(pTXT);
  if (tNAVIG) {
    pTXT=pTXT.replace(rNAVIG,'');
    if (pTAG=='BODY' || pTAG=='BODYSEKC') { 
      if (getO('NAVIGATOR')) { getO('NAVIGATOR').innerHTML=tNAVIG[1] }
    }
  }
  if (getO(pTAG)) { getO(pTAG).innerHTML=pTXT; DekodirajURI(); }
  if (getO('vmarquee')) { initializemarquee() }
  if (pTAG=='BODY' || pTAG=='BODYSEKC') {
    scrollTo(0,0);
    if (getO('PRVA')) { getO('PRVA').onclick(); }
    else { hs.close(); }
  }
  // if(pTAG =='IZLOG'){
	// hs.htmlExpand(getO('linkNaIzlog'), { contentId: 'DIVIZLOG', width: 900, height:650, align:'center', numberPosition:null } );
  // }
  if (cssdropdown != 'undefined' && pTAG=='MENU-TOP') { cssdropdown.startchrome('chromemenu') }
  if (typeof xDOC.ANK != 'undefined') {
    if (checkRadio(xDOC.ANK.OBC)=='DA') { getO('nastavak').className='show' }
  }
  InitNasTabs();  
}


function Update(pTAG,pURI) {
  if (hs)  { hs.close() }
  xURI=pURI;
  if (pTAG=='BODYx' || pTAG=='KatalogRez') {
    if (getO(pTAG)) { getO(pTAG).innerHTML='<div style="text-align:center;margin:50;"><img src="ucitavam.gif" width="48" height="48"></div>' }
  }
  if (pTAG=='BODY') { 
    xSAL.PassAjaxResponseToFunction('?JSRS='+pTAG+'&'+pURI+'&DUMMY='+new Date().getTime(),'ajaxCallback'); 
  }
  getDataReturnText('?JSRS='+pTAG+'&'+pURI,pTAG);
}


function encodeHtml(pTXT) {
  var tRET=escape(pTXT);
  tRET=tRET.replace(/&/g, '%26');
  tRET=tRET.replace(/\//g,'%2F');
  tRET=tRET.replace(/=/g, '%3D');
  tRET=tRET.replace(/\?/g,'%3F');
  tRET=tRET.replace(/@/g, '%40');
  return(tRET);
} 


function getElementFormValues(E) {
  var uri='';
  var rTAG=/^(TABLE|TBODY|TR|TD|NOBR|CENTER|DIV|BR|A|SPAN|FIELDSET)$/;
  for (var i=0; i<E.childNodes.length; i++) {
    var NODE=E.childNodes[i];
    if (rTAG.test(NODE.tagName))  { uri+=getElementFormValues(NODE) }
    if (NODE.name) {
      if (NODE.tagName=='INPUT') {
        if (NODE.type=='text')      { uri+=NODE.name+'='+encodeHtml(NODE.value)+'&' }
        if (NODE.type=='hidden')    { uri+=NODE.name+'='+encodeHtml(NODE.value)+'&' }
        if (NODE.type=='checkbox')  { if (NODE.checked) { uri+=NODE.name+'='+encodeHtml(NODE.value)+'&' } }
        if (NODE.type=='radio')     { if (NODE.checked) { uri+=NODE.name+'='+encodeHtml(NODE.value)+'&' } }
      }
      else if (NODE.tagName=='TEXTAREA') { uri+=NODE.name+'='+encodeHtml(NODE.value)+'&' }
      else if (NODE.tagName=='SELECT')   { uri+=NODE.name+'='+encodeHtml(NODE.options[NODE.selectedIndex].value)+'&' }
    }
  }
  return(uri);
}

function UpdateForm(pTAG,pFORMID) {
  var tFORM=getO(pFORMID);
  var tURI=getElementFormValues(tFORM);
  Update(pTAG,tURI);
}

///////////////////////////////////////////////////////////////////////////////////
//
// dekodiranja E-mailova
//
///////////////////////////////////////////////////////////////////////////////////

function DekodirajURI() {
  if (!xDOC.getElementsByTagName && !xDOC.createElement && !xDOC.createTextNode) return;
  var cvorovi=xDOC.getElementsByTagName('span');
  for(var i=cvorovi.length-1;i>=0;i--) {
    if (cvorovi[i].className=='DECODE' && cvorovi[i].firstChild) {
      var na=/ \(na\) /;
      var tocka=/ \(tocka\) /g;
      var cvor=xDOC.createElement('a');
      var URI=cvorovi[i].firstChild.nodeValue;

      URI = URI.replace(na,'@');
      URI = URI.replace(tocka,'.');
      cvor.setAttribute('href','mailto:'+URI);
      cvor.setAttribute('className','LINK');
      cvor.setAttribute('class','LINK');
      cvor.appendChild(xDOC.createTextNode(URI));
      
      var ispis = cvorovi[i].parentNode;
      for(var j=0;j<ispis.childNodes.length;j++)
        if (ispis.childNodes[j] == cvorovi[i]) {
          if (!ispis.replaceChild) return;
          ispis.replaceChild(cvor,ispis.childNodes[j]);
          break;
        }
    }
  }
}

//-------------------------------------------------------------------------------
// style/button switch
//-------------------------------------------------------------------------------

function C(pO,pID) {
   pO.className=pO.className.substr(0,pO.className.length-1)+pID;
}

function B(pO,pID) {
  pO.src=pO.src.replace(/[0-2]./,pID+'.');
}

///////////////////////////////////////////////////////////////////////////////////
//
// provjera formi
//
///////////////////////////////////////////////////////////////////////////////////

function CheckForm(form,name) {

    var email=/[\w\-\.]+\@[\-\w\.]+\.[\w\-\.]{2,4}/;
    var ime=/[\w\.]+.*\s+.*[\w\.]+/;
    var prazno=/[\d\w]+/;
    var captcha=/^[\w]{5}$/;
    if (name=='LIN') {
      if (!captcha.test(form.LIN_CODE.value)) {
        alert('Niste upisali ispravni kontrolni kod!');
        form.LIN_CODE.focus();
        return(false);
      }
      if (!ime.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!email.test(form.EPO.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EPO.focus();
        return(false);
      }
      else if (!email.test(form.EPR.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EPR.focus();
        return(false);
      }
    }
    
    // PRIJAVA SAJAM
    
      else if (name=='SAJ') {
      if (!captcha.test(form.SAJ_CODE.value)) {
        alert('Niste upisali ispravni kontrolni kod!');
        form.SAJ_CODE.focus();
        return(false);
      }
      else if (!ime.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!prazno.test(form.OBR.value)) {
        alert('Niste upisali naziv tvrtke ili obrta!');
        form.OBR.focus();
        return(false);
      }
      else if (!prazno.test(form.ADR.value)) {
        alert('Niste upisali adresu tvrtke ili obrta!');
        form.ADR.focus();
        return(false);
      }
      else if (!prazno.test(form.MJS.value)) {
        alert('Niste upisali mjesto tvrtke ili obrta!');
        form.MJE.focus();
        return(false);
      }
      else if (!prazno.test(form.DJE.value)) {
        alert('Niste upisali djelatnost tvrtke ili obrta!');
        form.DJE.focus();
        return(false);
      }
      else if (!prazno.test(form.JBM.value)) {
        alert('Niste upisali JBMG/MBS!');
        form.JBM.focus();
        return(false);
      }
      else if (!prazno.test(form.TEL.value)) {
        alert('Niste upisali broj telefona!');
        form.TEL.focus();
        return(false);
      }
      else if (!email.test(form.EMA.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EMA.focus();
        return(false);
      }
      else if (!ime.test(form.CON.value)) {
        alert('Niste upisali ime i prezime osobe za kontakt!');
        form.CON.focus();
        return(false);
      }
      else if (!checkRadio(form.KLU)) {
        alert('Niste odabrali veličinu klupe koju naručujete!');
        return(false);
      }
    }
    
    
    else if (name=='SIG') {
      if (!captcha.test(form.SIG_CODE.value)) {
        alert('Niste upisali ispravni kontrolni kod!');
        form.SIG_CODE.focus();
        return(false);
      }
      if (!ime.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!prazno.test(form.TEL.value)) {
        alert('Niste upisali broj telefona!');
        form.TEL.focus();
        return(false);
      }
      else if (!email.test(form.EMA.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EMA.focus();
        return(false);
      }
    }
    
   // PRIJAVA OBRTNICKO UCILISTE
    
      else if (name=='PRI') {
      if (!captcha.test(form.PRI_CODE.value)) {
        alert('Niste upisali ispravni kontrolni kod!');
        form.PRI_CODE.focus();
        return(false);
      }
      else if (!prazno.test(form.TVR.value)) {
        alert('Niste upisali naziv tvrtke ili obrta!');
        form.TVR.focus();
        return(false);
      }
      else if (!ime.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!prazno.test(form.ADR.value)) {
        alert('Niste upisali adresu tvrtke ili obrta!');
        form.ADR.focus();
        return(false);
      }
      else if (!prazno.test(form.TEL.value)) {
        alert('Niste upisali broj telefona!');
        form.TEL.focus();
        return(false);
      }
      else if (!email.test(form.EMA.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EMA.focus();
        return(false);
      }
      else if (!checkRadio(form.PRO)) {
        alert('Niste odabrali program za koji se prijavljujete!');
        return(false);
      }
      else if (!checkRadio(form.STA)) {
        alert('Niste odabrali svoj status!');
        return(false);
      }
      else if (!checkRadio(form.VOT)) {
        alert('Niste odabrali vrijeme održavanja tečaja!');
        return(false);
      }
    }
    
        // ANKETA
    
    else if (name=='RVR') {

      if (!captcha.test(form.RVR_CODE.value)) {
        alert('Niste upisali ispravni kontrolni kod!');
        form.RVR_CODE.focus();
        return(false);
      }
      else if (!ime.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!email.test(form.EMA.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EMA.focus();
        return(false);
      }
      else if (!checkRadio(form.RAD)) {
        alert('Niste odabrali trajanje radnog vremena!');
        return(false);
      }
      else if (!checkRadio(form.NED)) {
        alert('Niste odabrali jeste li za rad nedjeljom!');
        return(false);
      }
      else if (!checkRadio(form.ODR)) {
        alert('Niste odabrali tko treba određivati radno vrijeme!');
        return(false);
      }
      else if (!checkRadio(form.SAD)) {
        alert('Niste odabrali radite li sada nedjeljom!');
        return(false);
      }
      else if (!checkRadio(form.PRO)) {
        alert('Niste odabrali djelatnost!');
        return(false);
      }
      else if (checkRadio(form.PRO)=='OS') {
      
      if (!prazno.test(form.PRS.value)) {
        alert('Niste upisali djelatnost!');
        form.PRS.focus();
        return(false);
      }
      
      }
      
    }
    
    // ANKETA
    
    else if (name=='ANK') {

      if (!captcha.test(form.ANK_CODE.value)) {
        alert('Niste upisali ispravni kontrolni kod!');
        form.ANK_CODE.focus();
        return(false);
      }
      else if (!ime.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!email.test(form.EMA.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EMA.focus();
        return(false);
      }
      else if (!prazno.test(form.SEK.value)) {
        alert('Niste unijeli sekciju!');
        form.SEK.focus();
        return(false);
      }
      else if (!prazno.test(form.POV.value)) {
        alert('Niste unijeli površinu prostora!');
        form.POV.focus();
        return(false);
      }
      else if (!checkRadio(form.PRO)) {
        alert('Niste odabrali u kakvom prostoru poslujete!');
        return(false);
      }
      else if (!checkRadio(form.OBC)) {
        alert('Niste odabrali želite li ili ne prostor u obrtničkom centru!');
        return(false);
      }
      
      else if (checkRadio(form.OBC)=='DA') {

        if (!checkRadio(form.VLA)) {
          alert('Niste odabrali želite li prostor u vlasništvu ili najmu!');
          return(false);
        }
        else if (!checkRadio(form.PPK)) {
          alert('Niste odabrali kada bi kupili prostor!');
          return(false);
        }
        else if (!checkRadio(form.NAM)) {
          alert('Niste odabrali što bi željeli u tom prostoru!');
          return(false);
        }
        else if (!checkRadio(form.VEL)) {
          alert('Niste odabrali koliki prostor želite!');
          return(false);
        }
        else if (!checkRadio(form.POR)) {
          alert('Niste odabrali pored čega želite svoj prostor!');
          return(false);
        }
        else if (!checkRadio(form.KUP)) {
          alert('Niste odabrali na koliko etaža želite prostor!');
          form.KUP[0].focus();
          return(false);
        }
        else if (!checkRadio(form.ZAD)) {
          alert('Niste odabrali da li ćete zadržati postojeći prostor ili ne!');
          form.ZAD[0].focus();
          return(false);
        }

      }
    }
    
    else if (name=='REG') {
      if (!prazno.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!prazno.test(form.OBRT.value))  {
        alert('Niste upisali naziv obrta!');
        form.OBRT.focus();
        return(false);
      }
      else if (!email.test(form.MAIL.value))  {
        alert('Niste upisali mail!');
        form.MAIL.focus();
        return(false);
      }
      else if (!prazno.test(form.ULICA.value))  {
        alert('Niste upisali naziv ulice!');
        form.ULICA.focus();
        return(false);
      }
      else if (!prazno.test(form.KORIME.value))  {
        alert('Niste upisali kućni broj!');
        form.KORIME.focus();
        return(false);
      }
      else if (!prazno.test(form.POS.value))  {
        alert('Niste odabrali mjesto!');
        form.POS.focus();
        return(false);
      }
      else if (!prazno.test(form.TEL.value))  {
        alert('Niste upisali broj telefona!');
        form.TEL.focus();
        return(false);
      }

    }

    else if (name =='REGA') {
      if (!prazno.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!prazno.test(form.OBRT.value))  {
        alert('Niste upisali naziv obrta!');
        form.OBRT.focus();
        return(false);
      }
      else if (!prazno.test(form.PORBR.value))  {
        alert('Niste upisali naziv porezni broj!');
        form.PORBR.focus();
        return(false);
      }
      else if (!email.test(form.MAIL.value))  {
        alert('Niste upisali mail!');
        form.MAIL.focus();
        return(false);
      }
      else if (!prazno.test(form.ULICA.value))  {
        alert('Niste upisali naziv ulice!');
        form.ULICA.focus();
        return(false);
      }
      else if (!prazno.test(form.MJESTO.value))  {
        alert('Niste upisali naziv mjesta!');
        form.MJESTO.focus();
        return(false);
      }
      else if (!prazno.test(form.POS.value))  {
        alert('Niste odabrali poštanski broj!');
        form.POS.focus();
        return(false);
      }
      else if (!prazno.test(form.TEL.value))  {
        alert('Niste upisali broj telefona!');
        form.TEL.focus();
        return(false);
      }
    }
    else if (name == 'PLOZ') {
      if (form.LOZN.value != form.LOZP.value) {
        alert('Lozinke nisu iste!');
        form.LOZP.focus();
        return(false);
       }

    } 
    // FORMULAR ZA UPIT
    
    else if (name=='UPI') {
    if (!captcha.test(form.UPI_CODE.value)) {
        alert('Niste upisali kontrolni kod!');
        form.UPI_CODE.focus();
        return(false);
      }
      else if (!ime.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!email.test(form.EMA.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EMA.focus();
        return(false);
      }
      else if (!prazno.test(form.TEM.value)) {
        alert('Niste upisali temu poruke!');
        form.TEM.focus();
        return(false);
      }
      else if (!prazno.test(form.POR.value)) {
        alert('Niste upisali tekst poruke!');
        form.POR.focus();
        return(false);
      }
    }
    
    else {
    if (!captcha.test(form.KON_CODE.value)) {
        alert('Niste upisali kontrolni kod!');
        form.KON_CODE.focus();
        return(false);
      }
      else if (!ime.test(form.IME.value)) {
        alert('Niste upisali ime i prezime!');
        form.IME.focus();
        return(false);
      }
      else if (!email.test(form.EMA.value)) {
        alert('Niste upisali ispravni E-mail!');
        form.EMA.focus();
        return(false);
      }
      else if (!prazno.test(form.TEM.value)) {
        alert('Niste upisali temu poruke!');
        form.TEM.focus();
        return(false);
      }
      else if (!prazno.test(form.POR.value)) {
        alert('Niste upisali tekst poruke!');
        form.POR.focus();
        return(false);
      }
    }
    return(true);
}

///////////////////////////////////////////////////////////////////////////////////
//
// vraca vrijednost izabrane radio opcije, ako nista nije vraca prazno
//
///////////////////////////////////////////////////////////////////////////////////

function checkRadio(RADIO) {
  var tVALUE='';
  for (var tI=0;tI<RADIO.length;tI++) {
    if (RADIO[tI].checked) { tVALUE=RADIO[tI].value }
  }
  return(tVALUE);
}


///////////////////////////////////////////////////////////////////////////////////
//
//  WSP Capcha zastita formulara
//
///////////////////////////////////////////////////////////////////////////////////

function WSPCaptcha(ID) {
  if (!ID) { ID='WSP' }
  var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  var wsp_key_length = 32;
  var wsp_key = '';
  for (var i=0; i<wsp_key_length; i++) {
    var rnum = Math.floor(Math.random() * (chars.length-1));
    wsp_key += chars.substring(rnum, rnum+1);
  }
  getO(ID+'_CAPTCHA').src = 'http://webspamprotect.com/captcha.php?id=' + xWSPCID + '&key=' + wsp_key;
  getO(ID+'_KEY').value   = wsp_key;
}

///////////////////////////////////////////////////////////////////////////////////
// Floating Div from http://www.javascript-fx.com
// You may use this code for free on any web page provided that 
// these comment lines and the following credit remain in the code.
///////////////////////////////////////////////////////////////////////////////////

function FloatDiv (id, sx, sy) {

  var EL=xDOC.getElementById?getO(id):xDOC.all?xDOC.all[id]:xDOC.layers[id];
  var PX = xDOC.layers ? "" : "px";
  window[id + "_obj"] = EL;
  if (xDOC.layers) EL.style=EL;
  EL.cx = EL.sx = sx;
  EL.cy = EL.sy = sy;

  EL.sP=function(x,y) { 
    this.style.left=x+PX;this.style.top=y+PX; 
  };

  EL.floatIt=function () {
    var pX, pY;
    pX = (this.sx >= 0) ? 0 : xNS ? innerWidth : 
	xDOC.documentElement && xDOC.documentElement.clientWidth ? 
	xDOC.documentElement.clientWidth : xDOC.body.clientWidth;
    pY = xNS ? pageYOffset : xDOC.documentElement && xDOC.documentElement.scrollTop ? 
	xDOC.documentElement.scrollTop : xDOC.body.scrollTop;
    if (this.sy<0) 
    pY += xNS ? innerHeight : xDOC.documentElement && xDOC.documentElement.clientHeight ? 
	    xDOC.documentElement.clientHeight : xDOC.body.clientHeight;
    this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
    this.sP(this.cx, this.cy);
    setTimeout(this.id + "_obj.floatIt()", 40);
  }
  return EL;
}

///////////////////////////////////////////////////////////////////////////////////
//
// slanje linka
//
///////////////////////////////////////////////////////////////////////////////////

function ShowSendLink () {
  GrayOut(true);
  var X=getO('DIVSENDLINK').offsetWidth;
  var Y=getO('DIVSENDLINK').offsetHeight;
  FloatDiv('DIVSENDLINK',parseInt((ClientWidth()-X)/2),parseInt((ClientHeight()-Y)/2)).floatIt();
  getO('DIVSENDLINK').style.visibility='visible';
}

function ShowSendLinkIzlog () {
  //GrayOut(true);
  //var X=getO('DIVSENDLINKIZLOG').offsetWidth;
  //var Y=getO('DIVSENDLINKIZLOG').offsetHeight;
  //FloatDiv('DIVSENDLINKIZLOG',parseInt((ClientWidth()-X)/6),parseInt((ClientHeight()-Y)/6)).floatIt();
  getO('DIVSENDLINKIZLOG').style.visibility='visible';
}

function ShowKontakt () {
  getO('DIVKONTAKT').style.visibility='visible';
}


function SendLink (form) {
  var tURI=xURI.replace(/=/g,'%3D');
  Update('SENDLINK','A=LIN&SEND=LIN&URI='+tURI+'&IME='+form.IME.value+'&EPR='+form.EPR.value+'&EPO='+form.EPO.value+
		'&LIN_KEY='+form.LIN_KEY.value+'&LIN_CODE='+form.LIN_CODE.value);
}

function HideSendLink () {
  getO('DIVSENDLINK').style.visibility='hidden';
  GrayOut(false);
}  

function HideSendLinkIzlog () {
  getO('DIVSENDLINKIZLOG').style.visibility='hidden';
}

function HideKontakt () {
  getO('DIVKONTAKT').style.visibility='hidden';
} 


function ShowContactUs () {
  GrayOut(true);
  var X=getO('DIVCONTACTUS').offsetWidth;
  var Y=getO('DIVCONTACTUS').offsetHeight;
  FloatDiv('DIVCONTACTUS',parseInt((ClientWidth()-X)/2),parseInt((ClientHeight()-Y)/2)).floatIt();
  getO('DIVCONTACTUS').style.visibility='visible';
}

function HideContactUs () {
  getO('DIVCONTACTUS').style.visibility='hidden';
  GrayOut(false);
}

//-------------------------------------------------------------------------------
//
// Show hide div izbornik
//
//-------------------------------------------------------------------------------

menu_status = new Array(); 

function showHide(theid){
  if (document.getElementById) {
    var switch_id = document.getElementById(theid);

    if (menu_status[theid] != 'show') {
      switch_id.className = 'show';
      menu_status[theid] = 'show';
    }
    else {
      switch_id.className = 'hide';
      menu_status[theid] = 'hide';
    }
  }
}

var last_expanded = ''; 

function showHide(id) { 
  var obj = document.getElementById(id); 
  var status = obj.className; 

  if (status == 'hide') { 

    if (last_expanded != '') { 
      var last_obj = document.getElementById(last_expanded); 
      last_obj.className = 'hide'; 
    } 

    obj.className = 'show'; 

    last_expanded = id; 
  } 
  else { obj.className = 'hide' } 
} 

///////////////////////////////////////////////////////////////////////////////////
//
// prikaz i sakrivanje slike
//
///////////////////////////////////////////////////////////////////////////////////

function ShowPicture (BID,X,Y) {
  var I=getO('IMGSRC');
  GrayOut(true);
  X+=10;
  Y+=10;
  I.src=BID;
  I.width=X;
  I.height=Y;
  var XD=getO('DIVIMG').offsetWidth;
  var YD=getO('DIVIMG').offsetHeight;
  FloatDiv('DIVIMG',parseInt((ClientWidth()-XD)/2),parseInt((ClientHeight()-YD)/2)).floatIt();
  getO('DIVIMG').style.visibility='visible';
}


function HidePicture () {
  var DIV=getO('DIVIMG');
  DIV.style.visibility='hidden';
  var I=getO('IMGSRC');
  I.src='_.gif';
  I.width=100;
  I.height=70;
  GrayOut(false);
}



///////////////////////////////////////////////////////////////////////////////////
//
// print
//
///////////////////////////////////////////////////////////////////////////////////

function PrintBody () {
  window.open('index.cgi?&PRINT=Y&'+xURI,'PRINT','width=980,height=600,screenX=20,screenY=20,left=20,top=20')
}

function PrintIzlog () {
  window.open('index.cgi?&PRINT=Y&IZL=Y&'+xURI,'PRINT','width=980,height=600,screenX=20,screenY=20,left=20,top=20')
}

///////////////////////////////////////////////////////////////////////////////////
//	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
//	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
//	Web Site: http://txkang.com
//	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
//	
//	Please retain this copyright notice in the script.
//	License is granted to user to reuse this code on 
//	their own website if, and only if, 
//	this entire copyright notice is included.
///////////////////////////////////////////////////////////////////////////////////

// affected tags
var tgs = new Array( 'td','tr','body','span','a','br','p','font','li' );

// allowed fonts
var szs = new Array( '7pt','8pt','10pt','11pt','13pt' );
var startSz = 1;

function ChangeFont( trgt,inc ) {
  if (!xDOC.getElementById) return
  var d = xDOC,cEl = null,sz = startSz,i,j,cTags;
	
  sz += inc;
  if ( sz < 0 ) sz = 0;
  if ( sz > 4 ) sz = 4;
  startSz = sz;
		
  if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

  cEl.style.fontSize = szs[ sz ];

  for ( i = 0 ; i < tgs.length ; i++ ) {
    cTags = cEl.getElementsByTagName( tgs[ i ] );
    for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
  }
}

///////////////////////////////////////////////////////////////////////////////////
//
// GrayOut
//
///////////////////////////////////////////////////////////////////////////////////

function GrayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=getO('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = xDOC.getElementsByTagName("body")[0];
    var tnode = xDOC.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=getO('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( xDOC.body && ( xDOC.body.scrollWidth || xDOC.body.scrollHeight ) ) {
        var pageWidth = xDOC.body.scrollWidth+'px';
        var pageHeight = xDOC.body.scrollHeight+'px';
    } else if( xDOC.body.offsetWidth ) {
      var pageWidth = xDOC.body.offsetWidth+'px';
      var pageHeight = xDOC.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';				 
  } 
  else {
     dark.style.display='none';
  }
}

function ShowData(ID) {
  GrayOut(true);
  var DIV=getO('DATA'+ID);
  DIV.style.left=10;
  DIV.style.top=10;
  DIV.style.visibility='visible';
}

function HideData (ID) {
  getO('DATA'+ID).style.visibility='hidden';
  GrayOut(false);
}

///////////////////////////////////////////////////////////////////////////////////
//
// functions by tigra @ softcomplex
//
// http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
//
///////////////////////////////////////////////////////////////////////////////////

function ClientWidth() {
	return PositionResult (
		window.innerWidth ? window.innerWidth : 0,
		xDOC.documentElement ? xDOC.documentElement.clientWidth : 0,
		xDOC.body ? xDOC.body.clientWidth : 0
	);
}

function ClientHeight() {
	return PositionResult (
		window.innerHeight ? window.innerHeight : 0,
		xDOC.documentElement ? xDOC.documentElement.clientHeight : 0,
		xDOC.body ? xDOC.body.clientHeight : 0
	);
}

function ScrollLeft() {
	return PositionResult (
		window.pageXOffset ? window.pageXOffset : 0,
		xDOC.documentElement ? xDOC.documentElement.scrollLeft : 0,
		xDOC.body ? xDOC.body.scrollLeft : 0
	);
}

function ScrollTop() {
	return PositionResult (
		window.pageYOffset ? window.pageYOffset : 0,
		xDOC.documentElement ? xDOC.documentElement.scrollTop : 0,
		xDOC.body ? xDOC.body.scrollTop : 0
	);
}

function PositionResult(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

///////////////////////////////////////////////////////////////////////////////////
//
// izlozi
//
///////////////////////////////////////////////////////////////////////////////////

function PrikaziIzlog(DIR,LINK) {
  GrayOut(true);
  Update('IZLOG',LINK);
  var DIV=getO('DIVIZLOG');

  //DIV.style.left=(ClientHeight()-550)/2;
  //DIV.style.top=(ClientWidth()-850)/2;
  
  FloatDiv('DIVIZLOG',parseInt((ClientWidth()-850)/2),parseInt((ClientHeight()-570)/2)).floatIt();

  DIV.style.visibility='visible';
}


function SakrijIzlog () {
  getO('DIVIZLOG').style.visibility='hidden';
  GrayOut(false);
}



function PrikaziIzlog2(DIR,LINK) {
  Update('IZLOG',LINK);
  var DIV=getO('DIVIZLOG');
}

///////////////////////////////////////////////////////////////////////////////////
//
//Chrome Drop Down Menu v2.01- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: November 14th 06- added iframe shim technique
//
///////////////////////////////////////////////////////////////////////////////////

var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
disablemenuclick: true, //when user clicks on a menu item with a drop down menu, disable menu item's link?
enableswipe: 1, //enable swipe effect? 1 for yes, 0 for no
enableiframeshim: 1, //enable "iframe shim" technique to get drop down menus to correctly appear on top of controls such as form objects in IE5.5/IE6? 1 for yes, 0 for no

//No need to edit beyond here////////////////////////
dropmenuobj: null, ie: xDOC.all, firefox: xDOC.getElementById&&!xDOC.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},

showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)" //hide menu via clipping
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},

iecompattest:function(){
return (xDOC.compatMode && xDOC.compatMode!="BackCompat")? xDOC.documentElement : xDOC.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null) //hide previous menu
this.dropmenuobj.style.visibility="hidden" //hide menu
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
obj.onclick=function(){return !cssdropdown.disablemenuclick} //disable main menu item link onclick?
this.dropmenuobj=getO(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e)
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
this.positionshim() //call iframe shim function
}
},

positionshim:function(){ //display iframe shim function
if (this.enableiframeshim && typeof this.shimobject!="undefined"){
if (this.dropmenuobj.style.visibility=="visible"){
this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
this.shimobject.style.left=this.dropmenuobj.style.left
this.shimobject.style.top=this.dropmenuobj.style.top
}
this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
}
},

hideshim:function(){
if (this.enableiframeshim && typeof this.shimobject!="undefined")
this.shimobject.style.display='none'
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay) //hide menu
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},

startchrome:function(){
for (var ids=0; ids<arguments.length; ids++){
var menuitems=getO(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
var relvalue=menuitems[i].getAttribute("rel")
menuitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}
}
}
}
if (window.createPopup && 0){ //if IE5.5 to IE6, create iframe for iframe shim technique
xDOC.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
this.shimobject=getO("iframeshim") //reference iframe object
}
}

}

///////////////////////////////////////////////////////////////////////////////////
//
// Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
// This notice MUST stay intact for legal use
// Visit http://www.dynamicdrive.com/ for this script and 100s more.
//
///////////////////////////////////////////////////////////////////////////////////

var xDELAYSCROLLTIMEOUT;
var xSCROLLTIMEOUT;

var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
  if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+0))
    cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
  else
    cross_marquee.style.top=parseInt(marqueeheight)+0+"px"
}

function initializemarquee(){
  if (xDELAYSCROLLTIMEOUT) { clearTimeout(xDELAYSCROLLTIMEOUT) }
  if (xSCROLLTIMEOUT) { clearTimeout(xSCROLLTIMEOUT) }
  cross_marquee=getO("vmarquee")
  cross_marquee.style.top=0
  marqueeheight=getO("marqueecontainer").offsetHeight
  actualheight=cross_marquee.offsetHeight
  if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
    cross_marquee.style.height=marqueeheight+"px"
    cross_marquee.style.overflow="scroll"
    return
  }
  xDELAYSCROLLTIMEOUT=setTimeout('xSCROLLTIMEOUT=setInterval("scrollmarquee()",30)', delayb4scroll);
}


///////////////////////////////////////////////////////////////////////////////////
//
// vracanje vrijednosti polja u dokumentu
//
///////////////////////////////////////////////////////////////////////////////////

// vintage - NE KORISTITI!!!!!!!!!!!

function getSelectValue (ID) {
  var SEL=eval('xDOC.FOR.'+ID);
  if (SEL && SEL.selectedIndex>=0) { return(SEL.options[SEL.selectedIndex].value) }
  return('')
}

function getValue(pID) {
  var tSEL='';
  if (pID && pID.selectedIndex) { tSEL=pID }
  else { tSEL=getO(pID) }
  if (tSEL && tSEL.selectedIndex>=0) { return(tSEL.options[tSEL.selectedIndex].value) }
  return('')
}

// nove funkcije

function getS(pID) {
  var tSEL;
  if (xDOC.FOR!=undefined) {
    tSEL=eval('xDOC.FOR.'+pID);
    if (tSEL && tSEL.selectedIndex>=0) { return(tSEL.options[tSEL.selectedIndex].value) }
  }
  tSEL=getO(pID);
  if (tSEL && tSEL.selectedIndex>=0) { return(tSEL.options[tSEL.selectedIndex].value) }
  return('')
}

function getT(pID) {
  var tTXT;
  tTXT=getO(pID);
  if (tTXT) { return(tTXT.value) }
  if (xDOC.FOR!=undefined) {
    tTXT=eval('xDOC.FOR.'+pID);
    if (tTXT) { return(tTXT.value) }
  }
  return('')
}

function getO(pID) {
  return(xDOC.getElementById(pID))
}


function getIDSEKC() {
  var tRET='';
  if (getS('SEKCIJA')) { tRET=getS('SEKCIJA') }
  else if (getT('IDSEK')) { tRET=getT('IDSEK') }
  return(tRET);
}

///////////////////////////////////////////////////////////////////////////////////
//
// promjena stila
//
///////////////////////////////////////////////////////////////////////////////////

function setStyle (FIELD,OPT) {
  if (OPT==1) {
    FIELD.className=OPT;
  }
  else {
    FIELD.className=OPT;
  }
}

///////////////////////////////////////////////////////////////////////////////////
//
// prikazivanje DIV s detaljima
//
///////////////////////////////////////////////////////////////////////////////////

function showDetalji(pID) {
  var tDIV=getO('DET'+pID);
  var tX=tDIV.offsetWidth;
  var tY=tDIV.offsetHeight;
  GrayOut(true);
  FloatDiv('DET'+pID,parseInt((ClientWidth()-tX)/2),parseInt((ClientHeight()-tY)/2)).floatIt();
  tDIV.style.visibility='visible';
}

function hideDetalji(pID) {
  getO('DET'+pID).style.visibility='hidden';
  GrayOut(false);
}

function XshowDetalji(pID,pPOSTO) {
  var tTAB=getO('TAB'+pID);
  var tY=tTAB.offsetHeight;
  var tDIV=getO('DET'+pID);
  if (!pPOSTO) {
    // DIV je otvoren, zatvori ga
    if (tDIV.offsetHeight==tY) { hideDetalji(pID);return }
    // DIV se otvara
    else if (tDIV.offsetHeight>1) { return }
    // zatvori ostale detalje
    hideAllDetalji();
    pPOSTO=1;
  }
  var tP=Math.floor(tY*pPOSTO/100);
  tDIV.style.height=tP+'px';
  pPOSTO=pPOSTO+6;
  if (pPOSTO>=100) {
    tDIV.style.height=tY+'px';
    var tYDIVEND=AnchorPosition_getPageOffsetTop(tDIV)+tY;
    while (ClientHeight()+ScrollTop()<AnchorPosition_getPageOffsetTop(tDIV)+tY+2) {
      xDOC.body.scrollTop=ScrollTop()+1;
    }
    return
  }
  setTimeout("showDetalji('"+pID+"',"+pPOSTO+")",15);
}

function printDetalji(pID) {
  var tDIV=getO('PRINT'+pID);
  var tX=tDIV.offsetWidth;
  var tY=tDIV.offsetHeight;
  var tDETWIN=window.open('','DETWIN','width='+tX+',height='+tY+',screenX=20,screenY=20,left=20,top=20');
  tDETWIN.document.open();
  tDETWIN.document.write('<link rel="stylesheet" href="obrt-zg.css">');
  tDETWIN.document.write('<body style="margin:0;padding:0;">');
  tDETWIN.document.write(tDIV.innerHTML);
  tDETWIN.document.write('</body>');
  tDETWIN.document.close();
  tDETWIN.print();
  tDETWIN.close();
}

///////////////////////////////////////////////////////////////////////////////////
//
// AnchorPosition.js 
//
///////////////////////////////////////////////////////////////////////////////////

function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(xDOC.getElementById){use_gebi=true;}else if(xDOC.all){use_css=true;}else if(xDOC.layers){use_layers=true;}if(use_gebi && xDOC.all){x=AnchorPosition_getPageOffsetLeft(xDOC.all[anchorname]);y=AnchorPosition_getPageOffsetTop(xDOC.all[anchorname]);}else if(use_gebi){var o=getO(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(xDOC.all[anchorname]);y=AnchorPosition_getPageOffsetTop(xDOC.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<xDOC.anchors.length;i++){if(xDOC.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=xDOC.anchors[i].x;y=xDOC.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(xDOC.getElementById){if(isNaN(window.screenX)){x=coordinates.x-xDOC.body.scrollLeft+window.screenLeft;y=coordinates.y-xDOC.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(xDOC.all){x=coordinates.x-xDOC.body.scrollLeft+window.screenLeft;y=coordinates.y-xDOC.body.scrollTop+window.screenTop;}else if(xDOC.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-xDOC.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-xDOC.body.scrollTop;}


///////////////////////////////////////////////////////////////////////////////////
// Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
// This notice MUST stay intact for legal use
// Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
///////////////////////////////////////////////////////////////////////////////////

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=xDOC.all
var ns6=xDOC.getElementById && !xDOC.all
var enabletip=false

function ietruebody(){
  return (xDOC.compatMode && xDOC.compatMode!="BackCompat")? xDOC.documentElement : xDOC.body
}

function ddrivetip(thetext, thecolor, thewidth){
  if (ns6||ie){
    var tipobj=xDOC.all? xDOC.all["dhtmltooltip"] : xDOC.getElementById? getO("dhtmltooltip") : ""
    if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
    if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
    tipobj.innerHTML=thetext
    enabletip=true
    return false
  }
}

function positiontip(e){
  if (enabletip){
    var tipobj=xDOC.all? xDOC.all["dhtmltooltip"] : xDOC.getElementById? getO("dhtmltooltip") : ""
    var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
    var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
    //Find out how close the mouse is to the corner of the window
    var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
    var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

    var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

    //if the horizontal distance isn't enough to accomodate the width of the context menu
    if (rightedge<tipobj.offsetWidth)
      //move the horizontal position of the menu to the left by it's width
      tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
    else if (curX<leftedge)
      tipobj.style.left="5px"
    else
      //position the horizontal position of the menu where the mouse is positioned
      tipobj.style.left=curX+offsetxpoint+"px"

    //same concept with the vertical position
    if (bottomedge<tipobj.offsetHeight)
      tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
    else
      tipobj.style.top=curY+offsetypoint+"px"

    tipobj.style.visibility="visible"
  }
}

function hideddrivetip(){
  var tipobj=xDOC.all? xDOC.all["dhtmltooltip"] : xDOC.getElementById? getO("dhtmltooltip") : ""
  if (ns6||ie){
    enabletip=false
    tipobj.style.visibility="hidden"
    tipobj.style.left="-1000px"
    tipobj.style.backgroundColor=''
    tipobj.style.width=''
  }
}

xDOC.onmousemove=positiontip 

///////////////////////////////////////////////////////////////////////////////////
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
///////////////////////////////////////////////////////////////////////////////////

/* SOURCE FILE: AnchorPosition.js */
function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(xDOC.getElementById){use_gebi=true;}else if(xDOC.all){use_css=true;}else if(xDOC.layers){use_layers=true;}if(use_gebi && xDOC.all){x=AnchorPosition_getPageOffsetLeft(xDOC.all[anchorname]);y=AnchorPosition_getPageOffsetTop(xDOC.all[anchorname]);}else if(use_gebi){var o=getO(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(xDOC.all[anchorname]);y=AnchorPosition_getPageOffsetTop(xDOC.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<xDOC.anchors.length;i++){if(xDOC.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=xDOC.anchors[i].x;y=xDOC.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(xDOC.getElementById){if(isNaN(window.screenX)){x=coordinates.x-xDOC.body.scrollLeft+window.screenLeft;y=coordinates.y-xDOC.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(xDOC.all){x=coordinates.x-xDOC.body.scrollLeft+window.screenLeft;y=coordinates.y-xDOC.body.scrollTop+window.screenTop;}else if(xDOC.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-xDOC.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-xDOC.body.scrollTop;}

/* SOURCE FILE: date.js */
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}

/* SOURCE FILE: PopupWindow.js */
function PopupWindow_getXYPosition(anchorname){var coordinates;if(this.type == "WINDOW"){coordinates = getAnchorWindowPosition(anchorname);}else{coordinates = getAnchorPosition(anchorname);}this.x = coordinates.x;this.y = coordinates.y;}
function PopupWindow_setSize(width,height){this.width = width;this.height = height;}
function PopupWindow_populate(contents){this.contents = contents;this.populated = false;}
function PopupWindow_setUrl(url){this.url = url;}
function PopupWindow_setWindowProperties(props){this.windowProperties = props;}
function PopupWindow_refresh(){if(this.divName != null){if(this.use_gebi){getO(this.divName).innerHTML = this.contents;}else if(this.use_css){xDOC.all[this.divName].innerHTML = this.contents;}else if(this.use_layers){var d = xDOC.layers[this.divName];d.xDOC.open();d.xDOC.writeln(this.contents);d.xDOC.close();}}else{if(this.popupWindow != null && !this.popupWindow.closed){if(this.url!=""){this.popupWindow.location.href=this.url;}else{this.popupWindow.xDOC.open();this.popupWindow.xDOC.writeln(this.contents);this.popupWindow.xDOC.close();}this.popupWindow.focus();}}}
function PopupWindow_showPopup(anchorname){this.getXYPosition(anchorname);this.x += this.offsetX;this.y += this.offsetY;if(!this.populated &&(this.contents != "")){this.populated = true;this.refresh();}if(this.divName != null){if(this.use_gebi){getO(this.divName).style.left = this.x + "px";getO(this.divName).style.top = this.y + "px";getO(this.divName).style.visibility = "visible";}else if(this.use_css){xDOC.all[this.divName].style.left = this.x;xDOC.all[this.divName].style.top = this.y;xDOC.all[this.divName].style.visibility = "visible";}else if(this.use_layers){xDOC.layers[this.divName].left = this.x;xDOC.layers[this.divName].top = this.y;xDOC.layers[this.divName].visibility = "visible";}}else{if(this.popupWindow == null || this.popupWindow.closed){if(this.x<0){this.x=0;}if(this.y<0){this.y=0;}if(screen && screen.availHeight){if((this.y + this.height) > screen.availHeight){this.y = screen.availHeight - this.height;}}if(screen && screen.availWidth){if((this.x + this.width) > screen.availWidth){this.x = screen.availWidth - this.width;}}var avoidAboutBlank = window.opera ||( xDOC.layers && !navigator.mimeTypes['*']) || navigator.vendor == 'KDE' ||( xDOC.childNodes && !xDOC.all && !navigator.taintEnabled);this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");}this.refresh();}}
function PopupWindow_hidePopup(){if(this.divName != null){if(this.use_gebi){getO(this.divName).style.visibility = "hidden";}else if(this.use_css){xDOC.all[this.divName].style.visibility = "hidden";}else if(this.use_layers){xDOC.layers[this.divName].visibility = "hidden";}}else{if(this.popupWindow && !this.popupWindow.closed){this.popupWindow.close();this.popupWindow = null;}}}
function PopupWindow_isClicked(e){if(this.divName != null){if(this.use_layers){var clickX = e.pageX;var clickY = e.pageY;var t = xDOC.layers[this.divName];if((clickX > t.left) &&(clickX < t.left+t.clip.width) &&(clickY > t.top) &&(clickY < t.top+t.clip.height)){return true;}else{return false;}}else if(xDOC.all){var t = window.event.srcElement;while(t.parentElement != null){if(t.id==this.divName){return true;}t = t.parentElement;}return false;}else if(this.use_gebi && e){var t = e.originalTarget;while(t.parentNode != null){if(t.id==this.divName){return true;}t = t.parentNode;}return false;}return false;}return false;}
function PopupWindow_hideIfNotClicked(e){if(this.autoHideEnabled && !this.isClicked(e)){this.hidePopup();}}
function PopupWindow_autoHide(){this.autoHideEnabled = true;}
function PopupWindow_hidePopupWindows(e){for(var i=0;i<popupWindowObjects.length;i++){if(popupWindowObjects[i] != null){var p = popupWindowObjects[i];p.hideIfNotClicked(e);}}}
function PopupWindow_attachListener(){if(xDOC.layers){xDOC.captureEvents(Event.MOUSEUP);}window.popupWindowOldEventListener = xDOC.onmouseup;if(window.popupWindowOldEventListener != null){xDOC.onmouseup = new Function("window.popupWindowOldEventListener();PopupWindow_hidePopupWindows();");}else{xDOC.onmouseup = PopupWindow_hidePopupWindows;}}
function PopupWindow(){if(!window.popupWindowIndex){window.popupWindowIndex = 0;}if(!window.popupWindowObjects){window.popupWindowObjects = new Array();}if(!window.listenerAttached){window.listenerAttached = true;PopupWindow_attachListener();}this.index = popupWindowIndex++;popupWindowObjects[this.index] = this;this.divName = null;this.popupWindow = null;this.width=0;this.height=0;this.populated = false;this.visible = false;this.autoHideEnabled = false;this.contents = "";this.url="";this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";if(arguments.length>0){this.type="DIV";this.divName = arguments[0];}else{this.type="WINDOW";}this.use_gebi = false;this.use_css = false;this.use_layers = false;if(xDOC.getElementById){this.use_gebi = true;}else if(xDOC.all){this.use_css = true;}else if(xDOC.layers){this.use_layers = true;}else{this.type = "WINDOW";}this.offsetX = 0;this.offsetY = 0;this.getXYPosition = PopupWindow_getXYPosition;this.populate = PopupWindow_populate;this.setUrl = PopupWindow_setUrl;this.setWindowProperties = PopupWindow_setWindowProperties;this.refresh = PopupWindow_refresh;this.showPopup = PopupWindow_showPopup;this.hidePopup = PopupWindow_hidePopup;this.setSize = PopupWindow_setSize;this.isClicked = PopupWindow_isClicked;this.autoHide = PopupWindow_autoHide;this.hideIfNotClicked = PopupWindow_hideIfNotClicked;}


/* SOURCE FILE: CalendarPopup.js */

function CalendarPopup(){var c;if(arguments.length>0){c = new PopupWindow(arguments[0]);}else{c = new PopupWindow();c.setSize(150,175);}c.offsetX = -152;c.offsetY = 25;c.autoHide();c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");c.dayHeaders = new Array("S","M","T","W","T","F","S");c.returnFunction = "CP_tmpReturnFunction";c.returnMonthFunction = "CP_tmpReturnMonthFunction";c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";c.returnYearFunction = "CP_tmpReturnYearFunction";c.weekStartDay = 0;c.isShowYearNavigation = false;c.displayType = "date";c.disabledWeekDays = new Object();c.disabledDatesExpression = "";c.yearSelectStartOffset = 2;c.currentDate = null;c.todayText="Today";c.cssPrefix="";c.isShowNavigationDropdowns=false;c.isShowYearNavigationInput=false;window.CP_calendarObject = null;window.CP_targetInput = null;window.CP_dateFormat = "MM/dd/yyyy";c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;c.setReturnFunction = CP_setReturnFunction;c.setReturnMonthFunction = CP_setReturnMonthFunction;c.setReturnQuarterFunction = CP_setReturnQuarterFunction;c.setReturnYearFunction = CP_setReturnYearFunction;c.setMonthNames = CP_setMonthNames;c.setMonthAbbreviations = CP_setMonthAbbreviations;c.setDayHeaders = CP_setDayHeaders;c.setWeekStartDay = CP_setWeekStartDay;c.setDisplayType = CP_setDisplayType;c.setDisabledWeekDays = CP_setDisabledWeekDays;c.addDisabledDates = CP_addDisabledDates;c.setYearSelectStartOffset = CP_setYearSelectStartOffset;c.setTodayText = CP_setTodayText;c.showYearNavigation = CP_showYearNavigation;c.showCalendar = CP_showCalendar;c.hideCalendar = CP_hideCalendar;c.getStyles = getCalendarStyles;c.refreshCalendar = CP_refreshCalendar;c.getCalendar = CP_getCalendar;c.select = CP_select;c.setCssPrefix = CP_setCssPrefix;c.showNavigationDropdowns = CP_showNavigationDropdowns;c.showYearNavigationInput = CP_showYearNavigationInput;c.copyMonthNamesToWindow();return c;}
function CP_copyMonthNamesToWindow(){if(typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null){window.MONTH_NAMES = new Array();for(var i=0;i<this.monthNames.length;i++){window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i];}for(var i=0;i<this.monthAbbreviations.length;i++){window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i];}}}
function CP_tmpReturnFunction(y,m,d){if(window.CP_targetInput!=null){var dt = new Date(y,m-1,d,0,0,0);if(window.CP_calendarObject!=null){window.CP_calendarObject.copyMonthNamesToWindow();}window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);}else{alert('Use setReturnFunction() to define which function will get the clicked results!');}}
function CP_tmpReturnMonthFunction(y,m){alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m);}
function CP_tmpReturnQuarterFunction(y,q){alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q);}
function CP_tmpReturnYearFunction(y){alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y);}
function CP_setReturnFunction(name){this.returnFunction = name;}
function CP_setReturnMonthFunction(name){this.returnMonthFunction = name;}
function CP_setReturnQuarterFunction(name){this.returnQuarterFunction = name;}
function CP_setReturnYearFunction(name){this.returnYearFunction = name;}
function CP_setMonthNames(){for(var i=0;i<arguments.length;i++){this.monthNames[i] = arguments[i];}this.copyMonthNamesToWindow();}
function CP_setMonthAbbreviations(){for(var i=0;i<arguments.length;i++){this.monthAbbreviations[i] = arguments[i];}this.copyMonthNamesToWindow();}
function CP_setDayHeaders(){for(var i=0;i<arguments.length;i++){this.dayHeaders[i] = arguments[i];}}
function CP_setWeekStartDay(day){this.weekStartDay = day;}
function CP_showYearNavigation(){this.isShowYearNavigation =(arguments.length>0)?arguments[0]:true;}
function CP_setDisplayType(type){if(type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year"){alert("Invalid display type! Must be one of: date,week-end,month,quarter,year");return false;}this.displayType=type;}
function CP_setYearSelectStartOffset(num){this.yearSelectStartOffset=num;}
function CP_setDisabledWeekDays(){this.disabledWeekDays = new Object();for(var i=0;i<arguments.length;i++){this.disabledWeekDays[arguments[i]] = true;}}
function CP_addDisabledDates(start, end){if(arguments.length==1){end=start;}if(start==null && end==null){return;}if(this.disabledDatesExpression!=""){this.disabledDatesExpression+= "||";}if(start!=null){start = parseDate(start);start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}if(end!=null){end=parseDate(end);end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}if(start==null){this.disabledDatesExpression+="(ds<="+end+")";}else if(end  ==null){this.disabledDatesExpression+="(ds>="+start+")";}else{this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")";}}
function CP_setTodayText(text){this.todayText = text;}
function CP_setCssPrefix(val){this.cssPrefix = val;}
function CP_showNavigationDropdowns(){this.isShowNavigationDropdowns =(arguments.length>0)?arguments[0]:true;}
function CP_showYearNavigationInput(){this.isShowYearNavigationInput =(arguments.length>0)?arguments[0]:true;}
function CP_hideCalendar(){if(arguments.length > 0){window.popupWindowObjects[arguments[0]].hidePopup();}else{this.hidePopup();}}
function CP_refreshCalendar(index){var calObject = window.popupWindowObjects[index];if(arguments.length>1){calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));}else{calObject.populate(calObject.getCalendar());}calObject.refresh();}
function CP_showCalendar(anchorname){if(arguments.length>1){if(arguments[1]==null||arguments[1]==""){this.currentDate=new Date();}else{this.currentDate=new Date(parseDate(arguments[1]));}}this.populate(this.getCalendar());this.showPopup(anchorname);}
function CP_select(inputobj, linkname, format){var selectedDate=(arguments.length>3)?arguments[3]:null;if(!window.getDateFromFormat){alert("calendar.select: To use this method you must also include 'date.js' for date formatting");return;}if(this.displayType!="date"&&this.displayType!="week-end"){alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");return;}if(inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea"){alert("calendar.select: Input object passed is not a valid form input object");window.CP_targetInput=null;return;}if(inputobj.disabled){return;}window.CP_targetInput = inputobj;window.CP_calendarObject = this;this.currentDate=null;var time=0;if(selectedDate!=null){time = getDateFromFormat(selectedDate,format)}else if(inputobj.value!=""){time = getDateFromFormat(inputobj.value,format);}if(selectedDate!=null || inputobj.value!=""){if(time==0){this.currentDate=null;}else{this.currentDate=new Date(time);}}window.CP_dateFormat = format;this.showCalendar(linkname);}
function getCalendarStyles(){var result = "";var p = "";if(this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!=""){p=this.cssPrefix;}result += "<STYLE>\n";result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation{background-color:#C0C0C0;text-align:center;vertical-align:center;text-decoration:none;color:#000000;font-weight:bold;}\n";result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText{font-family:arial;font-size:8pt;}\n";result += "TD."+p+"cpDayColumnHeader{text-align:right;border:solid thin #C0C0C0;border-width:0px 0px 1px 0px;}\n";result += "."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate{text-align:right;text-decoration:none;}\n";result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled{color:#D0D0D0;text-align:right;text-decoration:line-through;}\n";result += "."+p+"cpCurrentMonthDate, .cpCurrentDate{color:#000000;}\n";result += "."+p+"cpOtherMonthDate{color:#808080;}\n";result += "TD."+p+"cpCurrentDate{color:white;background-color: #C0C0C0;border-width:1px;border:solid thin #800000;}\n";result += "TD."+p+"cpCurrentDateDisabled{border-width:1px;border:solid thin #FFAAAA;}\n";result += "TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled{border:solid thin #C0C0C0;border-width:1px 0px 0px 0px;}\n";result += "A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled{height:20px;}\n";result += "A."+p+"cpTodayText{color:black;}\n";result += "."+p+"cpTodayTextDisabled{color:#D0D0D0;}\n";result += "."+p+"cpBorder{border:solid thin #808080;}\n";result += "</STYLE>\n";return result;}
function CP_getCalendar(){var now = new Date();if(this.type == "WINDOW"){var windowref = "window.opener.";}else{var windowref = "";}var result = "";if(this.type == "WINDOW"){result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';}else{result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';result += '<TR><TD ALIGN=CENTER>\n';result += '<CENTER>\n';}if(this.displayType=="date" || this.displayType=="week-end"){if(this.currentDate==null){this.currentDate = now;}if(arguments.length > 0){var month = arguments[0];}else{var month = this.currentDate.getMonth()+1;}if(arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]){var year = arguments[1];}else{var year = this.currentDate.getFullYear();}var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);if( ((year%4 == 0)&&(year%100 != 0) ) ||(year%400 == 0) ){daysinmonth[2] = 29;}var current_month = new Date(year,month-1,1);var display_year = year;var display_month = month;var display_date = 1;var weekday= current_month.getDay();var offset = 0;offset =(weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;if(offset > 0){display_month--;if(display_month < 1){display_month = 12;display_year--;}display_date = daysinmonth[display_month]-offset+1;}var next_month = month+1;var next_month_year = year;if(next_month > 12){next_month=1;next_month_year++;}var last_month = month-1;var last_month_year = year;if(last_month < 1){last_month=12;last_month_year--;}var date_class;if(this.type!="WINDOW"){result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";}result += '<TR>\n';var refresh = windowref+'CP_refreshCalendar';var refreshLink = 'javascript:' + refresh;if(this.isShowNavigationDropdowns){result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';for( var monthCounter=1;monthCounter<=12;monthCounter++){var selected =(monthCounter==month) ? 'SELECTED' : '';result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';}result += '</select></TD>';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';for( var yearCounter=year-this.yearSelectStartOffset;yearCounter<=year+this.yearSelectStartOffset;yearCounter++){var selected =(yearCounter==year) ? 'SELECTED' : '';result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';}result += '</select></TD>';}else{if(this.isShowYearNavigation){result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;</A></TD>';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;</A></TD>';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');">&lt;</A></TD>';if(this.isShowYearNavigationInput){result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';}else{result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';}result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">&gt;</A></TD>';}else{result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;&lt;</A></TD>\n';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;&gt;</A></TD>\n';}}result += '</TR></TABLE>\n';result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';result += '<TR>\n';for(var j=0;j<7;j++){result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';}result += '</TR>\n';for(var row=1;row<=6;row++){result += '<TR>\n';for(var col=1;col<=7;col++){var disabled=false;if(this.disabledDatesExpression!=""){var ds=""+display_year+LZ(display_month)+LZ(display_date);eval("disabled=("+this.disabledDatesExpression+")");}var dateClass = "";if((display_month == this.currentDate.getMonth()+1) &&(display_date==this.currentDate.getDate()) &&(display_year==this.currentDate.getFullYear())){dateClass = "cpCurrentDate";}else if(display_month == month){dateClass = "cpCurrentMonthDate";}else{dateClass = "cpOtherMonthDate";}if(disabled || this.disabledWeekDays[col-1]){result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';}else{var selected_date = display_date;var selected_month = display_month;var selected_year = display_year;if(this.displayType=="week-end"){var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0);d.setDate(d.getDate() +(7-col));selected_year = d.getYear();if(selected_year < 1000){selected_year += 1900;}selected_month = d.getMonth()+1;selected_date = d.getDate();}result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';}display_date++;if(display_date > daysinmonth[display_month]){display_date=1;display_month++;}if(display_month > 12){display_month=1;display_year++;}}result += '</TR>';}var current_weekday = now.getDay() - this.weekStartDay;if(current_weekday < 0){current_weekday += 7;}result += '<TR>\n';result += '	<TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';if(this.disabledDatesExpression!=""){var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());eval("disabled=("+this.disabledDatesExpression+")");}if(disabled || this.disabledWeekDays[current_weekday+1]){result += '		<SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';}else{result += '		<A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';}result += '		<BR>\n';result += '	</TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';}if(this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year"){if(arguments.length > 0){var year = arguments[0];}else{if(this.displayType=="year"){var year = now.getFullYear()-this.yearSelectStartOffset;}else{var year = now.getFullYear();}}if(this.displayType!="year" && this.isShowYearNavigation){result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";result += '<TR>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');">&lt;&lt;</A></TD>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">&gt;&gt;</A></TD>\n';result += '</TR></TABLE>\n';}}if(this.displayType=="month"){result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<4;i++){result += '<TR>';for(var j=0;j<3;j++){var monthindex =((i*3)+j);result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';}result += '</TR>';}result += '</TABLE></CENTER></TD></TR></TABLE>\n';}if(this.displayType=="quarter"){result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<2;i++){result += '<TR>';for(var j=0;j<2;j++){var quarter =((i*2)+j+1);result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';}result += '</TR>';}result += '</TABLE></CENTER></TD></TR></TABLE>\n';}if(this.displayType=="year"){var yearColumnSize = 4;result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";result += '<TR>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');">&lt;&lt;</A></TD>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">&gt;&gt;</A></TD>\n';result += '</TR></TABLE>\n';result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<yearColumnSize;i++){for(var j=0;j<2;j++){var currentyear = year+(j*yearColumnSize)+i;result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';}result += '</TR>';}result += '</TABLE></CENTER></TD></TR></TABLE>\n';}if(this.type == "WINDOW"){result += "</BODY></HTML>\n";}return result;}


///////////////////////////////////////////////////////////////////////////////////
//
// kalendar
//
///////////////////////////////////////////////////////////////////////////////////

function Kalendar(KALDIV,FIELD,ANCHOR,DISABLE) {
  var KAL = new CalendarPopup(KALDIV);
  KAL.setMonthNames('sije&#269;anj','velja&#269;a','o&#382;ujak','travanj','svibanj','lipanj','srpanj','kolovoz','rujan','listopad','studeni','prosinac'); 
  KAL.setDayHeaders('N','P','U','S','Č','P','S'); 
  KAL.setWeekStartDay(1); 
  KAL.setTodayText('danas');
  KAL.showNavigationDropdowns();
  KAL.setCssPrefix('KAL');
  if (DISABLE) { 
    var JUCER=new Date();
    JUCER.setDate(JUCER.getDate()-1)   
    KAL.addDisabledDates(null,formatDate(JUCER,'yyyy-MM-dd'))  
  }  KAL.select(getO(FIELD),ANCHOR,'dd.MM.yyyy');
} 


///////////////////////////////////////////////////////////////////////////////////
//
// LyteFrame 
//
///////////////////////////////////////////////////////////////////////////////////

var lfINT='';

function startLyteFrame(title,url,width,height) {
  var anchor = this.document.createElement('a');
  if (lfINT) { clearInterval(lfINT) }
  anchor.setAttribute('rev','width: '+width+'px; height: '+height+'px; scrolling: auto;');
  anchor.setAttribute('title',title);
  anchor.setAttribute('href',url);
  anchor.setAttribute('rel','lyteframe');
  if (!myLytebox) { lfINT=setInterval('startLyteFrame("'+title+'","'+url+'",'+width+','+height+')',1000);return false; }
  if (lfINT) { clearInterval(lfINT) }
  myLytebox.start(anchor,false,true);
  return false;
}

///////////////////////////////////////////////////////////////////////////////////
//
// eventi
//
///////////////////////////////////////////////////////////////////////////////////

function stopEventPropagation(pEVENT) {
  if (!pEVENT) var pEVENT = window.event;
  pEVENT.cancelBubble=true;
  if (pEVENT.stopPropagation) pEVENT.stopPropagation();
}

///////////////////////////////////////////////////////////////////////////////////
// search
// - sakrij DIV-ove koji ne odgovaraju uvjetu
///////////////////////////////////////////////////////////////////////////////////

function search(pSS) {
  if (!xDOC.getElementsByTagName) return;
  var rSO=/^obrt/;
  var rSS=new RegExp(pSS,'i');
  var tNODES=xDOC.getElementsByTagName('div');
  for(var tI=tNODES.length-1;tI>=0;tI--) {
    if (tNODES[tI].title) {
      var tMSO=rSO.exec(tNODES[tI].id);
      if (tMSO) {
        var tDIS='block';
        if (pSS) {
          tDIS='none';
          var tMSS=rSS.exec(tNODES[tI].title);
          if (tMSS) {
            tDIS='block';
          }
        }
        tNODES[tI].style.display=tDIS;
      }
    }
  }
}

///////////////////////////////////////////////////////////////////////////////////
// tabovi
///////////////////////////////////////////////////////////////////////////////////

function InitNasTabs() {
  if (getO('dNOSAS')) {
    var tTABS=new ddtabcontent('dNOSAS')
    tTABS.setpersist(true)
    tTABS.setselectedClassTarget('link')
    tTABS.init()
  }
}

/***********************************************
* Tab Content script v2.2- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//** Tab Content script v2.0- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Updated Oct 7th, 07 to version 2.0. Contains numerous improvements:
//   -Added Auto Mode: Script auto rotates the tabs based on an interval, until a tab is explicitly selected
//   -Ability to expand/contract arbitrary DIVs on the page as the tabbed content is expanded/ contracted
//   -Ability to dynamically select a tab either based on its position within its peers, or its ID attribute (give the target tab one 1st)
//   -Ability to set where the CSS classname "selected" get assigned- either to the target tab's link ("A"), or its parent container
//** Updated Feb 18th, 08 to version 2.1: Adds a "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically
//** Updated April 8th, 08 to version 2.2: Adds support for expanding a tab using a URL parameter (ie: http://mysite.com/tabcontent.htm?tabinterfaceid=0) 

////NO NEED TO EDIT BELOW////////////////////////

function ddtabcontent(tabinterfaceid){
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence=true
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}

ddtabcontent.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

ddtabcontent.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}

ddtabcontent.prototype={

	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
		this.cancelautorun() //stop auto cycling of tabs (if running)
		var tabref=""
		try{
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=document.getElementById(tabid_or_position)
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=this.tabs[tabid_or_position]
		}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="") //if a valid tab is found based on function parameter
			this.expandtab(tabref) //expand this tab
	},

	cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
		if (dir=="next"){
			var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
		}
		else if (dir=="prev"){
			var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
		}
		if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function
			this.cancelautorun() //stop auto cycling of tabs (if running)
		this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
	},

	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
			this.enabletabpersistence=bool
	},

	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
		this.selectedClassTarget=objstr || "link"
	},

	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
	},

	urlparamselect:function(tabinterfaceid){
		var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) //check for "?tabinterfaceid=2" in URL
		return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
	},

	expandtab:function(tabref){
		var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		this.expandsubcontent(subcontentid)
		this.expandrevcontent(associatedrevids)
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
		}
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
	},

	expandsubcontent:function(subcontentid){
		for (var i=0; i<this.subcontentids.length; i++){
			var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)
			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value
		}
	},

	expandrevcontent:function(associatedrevids){
		var allrevids=this.revcontentids
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
		}
	},

	setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)
		for (var i=0; i<this.hottabspositions.length; i++){
			if (tabposition==this.hottabspositions[i]){
				this.currentTabIndex=i
				break
			}
		}
	},

	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
		this.cycleit('next', true)
	},

	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)
	},

	init:function(automodeperiod){
		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
		var selectedtab=-1 //Currently selected tab index (-1 meaning none)
		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
		this.automodeperiod=automodeperiod || 0
		for (var i=0; i<this.tabs.length; i++){
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
			if (this.tabs[i].getAttribute("rel")){
				var tabinstance=this
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)
				this.tabs[i].onclick=function(){
					tabinstance.expandtab(this)
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
					return false
				}
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
				}
				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
					selectedtab=i //Selected tab index, if found
				}
			}
		} //END for loop
		if (selectedtab!=-1) //if a valid default selected tab index is found
			this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
		else //if no valid default selected index found
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
		}
	} //END int() function

} //END Prototype assignment
