$(document).ready(function() {
	$.initSocialMediaWidget();
	$.initHomepageAccordion();
	$.initBookingWidgetCalendars();
	$.initBrochureGuideDownload();
});

jQuery.initBrochureGuideDownload = function() {
	if ($('#boxBrochureGuideDownload').length > 0) {
        var hideSummerBrochure = true;
        if (hideSummerBrochure) {
            $('#imgBrochureDownload').css('visibility','hidden');
        }
		// Wire up hover to swap images
		$('#imgGuideDownload').hover(
			function() {
				$('#imgGuideDownload').attr('src','/SBCCBase/wrap/theme4/images/visitors.guide.on.gif');
                if (!hideSummerBrochure) {
				    $('#imgBrochureDownload').attr('src','/SBCCBase/wrap/theme4/images/summer.brochure.off.gif');
				    $('#imgBrochureGuideDownload').attr('src','/SBCCBase/wrap/theme4/images/visitors.guide.jpg');
                }
			},
			function() {
				$('#imgGuideDownload').attr('src','/SBCCBase/wrap/theme4/images/visitors.guide.off.gif');
                if (!hideSummerBrochure) {
				    $('#imgBrochureDownload').attr('src','/SBCCBase/wrap/theme4/images/summer.brochure.on.gif');
				    $('#imgBrochureGuideDownload').attr('src','/SBCCBase/wrap/theme4/images/summer.brochure.jpg');
                }
			}
		);	
	}
}

jQuery.initSocialMediaWidget = function() {
	if ($('#boxSocialUtils').length > 0) {
		$.tools.tooltip.addEffect("slideupdown",
			// opening  
			function(done) {
				this.getTip().toggle('slide', {easing: 'easeOutQuint', direction: 'down'}, 1000);
			},  
			// closing  
			function(done) {
				this.getTip().toggle('slide', {easing: 'easeOutQuint', direction: 'down'}, 500, function() {
					$(this).hide();
					done.call();
				}); 
			}
		); 
	    
		// Set up interactivity with icons
		$('#btnSocialIcons > li > img').each(function(index, item) {
			// Img swaps
			var sImgSrcOff = $(item).attr('src');
			var sImgSrcOn = sImgSrcOff.replace('.off.','.on.');
			$(item).hover(
				function() {
					$(this).attr('src', sImgSrcOn);
				},
				function() {
					$(this).attr('src', sImgSrcOff);
				}
			);
			// Calculate offset for tooltip so that it is centered above all icons
			var iOffsetX = 258 - (49 + (index * 28));
			// Click handler to fire tooltip
			$(this).tooltip({
				relative: true,
				position: 'top left',
				offset: [0, iOffsetX]
			});
		});
		
		// Populate the facebook data
		$('div.rssFacebookFeed').rssfeed('http://www.facebook.com/feeds/page.php?format=atom10&id=38524151374', {
			limit: 1
		}); 
		// Populate the Twitter data
		//$('div.rssTwitterFeed').rssfeed('http://twitter.com/statuses/user_timeline/23129279.rss', {
		//	limit: 1
		//});
		// Populate the YouTube data
		//$('div.rssYouTubeFeed').rssfeed('http://gdata.youtube.com/feeds/base/users/steamboatchamber/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile', {
		//	limit: 1
		//});
		// Populate the Blog data
		$('div.rssBlogFeed').rssfeed('http://steamboatsummer.wordpress.com/feed/', {
			limit: 2
		});
	}
}

jQuery.initHomepageAccordion = function() {
	if ($('#boxToolboxAccordian').length > 0) {
		transitionAccordianPanel(3, 4);
	}
}

jQuery.initBookingWidgetCalendars = function() {
	$("#txtDateArrive").datepicker({ 
		onSelect: function(dateText) { 
			$("#txtDateDepart").datepicker('setDate', new Date(dateText)); 
			$("#txtDateDepart").datepicker('option', 'minDate', new Date(dateText)); 
		},
		showAnim: 'fadeIn',
		minDate: '+2D',
		numberOfMonths: 2,
		showButtonPanel: true,
		dateFormat: 'mm/dd/yy'
	});
	$("#txtDateDepart").datepicker({ 
		showAnim: 'fadeIn',
		minDate: '+3D',
		numberOfMonths: 2,
		showButtonPanel: true,
		dateFormat: 'mm/dd/yy'
	});

	if ($('#frmVacationPlanner2').length > 0) {
		$("#txtDateArrive2").datepicker({ 
			onSelect: function(dateText) { 
				$("#txtDateDepart2").datepicker('setDate', new Date(dateText)); 
				$("#txtDateDepart2").datepicker('option', 'minDate', new Date(dateText)); 
			},
			showAnim: 'fadeIn',
			minDate: '+2D',
			numberOfMonths: 2,
			showButtonPanel: true,
			dateFormat: 'mm/dd/yy'
		});
		$("#txtDateDepart2").datepicker({ 
			showAnim: 'fadeIn',
			minDate: '+3D',
			numberOfMonths: 2,
			showButtonPanel: true,
			dateFormat: 'mm/dd/yy'
		});
	}
}

