$(function(){
	/**
	 * Demo binding and preparation, no need to read this part
	 */
		//borrowed from jQuery easing plugin
		//http://gsgd.co.uk/sandbox/jquery.easing.php
		$.easing.easeOutExpo = function(x, t, b, c, d) {
				return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
		};
	//by default, the scroll is only done vertically ('y'), change it to both.
	$.scrollTo.defaults.axis = 'x'; 	
	$.scrollTo.defaults.duration = '200';
	// We define the index of our current selected item in the menu
	gb_menu = 0;
	//this one is important, many browsers don't reset scroll on refreshes
	$("#block_site").scrollTo(0,0);//reset the screen to (0,0)
	resizeScreen();
	$("#nav img").click(function(){
		var i = $("#nav img").index(this);
		gb_menu = i;
		var x = screenW * i;
		$("#block_site").scrollTo(x+"px", { easing:'easeOutExpo' });
		return false;
	});
	$(".thomasBox").click(function(e){
		e.preventDefault();
		$(document.body).modal();
		var d = $(this).attr("rel");
		if ( d.indexOf(' ') !== -1 ){
			d = d.split(' ');
			var t = $(this).attr("title");
			var w = parseInt(d[0]);
			var h = parseInt(d[1]);
			var h2 = h + 30;
			var x = Math.floor(screenW/2) - Math.floor(w/2);
			var y = Math.floor(screenH/2) - Math.floor(h2/2);
			var c = $("<div/>")
			.addClass("popup")
			.appendTo(document.body)
			.width(w)
			.height(h2)
			.css({
				left: x,
				top: y
			})
			.append(
				$("<div/>")
				.addClass("content")
				.flash({
					swf: $(this).attr("href"),
					wmode: "transparent",
					expressinstall: "Scripts/expressInstall.swf",
					swfversion: "6.0.65.0",
					width: w,
					height: h
				})
			)
			.append(
				$("<div/>")
				.addClass("title")
				.html(t)
			)
			.append(
				$("<div/>")
				.addClass("close")
				.click(function(){
					$(this).parent().hide("scale",{percent: 0},"slow", function(){
						$(document.body).modal("destroy");
						$(this).remove();
					})
				})
			)
			.show("scale",{percent: 100},"slow");
		}
	});
});
$(window).resize(function(){
	resizeScreen();
});

