var MSIE=false, NN5=false, NN6=false;
var dAll=null;
var vidljiv=null,nevidljiv=null;

var procesi=new Array(3);


if (document.all) {
	MSIE=true; NN5=false; NN6=false;
	dAll=document.all;
	vidljiv='visible';
	nevidljiv='hidden';
	}
 else
 if (document.layers) {
	 MSIE=false; NN5=true; NN6=false;
	 dAll=document.layers;
 	vidljiv='show';
	nevidljiv='hide';
	 }
  else if (document.getElementById && !document.all)
  {
	 MSIE=false; NN5=false; NN6=true; 
	 dAll=null;
 	vidljiv='visible';
	nevidljiv='hidden';
  }

   // standardizacija starijih MSIE verzija
  if (!document.getElementById && document.all) {
	document.getElementById = new Function('id', 'return document.all[id]')
	}

// microsoft diktira standarde pa moram izmisljati toplu vodu... 
function prikaciEvent(objekt, dogadjaj, funkcija)
{
if (MSIE)
{
objekt.attachEvent(dogadjaj,funkcija);
}
else
{
 objekt.addEventListener(dogadjaj, funkcija, false);
}
}

function PrikaziEmailAdresu(Server, Login, Prikaz, Subjekt)
{
	if (Subjekt && Subjekt.length>0)
     Subjekt="?Subject="+Subjekt;
	else Subjekt="";
	
	if ((Prikaz.length == 0) || (Prikaz.indexOf('@')+1)) {
	document.write("<A HREF=" + "'mai" + "lto:" + Login + "@" + Server + ""+Subjekt+"'>" + Login + "@" + Server + "</A>"); }
	else  {
	document.write("<A HREF=" + "'mai" + "lto:" + Login + "@" + Server + ""+Subjekt+"'>" + Prikaz + "</A>"); }
}


// fja prolazi kroz sve png slike i ugradjuje im transparentnost ako je browser MSIE
function correctPNG() 
   {
   if (MSIE)
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 var imgAttribs = img.attributes;
		 for (var j=0; j<imgAttribs.length; j++)
			{
			var imgAttrib = imgAttribs[j];
			if (imgAttrib.nodeName == "align")
			   {		  
			   if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
			   if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
			   break
			   }
            }
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 strNewHTML += "(src=\'" + img.src + "\', sizingMethod='none');\"></span>" 
		 img.outerHTML = strNewHTML
	
		 i = i-1
	     }
      }
   }

var iVoz=0;

function vozajSliku(slika, koordinate,procesID)
{
var i=0, intID=0;

var tTop,tLeft;
var st,sl;

cTop=koordinate[iVoz];
cLeft=koordinate[iVoz+1];

var oSlika=getObject(slika);

var skok=0;

tTop=getTop(oSlika);
tLeft=getLeft(oSlika);

st=(tTop.substring(0,tTop.length-2));
sl=(tLeft.substring(0,tLeft.length-2));


tTop=Math.floor(st);
tLeft=Math.floor(sl);


if (tTop==cTop && tLeft==cLeft ) 
	{
	iVoz+=2;
	if (iVoz>=koordinate.length)
	{
    iVoz=0;
	srusiProces(procesID);
	}
	
	return;
	}
   
	 skok=Math.abs(tLeft-cLeft)/8;

	 skok=Math.floor(skok);

	 if (skok==0) skok=1;

	if (tLeft<cLeft)
		tLeft+=skok;
	else 
	 if (tLeft>cLeft)
	  tLeft-=skok;

	 skok=Math.abs(tTop-cTop)/8;

	 skok=Math.floor(skok);

	 if (skok==0) skok=1;
		
	if (tTop<cTop)
	 tTop+=skok;
      else
	  if (tTop>cTop)
		tTop-=skok;
	

	tTop=Math.floor(tTop);
	tLeft=Math.floor(tLeft);

    moveLayerOTo(oSlika,tLeft, tTop);

}//vozajSliku


function srusiProces(id)
{
clearInterval(procesi[id]);
procesi[id]=-1;
}

function pomakniSliku(slika, cTop, cLeft, procesID)
{
var tTop,tLeft;
var st,sl;

var oSlika=getObject(slika);

var skok=0;

tTop=getTop(oSlika);
tLeft=getLeft(oSlika);

st=(tTop.substring(0,tTop.length-2));
sl=(tLeft.substring(0,tLeft.length-2));


tTop=Math.floor(st);
tLeft=Math.floor(sl);


if (tTop==cTop && tLeft==cLeft ) 
	{	
	srusiProces(procesID);
	return;
	}
   
	 skok=Math.abs(tLeft-cLeft)/8;

	 skok=Math.floor(skok);

	 if (skok==0) skok=1;

	if (tLeft<cLeft)
		tLeft+=skok;
	else 
	 if (tLeft>cLeft)
	  tLeft-=skok;

	 skok=Math.abs(tTop-cTop)/8;

	 skok=Math.floor(skok);

	 if (skok==0) skok=1;
		
	if (tTop<cTop)
	 tTop+=skok;
      else
	  if (tTop>cTop)
		tTop-=skok;
	

	tTop=Math.floor(tTop);
	tLeft=Math.floor(tLeft);

    moveLayerOTo(oSlika,tLeft, tTop);
 


}//pomakniSliku



function fillLayerWithText(layerID, text)
{
if (MSIE)
{dAll[layerID].innerText=text;}
else if (NN5)
{dAll[layerID].write(text); dAll[layerID].close();}
else if (NN6)
{document.getElementById(layerID).write(text); 
document.getElementById(layerID).close();}
}//fja


/* moves layer 'layerID' to xpos, ypos */
function moveLayerTo(layerID, xpos, ypos) {
if(MSIE) {
    dAll[layerID].style.left = xpos;
    dAll[layerID].style.top = ypos;
  }
  else if (NN6)
  {
    myObj = document.getElementById(layerID);
    myObj.style.top = yPos +"px";
    myObj.style.left = xPos + "px";
  }
  else if (document.getElementById)
  {
    myObj = document.getElementById(layerID);
    myObj.style.top = yPos +"px";
    myObj.style.left = xPos + "px";
  }
  else if(NN5) 
   { dAll[layerID].moveTo(xpos, ypos);} 


}//mlt

function moveLayerOTo(layerID, xpos, ypos) {
if(MSIE || NN6) {
    layerID.style.left = xpos+"px";
    layerID.style.top = ypos+"px";
  }
  else if(NN5) 
   { layerID.moveTo(xpos, ypos);} 
}

function showLayer(layerID)
{
	 if(MSIE) {dAll[layerID].style.visibility=vidljiv;}
  else if(NN5) {dAll[layerID].visibility=vidljiv; } 
  else if(NN6) { document.getElementById(layerID).style.visibility=vidljiv; } 
}

function hideLayer(layerID)
{
 if(MSIE) {dAll[layerID].style.visibility=nevidljiv;}
  else if(NN5) {dAll[layerID].visibility=nevidljiv; } 
  else if(NN6) { document.getElementById(layerID).style.visibility=nevidljiv; } 
}

// fje koje primaju konkretan objekt kao parametar
function showLayerO(layerID)
{
     if(MSIE && layerID) {
		 layerID.style.visibility=vidljiv;}
  else if(NN5) {layerID.visibility=vidljiv; } 
  else if(NN6 && layerID) { layerID.style.visibility=vidljiv; } 
}

function hideLayerO(layerID)
{
	 if(MSIE) {layerID.style.visibility=nevidljiv;}
  else if(NN5) 
	  {layerID.visibility=nevidljiv; } 
    else if(NN6) { layerID.style.visibility=nevidljiv; } 
}

function setCursorO(layerID, cursor)
{
if(MSIE && layerID)	{layerID.style.cursor=cursor;}
else if(NN5) {layerID.cursor=cursor; } 
 else if(NN6 && layerID) { layerID.style.cursor=cursor; } 
}

function setCursor(layerID, cursor)
{
if(MSIE )	{document.all(layerID).style.cursor=cursor;}
else if(NN5) {layerID.cursor=cursor; } 
 else if(NN6) { document.getElementById(layerID).style.cursor=cursor; } 
}

function getObject(objID)
{
if(MSIE )	{return document.all(objID);}
else if(NN5) {return objID; } 
 else if(NN6) { return document.getElementById(objID); } 
  else
	  if (document.getElementById)
	  return document.getElementById(objID);
      else return null;
}


function getLeft(layID)
{
if(MSIE)	{return layID.style.left;}
else if(NN5) {return layID.left; } 
  else if(NN6) {return layID.style.left; } 
}

function getTop(layID)
{
if(MSIE)	{return layID.style.top;}
else if(NN5) {return layID.top; } 
  else if(NN6) {return layID.style.top; } 
}

function showPicInFrame(ulaz)
{
w=window.open("","slika","height=200,width=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");

wd=w.document;
 
wd.write("<html>");
wd.write("<head><title>Issa Apartmani</title><script language='JavaScript'>");
wd.write("function povecaj()");
wd.write("{var sl=document.getElementById('slika'); if (sl.complete) self.resizeTo(sl.width+15,sl.height+63); else setTimeout('povecaj()',50);}");
wd.write("function pripremi()");
wd.write("{setTimeout('povecaj()',5); }");
wd.write("<"+"/"+"script><"+"/"+"head>");
wd.write("<body bgcolor='#17679A' leftmargin='0' topmargin='0' align='center' valign='middle' scroll='no'>");
wd.write("<table marginwidth='0' marginheight='0'><tr><td align='center'>");
wd.write("<a align='center' href='#' style='color:white;text-decoration:none' onclick='self.close()'>Zatvori - Close</a>");
wd.write("<tr><td><img id='slika' src='"+ulaz+"'>");
wd.write("</table>");
wd.write("<script language='JavaScript'>pripremi();<"+"/"+"script>");
wd.write("</body></html>");
wd.close();

w.focus();
}

function openFrame(ulaz, visina)
{
w=window.open(ulaz,"prozor","height="+visina+",width=790,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");

w.focus();
}
