
/* Smart background */


$.fn.calcBg = function() { 
var hd = $('.b-header');
var tab = $(this);
var bg_offset = hd.offset().left - tab.offset().left + 'px 0px';
$(this).css('backgroundPosition', bg_offset);
}

$(function() {
if($('.b-header .b-tabs li').is('.active')) {
$('.b-header .b-tabs li.active').calcBg();
}
if($('.b-main-menu li').is('.active')) {
$('.b-main-menu').find('li.active').calcBg();
}
});

$(function() {
$('.b-main-menu-item').hover(function(){
$(this).addClass('hitem');
$(this).calcBg();
}, function(){
$(this).removeClass('hitem');
});
});

$(function() {
if($('.b-menu-ul li').is('.active')) {
$('.b-menu-ul .active').calcBg();
}
});

$(function() {
$('.b-menu-item').click(function(){
$('.b-menu-item').removeClass('active');
$(this).addClass('active');
$(this).calcBg();
});
});


