$(window).ready(function(){
	outer_shift = function (width, innerlimit, outerlimit) {
		$('#leaves_wrap').css('width', width);
		$('#leaves_right').css( 'background-position', '0px 0px' );
		$('#leaves_left').css( 'background-position', '0px 0px' );
		$('#center_wrap').css('left', (width-innerlimit)/2); 
	}
	
	middle_shift = function (width, innerlimit, outerlimit) {
		$('#leaves_wrap').css('width', width);
		$('#leaves_right').css( 'background-position', 0+(outerlimit-width)/2 + 'px 0px');
		$('#leaves_left').css( 'background-position', 0-(outerlimit-width)/2 + 'px 0px');
		$('#center_wrap').css('left', (width-innerlimit)/2);
	}

	inner_shift = function (width, innerlimit, outerlimit) {
		$('#leaves_wrap').css('width', innerlimit);
		$('#leaves_right').css( 'background-position', 0+(outerlimit-900)/2 + 'px 0px');
		$('#leaves_left').css( 'background-position', 0-(outerlimit-900)/2 + 'px 0px');
		$('#center_wrap').css('left', 0);
	}
	
	shiftleaves = function () {
		var width = $(window).width();
		var height = $(window).height();
		
		var outerlimit = 1300;
		var innerlimit = 900;

		if (width >= outerlimit) {
			outer_shift(width, innerlimit, outerlimit);
		} else if ((width < outerlimit) && (width >= innerlimit)) {
			middle_shift(width, innerlimit, outerlimit);
		} else if (width < 900) {
			inner_shift(width, innerlimit, outerlimit);
		}
	}
	
	/*
	if ($.browser.msie  && parseInt($.browser.version) == 7) {
		$('#body_wrap').css('top', '-235px');
	}
	*/
   
	
	outer_shift(1300, 900, 1300);
	middle_shift(900, 900, 1300);
	shiftleaves();
	$('body').show();
	
	$(window).resize(function () {shiftleaves()});
});
