// JavaScript Document

$(function() {
		   
	function fixIE6(inner, outer) {
		var offset = $(inner).offset().top;
		$(outer).css({top: $(this).scrollTop() + "px"});
		$(inner).css({top: $(this).scrollTop() + offset + "px"});
		$(window).scroll(function(event) {
			$(outer).css({top: $(this).scrollTop() + "px"});
			$(inner).css({top: $(this).scrollTop() + offset + "px"});
			});
		}
		
	$(".movieClip").click(function(event) {
		event.preventDefault();
		var $$ = this;
		$.ajaxSetup({cache: false});
		$("#movie").load("videos.asp", {movie: $("input:hidden", $$).val()}, function(data) {
			
			$("#outerbox").css({opacity: 0, display: "block"});
			
			$("#movie").css({opacity: 0, display: "block", top: ($("#outerbox").height() - $("#movie").height()) / 2 + "px", left: ($("#outerbox").width() - $("#movie").width()) / 2 + "px"});
			
			// Fix IE 6
			if ($.browser.msie && parseInt($.browser.version) <= 7)
				fixIE6("#movie", "#outerbox");
			
			$("#outerbox").animate({opacity: .7}, 'fast');
			$("#movie").animate({opacity: 1}, 'fast');
			
			$(".closeMovie").click(function(event) {
				event.preventDefault();
				
				$("#movie").animate({opacity: 0}, 'fast', function() {
					$(this).css({display: "none"});
					});
				
				$("#outerbox").animate({opacity: 0}, 'fast', function() {
					$(this).css({display: "none"});
					});
				});
			});
		});
	});