
CurrentMenu = {
	active: true,

	objCurrentMenu: null,
	objTagHtml: null,
	objTagBody: null,
	objBody: null,
	objTopbanner: null,
	objPage: null,

	activate: function() {
		this.active		= true;
	},

	deactivate: function() {
		this.active		= false;
	},

	init: function() {
		this.objCurrentMenu	= $( 'current_menu' );
		this.objTagHtml		= document.getElementsByTagName( 'html' )[0];
		this.objTagBody		= document.getElementsByTagName( 'body' )[0];
		this.objBody		= $( 'body' );
		this.objTopbanner	= $( 'topbanner' );
		this.objPage		= $( 'page' );

		this.toggleCurrentMenu();
	},

	toggleCurrentMenu: function() {
		var win = this.browserSize();

		if (this.active) {
			if (win.width >= 1270) {
				var offset		= Math.floor( (win.width - 1050 - 198 - 20) / 2 );
				var position	= (-270 + offset) + 'px 0';

				this.objCurrentMenu.style.display			= 'block';
				this.objTagHtml.style.backgroundPosition	= position;
				this.objTagBody.style.backgroundPosition	= (30 + offset) + 'px 0';
				this.objBody.style.backgroundPosition		= position;
				this.objTopbanner.style.backgroundPosition	= position;
				this.objTopbanner.style.paddingLeft			= (35 + offset) + 'px';
				this.objPage.style.marginLeft				= (30 + offset) + 'px';
			} else {
				this.objCurrentMenu.style.display			= 'none';
				this.objTagHtml.style.backgroundPosition	= '-270px 0';
				this.objTagBody.style.backgroundPosition	= '30px 0';
				this.objBody.style.backgroundPosition		= '-270px 0';
				this.objTopbanner.style.backgroundPosition	= '-270px 0';
				this.objTopbanner.style.paddingLeft			= '35px';
				this.objPage.style.marginLeft				= '30px';
			}
		} else {
			if (win.width >= 1072) {
				var offset		= Math.floor( (win.width - 1050 - 20) / 2 );
				var position	= (-270 + offset) + 'px 0';

				this.objCurrentMenu.style.display			= 'none';
				this.objTagHtml.style.backgroundPosition	= position;
				this.objTagBody.style.backgroundPosition	= (30 + offset) + 'px 0';
				this.objBody.style.backgroundPosition		= position;
				this.objTopbanner.style.backgroundPosition	= position;
				this.objTopbanner.style.paddingLeft			= (35 + offset) + 'px';
				this.objPage.style.marginLeft				= (30 + offset) + 'px';
			} else {
				this.objCurrentMenu.style.display			= 'none';
				this.objTagHtml.style.backgroundPosition	= '-270px 0';
				this.objTagBody.style.backgroundPosition	= '30px 0';
				this.objBody.style.backgroundPosition		= '-270px 0';
				this.objTopbanner.style.backgroundPosition	= '-270px 0';
				this.objTopbanner.style.paddingLeft			= '35px';
				this.objPage.style.marginLeft				= '30px';
			}
		}
	},

	browserSize: function() {
		var win			= new Object();

		if (self.innerHeight) {
			win.width	= self.innerWidth;
			win.height	= self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			win.width	= document.documentElement.clientWidth;
			win.height	= document.documentElement.clientHeight;
		} else if (document.body) {
			win.width	= document.body.clientWidth;
			win.height	= document.body.clientHeight;
		} else {
			win.width	= 0;
			win.height	= 0;
		}

		return win;
	}
};

window.onload = function() {
	CurrentMenu.init();
}

window.onresize = function() {
	CurrentMenu.toggleCurrentMenu();
}
