$(document).ready(function(){
  var clicked = false;
  
  
  /*----------HEADER MENU START----------*/
  $("#header_menu li").hover(
    function(){$('ul', this).slideDown();},
    function(){$('ul', this).slideUp();}
  );
  /*----------HEADER MENU END----------*/
  
  
  /*----------LOGO, ICONS HOVER START----------*/
  $("#logo").hover(
    function(){$("#logo span").css({backgroundPosition: "0 -90px"});},
    function(){$("#logo span").css({backgroundPosition: "0 0"});}
  );
  
  $("#home_link").hover(
    function(){$(this).css({backgroundPosition: "0 -20px"});},
    function(){$(this).css({backgroundPosition: "0 0"});}
  ); 
  
  $("#offer_link").hover(
    function(){$(this).css({backgroundPosition: "0 -19px"});},
    function(){$(this).css({backgroundPosition: "0 0"});}
  );  
  
  $("#sitemap_link").hover(
    function(){$(this).css({backgroundPosition: "0 -18px"});},
    function(){$(this).css({backgroundPosition: "0 0"});}
  );  
  
  $("#search_link").hover(
    function(){$(this).css({backgroundPosition: "0 -21px"});},
    function(){$(this).css({backgroundPosition: "0 0"});}
  );    
  
  $(".footer_small_links img").hover(
    function(){
      imgsrc = $(this).attr("src");
      new_imgsrc = imgsrc.replace(/(\.[a-z 0-9]+)$/i, "_hover$1");
      old_imgsrc = imgsrc.replace(/_over(\.[a-z 0-9]+)$/i, "$1");
        
      $(this).attr("src" , new_imgsrc);
    },
    
    function(){$(this).attr("src" , old_imgsrc);}
  );       
  /*----------LOGO, ICONS HOVER END----------*/
  
  
  /*----------SEARCH BOX START----------*/
  $("#search_link").click(function(){
    if (clicked == false) {
      $(".search_box, .search_box div").fadeIn();
      
      clicked = true;  
    }
    
    else {
      $(".search_box div").fadeOut();
      
      clicked = false;  
    }
  });
  /*----------SEARCH BOX END----------*/
  
  
  /*----------OFFER POPUP START----------*/
  $(".offer_box a").click(function(){$(".offer_popup").fadeIn();});
  
  $(".offer_popup .close").click(function(){$(".offer_popup").fadeOut();});
  /*----------OFFER POPUP END----------*/
  
  
  /*----------COMMENT POPUP START----------*/
  $(".comments_bottom a").click(function(){$(".comment_popup").fadeIn();});
  
  $(".comment_popup .close").click(function(){$(".comment_popup").fadeOut();});  
  /*----------COMMENT POPUP END----------*/
});
