var nav = {
	normalCss: { backgroundImage:"url('/img/chrome/arrowRight.gif')" },
	selectedCss: { backgroundImage:"url('/img/chrome/arrowDown.gif')" }
}

$(document).ready( function(){
	/* Fix for rel="nofollow" on fancybox elements */
	$('a[rel=nofollow]').each(function(i) {
		$(this).attr('rel', '');
	});

	$('#leftColumn>ul>li>a').click( function(e){
		var siblings = $(this).siblings('ul')
		if ( siblings.length ) {
			e.preventDefault()
			$('#leftColumn>ul>li>a').css(nav.normalCss)
			if ( $(siblings).css('display') == 'none' ) {
				$(this).css(nav.selectedCss)
			}
			$(siblings).toggle()
		}
	})
	if ( here ) {
		var found = false
		$('#leftColumn>ul>li').each( function(){
			if ( $('a',this).attr('href') == here ) {
				$(this).addClass('selected')
				found = true
			}
		})
		if ( !found ) {
			$('#leftColumn>ul>li>ul>li').each( function(){
				if ( $('a',this).attr('href') == here ) {
					var self = $(this)
					var parent = self.parent()
					self.addClass('selected')
					parent.show().siblings('a').css(nav.selectedCss)
				}
			})
		}
	}
	if ( $.browser.msie && $.browser.version < 7 ) {
		$('#leftColumn li, #rightColumn .linkList li').hover(
			function(){ $(this).addClass('hover') },
			function(){ $(this).removeClass('hover') }
		)
	}
	/*
	$('#subscribeLink').fancybox({frameWidth: 660})
	$('#launchLink').fancybox({frameWidth: 600})
	$('a.promotion').fancybox({frameWidth: 650})
	$('a.fancybox').fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'width'				: '864',
		'height'			: '687',
		'swf'				: {'wmode': 'opaque'}
	});
	*/

	$('#tabContainer2 ul.tabList a').click(function() {
		$('#tabContainer2 div.tab').hide();
		$('#tabContainer2 div.' + $(this).attr('rel')).show();

		return false;
	});
})

$('#tabContainer1').ready(function() {
	$('#tabContainer1 ul.tabList a').click(function() {
		$('#tabContainer1 ul.tabList a').removeClass('active');

		var marginLeft = 0;

		switch ($(this).attr('rel')) {
			case 'tab2':
				marginLeft = '-560px';
				break;

			case 'tab3':
				marginLeft = '-1120px';
				break;
		}

		$(this).addClass('active');

		$('#tabContainer1 div.tabArea').animate({"marginLeft": marginLeft}, 'slow');
		$('#tabContainer1 div.' + $(this).attr('rel')).show();

		return false;
	});
});

$('#tabContainer2').ready(function() {
	$('#tabContainer2 div.tab:gt(0)').hide();

	$('#tabContainer2 ul.tabList a').click(function() {
		$('#tabContainer2 div.tab').hide();
		$('#tabContainer2 div.' + $(this).attr('rel')).show();

		return false;
	});
});