function getobj(mtxt)
{
  if(document.getElementById)
    m = document.getElementById(mtxt);
  else if(document.all)
    m = document.all[mtxt];
  else if(document.layers)
    m = document.layers[mtxt];
  else
    alert("problem with finding object by id");
  return m;
}

function findMenuPos(el, txt)
{
  if( !this.dom && document.layers )
    {   /*Netscape 4*/
      x = document.layers[txt].pageX;
      y = document.layers[txt].pageY;
    }
  else
    {   /*other browsers*/
      x=0; y=0;
      var temp;
      if(el && el.offsetParent)
	{
	  temp = el;
	  while(temp.offsetParent)
	    { /*Looping parent elements to get the offset of them as well*/
	      temp=temp.offsetParent;
	      x+=temp.offsetLeft;
	      y+=temp.offsetTop;
	    }
	}
      x+=el.offsetLeft;
      y+=el.offsetTop;
    }
  return [x,y];
}

var dbg = "";

var __menu_sub;
var __menu_tmout;
function menuMouseIn(obj, txt, $bgcolor, pom)
{
  dbg += "menuMouseIn;";
  clearTimeout(__menu_tmout);
  if( __menu_sub ) __menu_sub.style.visibility = 'hidden';
  obj.style.backgroundColor = $bgcolor;
	if (pom == 1) 
  	{
   	obj.style.color = '#f5d89e'; //kajsija
  	}
	
	if (pom == 3) 
  	{
   	obj.style.backgroundImage = "url(images/pom.gif)";
  	}
  	if (pom==5)
    {
   	obj.style.backgroundColor = '#F7D89F';
   	obj.style.color = '#1E485E'; /*boja separatora kad se mis skloni */
    }
	if (pom==2)
	{
	  	obj.style.backgroundImage = "url(images/kanika_lmenu_shadow.gif)"; //slika sjenke preko oznacenog reda menija
	}
  		
  obj.style.cursor = 'pointer';
  
  window.status = txt;
  
}

function menuMouseOut(obj, $bgcolor, pom)
{
  dbg += "menuMouseOut;";
  obj.style.backgroundColor = $bgcolor;
  
  if (pom==2)
   {
  	obj.style.backgroundImage = "url(images/kanika_bcgr1.gif)";
  	}
  if (pom==3)
  {
   obj.style.backgroundImage = "url()";
    obj.style.color = '#f5d89e';
   }
  if (pom==1)
  {
   obj.style.backgroundColor = $bgcolor;
   obj.style.color = '#f5d89e'; /*boja separatora kad se mis skloni */
   }
	if (pom==5)
  {
   obj.style.backgroundColor = '#1E485E';
   obj.style.color = '#F7D89F'; /*boja separatora kad se mis skloni */
   }
	if (pom==4)
  {
   obj.style.backgroundColor = '#1e485e';
   obj.style.color = '#f5d89e'; /*boja separatora kad se mis skloni */
   }
  obj.style.cursor = 'normal';
  
  window.status = '';
}

function menuSubOpen(obj, id, pom, $bgcolor)
{ 
  dbg += "menuSubOpen;";
  clearTimeout(__menu_tmout);
  if( __menu_sub ) __menu_sub.style.visibility = 'hidden';
  menuMouseIn(obj, '', $bgcolor,pom);
  sub = getobj(id);
  if( pom==4 )
    {
      pos = findMenuPos(obj);
      pos[1] += 20;
    }
  else
    pos = [obj.offsetWidth-3, obj.offsetTop+2];
  sub.style.left = pos[0] + 'px';
  sub.style.top = pos[1] + 'px';
  sub.style.visibility = 'visible';
}

function menuSubClose(obj, id, pom, $bgcolor)
{
  dbg += "menuSubClose;";
  menuMouseOut(obj,$bgcolor,pom);
  if(pom==4)
    {
      __menu_sub = getobj(id);
      __menu_tmout = setTimeout("__menu_sub.style.visibility = 'hidden'", 500);
    }
  else
    {
      var sub = getobj(id);
      sub.style.visibility = 'hidden';
    }
}


