$(document).ready(function () {

  $('input[name=k]').focus(function () {
    if ($(this).val() == 'Parola chiave') $(this).val('');
  });

  $('input[name=k]').blur(function () {
    if ($(this).val() == '') $(this).val('Parola chiave');
  });

  $('select#brands').change(function () {
    location = $(this).val();
  });

});

function bookmark(url, title) {
  if (window.sidebar) {
    // firefox
    window.sidebar.addPanel(title, url, "");
  }
  else if (window.opera && window.print) {
    // opera
    var elem = document.createElement('a');

    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
  }
  else if(document.all) {
    // ie
    window.external.AddFavorite(url, title);
  }
}

jQuery.fn.not_exists = function(){return jQuery(this).length==0;}
jQuery.fn.jqcollapse = function(o) {
 
 // Defaults
 var o = jQuery.extend( {
   slide: true,
   speed: 300,
   easing: ''
 },o);

 
 $(this).each(function(){
   var e = $(this).attr('id');

   $('#'+e+' li > ul').each(function(i) {
     var parent_li = $(this).parent('li');
     var sub_ul = $(this).remove();

     // Create 'a' tag for parent if DNE

     if (parent_li.children('a').not_exists()) {
       parent_li.wrapInner('<a/>');
     }

     parent_li.find('a').addClass('jqcNode').css('cursor','pointer').click(function() {
       if (o.slide==true) {
         sub_ul.slideToggle(o.speed, o.easing);
       }
       else sub_ul.toggle();
     });

     parent_li.append(sub_ul);
   });

   //Hide all sub-lists
   $('#'+e+' ul').hide();
 });

};

