// Weather Underground Scripts

// Carousel
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();
    });
};

$(document).ready(function() {
						   
	// Hide Inactive Sidebar Modules
	if ($('#wu_template').length) { // implies *not* zero
		// Sidebar should display
	} else {
		$("#sidebar .wu_module:not(:first-child)").css("display","none");
		$("#sidebar #ugc:not(:first-child)").css("display","block");
	}
	
	// Carousel Document Ready
	jQuery('#wu_carousel').jcarousel({
		auto: 5,
		wrap: 'last',
		initCallback: mycarousel_initCallback
	});
					   
	// CSS Forecast Border Style Fix
	$('.wu_forecastBox:nth-child(6n)').css('border', 'none');
	
	// Button Controls
	$('#pwsTab, #nwsTab').hide();
	$('.forecastButton').click(function() {
		$('#fcHours, #fcDays').slideDown('slow').fadeIn('slow');
		$('#pwsTab, #nwsTab').hide();
		$('#fcMain, #fcWarning').fadeIn('slow');
	});
	$('.pwsButton').click(function() {
		$('#fcHours, #fcDays').slideUp('slow').fadeOut('slow');
		$('#pwsTab').fadeIn('slow');
		$('#fcMain, #fcWarning, #nwsTab').hide();
	});
	$('.nwsButton').click(function() {
		$('#fcHours, #fcDays').slideUp('slow').fadeOut('slow');
		$('#pwsTab, #fcMain, #fcWarning').hide();
		$('#nwsTab').fadeIn('slow');
	});
	
});
