//Begin jQuery onload
$(function() {
		//Create tabs
		$("#tabs").tabs();
		
		//Create accordions
		$(".accordion").accordion({ 
			autoHeight: false,
			clearStyle: true
		});
		
		//Fade success messages
		setTimeout(function(){
			$("#success-message").fadeOut("slow", function() {
				$("#success-message").remove();
			});
		}, 2000);
		
		//Fade error messages
		setTimeout(function(){
			$("#error-message").fadeOut("slow", function() {
				$("#error-message").remove();
			});
		}, 5000);
		
		//Create homepage scroller	
		$("#film_nav").localScroll({
			target: '#film_large_image',
			onBefore: function(event_obj, target_href) {			
				//Set trailer link
				$("#trailer_link").attr("href", target_href+"?show_trailer=true");
				
				//Set about link
				$("#about_link").attr("href", target_href);
			}
		});
		
		//Enable first links
		var trailer_link = $("#trailer_link");
		if(trailer_link.attr("href") == "#") {
			//Grab info from first large film image
			var first_film = $("#film_large_image a:first");
			if(first_film.length > 0) {
				$("#trailer_link").attr("href", first_film.attr("href")+"?show_trailer=true");
				$("#about_link").attr("href", first_film.attr("href"));
			}
		}
});