/////////////////////////////////////////////////////////////////////////////////
//
// Auto Prikratki Javascript
//
// (c)2005-2009 by Abacus, info (ath] abacus (doth] hr
//
// v1.10 4.5.2009. TCrnicki
//
/////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////
//
// globalne varijable
//
///////////////////////////////////////////////////////////////////////////////////

var xURI='';
var xMENU='NAS';
var xTIMEOUTRAB;
var xREKLAMA=0; // 0 - prikazi reklamu, 1 - ne prikazi
var xNS=(navigator.appName.indexOf("Netscape") != -1);
var xDOC=document;

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

window.defaultStatus='Auto Prikratki';

function S(Msg) {
  if (Msg!='') { Msg='Auto Prikratki: '+Msg }
  window.status=Msg;
  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 (url, tag) { 
  var XMLHttpRequestObject = false; 
  if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  }

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

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

    XMLHttpRequestObject.send(null); 
  }
}


function ajaxCallback (txt,tag) {
  ajaxEvaluate(txt);
  var rAKC=/&*A=(...)/;
  var eAKC=rAKC.exec(xURI);
  if (eAKC) {
    if (eAKC[1]!=xMENU) { 
      Update('MENU-TOP','A='+eAKC[1]);
      Update('MENU-GUMBI','A='+eAKC[1]);
      xMENU=eAKC[1];
    }
  }
  cssdropdown.startchrome("MAINMENU");
  if (xDOC.getElementById(tag)) { xDOC.getElementById(tag).innerHTML=txt; DekodirajURI(); }
  if (myLytebox) { myLytebox.updateLyteboxItems() }
}


function Update(tag,uri) {
  xURI=uri;
  if (tag=='BODY') { scrollTo(0,0) }
  getDataReturnText('?JSRS='+tag+'&'+uri,tag);
}

///////////////////////////////////////////////////////////////////////////////////
//
// podesavanje parametara za ispis velike slike
//
///////////////////////////////////////////////////////////////////////////////////


function SetPixParam(pVSLIKA,pVX,pVY,pXSLIKA) {
  var S=document.getElementById('SLIKA');
  S.src=pVSLIKA;
  S.style.width=pVX;
  S.style.height=pVY;
  document.getElementById('LYTEBOX').href=pXSLIKA;
  myLytebox.updateLyteboxItems();
}


///////////////////////////////////////////////////////////////////////////////////
//
// dekodiranje
//
///////////////////////////////////////////////////////////////////////////////////

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') {
      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;
        }
    }
  }
}

///////////////////////////////////////////////////////////////////////////////////
//
// funkcija za provjeru forme
//
///////////////////////////////////////////////////////////////////////////////////

xL={
NisUpiIme:'Niste upisali ime i prezime',
NisUpiAdr:'Niste upisali adresu',
NisUpiMje:'Niste upisali mjesto',
NisUpiDrz:'Niste upisali drzavu',
NeiEmaAdr:'Niste upisali ispravni E-mail',
NisUpiPor:'Niste upisali tekst poruke'
};

function CheckForm(form) {
    email=/[\w\-\.]+\@[\-\w\.]+\.[\w\-\.]{2,4}/;
    ime=/[\w\.]+.*\s+.*[\w\.]+/;
    prazno=/[\d\w]+/;
    if (!ime.test(form.IME.value)) {
      alert(xL.NisUpiIme+'!');
      return(false);
    }
    else if (!prazno.test(form.ULI.value)) {
      alert(xL.NisUpiAdr+'!');
      return(false);
    }
    else if (!prazno.test(form.MJE.value)) {
      alert(xL.NisUpiMje+'!');
      return(false);
    }
    else if (!email.test(form.EMA.value)) {
      alert(xL.NeiEmaAdr+'!');
      return(false);
    }
    else if (!prazno.test(form.POR.value)) {
      alert(xL.NisUpiPor+'!');
      return(false);
    }
    return(true);
}

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


///////////////////////////////////////////////////////////////////////////////////
//
// 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 || '#AD1722';
  var dark=xDOC.getElementById('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=xDOC.getElementById('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';
  }
}

///////////////////////////////////////////////////////////////////////////////////
//
// prikaz diva s podacima
//
///////////////////////////////////////////////////////////////////////////////////

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

function HideData (ID) {
  var DIV=xDOC.getElementById('DATA'+ID);
  DIV.style.visibility='hidden';
  DIV.style.top=0;
  DIV.style.left=0;
  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;
}


///////////////////////////////////////////////////////////////////////////////////
//
// 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: 0, //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=xDOC.getElementById(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=xDOC.getElementById(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 && !window.XmlHttpRequest){ //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; frameBorder="0" scrolling="no"></IFRAME>')
//this.shimobject=xDOC.getElementById("iframeshim") //reference iframe object
}
}

}


///////////////////////////////////////////////////////////////////////////////////
//
// 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?xDOC.getElementById(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;
}


///////////////////////////////////////////////////////////////////////////////////
//
// prikaz i sakrivanje reklame
//
///////////////////////////////////////////////////////////////////////////////////

function ShowAd() {
  // reklama je jednom prikazana, nemoj vise
  if (xREKLAMA) { return }

  var tAD=xDOC.getElementById('REKLAMA');
  var tXD=tAD.offsetWidth;
  var tYD=tAD.offsetHeight;
  var tY=parseInt((ClientHeight()-tYD)/2);
  if (tY<0) tY=0;
  FloatDiv('REKLAMA',parseInt((ClientWidth()-tXD)/2),tY).floatIt();
  tAD.style.visibility='visible';
  xREKLAMA=1;
}


function HideAd() {
  xDOC.getElementById('REKLAMA').style.visibility='hidden';
}


///////////////////////////////////////////////////////////////////////////////////
//
// Typing Scroller
//
// Submitted by bengaliboy00 @ hotmail.com
//   (hp: http://www.angelfire.com/nt/bengaliboy/)
// With modifications by Dynamicdrive.com
// For full source code, usage terms, and 100s more scripts, 
//   visit http://dynamicdrive.com
//
///////////////////////////////////////////////////////////////////////////////////

var tsLINE=new Array()
// Specify scroller contents
tsLINE[1]='veæ od 299,00 kn po danu!'

var tsLONGESTMSG=1
for (i=2;i<tsLINE.length;i++){
  if (tsLINE[i].length>tsLINE[tsLONGESTMSG].length)
  tsLONGESTMSG=i
}

var tsSCROLLERWIDTH=tsLINE[tsLONGESTMSG].length

var tsLINES=tsLINE.length-1

var tsTEMP='';
var tsNEXTCHAR=-1;
var tsNEXTLINE=1;
var tsCURSOR='\\';
var tsTIMEOUT;

function TypingScroller(pINIT) {
  if (tsTEMP==tsLINE[tsNEXTLINE] & tsTEMP.length==tsLINE[tsNEXTLINE].length & tsNEXTLINE!=tsLINES){
    tsNEXTLINE++;
    tsNEXTCHAR=-1;
    xDOC.getElementById('tsBANNER').value=tsTEMP;
    tsTEMP="";
    if (tsTIMEOUT) { clearTimeout(tsTIMEOUT) }
    tsTIMEOUT=setTimeout("TypingScrollerNextStep()",1000)}
  else if (tsNEXTLINE==tsLINES & tsTEMP==tsLINE[tsNEXTLINE] & tsTEMP.length==tsLINE[tsNEXTLINE].length){
    tsNEXTLINE=1;
    tsNEXTCHAR=-1;
    xDOC.getElementById('tsBANNER').value=tsTEMP;
    tsTEMP='';
    if (tsTIMEOUT) { clearTimeout(tsTIMEOUT) }
    tsTIMEOUT=setTimeout("TypingScrollerNextStep()",1000)}
  else{
    TypingScrollerNextStep()}
  }


function TypingScrollerNextStep() {
  if (tsCURSOR=="\\")     { tsCURSOR="|" }
  else if (tsCURSOR=="|") { tsCURSOR="/" }
  else if (tsCURSOR=="/") { tsCURSOR="-" }
  else if (tsCURSOR=="-") { tsCURSOR="\\"}
  tsNEXTCHAR++;
  tsTEMP+=tsLINE[tsNEXTLINE].charAt(tsNEXTCHAR);
  xDOC.getElementById('tsBANNER').value=tsTEMP+tsCURSOR
  if (tsTIMEOUT) { clearTimeout(tsTIMEOUT) }
  tsTIMEOUT=setTimeout("TypingScroller()",60)
}


