/****************************************
*                                       *
*          2c-Interactive B.V.          *
*      http://www.2c-interactive.com    *
*                                       *
****************************************/

window.onload = function(){
	model = new Model();
	stageControl = new StageControl();
	stageControl.repositionElement();
}

//Contains all usefull data
function Model()
{
	this.right = document.getElementById("right");
	this.headerOffset = 96;
	this.notIE = false;

	//Returns display width
	function stageWidth(){
		var width;
		if (window.innerWidth > 0) {
			width = window.innerWidth;
			this.notIE = true;
		} else if (document.documentElement.clientWidth > 0) {
			width = document.documentElement.clientWidth;
		} else {
			width = document.body.clientWidth;
		}
		return width;
	}

	//Returns display height
	function stageHeight(){
		var height;
		if (window.innerHeight > 0) {
			height = window.innerHeight
		} else if (document.documentElement.clientHeight > 0) {
			height = document.documentElement.clientHeight
		} else {
			height = document.body.clientHeight
		}
		return height;
	}

	//public functions
	this.stageWidth = stageWidth;
	this.stageHeight = stageHeight;
}


//Handles all events
function StageControl()
{
	//Starting point for resize & reposition
	function repositionElement(){
		var stageHeight = model.stageHeight();
		var offsetHeight = model.headerOffset;
		var calculated = stageHeight - offsetHeight;
		if(calculated < 0){ calculated = 0; }
		model.right.style.height = calculated + "px";
	}

	//public functions
	this.repositionElement = repositionElement;
}
