/* [mjh] preload images: */

arrowImage          = new Image( 21, 11 );

arrowImageHover     = new Image( 21, 11 );

arrowImage.src      = s_WEBROOT + '/images/dot.gif';

arrowImageHover.src = s_WEBROOT + '/images/nav_icn_on.gif';



function menuItemHover( e )

{

  /* the e variable is present in Mozilla, it contains the current event */

  xEvent = ( e ) ? e : window.event;

  xObj = ( e ) ? xEvent.target : xEvent.srcElement;



  if( xObj.className != 'menuitem' 

      && xObj.className != 'menuitemHover' 

      && xObj.className != 'submenuitem' 

      && xObj.className != 'submenuitemHover'

      && xObj.className != 'subsubmenuitem' 

      && xObj.className != 'subsubmenuitemHover' )

    return;



  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */



  if( xObj.tagName.toUpperCase() == 'A' )

    xObj = xObj.parentNode;



  if( xObj.parentNode.childNodes.length > 2 )

  {

    /* Mozilla: */

    xLeftCol  = xObj.parentNode.childNodes[1];

    xRightCol = xObj.parentNode.childNodes[3];

  }

  else

  {

    /* IE */

    xLeftCol  = xObj.parentNode.childNodes[0];

    xRightCol = xObj.parentNode.childNodes[1];

  }



  if( xObj.className == 'menuitem' || xObj.className == 'menuitemHover'  )

  {

    xLeftCol.style.backgroundColor  = ( xEvent.type == "mouseover" ) ? "#F3F3F3" : "#FFFFFF";

    xRightCol.style.backgroundColor = ( xEvent.type == "mouseover" ) ? "#F3F3F3" : "#FFFFFF";

  }

  else if( xObj.className == 'submenuitem' || xObj.className == 'submenuitemHover'  )

  {

    xLeftCol.style.backgroundColor  = ( xEvent.type == "mouseover" ) ? "#FFD62D" : "#FFE487";

    xRightCol.style.backgroundColor = ( xEvent.type == "mouseover" ) ? "#FFD62D" : "#FFE487";

  }

  else

  {

    xLeftCol.style.backgroundColor  = ( xEvent.type == "mouseover" ) ? "#EFEFEF" : "#ffffff";

    xRightCol.style.backgroundColor = ( xEvent.type == "mouseover" ) ? "#EFEFEF" : "#ffffff";

  }

  xRightCol.childNodes[0].src     = ( xEvent.type == "mouseover" ) ? arrowImageHover.src : arrowImage.src;



  return true;

}



function menuToggle( sObjID )

{

  var xObj            = document.getElementById( sObjID );

  var bExpand         = xObj.style.display == 'none' ? true: false;

  var xCookie         = getCookie( 'MENUCOLLAPSED' );

  var sAction         = '';

  xObj.style.display  = bExpand ? 'inline' : 'none';



  lTmpList = '';



  if( xCookie )

  {

    /* cookie exists, edit it... */

    if( bExpand )

    {

      /* remove entry from list */

      for( i=0; i<listLen( xCookie, '_' ); i++ )

        if( listGetAt( xCookie, i, '_' ) != sObjID )

          lTmpList = listAppend( lTmpList, listGetAt( xCookie, i, '_' ), '_' );

    }

    else

    {

      /* add entry to list */

      lTmpList = listAppend( xCookie, sObjID, '_'  );

    }

  }

  else

  {

    /* cookie not found, create it... */

    if( !bExpand )

    {

      /* add entry to list */

      lTmpList = sObjID;

    }

  }



  /*            +~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+ */

  /*            | name            | value           | expires         | path            | domain          | secure          | */

  /*            +~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~+ */

  deleteCookie(  'MENUCOLLAPSED',                                       '/',             'www.uzicecityoglasi.com'                       );

     setCookie(  'MENUCOLLAPSED',   lTmpList,         null,             '/',             'www.uzicecityoglasi.com',    false             );



  // initDebugger( sAction );

}



document.onmouseover = document.onmouseout = menuItemHover;



function initDebugger( sMessage )

{

  xDebuggerContent = document.getElementById( 'debugger' );

  xDebuggerContent.innerHTML = '';



  for( i=0; i<listLen( document.cookie, ';' ); i++ )

    xDebuggerContent.innerHTML = xDebuggerContent.innerHTML + ( listGetAt( listGetAt( document.cookie, i, ';' ), 0, '=' ) + ' = ' + listGetAt( listGetAt( document.cookie, i, ';' ), 1, '=' ) + '<br />' );

}


