function initKLayers()
{
  isDOM=(document.getElementById)?true:false
  isOpera=(window.opera)?true:false
  isOpera5=isOpera && isDOM
  isOpera6=(isOpera5 && window.print)?true:false
  isMSIE=isIE=(document.all && document.all.item && !isOpera)
  isNC=navigator.appName=="Netscape"
  isNC4=isNC && !isDOM
  isNC6=isMozilla=isNC && isDOM

  if(!isDOM && !isNC && !isMSIE && !isOpera5)
  {
    KLayers=false
    return false
  }

  pageLeft=0
  pageTop=0

  KL_imagePreloaderCount=0
  KL_imagePreloaderArray=new Array()

  KL_imageRef="document.images[\""
  KL_imagePostfix="\"]"
  KL_styleSwitch=".style"
  KL_layerPostfix="\"]"

  if(isNC4){
    KL_layerRef="document.layers[\""
    KL_styleSwitch=""
  }

  if(isMSIE){
    KL_layerRef="document.all[\""
  }

  if(isDOM){
    KL_layerRef="document.getElementById(\""
    KL_layerPostfix="\")"
  }

  KLayers=true
  return true
}

initKLayers();

function getWindowWidth(w)
{
  if(!w) w=self
  if(isMSIE) return w.document.body.clientWidth
  if(isNC || isOpera) return w.innerWidth
}

function setLeft(div,x)
{
  x+=pageLeft
  if(isOpera){
    div.style.pixelLeft=x
  }else if(isNC4){
  	div.object.x=x
  }else{
    div.style.left=x
  }
}

function setTop(div,y)
{
  y+=pageTop
  if(isOpera)
  {
    div.style.pixelTop=y-window.pageYOffset;
  }else if(isNC4){
  	div.object.y=y
  }else{
    div.style.top=y
  }

}

var mousex = 0
var mousey = 0
if(isNC4) document.captureEvents(Event.MOUSEMOVE)
if(isMSIE){
  document.onmousemove=function(){
    mousex=event.clientX+document.body.scrollLeft
    mousey=event.clientY+document.body.scrollTop
    return true
  }
}else if(isOpera){
  document.onmousemove=function(){
    mousex=event.clientX
    mousey=event.clientY
    return true
  }
}else if(isNC){
  document.onmousemove=function(e){
    mousex = e.pageX
    mousey = e.pageY
    return true
  }
}

var receiveReq = getXmlHttpRequestObject();

function makeRequest(url, param,typ)
{
 if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
   receiveReq.open("GET", url, true);
   if(typ="p")
	   receiveReq.onreadystatechange = updatePage_p;
   if(typ="m")
	   receiveReq.onreadystatechange = updatePage_m;
   receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   receiveReq.setRequestHeader("Content-length", param.length);
   receiveReq.setRequestHeader("Connection", "close");
   receiveReq.send(param);
 }
}
function getXmlHttpRequestObject() {
 if (window.XMLHttpRequest) {
    return new XMLHttpRequest(); //Mozilla, Safari ...
 } else if (window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP"); //IE
 } else {
    alert("Your browser doesn't support the XmlHttpRequest object.");
 }
}
function updatePage_p()
{
 if (receiveReq.readyState == 4)
 {
   document.body.style.cursor='auto';
   var w=300;
   var d=document.getElementById('molitva')
   var ww=getWindowWidth();
   d.innerHTML = receiveReq.responseText+"<div class='X' id='x_btn' onclick='closeM()'><a href='javascript:closeM()' style='text-decoration:none'>X</a></div>";
   var s =new String(d.innerHTML);
   var scroll_comp=0;
   var closex_pos=300-15;
   if(s.length>1000)
    {
       if(s.length>5000)
       {
   			d.style.height=500;
   			d.style.width=400;
            closex_pos=400-15;
       }
	   else
       {
   			d.style.height=300;
   			d.style.width=300;
       }
        d.style.overflow="scroll";
        scroll_comp=15;
	}
    else
    {
   		d.style.height="auto";
        d.style.width=300;
        d.style.overflow="auto";
	}
   var pl=mx-150;
   if(pl<10)
   	pl=10;
   if(pl+w>ww)
   		pl=ww-300;
   var t=my+10;
   setTop(d,t);
   setLeft(d,pl);
   d.style.display="block";
    var x=document.getElementById('x_btn');
    if(isMozilla || isOpera6)
    	comp=19;
    else
    	comp=-2;
    setLeft(x,closex_pos+comp-scroll_comp);
	setTop(x,0);
	x.style.display="block";
 }
}
function updatePage_m()
{
 if (receiveReq.readyState == 4)
 {
   document.body.style.cursor='auto';
   var w=304;
   var d=document.getElementById('molitva')
   var ww=getWindowWidth();
   d.innerHTML = receiveReq.responseText+"<div class='X' id='x_btn' onclick='closeM()'><a href='javascript:closeM()' style='text-decoration:none'>X</a></div>";
   var s =new String(d.innerHTML);
   var scroll_comp=0;
   var closex_pos=300-15;
   if(s.length>1000)
    {
       if(s.length>5000)
       {
   			d.style.height=500;
   			d.style.width=400;
            closex_pos=400-15;
       }
	   else
       {
   			d.style.height=300;
   			d.style.width=300;
       }
        d.style.overflow="scroll";
        scroll_comp=15;
	}
    else
    {
   		d.style.height="auto";
        d.style.width=300;
        d.style.overflow="auto";
	}
   var pl=mx-150;
   if(pl<10)
   	pl=10;
   if(pl+w>ww)
   		pl=ww-300;
   var t=my+10;
   setTop(d,t);
   setLeft(d,pl);
   d.style.display="block";
    var x=document.getElementById('x_btn');
    if(isMozilla || isOpera6)
    	comp=19;
    else
    	comp=-2;
    setLeft(x,closex_pos+comp-scroll_comp);
	setTop(x,0);
	x.style.display="block";
 }
}
//////////////
function closeM()
{
   var d=document.getElementById('molitva')
   d.style.display="none";
   var x=document.getElementById('x_btn');
    x.style.display="none";
}
var mx=0;
var my=0;
function p(id)
{
   document.body.style.cursor='wait';
   var url = '/catch/p_'+id+".htm";
   var postStr = "";
   mx=mousex;
   my=mousey;
   makeRequest(url, postStr,"p");
}
function m(id)
{
   document.body.style.cursor='wait';
   var url = '/catch/m_'+id+".htm";;
   var postStr = "";
   mx=mousex;
   my=mousey;
   makeRequest(url, postStr,"m");
}





var boxname='YWBOX';
var main_class='yptrans';


//////////////////////////
function ShowYW(txt,wopt,hopt,nomove)
{
   mx=mousex+150;
   my=mousey;


   document.body.style.cursor='auto';

   var w=304;


   var d=document.getElementById(boxname);
   if(d==null)
   {
	   addCSS(yp_css);
	   addCSS(onsite_css);

       makeYWBox();
	   var d=document.getElementById(boxname);


   }

  d.className=main_class;
   var ww=getWindowWidth();
   d.innerHTML ="<div  id='YW_WAIT' ></div>"+ txt+"<div class='X' id='x_btn' onclick='closeYP()'><a href='javascript:closeYP()' style='text-decoration:none'>X</a></div>";
   var s =new String(d.innerHTML);
   var scroll_comp=0;
   var closex_pos=300-15;
   if(s.length>1000)
    {
       if(s.length>5000)
       {
   			d.style.height=500;
   			d.style.width=400;
            closex_pos=400-15;
       }
	   else
       {
   			d.style.height=330;
   			d.style.width=300;
       }
        d.style.overflow="scroll";
        scroll_comp=15;
	}
    else
    {
   		d.style.height="auto";
        d.style.width=300;
        d.style.overflow="auto";
	}
   if(hopt!=undefined)
        d.style.height=hopt;
   if(wopt!=undefined)
   {
        d.style.width=wopt;
        closex_pos=wopt-15;
        w=wopt;
   }

   var pl=mx-150;
   if(pl<10)
   	pl=10;
   if(pl+w>ww)
   {
   		pl=ww-w;
	}
    //alert(pl+'w' +w+' ww'+ ww);
   var t=my+10;
   if(nomove!=true)
   {
	   setTop(d,t);
	   setLeft(d,pl);
   }
   d.style.display="block";
    var x=document.getElementById('x_btn');
    if(isMozilla || isOpera6)
    	comp=19;
    else
    	comp=-2;
    setLeft(x,closex_pos+comp-scroll_comp);
	setTop(x,0);
	x.style.display="block";
}
////////////////////////
function makeYWBox()
{

	var oDiv = document.createElement('DIV');
	oDiv.className = main_class;
	oDiv.id=boxname;
	document.body.appendChild(oDiv);

}
/////////////
function addCSS(filename)
{
    link = document.createElement('LINK');
    link.href=filename;
    link.type='text/css';
    link.rel='stylesheet';
    document.appendChild(link);
}
//////////////
function closeYP()
{
   var d=document.getElementById(boxname)
   d.style.display="none";
   var x=document.getElementById('x_btn');
    x.style.display="none";
}
