$(function(){
	$('#nav_items [@sa=hm]').each(function(i){
      $(this).mouseover(function(){
         $(this).find('img').attr('src', '/i/' + $(this).find('img').attr('name') + '_a.gif');
      });
      $(this).mouseout(function(){
         $(this).find('img').attr('src', '/i/' + $(this).find('img').attr('name') + '.gif');
      });
   });
});


$(function(){
   $("[@name=q]").focus(function(){
      if( $("#searchDIV").css("display") == 'none' ){
         $("#searchDIV").slideDown("normal");
      }
   });
   $("#search_close").click(function(){
      $("#searchDIV").slideUp("normal");
   });
   var opt_all = '<option value="-1" style="color:#5B5B5B">Βρε</option>';
   $("select#s_firm").change(function(){
      $.getJSON("/catalogue.backend.php",{what:'category', firm_id: $(this).val()}, function(json){
         var opt = opt_all;
         if(json && json != ''){
            if(json.length > 0){
               $("select#s_cat").html(opt);
               for (var i = 0; i < json.length; i++) {
                  opt += '<option value="' + json[i].id + '">' + json[i].name + '</option>';
               }
               $("select#s_cat").html(opt);
            }
         } else {
            $("select#s_cat").html(opt_all);
         }
      })
      $("select#s_cat").focus();
	});
   $("select#s_cat").change(function(){
      $.getJSON("/catalogue.backend.php", {what:'type', category_id:$(this).val()}, function(json){
         var opt = opt_all;
         if(json && json != ''){
            if(json.length > 0){
               $("select#s_type").html(opt);
               for (var i = 0; i < json.length; i++) {
                  opt += '<option value="' + json[i].id + '">' + json[i].name + '</option>';
               }
               $("select#s_type").html(opt);
            }
         } else {
            $("select#s_type").html(opt_all);
         }
      });
	});
});
