﻿/* ========================== Mouvement by Kashi Samaraweera ============================= */
		 
	 /*                                                                                    *
	  * KashmaNiaC.com.au 2010 uses several animations which are activated by Javascript.  *
	  * Instead of relying on frameworks such as YUI or JQuery, I decided to develop my    *
	  * own (basic) framework with which to provide motion and give depth to the web site. *
	  * As a result here is "Mouvement" (inspired by the French word for movement), an     *
	  * animation framework I wrote specifically for the site.                             *
	  *                                                                                    *
	  * I've included a full version here rather than an obfuscated version (which you'd   *
	  * usually expect in a production enviroment) for anyone who has ever asked the       *
	  * question "Does he know anything about JavaScript?". I'll stop wasting bytes now.   *
	  *                                                                                    *
	  * Kashi Samaraweera 2010 | KashmaNiaC.com.au | v 0.9.3                               *
	  *                                                                                    */
	
// Begin Movement class ==================================================================== />

/* Mouvement is a lightweight frame-based animation framework which offers some basic cross-
   browser animations for HTML elements.
   
   Mouvement's play mechanism runs infinately from initialisation. I'd love to implement some
   threading here by sadly JavaScript doesn't accomodate it (I might hack a simulated multi-
   threading into the next revision; who knows?) Each each repetition processes a list of
   instructions which are added via API commands such as move(), alpha(), etc.

   Instructions are added to a play queue using methods of Mouvment or each of Mouvement's 
   HTML objects. Each method manages a different style of animation from changes in position,
   to size and alpha transparacy.

   */
   
	function Mouvement() {
		ShineDuplicate.prototype.parent = this;
		Unit.prototype.parent = this;
	}
		// Stores the list of animate elements.
		Mouvement.prototype.elements = Array();
		
		// Stores the pending animations.
		Mouvement.prototype.moveQueue = Array();
		Mouvement.prototype.active = false;
		Mouvement.prototype.loaded = false;
		Mouvement.prototype.stageWidth = 1000;
		Mouvement.prototype.fps = 24;
		Mouvement.prototype.heartbeat = Math.round(1000/Mouvement.prototype.fps);
		Mouvement.prototype.shineDuplications = Array();
		Mouvement.prototype.shineStrength = 4;
		Mouvement.prototype.lastRun = 0;

		// Let's define the methods of Mouvement...
		
		Mouvement.prototype.play = function() {
			
			this.active = true;
			var playSheet = this.moveQueue.shift();
			if (playSheet != undefined) {
				var i = playSheet.length;
				while (i--) {
					var element = playSheet[i].element;
					var domElement = element.domElement;
					
					var style = domElement.style;
					var display = element.display;
					if (element.placeHolder !== false) {
						var placeHolder = element.placeHolder;
					} else {
						var placeHolder = false;
					}

					var currentSheet = playSheet[i];					
					if (currentSheet.x !== false) {
						style.left = currentSheet.x + "px";
						display.x = currentSheet.x;
					}
					if (currentSheet.y !== false) {
						style.top = currentSheet.y + "px";
						display.y = currentSheet.y;
					}
					if (currentSheet.width !== false){
						style.width = currentSheet.width + "px";
						display.width = currentSheet.width;
						if (placeHolder) {
							var width = display.width;
							width += display.marginLeft;
							width += display.marginRight;
							placeHolder.style.width = width + "px";
						}
					}
					if (currentSheet.height !== false){
						style.height = currentSheet.height + "px";
						display.height = currentSheet.height;
						if (placeHolder) {
							var height = display.height;
							height += display.marginTop;
							height += display.marginBottom;
							placeHolder.style.height = height + "px";
						}
					}
					if (currentSheet.alpha !== false){
						var alpha = currentSheet.alpha * 100;
						style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + alpha + ')';
						style.filter = 'alpha(opacity=' + alpha + ')';
						style.opacity = alpha/100;
						display.alpha = alpha;
					}
				}
			}
			var lastRun = this.lastRun;
			var startTime = new Date();
			startTime = startTime.getTime();
			lastRun = startTime - lastRun;
			var nextRun = this.heartbeat - lastRun;
			nextRun = (nextRun < 0) ? 0 : nextRun;
			setTimeout(this.playAgain = function() { Page.play(); }, nextRun);
			this.active = false;
			this.lastRun = startTime;
		}
		
		Mouvement.prototype.grabItem = function(itemIdentifier) {
			var newItem = new Unit(itemIdentifier);
			var i = this.elements.length;
			while (i--) {
				if (newItem.domElement === this.elements[i].domElement) {
					return this.elements[i];
				}
			}
			this.elements.push(newItem);
			return newItem;
		}
	    
		Mouvement.prototype.move = function(element, x, y, time, ease) {
			var aniFrames = Math.ceil(time * this.fps);
//			this.elements[element].locate();
			for (var i = 0; i <= aniFrames; i++) {
				var display = element.display;
				var newX = (isNaN(x)) ? display.x : this.easeOut(display.x, x, i, aniFrames);
				var newY = (isNaN(y)) ? display.y : this.easeOut(display.y, y, i, aniFrames);
				this.addInstruction(i, new Instruction(element, newX, newY, false, false, false));
			}
			this.clearSchedule(aniFrames,element,"move");
			return true;
		}
		
		Mouvement.prototype.snapMove = function(element, x, y) {
			this.addInstruction(0, new Instruction(element, x, y));
			this.clearSchedule(1,element,"move");
			return true;
		}
		
		Mouvement.prototype.resize = function(element, width, height, time, ease) {
			var aniFrames = Math.ceil(time * this.fps);
//			this.elements[element].locate();
			for (var i = 0; i <= aniFrames; i++) {
				var display = element.display;
				var newWidth = this.easeOut(display.width, width, i, aniFrames);
				var newHeight = this.easeOut(display.height, height, i, aniFrames);
				this.addInstruction(i, new Instruction(element, false, false, newWidth, newHeight, false));
			}
			this.clearSchedule(aniFrames,element,"resize");
			return true;
		}
		Mouvement.prototype.alpha = function(element, alpha, time) {
			var aniFrames = Math.ceil(time * this.fps);
//			this.elements[element].locate();
			for (var i = 0; i <= aniFrames; i++) {
				var display = element.display;
				var newAlpha = Math.round(this.easeOut(display.alpha, alpha, i, aniFrames)) / 100;
				this.addInstruction(i, new Instruction(element, false, false, false, false, newAlpha));
			}
			this.clearSchedule(aniFrames,element,"alpha");
			return true;
		}
		
		Mouvement.prototype.addInstruction = function (frame, instruction) {
			if (this.moveQueue[frame] == undefined) {
				// Check each frame leading up to the frame to see that they exist
				for (var checkFrame = 0; checkFrame < frame; checkFrame++) {
					if (this.moveQueue[checkFrame] == undefined) {
						this.moveQueue[checkFrame] = Array();
					}
				}
				this.moveQueue[frame] = Array();
				this.moveQueue[frame].push(instruction);
				return true;
			} else {
				// Now check each of the instructions for the frame to see if they apply to the same element.
				var i = this.moveQueue[frame].length;
				while (i--) {
					var queued = this.moveQueue[frame][i];
					if (queued.element === instruction.element) {
						if (instruction.x !== false) {
							queued.x = instruction.x;
						}
						if (instruction.y !== false) {
							queued.y = instruction.y;
						}
						if (instruction.width !== false){
							queued.width = instruction.width;
						}
						if (instruction.height !== false){
							queued.height = instruction.height;
						}
						if (instruction.alpha !== false){
							queued.alpha = instruction.alpha;
						}
						return true;
					}
				}
				this.moveQueue[frame].push(instruction);
				return true;
			}
			
		}
	
		Mouvement.prototype.clearSchedule = function(frame, element, clearType) {
			var moves = this.moveQueue.length;
			if (frame < moves) {
				for (var frameNo = frame + 1; frameNo < moves; frameNo++) {
					var i = this.moveQueue[frameNo].length;
					while  (i--) {
						var currInst = this.moveQueue[frameNo][i];
						if (currInst.element === element) {
							switch (clearType) {
								case "move" :
									currInst.x = false;
									currInst.y = false;
									break;
								case "resize" :
									currInst.width = false;
									currInst.height = false;
									break;
								case "alpha" :
									currInst.alpha = false;
									break;
								default :
									break;
							}
							if (currInst.alpha === false && (currInst.y === false && (currInst.x === false && (currInst.height === false && (currInst.width === false))))) {
								this.moveQueue[frameNo].splice(i,1);
							}
						}
					}
				}
			}
			return true;
		}
		
		Mouvement.prototype.hoverFade = function(element, fadeIn, fadeOut, timeIn, timeOut) {
			fadeOut = (fadeOut == undefined) ? fadeIn : fadeOut;
			timeOut = (timeOut == undefined) ? timeIn : timeOut;
			if (element.domElement.addEventListener != undefined) {
				element.domElement.addEventListener('mouseover', function(event) { element.alpha(fadeIn, timeIn); element.domElement.style.zIndex = 4000;}, false);
				element.domElement.addEventListener('mouseout', function(event) { element.alpha(fadeOut, timeOut); element.domElement.style.zIndex = 4000;}, false);
			} else {
				element.domElement.attachEvent('onmouseover', function(event) { element.alpha(fadeIn, timeIn); element.domElement.style.zIndex = 100;});
				element.domElement.attachEvent('onmouseout', function(event) { element.alpha(fadeOut, timeOut); element.domElement.style.zIndex = 100;});
			}
		}
		
		Mouvement.prototype.preShine = function(elementId, active, flip) {
			var cloneElement = function(original, number) {
					var clone = original.cloneNode(true);
					clone.id = original.id + number;
					original.parentNode.appendChild(clone);
					return clone;
			};
			
			var shineDup = new ShineDuplicate();
			var stDiv = Page.grabItem(elementId);
			var elements = Array();
			shineDup.originalElement = stDiv;

			if (Page.isIE) { /* For browsers try to push the boundaries (albeit while ignoring the W3C) :) */
				var clone = cloneElement(stDiv.domElement,0);
				var shineStrength = this.shineStrength;
				clone.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
				clone.style.filter = 'alpha(opacity=0)';
				clone.style.opacity = 0;
				clone.style.position = "absolute";
				clone.style.left = 0 - Math.ceil(Page.shineStrength) + "px";
				clone.style.top = 0 - Math.ceil(Page.shineStrength) + "px";

				var cloneElements = clone.getElementsByTagName("img");
				var clones = cloneElements.length;
				while (clones--) {
					var currentClone = cloneElements[clones];
					currentClone.style.filter = "progid:DXImageTransform.Microsoft.Blur(pixelRadius=" + shineStrength + ")";
					currentClone.style.opacity = 0;
					elements[clones] = Page.grabItem(clone);
				}
				shineDup.cloneOver = function(event) {
					var elements = shineDup.shineElements;
					var i = elements.length;
					while (i--) {
						elements[i].alpha(Page.shineStrength*15, 0.4);
						shineDup.originalElement.domElement.zIndex = 200;
					}
				}
				shineDup.cloneOut = function(event) {
					var elements = shineDup.shineElements;
					var i = elements.length;
					while (i--) {
						elements[i].alpha(0, 0.8);
						shineDup.originalElement.domElement.zIndex = 99;
					}
				}
				var element = Page.grabItem(clone);
			} else { /* For browsers that don't have DirectX extensions but abide by the W3C, we do it the fun way :) */
				var pageClones = Array();
				var shineStrength = this.shineStrength * 4;
				
				for (var i = 0; i < shineStrength; i++) {
					var clone = cloneElement(shineDup.originalElement.domElement, i);
					var style = clone.style;
					style.position = 'absolute';
					style.zIndex = 100 + i;
					if (i%4 === 0) { // up
						style.left = "0px";
						style.top = "-" + (Math.floor(i/4)+ 1) + "px";
					} else if (i%4 === 1) { // right
						style.left = (Math.floor(i/4)+ 1) + "px";
						style.top =  "0px";
					} else if (i%4 === 2) { // down
						style.left = "0px";
						style.top = (Math.floor(i/4)+ 1) + "px";
					} else if (i%4 === 3) { // left
						style.left = "-" + (Math.floor(i/4)+ 1) + "px";
						style.top = "0px";
					}
					style.opacity = 0;
					elements[i] = Page.grabItem(clone);
					var element = elements[i];
					shineDup.cloneOver = function(event) {
						var shineStrength = Page.shineStrength;
						var i = shineStrength * 4;
						while (i--) {
	/*
							elements[i].alpha(((shineStrength + 1)) - (Math.floor(i/4) + 1), 0.5);
							shineDup.originalElement.alpha(0,0.5); // ZOMG I MADE THE FIRST EVER purely-JavaScript BLUR-ANIMATION EFFECT!*/
							elements[i].alpha(((shineStrength + 1)*5) - (Math.floor(i/4) + 1)*4, 0.8);
							shineDup.originalElement.domElement.zIndex = 200;
						}
					}
					shineDup.cloneOut = function(event) { 
						var shineStrength = Page.shineStrength;
						var i = shineStrength * 4;
						while (i--) {
							elements[i].alpha(0, 0.65);
							shineDup.originalElement.domElement.zIndex = 99;
							//shineDup.originalElement.alpha(100,0.65);
						}
					}
					if (active !== undefined && (active === true && (i === (shineStrength-1)))) {

					}
					element.display.alpha = 0;
					this.alpha(element, 0, 0.5); /*make the clone disappear gradually*/
					pageClones[i] = clone;
				}
			}
			
			totalElements = elements.length;
			for (i = 0; i < totalElements; i++) {
				shineDup.shineElements.push(elements[i]);
			}
			this.shineDuplications.push(shineDup);
			
			var mouse0 = (flip !== undefined && (flip == true)) ? "mouseout" : "mouseover";
			var mouse1 = (flip !== undefined && (flip == true)) ? "mouseover" : "mouseout";

			if (element.domElement.addEventListener != undefined) {
				clone.addEventListener(mouse0, shineDup.cloneOver, false);
				clone.addEventListener(mouse1, shineDup.cloneOut, false);
			} else {
				clone.attachEvent('on' + mouse0, shineDup.cloneOver);
				clone.attachEvent('on' + mouse1, shineDup.cloneOut);
			}
			return shineDup;
		}
				
		Mouvement.prototype.easeOut = function(x0, x1, t0, tT) {
			var xDiff = x1 - x0;
			var tDiff = t0/tT;
			if (tDiff === 0) {
				return Math.round(x0);
			}
			return (tDiff === 1) ? x1 : (xDiff > 0) ? Math.ceil(x0 + xDiff * (Math.sin((Math.PI/2*tDiff)))) : Math.floor(x0 + xDiff * (Math.sin((Math.PI/2*tDiff))));
		}
		  
		// Instruction Object ===========================================================/>
		function Instruction(element, x, y, width, height, alpha){
			this.element = element;
			(x == undefined) ? null:this.x = x;
			(y == undefined) ? null:this.y = y;
			(width == undefined) ? null:this.width = width;
			(height == undefined) ? null:this.height = height;
			(alpha == undefined) ? null:this.alpha = alpha;
			return this;
		}
		
		Instruction.prototype.element = null;
		Instruction.prototype.x = false;
		Instruction.prototype.y = false;
		Instruction.prototype.width = false;
		Instruction.prototype.height = false;
		Instruction.prototype.alpha = false;
		
		// Shine Duplication Object ===========================================================/>
		function ShineDuplicate(){ return this; }
		
		ShineDuplicate.prototype.shine = function() {
			for (i = 0; i < this.parent.shineStrength * 4; i++) {
				this.parent.alpha(this.shineElements[i], ((Page.shineStrength + 1) * 5) - (Math.floor(i/4)+ 1)*5, 0.25);
			}
		}
		
		ShineDuplicate.prototype.originalElement = null;
		ShineDuplicate.prototype.parent = null;
		ShineDuplicate.prototype.shineElements = Array();
		
		/*<// End Instruction Object =========================================================== */
	
/*<// End Movement class ==================================================================== */	

// Begin Unit class ==================================================================== />
function Unit(itemIdentifier) {
	this.domElement = this.getDOMElement(itemIdentifier);
	this.display = new DisplayModel();
	this.parent = Page;
	this.index = this.parent.elements.length;
	this.locate();
	return this;
}

	Unit.prototype.getDOMElement = function(itemIdentifier) {
		if (itemIdentifier.parentNode != undefined) {
			return itemIdentifier;			
		} else if (document.getElementById(itemIdentifier) != undefined) {
			return document.getElementById(itemIdentifier);
		} else {
			window.alert("This is not a DOM object!");
		}
		return false;
	}

	Unit.prototype.locate = function() {
		// There are three possibilities
		var element = this.domElement;
		var display = this.display;
		
		// 1. Firstly we'll get the element's dimensions.
			
			// 1.1 Find it's padding value.
			var paddingX = parseInt(this.readCSS(element, 'padding-left','paddingLeft'),10) + parseInt(this.readCSS(element, 'padding-right','paddingRight'),10);
			var paddingY = parseInt(this.readCSS(element, 'padding-top','paddingTop'),10) + parseInt(this.readCSS(element, 'padding-bottom','paddingBottom'),10);
			
			// 1.2 Find the element's actual dimensions.
			display.width = element.clientWidth - paddingX;
			display.height = element.clientHeight - paddingY;
			
			// 1.3 Set the original dimensions if they're not set.
			display.originalWidth = (display.originalWidth == -1) ? display.width : display.originalWidth;
			display.originalHeight = (display.originalHeight == -1) ? display.height : display.originalHeight;

		// 2. Next the postions (this is the hard part!).
		

			if (display.originX == -1) {
			// 2.1 The element is static and it's parent is static.
				var position = this.readCSS(element, 'position');
				var parentPosition = this.readCSS(element.parentNode, 'position');
				
				var marginLeft = parseInt(this.readCSS(element, 'margin-left', 'marginLeft'),10);
				display.marginLeft = (isNaN(marginLeft)) ? 0 : marginLeft;
				var marginTop = parseInt(this.readCSS(element, 'margin-top', 'marginTop'),10);
				display.marginTop = (isNaN(marginTop)) ? 0 : marginTop;
				var marginRight = parseInt(this.readCSS(element, 'margin-right', 'marginRight'),10);
				display.marginRight = (isNaN(marginRight)) ? 0 : marginRight;
				var marginBottom = parseInt(this.readCSS(element, 'margin-bottom', 'marginBottom'),10);
				display.marginBottom = (isNaN(marginBottom)) ? 0 : marginBottom;
				
				if (position == parentPosition && (position == "static")) {
					// We'll make the element absolute whilst leaving the parent static.
					// Create a placeholder
					var placeHolder = document.createElement("div");
					placeHolder.id = "placeHolderElement" + this.index;


					placeHolder.style.width = element.clientWidth + display.marginLeft +  display.marginRight + "px";
					placeHolder.style.height = element.clientHeight + display.marginTop +  display.marginBottom + "px";
			
					display.originX = (element.offsetLeft == display.marginLeft && (element.offsetParent != undefined)) ? element.offsetLeft + element.offsetParent.offsetLeft : element.offsetLeft;
					display.originY = (element.offsetTop == display.marginTop && (element.offsetParent != undefined)) ? element.offsetTop + element.offsetParent.offsetTop : element.offsetTop;
					
					element.style.left = (display.originX - display.marginLeft) + "px";
					element.style.top = (display.originY - display.marginTop) + "px";

					element.parentNode.insertBefore(placeHolder, element);
					element.style.position = "absolute";
					
					this.placeHolder = placeHolder;
					
					// 2.1.1 Find the parent's height as it stands.
				}
				if (position == "absolute" && (parentPosition == "static" || parentPosition == "absolute")) {
					this.position = "absolute";
					
					var newWidth = (document.documentElement.clientWidth == undefined) ? window.innerWidth : document.documentElement.clientWidth;
					newWidth = Math.round(newWidth / 2);
					
					display.originX = newWidth - (element.offsetLeft - display.marginLeft);
					display.originY = element.offsetTop;
				}
			}		
			display.x = (element.offsetLeft == display.marginLeft && (element.offsetParent != undefined)) ? element.offsetLeft + element.offsetParent.offsetLeft : element.offsetLeft - display.marginLeft;
			display.y = (element.offsetTop == display.marginTop && (element.offsetParent != undefined)) ? element.offsetTop + element.offsetParent.offsetTop : element.offsetTop - display.marginTop;

			// 2.2 The element is relative and it's parent is irrelevant

			// 2.3 The element is absolute and it's parent is absolute.
			//     We'll make the element absolute whilst leaving the parent static.
			
		
		// 3. Lastly, the alpha opacity.
		var alpha = parseInt(this.readCSS(this.domElement, 'opacity'),10)*100;
		display.displayFlag = this.readCSS(this.domElement, 'display');
	}
	
	Unit.prototype.readCSS = function(element, propertyW3C, propertyIE) {
		element = (element == undefined) ? this.domElement : this.getDOMElement(element);
		propertyIE = (propertyIE == undefined) ? propertyW3C : propertyIE;
		
		if (document.defaultView) {
			var propertyValue = document.defaultView.getComputedStyle(element, null);
			propertyValue = propertyValue.getPropertyValue(propertyW3C);
		} else if (element.currentStyle != undefined) {
			var propertyValue = element.currentStyle[propertyIE];
		}
		
		return (propertyValue != undefined) ? propertyValue : 0;
	}
	
	Unit.prototype.move = function(x, y, time, delay, futureX, futureY) {
		delay = (delay == undefined) ? 0 : (!isNaN(delay)) ? delay : 0;
		var delayFrames = Math.ceil(delay * this.parent.fps);
		var aniFrames = Math.ceil(time * this.parent.fps);
		var currX = (isNaN(futureX)) ? this.display.x : futureX;
		var currY = (isNaN(futureX)) ? this.display.y : futureY;
//		this.locate();
		for (var i = 0; i <= aniFrames; i++) {
			var newX = (isNaN(x)) ? currX : this.parent.easeOut(currX, x, i, aniFrames);
			var newY = (isNaN(y)) ? currY : this.parent.easeOut(currY, y, i, aniFrames);
			this.parent.addInstruction(i + delayFrames, new Instruction(this, newX, newY, false, false, false));
		}
		this.parent.clearSchedule(aniFrames + delayFrames,this,"move");
		return true;
	}
	
	Unit.prototype.alpha = function(alpha, time, delay, futureAlpha) {
		delay = (delay == undefined) ? 0 : (!isNaN(delay)) ? delay : 0;
		var delayFrames = Math.ceil(delay * this.parent.fps);
		var aniFrames = Math.ceil(time * this.parent.fps);
//		this.locate();
		for (var i = 0; i <= aniFrames; i++) {
			if (futureAlpha != undefined && (!isNaN(futureAlpha))) {
				var newAlpha = Math.round(this.parent.easeOut(futureAlpha, alpha, i, aniFrames)) / 100;
			} else {
				var newAlpha = Math.round(this.parent.easeOut(this.display.alpha, alpha, i, aniFrames)) / 100;
			}
			this.parent.addInstruction(i + delayFrames, new Instruction(this, false, false, false, false, newAlpha));
		}
		this.parent.clearSchedule(aniFrames + delayFrames,this,"alpha");
		return true;

	}
	
	Unit.prototype.resize = function(width, height, time, delay, futureWidth, futureHeight) {
		delay = (delay == undefined) ? 0 : (!isNaN(delay)) ? delay : 0;
		var delayFrames = Math.ceil(delay * this.parent.fps);
		var aniFrames = Math.ceil(time * this.parent.fps);
		var currWidth= (isNaN(futureWidth)) ? this.display.width : futureWidth;
		var currHeight = (isNaN(futureHeight)) ? this.display.height : futureHeight;
//		this.locate();
		for (var i = 0; i <= aniFrames; i++) {
			var newWidth = this.parent.easeOut(currWidth, width, i, aniFrames);
			var newHeight = this.parent.easeOut(currHeight, height, i, aniFrames);
			this.parent.addInstruction(i + delayFrames, new Instruction(this, false, false, newWidth, newHeight, false));
		}
		this.parent.clearSchedule(aniFrames + delayFrames,this,"resize");
		return true;
	}
	
	// Display Data Object ===========================================================/>
	function DisplayModel(){}

	DisplayModel.prototype.width = -1;
	DisplayModel.prototype.height = -1;
	DisplayModel.prototype.x = -1;
	DisplayModel.prototype.y = -1;
	DisplayModel.prototype.originX = -1;
	DisplayModel.prototype.originY = -1;
	DisplayModel.prototype.originalWidth = -1;
	DisplayModel.prototype.originalHeight = -1;
	DisplayModel.prototype.alpha = -1;
	DisplayModel.prototype.marginLeft = 0;
	DisplayModel.prototype.marginTop = 0;
	DisplayModel.prototype.marginRight = 0;
	DisplayModel.prototype.marginBottom = 0;
	DisplayModel.prototype.displayFlag = "block";
	
	/*<// End Display Data Object =========================================================== */
	
	Unit.prototype.index;
	Unit.prototype.parent;
	Unit.prototype.domElement;
	Unit.prototype.display = DisplayModel;
	Unit.prototype.placeHolder = false;
	Unit.prototype.position = "";
		
/*<// End Unit class ==================================================================== */

var Page = new Mouvement();

	loadFunction =  function() {
		window.onresize = function(){
			var newWidth = (document.documentElement.clientWidth == undefined) ? window.innerWidth : document.documentElement.clientWidth;
			newWidth = Math.round(newWidth / 2);
			for (var i = Page.elements.length - 1; i >= 0; i--) {
				// Get the parent's CSS position value
				if (Page.elements[i].position != undefined && (Page.elements[i].position == "absolute")) {
					Page.snapMove(Page.elements[i], newWidth + Page.elements[i].display.originX, Page.elements[i].display.y);
				}
			}
		};
		Page.onReady();
	};
	
	if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", loadFunction, false);
	} else {
		window.onload = loadFunction;
	}
	
	// Microsoft's own IE Detection snippet - obfuscated. (Credit to MSDN http://msdn.microsoft.com/en-us/library/ms537509(VS.85).aspx)
	var _0xb426=["\x61\x70\x70\x4E\x61\x6D\x65","\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\x20\x49\x6E\x74\x65\x72\x6E\x65\x74\x20\x45\x78\x70\x6C\x6F\x72\x65\x72","\x75\x73\x65\x72\x41\x67\x65\x6E\x74","\x4D\x53\x49\x45\x20\x28\x5B\x30\x2D\x39\x5D\x7B\x31\x2C\x7D\x5B\x2E\x30\x2D\x39\x5D\x7B\x30\x2C\x7D\x29","\x65\x78\x65\x63","\x49\x45\x38","\x49\x45"];function getInternetExplorerVersion(){var _0xa4d7x2=-1;if(navigator[_0xb426[0]]==_0xb426[1]){var _0xa4d7x3=navigator[_0xb426[2]];var _0xa4d7x4= new RegExp(_0xb426[3]);if(_0xa4d7x4[_0xb426[4]](_0xa4d7x3)!=null){_0xa4d7x2=parseFloat(RegExp.$1);} ;} ;return _0xa4d7x2;} ;function isIE(){var _0xa4d7x6=getInternetExplorerVersion();if(_0xa4d7x6>-1){if(_0xa4d7x6>=8.0){return _0xb426[5];} else {return _0xb426[6];} ;} ;return false;} ;
	Page.isIE = isIE();