var isMenuEnter = false;

function showMenu( id )
{
//  alert(id);
  logString( "show " + id );
  document.getElementById('menu_'+id).style.display = "inline";
}

function hideMenu( id )
{
//  alert("!!");
  logString( "hiding " + id );
  if( isMenuEnter ) return;
  logString( "hided " + id );
  document.getElementById('menu_'+id).style.display = "none";
}

function onMenuEnter( id )
{
//alert(1);
  logString( "on enter " + id );
  isMenuEnter = true;
}

function onMenuLeave( id )
{
//alert(1);
  logString( "on leave " + id );
  isMenuEnter = false;
  hideMenu(id);
}

function logString( what )
{
//  document.getElementById("log").innerHTML += what + "<br>";
}

function openProductImage( id )
{
  window.open( "index.php?mode=simple&submode=product_image&product_id=" + id, "_blank", "toolbar=no, resizable=yes, width=1020, height=620" );
}

function openNewsImage( id )
{
  window.open( "index.php?mode=simple&submode=news_image&news_id=" + id, "_blank", "toolbar=no, resizable=yes" );
}

function onSearchFocus()
{
  if( document.getElementById("search_input").value == "поиск по сайту" )
    document.getElementById("search_input").value = "";
}

function onSearchFocusLost()
{
  if( document.getElementById("search_input").value == "" )
    document.getElementById("search_input").value = "поиск по сайту";
}

function doSearch()
{
  if( document.getElementById("search_input").value == "" ) return;

  document.getElementById("search_form").submit();
}

function addBookmark(url, title)
{
  if (!url) url = location.href;
  if (!title) title = document.title;

  //Gecko
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel
(title, url, "");
  //IE4+
  else if (typeof window.external == "object") window.external.AddFavorite(url, title);
  //Opera7+
  else if (window.opera && document.createElement)
  {
    var a = document.createElement('A');
    if (!a) return false; //IF Opera 6
    a.setAttribute('rel','sidebar');
    a.setAttribute('href',url);
    a.setAttribute('title',title);
    a.click();
  }
  else return false;

  return true;
}

function setHomepage()
{
  this.style.behavior='url(#default#homepage)';
  this.setHomePage('http://www.mobikom.biz/');
}
