/////////////////////////////////////////////////////////////////////////////////
//
// Pro-Mil
//
// (c)2006-2009 by Abacus, info (ath] abacus (doth] hr
//
// v1.02 4.10.2009. TCrnicki
//
/////////////////////////////////////////////////////////////////////////////////

var xDOC=document;
var xNS=(navigator.appName.indexOf("Netscape") != -1);

var xSHOWINFO=0; // 0 - prikazi reklamu, 1 - ne prikazi

///////////////////////////////////////////////////////////////////////////////////
//
// AJAX
//
///////////////////////////////////////////////////////////////////////////////////

function ajaxGetDataReturnText (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) {
  if (tag) { document.getElementById(tag).innerHTML=txt }
}


function Anketa(tag,uri) {
  ajaxGetDataReturnText('?JSRS='+tag+'&'+uri,tag);
}


///////////////////////////////////////////////////////////////////////////////////
//
// prikaz i sakrivanje info prozora
//
///////////////////////////////////////////////////////////////////////////////////

function ShowInfo(pNAME) {
  
  if (xSHOWINFO && pNAME=='INFO') { return }

  var tINFO=xDOC.getElementById(pNAME);
  if (!tINFO) { return }
  
  var tXD=tINFO.offsetWidth;
  var tYD=tINFO.offsetHeight;
  var tY=parseInt((ClientHeight()-tYD)/2);
  if (tY<0) tY=0;
  FloatDiv(pNAME,parseInt((ClientWidth()-tXD)/2),tY).floatIt();
  tINFO.style.visibility='visible';
  xSHOWINFO=1;
}


function HideInfo(pNAME) {
  xDOC.getElementById(pNAME).style.visibility='hidden';
}

///////////////////////////////////////////////////////////////////////////////////
//
// 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;
}

///////////////////////////////////////////////////////////////////////////////////
//
// 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;
}
