jQuery('.hover,.nohover').live('mouseover', function(){
  jQuery(this).addClass('hover');
  jQuery(this).removeClass('nohover');
});
jQuery('.hover,.nohover').live('mouseout', function(){
  jQuery(this).removeClass('hover');
  jQuery(this).addClass('nohover');
});


var watchPromo1 = null;
var watchLists1 = null;
var countPromo1 = 0;
var countLists1 = 0;
var limitCount = 10;

jQuery('body').ready(function(){
  watchPromo1 = setInterval('fixPromo1()', 1000);
  watchLists1 = setInterval('fixRightList()', 1000);
});

function fixPromo1()
{
  countPromo1++;
  if (watchPromo1 == null || jQuery('#side-promo .boo-widget').length > 0)
  {
	  countPromo1 = limitCount;
    jQuery('#side-promo .boo-widget').each(function()
    {
      var width = jQuery(this).find('img,embed,iframe').width();
      var marginX = jQuery('#sidebar').width();
      marginX = Math.floor((marginX - width)/2);
	    width = jQuery('#sidebar').width()-2*marginX;
  
      var height = jQuery(this).find('img,embed,iframe').height();
      marginY = 10;
     
      jQuery('#side-promo').css('width', width+"px");
      jQuery('#side-promo').css('height', height+"px");
      jQuery('#side-promo').css('padding', marginY+"px "+marginX+"px");
    });
  }
  if(countPromo1 >= limitCount)
  {
    clearInterval(watchPromo1);
    watchPromo1 = null;
  }
}

function debugMsg(msg, ale)
{
  if (debug)
  try
  {
    console.log(msg);
  } catch (e)
  {
    if (ale)
      alert(msg);
  }
}

function fixRightList()
{
  countLists1++;
  if (watchLists1 == null || jQuery('#linkcat-2,#categories-2').length > 1)
  {
	countLists1 = limitCount;
    catEnd = jQuery('#categories-2 ul').offset().top+jQuery("#categories-2 ul").height();
    linkEnd = jQuery('#linkcat-2 ul').offset().top+jQuery("#linkcat-2 ul").height();

    diff = catEnd-linkEnd;
    if (diff > 0)
      select = "#linkcat-2";
    else
    {
      diff = -diff;
      select = "#categories-2";
    }
    size = jQuery(select+' ul').height()+diff;
    jQuery(select+' ul').css('height', size+'px');
  }
  if(countLists1 >= limitCount)
  {
    clearInterval(watchLists1);
    watchLists1 = null;
  }
}

jQuery('html').ready(function()
{
	jQuery('.html-tut-wrap').each(function()
	{
	  new HtmlTut(this);
	});
});