var galleryInterval = 0;
var bannerInterval = 0;
var bannerVisible = 0;

function swap_gallery() {
	$("div#gallery div.gallery_entry:visible").each( function() {
		$(this).hide();
		
		if( $(this).is(":last-child") ) {
			$("div#gallery div.gallery_entry:first-child").show();
		} else {
			$(this).next().show();
		}
	});
}

/*
function swap_banner() {
	$("div#banners div.banner_entry:visible").each( function() {
		$(this).hide();

		
		if( $(this).is(":last-child") ) {
			bannerVisible = 0;
			$("div#banners div.banner_entry:first-child").show();
		} else {
			bannerVisible++;
			$(this).next().show();
		}
		
		bannerBackground = bannerVisible * 34;
		$("div#banner_footer").css( "background-position", "0px -" + bannerBackground + "px" );
	});
}
*/


$(document).ready( function() {
	$("div.padded").each( function() {
		$(this).width( $(this).width() - 20 );
		$(this).css( "padding-left", "10px" ).css( "padding-right", "10px" );
	});

	if( document.getElementById("gallery") ) {
		galleryInterval = setInterval( "swap_gallery()", 7000 );
	}
	
	if( document.getElementById("youtube_videos") ) {
		swfobject.embedSWF( "http://www.youtube.com/v/" + $("div#youtube_video_selector td:first a").attr("href") + "&amp;border=0&amp;enablejsapi=1&amp;playerapiid=ytplayer", "flash_video", "336", "200", "9" );
		
		$("a.youtube_video_select").click( function(event) {
			event.preventDefault();
			swfobject.embedSWF( "http://www.youtube.com/v/" + $(this).attr("href") + "&amp;border=0&amp;enablejsapi=1&amp;playerapiid=ytplayer", "flash_video", "336", "200", "9" );
		});
	}
	
/*
	if( document.getElementById("rotating_banner") ) {
		bannerInterval = setInterval( "swap_banner()", 10000 );
	}
*/
	
	
/*
	$("div.banner_select").click( function(event) {
		if( bannerInterval ) {
			clearInterval( bannerInterval );
			bannerInterval = 0;
		}
		
		$("div#banners div.banner_entry").hide();
		bannerSelect = $(this).attr("banner");
		
		bannerBackground = bannerSelect * 34;
		
		$("div#banner_footer").css( "background-position", "0px -" + bannerBackground + "px" );
		
		bannerSelect++;
		
		$("div#banners div:nth-child(" + bannerSelect + ")").show();
	});
*/
});