$(document).ready(function () {
	var hash = location.hash;

	$('#body_main').flashembed({
		src : 'images/overview/preloader.swf',
		version : [9, 0],
		width : '666px',
		height : '950px',
		wmode : 'opaque',
		scale : 'noscale',
		salign : 'tl',
		onFail : function () {
			// If flash was not successful, this code will set up the animations for scrolling
			$('.button').click(function (event) {
				event.preventDefault();

				if (hash < this.hash) {
					$.scrollTo(this.hash, 1250, {easing:'easeOutBounce'});
				}
				else {
					$.scrollTo(this.hash, 800, {easing:'easeOutBack'});
				}

				// because of event.preventDefault(), we have to change hash ourselves so the conditionaly statement will work correctly next time
				hash = this.hash;
			});
			
			// Only add the up arrow to the screen when it will not overlay the top corner image
			$('#line-links > a').filter('#button-0').css('opacity', 0).click(function () {
				$(this).stop().fadeTo('slow', 0);
			});
			$('#line-links > a').filter(':not(#button-0)').click(function () {
				$('#button-0').stop().fadeTo('slow', 1);
			});
		}
	}, {
		fileName : 'images/overview/line-flash.swf'
	});
	
	$('#body_main > object').css('margin-left', '-22px');
	
	// Set up corner image
	// Put corner-image div back up if the flashembed function took it away
	if ($('#corner-image').length == 0) {
		$('<div></div>').attr('id', 'corner-image').appendTo('#body_main');
	}
	
	// Animate the corner-image in
	$('#corner-image').css('opacity', 0).fadeTo(5000, 1);
});
