try {document.execCommand("BackgroundImageCache", false, true);} catch(err) {}
function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	arrayPageSize = new Array(windowWidth,$("#texture").height());
	return arrayPageSize;
};


$(document).ready(function () {
	
	
	
	$("#f-order-check-1").click(function() {
		if ($("#f-order-check-1").attr("checked") == true) {
			$(".submit div.btn input").css("background-image","url(/images/submit-btn-hover.gif)");
		} else {
			$(".submit div.btn input").css("background-image","url(/images/submit-btn.gif)");
		};
	});
	
	
	
	
$('#menuanimation').prepend('<div id="_menuhover_" style="position:absolute; top:0; z-index:0; height:63px; background:#F65822; overflow:hidden; left:-100px;" />');
var $menuhover = $('#_menuhover_'),
	$menuItems = $('#menu div ul li');
	if ($("*").index($('#menu #menuanimation div ul li a.active')[0]) > -1){
		var $sItem = $('#menu #menuanimation div ul li a.active');
		
		var	sW = $sItem.width();
		var	sL = $sItem.offset().left;
	} else {
		sW = 0;
		sL = 0;
	}
    
	$menuItems.hover(function(){
        var $this = $(this),
            W = $this.width(),
            L = $this.offset().left;
			
        $menuhover.stop().animate({ width:W, left:L }, 500, null, null);
    }, function(e){
		if ($("*").index($('#menu #menuanimation div ul li a.active')[0]) > -1){
			var $sItem = $('#menu #menuanimation div ul li a.active'),
				sW = $sItem.width(),
				sL = $sItem.offset().left;
				
		} else {
			sW = 0;
			sL = 0;
		}
        if (e.pageY > 34) {
            $menuhover.stop().animate({ width:sW, left:sL }, 500, null, null);
        }
    });


    $menuhover.animate( { width:sW, left:sL }, 0, null, null);

    $(window).resize(function(){
			if ($("*").index($('#menu #menuanimation div ul li a.active')[0]) > -1){
				var $sItem = $('#menu #menuanimation div ul li a.active'),
					sW = $sItem.width(),
					sL = $sItem.offset().left;
			} else {
				sW = 0;
				sL = 0;
			}
	        $menuhover.stop().css({ width:sW, left:sL });
	    });
	
/* No need to change anything after this */	
	
M = $(document.body);
b = $("#img");
b.css("position","fixed");
var wt = $("#texture").width();
var ht = window.innerHeight;
if(M.get(0)) {
	typeImg="";
}
else {typeImg="site"; b.hide();}
fi = 0;
bp = 0;
fi1 = 0;

function imagesLoaded()	{
	if(fi1==0) {
		if(bw > arrPageSizes[0]) {
			b.css({ width:wt, marginLeft: "0%", left:0}).show();
		}
		else {				
			b.css({ width: wt, marginLeft: 0, left:"0%"}).show();
		}
		fi1=1;
	}
	else {b.fadeOut("normal", function() {b.attr("src", href); fi = 1; bresize();});}
}
checkLoad = function() {
	bp++;
	t.css({backgroundPosition: bp});
	if(!objImage.complete) {checkLoadT = setTimeout("checkLoad()",20);}
	else {imagesLoaded();}
};

function bresize() {
	var bw = $(b).width();
	var bh = $(b).height();
	var wt = $("#texture").width();
	var ht = window.innerHeight;
	if(bw == 0){
		bw = 2400;
	};
	if(bh == 0){
		bh = 1600;
	};
	arrPageSizes = getPageSize();
	
	
	
	if(typeImg=="site") {
		if(fi1==0) {
			b.css({marginTop: 0, top:"25px"});
			objImage = new Image();
			objImage.src=$(b).attr("src");
			t=$(".active").parent();
			checkLoad();
		}
		else {
			var wt = $("#texture").width();
			var ht = window.innerHeight;
			if (ht > wt/(1.5)) {
				b.css({ height:ht,width:"auto", marginLeft: "0%", left:0, marginTop: 0, top:"0"}).show();
			} else {
				b.css({height:"auto", width:wt, marginLeft: "0%", left:0, marginTop: 0, top:"0"}).show();
			};
		}
	}
	else {
		var ratio = arrPageSizes[0]/arrPageSizes[1];
	
		if(ratio >= 1.5) {
			var wt = $("#texture").width();
			var ht = window.innerHeight;
			dif = arrPageSizes[0] - 1600;
			res = 40+dif/(2400/100);
			bwr = 2400*res/100;
			bhr = 1600*res/100;
			if (ht > wt/(1.5)) {
				b.css({ height:ht,width:"auto", marginLeft: "0%", left:0, marginTop: 0, top:"0"}).show();
			} else {
				b.css({height:"auto", width:wt, marginLeft: "0%", left:0, marginTop: 0, top:"0"}).show();
			};		
			
		}
		else if(ratio < 1.5) {
			var wt = $("#texture").width();
			var ht = window.innerHeight;
			dif = arrPageSizes[1] - bh;
			res = 40+dif/(bh/100);
			bwr = bw*res/100;
			bhr = bh*res/100;
			if (ht > wt/(1.5)) {
				b.css({ height:ht,width:"auto", marginLeft: "0%", left:0, marginTop: 0, top:"0"}).show();
			} else {
				b.css({height:"auto", width:wt, marginLeft: "0%", left:0, marginTop: 0, top:"0"}).show();
			};			

		}
	}
	if(fi==1) {b.fadeIn("normal"); fi=0;}
}
$(window).resize(function() {bresize();});
bresize();	
});
