// JavaScript Document
function resizeBackground() {
	var win_width = $(window).width();
	var win_height = $(window).height();
	//if (win_height < 800) win_height = 800;
	var win_aspect_ratio = win_width / win_height;

	pic_aspect_ratio = 1.5;
	
	if (win_aspect_ratio > pic_aspect_ratio) {
		// scale pic to fit window width
		new_height = win_width / 1.5;
		new_width = win_width;
	} else {
		// scale pic to fit window height		
		new_height = win_height;
		new_width = win_height * 1.5;
	}
	
	// center image
	new_top = 0 - ((new_height - win_height) / 2);
	new_left =  0 - ((new_width - win_width) / 2);
//	alert('new_top: ' + new_top + 'new_left: ' + new_left);
	$backgroundImg.css({top: new_top, left: new_left});

	$backgroundImg.css({height: new_height, width: new_width});
}
function photos() {
	$photos = $('.photos li a');
	$track = $('.track');
	$full = $('.full a');
	$photos.click(function() {
		img = $(this).attr('class');
		$("."+img, $full).show();
		$track.animate({left: "-890px"}, "normal"); 
		return false;
	});
	$full.click(function() {
		$track.animate({left: "0"}, "normal", function() {
			$("img", $full).hide();
		}); 
		return false;
	});
}
function trailer() {
	swfobject.registerObject("trailer", "9.0.0");
}
function sectionInteract() {
	if (section == "photos") {
		photos();
	} //else if (section == "trailer") {
		//trailer();
	//}
}
function interact() {
	$content = $('#content');
	$('#sections li a').click(function() {
		$('#sections li a.active').removeClass('active');
		$(this).blur().addClass('active');
		section = $(this).attr('id');
		if (section == "synopsis") {section = "sy";}
		$content.load(base + "includes/" + section + ".php?b=" + base, function() {
			sectionInteract();
		});
		return false;
	});
}
$(document).ready(function() {
	$background = $('#background');
	$backgroundImg = $('img', $background);
	resizeBackground();
	interact();
	sectionInteract();
	$(window).resize(function(){
		resizeBackground();
	});
});