function switchScreen(divNum) {
	theDiv = "#screen" + divNum;
	if (!$(theDiv).hasClass("current")) {
		$(".current p").fadeOut(400);
		$(".current img")
			.fadeOut(200)
			.parent().removeClass("current");
		$(theDiv + " p")
			.animate({opacity: 1.0}, 1000)
			.fadeIn(400, function() {
				if ($.browser.msie)
		        	this.style.removeAttribute('filter');
			});	
		$(theDiv + " img")
			.animate({opacity: 1.0}, 400)
			.fadeIn(800)
			.parent().addClass("current");
	}
};

function loadVideo() {
	$("#video").flash ({
		src: 'http://www.youtube.com/v/5jvdL8zkc04&hl=en&fs=1&',
		width:560,
		height:340,
		wmode:'transparent'
	});
}

$(document).ready(function(){
	
	if(/MSIE (5\.5|6)/.test(navigator.userAgent) || typeof filters == 'unknown') return;
	
	loadVideo();

	$("a#watchVideo").click(
		function() {
			$('#videoFlood')
				.fadeTo(0, 0)
				.css('display', 'block')
				.css({ 'width': $(document).width(), 'height': $(document).height() } )
				.fadeTo(400, .9);
			$("#video")
				.fadeTo(0, 400)
				.css('display', 'block')
				.css({'top' : ($(window).scrollTop() + 150), 'left' : (($(window).width()-$("#video").width()) / 2) })
				.animate({opacity: 1.0}, 400);			
		}
	);
	
	$("#videoFlood").click(
		function() {
			$("#video").fadeOut(400)
			$("#videoFlood").fadeOut(400);
		}
	);
	
	$(document).keypress(function(e) {
		if (e.keyCode == 27) {
			$("#video").fadeOut(400)
			$("#videoFlood").fadeOut(400);			
		}}
	);
	
	$(".screen img").click(function() {
		divNum = parseInt($(".current").attr("id").substring(6));
		divNum = divNum + 1;
		if (divNum > 6) { divNum = 1; };
		switchScreen(divNum);
	});
	
	$(".screen a.thumb").click(function() {
		divNum = $(this).parent().attr("id").substring(6);
		switchScreen(divNum);
	});
		
	switchScreen("1");

});

