jQuery(document).ready(function() {
	jQuery("#video-open").live("click", function() {
		jQuery("div.video-wrapper").show();
		jQuery("div.silver").show();
		jQuery("img.logo").css({ zIndex: "30" });
		
			setTimeout(function() {
				flash.init();
			}, 1200);
	});
	
	jQuery("#video-close").live("click", function() {
		flash.stop();
		jQuery("div.video-wrapper").hide();
		jQuery("div.silver").hide();
		jQuery("img.logo").css({ zIndex: "3" });
	});
	
	$people = jQuery("img.people");
	$logo = jQuery("img.logo");
	$links = jQuery("div.links");
	$links.css({ bottom: Math.round(Math.round($people.width()/ 2.435) * 0.12)  + "px"});

	$html = jQuery("html");
	$body = jQuery("body");
	$dummy = jQuery("div.dummy");
	$outer = jQuery("div.outer");

	if (jQuery.browser.msie) {
		$people.css({ height: Math.round($people.width()/ 2.435) + "px" });
		$logo.css({ height: Math.round($logo.width()/ 3.856) + "px" });
	}
	
	if ($people.height() > 950) {
		setTimeout(function() {
			var height;
			height = Math.round($people.height() + 200);
			//if (height > 800)
			//	height = 800;
			
			$html.css({ minHeight: height + "px" });
			$body.css({ minHeight: height + "px" });
			$dummy.css({ height: height + "px" });
			if (jQuery.browser.msie && jQuery.browser.version=="6.0") {
				$outer.css({ height: height + "px" });
			}
		}, 1);
	}
	else {
		var height;
		height = Math.round($people.height() + 200);
		//if (height > 800)
		//	height = 800;
		
		$html.css({ minHeight: height + "px" });
		$body.css({ minHeight: height + "px" });
		$dummy.css({ height: height + "px" });
		if (jQuery.browser.msie && jQuery.browser.version=="6.0") {
			$outer.css({ height: height + "px" });
		}
	}

	jQuery(window).resize(function() { 
		if (jQuery.browser.msie) {												 
			$people.css({ height: Math.round($people.width()/ 2.435) + "px" });
			$logo.css({ height: Math.round($logo.width()/ 3.856) + "px" });
		}
		$links.css({ bottom: Math.round(Math.round($people.width()/ 2.435) * 0.12)  + "px"});
		
		var height;
		height = Math.round($people.height() + 200);
		//if (height > 800)
		//	height = 800;
		
		$html.css({ minHeight: height + "px" });
		$body.css({ minHeight: height + "px" });
		$dummy.css({ height: height + "px" });
		if (jQuery.browser.version=="6.0") {
			$outer.css({ height: height + "px" });
		}
	});
});

flash = {
	
	id: "player",
	initiated: false,
	
	init: function() {

		flash.initiated = true;
		window.flashVideoPlayerReady = function() {
			flash.play();
		}
		
		var so = new SWFObject("iimages/player-2.swf", flash.id, "530", "304", "8", "#000000");
		so.addParam("wmode", "opaque");
		so.addParam("menu", "false");
		so.addParam("allowscriptaccess", "always");
		//so.addVariable("file", "football.flv");
		so.write("flash");
	},
	
	play: function() { 
		flash._getFlash(flash.id).playVideo("football.flv");
	},
	
	stop: function() {
		flash._getFlash(flash.id).stopVideo();
	},

	_getFlash: function(flashID) {
		return navigator.appName.indexOf("Microsoft") != -1 ? window[flashID] : document[flashID];
	}
}
