$(document).ready(function(){

	// on click promo tabs - change promo image and tab
	$('.promos .tabs a').click(function(){
		target = $(this).attr('rel');

		$old_promo = $('.promos div.current');
		$new_promo =$('.promos #'+target);

		$old_promo.fadeOut('slow',function(){ $(this).removeClass('current'); });
		$new_promo.fadeIn('slow',function(){ $(this).addClass('current'); });

		old_tab = $(this).parent().attr('class').split(" ").pop();
		$(this).parent().removeClass( old_tab );
		$(this).parent().addClass( $(this).attr('class') );

		return false;
	});

	// cycle recent reviews
	// @see http://malsup.com/jquery/cycle/lite/
    $('#reviews-container').cycle({
		fx: 'fade',
		timeout	: 7000
	});


	//{{{ Setup vb100 panel

	$vb100 = $("<a class='vb100' href='/en/software/antivirus/#reviews'>Auslogics Antivirus is among the top 10   most effective antiviruses in the world  according to the independent security software test from VB100.</a>");
	$vb100.css({
		'display'    : 'block',
		'width'      : '868px',
		'height'     : '106px',
		'overflow'   : 'hidden',
		'margin'     : '0px auto',
		'background' : "url('/includes/images/home-page/vb100.jpg') no-repeat",
		'text-indent': '-5000px'
	}); 
	$('.site-main.center.promos').before($vb100);
	$vb100.hide();

	$('.tabs a').click(vb100_click);

	//}}}

	//{{{ Setup events for Google Analytics

	$('.tabs a').click(function(){
		_gaq.push(['_trackEvent','home page','promo slider',$(this).attr('class')]);
	});
	$('.video .video-container').click(function(){
		_gaq.push(['_trackEvent','home page','video','click']);
	});
	$('a.vb100').live('click',function(){
		_gaq.push(['_trackEvent','home page','antivirus banner','click']);
	});

	//}}}


});


/** 
 * Fixes footer position for IE6 and IE7
 *
 * fires when the slider stoped
 */
function vb100_fix_ie_footer()
{
	if ( $.browser.msie )
	{
		$('.site-footer').css({
			'top'   : 'auto',
			'bottom':'0px'
		});
	}
}

/**
 * When click on the third tab - slideDown and show antivirus panel
 * When click on other tab - slideIp and hide antivirus panel
 */ 
function vb100_click()
{
    if ( $(this).hasClass('tab03') )
    {
		$('a.vb100').slideDown('slow',vb100_fix_ie_footer);
    }
    else
    {
    	$('a.vb100').slideUp('slow',function(){
			$('a.vb100').hide();
			vb100_fix_ie_footer();
		});
    }
}
