// JavaScript Document

var Header = {
	// Let's write in JSON to make it more modular
	addFade : function(selector){
		var $this = $(this);

		// Safari dislikes hide() for some reason
		$(selector+" a").bind("mouseenter",function(){
			var thix = $(this).attr("rel");
			$(selector+" .fake-"+thix).fadeIn("fast");
		});
		$(selector+" a").bind("mouseleave",function(){
			var thix = $(this).attr("rel");
			$(selector+" .fake-"+thix).fadeOut("fast");
		});
	}
};
$(function(){
	Header.addFade(".fade");
});

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#main-slide').jcarousel({
        scroll: 1,
		auto:4,
		wrap:'last',
		initCallback: mycarousel_initCallback
    });
	
	$('#today').click(function(){
		if ($(this).is('.open')) { 	
			$('#series_collapse').addClass('show');
			$('#series_collapse').removeClass('hide');
			$('#today').removeClass('open');
		} else {
			$('#series_collapse').addClass('hide');
			$('#series_collapse').removeClass('show');
			$('#today').addClass('open');
		}
		return false;
	});
	
	$('#today').addClass('open');
	$('#series_collapse').addClass('hide');
	
});
