$(document).ready(function(){
setTimeout(function(){ 
if ($.cookie("ava_tab")){
if ($.cookie("ava_tab") != 'cp'){
   $('#panel a.active').removeClass('active');
   $('#'+$.cookie("ava_tab")).addClass('active');
   $('#panel-content-ajax').load('/' + $.cookie("ava_tab") + '.php?r='+Math.random());
   $('#panel-content').hide();  
   $('#panel-content-ajax').show(); 
}
}
  }, 500);
  $(".menu-main-item").hover(
    function() {
      $(this).children('a').addClass('hover');
      $("#sub-"+$(this).attr('id')).show();
    },
    function() {
      $(this).children('a').removeClass('hover');
      $("#sub-"+$(this).attr('id')).hide();
    }
  );
  
  var clearMePrevious;

  $("#login_input, #password_input, #q").focus(function(){
    if($(this).val()!=''){
        clearMePrevious = $(this).val();
        $(this).val('');
    }
  });

  $("#login_input, #password_input, #q").blur(function(){
    if($(this).val()=='')
        $(this).val(clearMePrevious);
  });


  $("#panel a").click(function(){
    $(this).parent().children('a.active').removeClass('active');
    $(this).addClass('active');
    var date = new Date();
    date.setTime(date.getTime() + (31 * 24 * 3600000)); 
    $.cookie("ava_tab", $(this).attr('id'),  { path: '/', expires: date });
    if ($(this).attr('id') == 'cp'){
      $('#panel-content').show();
      $('#panel-content-ajax').hide();
    }else{
      $('#panel-content-ajax').load('/' + $(this).attr('id') + '.php?r='+Math.random());
      $('#panel-content').hide();  
      $('#panel-content-ajax').show();
    }
     return false; 
  });
});