function showPreloader() {
	var b = $(window).width() / 2;
	var a = $(".loading").outerWidth(true) / 2;
	var d = $(window).height() / 2;
	var c = $(".loading").outerHeight(true) / 2;
	$(".loading").css(({
		left: b - a,
		top: d - c
	}));
	$("html,body").animate({
		scrollTop: 0
	}, 300);
	$(".loading").stop(true, true).fadeIn(200);
	$(".transBg").stop(true, true).fadeTo(300, 0.6)
}
function showPreloaderLower() {
	var b = $(window).width() / 2;
	var a = $(".loading").outerWidth(true) / 2;
	$(".loading").css(({
		left: b - a,
		top: 400
	}));
	$(".loading").stop(true, true).fadeIn(300)
}
function hidePreloader() {
	$(".loading").stop(true, true).fadeOut(300);
	$(".transBg").stop(true, true).fadeOut(300)
}
function browserSizeTest() {
	var a = ($(window).width() / 2) - (950 / 2);
	$("#pageOverlay").css({
		left: a
	})
}
/*
$.fn.pageSetup = function() {
	var viewportwidth;
	var viewportheight;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if ( typeof window.innerWidth != 'undefined' ) {
		viewportwidth = window.innerWidth;
		viewportheight = window.innerHeight;
	} else if ( typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0 ) {
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		viewportwidth = document.documentElement.clientWidth;
		viewportheight = document.documentElement.clientHeight;
	} else {
		// older versions of IE
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
		viewportheight = document.getElementsByTagName('body')[0].clientHeight;
	}

	$bg = $("#bg");

	aspectRatio = 1.094; //document.getElementById("bg").offsetWidth / document.getElementById("bg").offsetHeight;

	//height = viewportheight;

	if ( ( viewportwidth / viewportheight ) < aspectRatio ) {
		$bg
			.removeClass()
			.addClass('bgheight');
	} else {
		$bg
			.removeClass()
			.addClass('bgwidth');
	}
};
*/
$(document).ready(function () {
	/*$.fn.pageSetup();*/
	browserSizeTest();
	$(window).resize(function () {
		$.fn.pageSetup();
		browserSizeTest();
	});
	if( $("#left").length > 0 ) {
		$("#left a.frame").hover(function () {
			$("#middle a").css("background-position", "-369px 0px")
		}, function () {
			$("#middle a").css("background-position", "0px 0px")
		});
	}
	if( $("#featureSlideshow").length > 0 ) {		
		$("#featureSlideshow").cycle({
			fx: "fade",
			speed: 1000,
			timeout: 10000,
			next: "#next",
			prev: "#prev"
		});
	}
	if( $("#grid").length > 0 ) {
		$("#grid").show();
	}
	if( $(".box").length > 0 ) {
		$(".box").each(function () {
			$(this).hover(function () {
				$(this).children(".overlayer").slideDown(200);
				$(this).children(".overoverlayer").slideDown(200)
			}, function () {
				$(this).children(".overlayer").slideUp(0);
				$(this).children(".overoverlayer").slideUp(0)
			})
		})
	}
});

