var timeout_id;

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
    jQuery("<img>").attr("src", "assets/templates/lmk/images/" + arguments[i]);
}

jQuery(document).ready(function(){

  if (jQuery("div.user_logged span").html() != '') {
     jQuery("#sidebarloginplace").css("display", "none");
     jQuery("div.user_logged a").html("Выход");
     jQuery("div.user_logged a").attr("href", jQuery("div.user_logged a").attr("href")+"?webloginmode=lo");
  } else {
     jQuery("div.user_logged span").html("Гость");
     jQuery("div.user_logged a").html("Вход &raquo;");
     jQuery("div.user_logged a").attr("href", jQuery("div.user_logged a").attr("href")+"index.php?id=4");
  }

  jQuery.preloadImages("btn_search.gif", "btn_sitemap.gif", "btn_contacts.gif", "btn_email.gif", "btn_forum.gif", "search_bg.jpg", "logo_highlight.gif");
  
  jQuery("#a_main").bind("mouseover", function(e) {
     jQuery("div.page_logo_highlight img").attr("src", "assets/templates/lmk/images/logo_highlight.gif");
  });

  jQuery("#a_main").bind("mouseout", function(e) {
     jQuery("div.page_logo_highlight img").attr("src", "assets/templates/lmk/images/empty.gif");
  });

  jQuery("#a_english").bind("mouseover", function(e) {
     jQuery("div.page_english").css("background", "transparent");
  });

  jQuery("#a_english").bind("mouseout", function(e) {
     jQuery("div.page_english").css("background", "#ffffff");
  });

  jQuery("#a_deutch").bind("mouseover", function(e) {
     jQuery("div.page_deutch").css("background", "transparent");
  });

  jQuery("#a_deutch").bind("mouseout", function(e) {
     jQuery("div.page_deutch").css("background", "#ffffff");
  });

  jQuery("#a_search, #a_sitemap, #a_contacts, #a_email, #a_forum").bind("mouseover", function(e) {
     var s;
     window.clearTimeout(timeout_id);
     s = jQuery(this).attr("id");
     s = s.substring(1,s.length);
     jQuery("div.page_btn"+s+" img").attr("src", "assets/templates/lmk/images/btn"+s+".gif");
     s = jQuery(this).attr("title");
     jQuery("div.page_address").html(s);
  });

  jQuery("#a_search, #a_sitemap, #a_contacts, #a_email, #a_forum").bind("mouseout", function(e) {
     jQuery("div.page_btn_sitemap img, div.page_btn_contacts img, div.page_btn_email img, div.page_btn_forum img").attr("src", "assets/templates/lmk/images/empty.gif");
     if (jQuery("div.search_place").css("display") == "none")
       jQuery("div.page_btn_search img").attr("src", "assets/templates/lmk/images/empty.gif");
     timeout_id = window.setTimeout('clear_info()',300);
  });

  jQuery("#ajaxSearch_submit").bind("mouseover", function(e) {
     var s = $('ajaxSearch_submit'); //mootools code - works in IE!
     s.setStyle('opacity', '1');     //
  });

  jQuery("#ajaxSearch_submit").bind("mouseout", function(e) {
     var s = $('ajaxSearch_submit'); //mootools code - works in IE!
     s.setStyle('opacity', '0.01');  //
  });

  jQuery("#a_search").bind("click", function() {
     if (jQuery("div.search_place").css("display") == "none")
       jQuery('div.search_place').animate({height: 'show'}, 200);
     else
       jQuery('div.search_place').animate({height: 'hide'}, 200);
     return false;
  });

  jQuery("#bottom_blocks").load(jQuery("#bottom_blocks").attr("title"), {} ,function() {
     jQuery("div.page_banners_bottom a img").bind("mouseover", function(e) {
        jQuery(this).css("border", "solid 1px #ECC2C5");
     });

     jQuery("div.page_banners_bottom a img").bind("mouseout", function(e) {
        jQuery(this).css("border", "solid 1px #e5e5ef");
     });
     jQuery("#bottom_blocks").removeAttr("title");
  });
  
});
