<!--
/*	Site Overlays v1 - 
	Copyright Adam Walker Film 2010 - All rights reserved
*/
// overlayManager prototype class declarations---------------------
function overlayManager()//object constructor function
{
	this.overlays = new Array();
	this.overlayContainer = null;
	this.moveTimeStep = 25; // milliseconds
	this.overlayAssets = {swfOverlay: new Array("url")};
	this.browser = {type:null,versionMajor:null,versionMinor:null}
}

overlayManager.prototype.init = function(divID)
{
	//validate browser firstly
	if(this.validateBrowser())
	{
		//setup browser 
		if(this.browser.type =="Explorer")// && this.browser.versionMajor<=6)
		{
			generalOverlay.prototype.positionSet = generalOverlay_positionSet_IE6;
		}
		//create container div
		if(divID == "new")
		{
			this.overlayContainer = document.createElement("div");
		}
		else{
			this.overlayContainer = document.getElementById(divID);
		}
		
		this.overlayContainer.style.position = "absolute";
		this.overlayContainer.style.top = "0px";
		this.overlayContainer.style.left = "0px";
		this.overlayContainer.style.zIndex = 100;
		if(divID == "new")
		{
		var theBody = document.getElementsByTagName('body')[0]; 
		theBody.appendChild(this.overlayContainer);
		}
		
		// TEMP !!!!  init a overlay - temp	
		//this.addSimpleOverlay(0);
		//this.addSimpleOverlay(150);
		//this.addSimpleOverlay(300);
		//
		//swf
		var testB = this.create("assets/overlays/multiOverlay.swf","swfOverlay");
		this.overlays[testB].init();
		//var testB = this.create("birchallsOwl.swf","swfOverlay");
		//this.overlays[testB].init();
	}
}
overlayManager.prototype.addSimpleOverlay = function(offset)
{
		var buildArgs = {};
		buildArgs.size = {w:100,h:100};
		buildArgs.pos = {x:offset,y:0};
		buildArgs.posArgs = {type:"fixed",xEdge:"left",xUnit:"px",yEdge:"top",yUnit:"px"};
		buildArgs.deltaValues = {vx:6,vy:0};
		buildArgs.conditions = {move: null,size:null,lifespan:null};	
		buildArgs.conditions.move = {functionName:"condition_xStage",onComplete:"addSelfAgain"};
		var testA = this.create("birchallsTrain.swf","swfOverlay");
	//	alert("create:"+testA);
		this.overlays[testA].init();
		this.overlays[testA].build(buildArgs);
		this.overlays[testA].positionMove(buildArgs.pos,buildArgs.deltaValues,buildArgs.conditions.move);
}
overlayManager.prototype.getVersion = function(agent, searchString)
{
	var index = agent.indexOf(searchString);
	if (index == -1)
	{
		return 0;			
	}
	else
	{
		return parseFloat(agent.substring(index+searchString.length+1));
	}
}
overlayManager.prototype.validateBrowser = function()
{
	//java version (?????? too late) - no way to accuratly detect java version - use object detection(test if method can be used before using it)
	//if java turned off - will never get here anyway - javascript 1.0 is now obsolete. javascript 1.1 introduced prototype
	
	// gather browser info
	var info = navigator.userAgent;
	//detection order is very important - general rule is to check minor browsers first.
	if(info.indexOf("Chrome") != -1) //for Chrome
	{
		this.browser.type = "Chrome";
		this.browser.versionMajor = this.getVersion(info,"Chrome");

	}
	else if (info.indexOf("Apple") != -1) //for Safari
	{
		this.browser.type = "Safari";
		this.browser.versionMajor = this.getVersion(navigator.vendor,"Version");
	}
	else if (info.indexOf("Firefox") != -1) //for Firefox
	{
		this.browser.type = "Firefox";
		this.browser.versionMajor = this.getVersion(info,"Firefox");
		if(this.browser.versionMajor < 3){
			return false;	
		}
	}
	else if (info.indexOf("MSIE") != -1) //for IE
	{
		this.browser.type = "Explorer";
		this.browser.versionMajor = this.getVersion(info,"MSIE");
	}
	else if(info.indexOf("Mozilla") != -1) //all others - older
	{
		this.browser.type = "Netscape";
		this.browser.versionMajor = this.getVersion(info,"Mozilla");
	}else
	{
		return false;
		alert("Your browser does not support overlays");
	}
	return true;
	//alert("type:"+this.browser.type+" _ Version: "+this.browser.versionMajor);
}
//create instance function and assign to prototype of object constructor
overlayManager.prototype.create = function(fileUrl, type)
{
	var newID = this.createUniqueID()
	var newOverlay;
	switch(type)
	{
		case "swfOverlay":
			newOverlay = new swfOverlay(this,newID, fileUrl);
		break;
		default:
			newOverlay = new generalOverlay(this,newID);	
		break;
	}
	this.overlays[newID] = newOverlay;
	return newID;
}
overlayManager.prototype.newRandomOverlay = function(clips)
{
	var length = (clips.length <= 0) ? 0 : clips.length-1;
	var newUrl = clips[Math.round(Math.random()*(length))];
	
	var idVar = overlayController.create(newUrl,"swfOverlay");
	overlayController.overlays[idVar].init();	
}
overlayManager.prototype.remove = function(id)
{
	delete this.overlays[id];
}
overlayManager.prototype.createUniqueID = function()//also collect id's which exist to avoid duplicates
{
	var strings = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstyvwxyz0123456789";
	var uniqueKey = "";
	var num = 12;
	
	for(var i=1;i <= num; i++)
	{
		var int = Math.random()*(strings.length-1);
		uniqueKey += strings.substr(int,1);
	}
	return uniqueKey;
}
overlayManager.prototype.createInterval = function(id, fnCode, time)
{
	//becuase setInterval operates on the global object scope - call on the instance vars of the objects themselves.
	//alert(this.overlays[id]);
	if(this.overlays[id] != undefined)
	{
		var codeRun = "overlayController.overlays['"+id+"']."+fnCode+"";//code must eval on a global instance
		this.overlays[id].intervalID = setInterval(codeRun,time);
	}
}

overlayManager.prototype.removeInterval = function(id)
{
	clearInterval(this.overlays[id].intervalID);
}
overlayManager.prototype.condition_xPosition = function(id,condition)
{
	if(this.overlays[id].pos.x > condition.x)//stop at target
	{
		return true;
	}
	return false;
}
overlayManager.prototype.condition_xStagePastCentre = function(id,condition)
{
	//condition check for overlay in centre of stage.
	var scrollOffset = this.stageScrollOffset();
	if((this.overlays[id].pos.x+(this.overlays[id].size.w/2)) >= (scrollOffset.w/2))//stop at target - going right from left
	{
		return true;
	}
	return false;
}
overlayManager.prototype.condition_yStagePastCentre = function(id,condition)
{
	var scrollOffset = this.stageScrollOffset();
	if((this.overlays[id].pos.y+(this.overlays[id].size.h/2)) >= (scrollOffset.h/2))//stop at target - going down from up
	{
		return true;
	}
	return false;
}
overlayManager.prototype.condition_xStage = function(id,condition)//need to consider the fixed position overlays
{
	var scrollOffset = this.stageScrollOffset();
	if((this.overlays[id].pos.x) >= (scrollOffset.w+this.overlays[id].size.w))//stop at target
	{
		return true;
	}
	return false;
}
overlayManager.prototype.condition_yStage = function(id,condition)//need to consider the fixed position overlays
{
	var scrollOffset = this.stageScrollOffset();
	if((this.overlays[id].pos.y) >= (scrollOffset.h+this.overlays[id].size.h))//stop at target
	{
		return true;
	}
	return false;
}
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

overlayManager.prototype.stageScrollOffset = function()
{
	//window.innerWidth, h:window.innerHeight are used bu most browsers with the exception of IE
	return {x:f_scrollLeft(), y:f_scrollTop(), w:f_clientWidth(), h:f_clientHeight()};	
}
overlayManager.prototype.collectEmbedObj = function(idVal)
{		
	var swfObj = undefined;
	var id = "swf"+idVal;
	if(document[id] != undefined && document[id] != null)	
	{
			//alert(this.uniqueID+"_"+document[id]);
		switch(true)//find swf across multi browser test
		{
			case (document[id].sendToActionScript != undefined):
				swfObj = document[id];
			break;
			case (document[id][0].sendToActionScript != undefined):				
				swfObj = document[id][0];
			break;
			case (document[id][1].sendToActionScript != undefined):
				swfObj = document[id][1];
			break;
		}
		
		return swfObj;
	}
}
function generalOverlay(manager, uniqueID)//object constructor function
{
	this.managerRef = manager;
	this.uniqueID = uniqueID;
	this.intervalID = null;
	this.secondIntervalID = null;
	this.size = {w:1,h:1};
	this.pos = {x:0,y:0}
	this.posArgs = {type:"absolute",xEdge:"left",xUnit:"px",yEdge:"top",yUnit:"px"};
	this.age = 0;
	this.deltaValues = {vx:0,vy:0};
	this.conditions = {move: null,size:null,lifespan:null};
	this.overlayBuilt = false;//temp value for firefox externalInterface bug with position = fixed
	this.overlayBehaviour = null;//position problem, stop firefox calling functions twice due to the externalInterface duplicate calls
}

generalOverlay.prototype.init = function()
{
	//create container div which is used to add content whether it swf or img
	this.contentDiv = document.createElement("div");//if created in constructor is not unique
	this.contentDiv.setAttribute("id",this.uniqueID);//is null if defined in constructor
	//add to dom - at start else swf throw a about:blank error
	this.managerRef.overlayContainer.appendChild(this.contentDiv);	
}
/*
condition:
functionName, args, onComplete
*/
generalOverlay.prototype.build = function(buildArgs)
{
	if(!this.overlayBuilt || (buildArgs.rebuild != null && buildArgs.rebuild == "true"))
	{
		
		this.overlayBuilt = true;
		this.pos = buildArgs.pos;
		this.size = buildArgs.size;
		this.posArgs = buildArgs.posArgs;
		this.deltaValues = buildArgs.deltaValues;
		this.conditions = buildArgs.conditions;
		//start width/hieght
		this.contentDiv.style.width = this.size.w+"px";
		this.contentDiv.style.minWidth = this.size.w+"px";
		this.contentDiv.style.maxWidth = this.size.w+"px";
		this.contentDiv.style.height = this.size.h+"px";
		this.contentDiv.style.minHeight = this.size.h+"px";
		this.contentDiv.style.maxHeight = this.size.h+"px";
		//reset
		this.contentDiv.style.left= null; // horiz
		this.contentDiv.style.top= null; // vert	
		//start pos
		//if flash wants a random position.
		this.pos  = (buildArgs.pos.x == "center") ? this.centerPosition("x",buildArgs.pos) : this.pos;
		this.pos  = (buildArgs.pos.x == "random") ? this.randomPosition("x",buildArgs.pos) : this.pos;
		this.pos  = (buildArgs.pos.y == "random") ? this.randomPosition("y",buildArgs.pos) : this.pos;
		// -
		this.positionSet(this.pos);		
		//this.contentDiv.style.backgroundColor = "#FF0000";
		return true;
	}
}
generalOverlay.prototype.dimensionsSet = function(dimensions)
{
	
	this.contentDiv.style.width = dimensions.w+"px";
	this.contentDiv.style.minWidth = dimensions.w+"px";
	this.contentDiv.style.maxWidth = dimensions.w+"px";
	this.contentDiv.style.height = dimensions.h+"px";
	this.contentDiv.style.minHeight = dimensions.h+"px";
	this.contentDiv.style.maxHeight = dimensions.h+"px";
}
generalOverlay.prototype.continueNewBehaviour = function()
{
	//swf remains loaded, but new clip is loaded within swf.
	this.managerRef.removeInterval(this.uniqueID);
	
}
generalOverlay.prototype.remove = function()
{
	this.managerRef.removeInterval(this.uniqueID);
	this.contentDiv.innerHTML = null;
	this.managerRef.overlayContainer.removeChild(this.contentDiv);
	this.managerRef.remove(this.uniqueID);	
	this.pos = null;
	this.size = null;
	this.posArgs = null;
	this.deltaValues = null;
	this.conditions = null;
	this.managerRef = null;
}
generalOverlay.prototype.addSelfAgain = function()
{
	this.managerRef.addSimpleOverlay(0);
	this.remove();
}
generalOverlay.prototype.assignRandomOverlay = function()
{
	var clips = this.conditions.move.urls;
	this.managerRef.newRandomOverlay(clips);
	this.remove();		
	//---- temp code fix for birchells.
	//var swfObj = this.managerRef.collectEmbedObj(this.uniqueID);
	//this.managerRef.removeInterval(this.uniqueID);
	//alert("Weak Replace: "+swfObj.movie+"_"+swfObj.src);
	//swfObj.movie="birchallsTrain.swf";
}
generalOverlay.prototype.positionSet = function(position) 
{
	this.contentDiv.style.position = this.posArgs.type;
	var scl = this.managerRef.stageScrollOffset();
	this.pos.x = position.x;
	this.pos.y = position.y;
	this.contentDiv.style[this.posArgs.xEdge]= this.pos.x + this.posArgs.xUnit; // horiz
	this.contentDiv.style[this.posArgs.yEdge]= this.pos.y + this.posArgs.yUnit; // vert	
}

function generalOverlay_positionSet_IE6(position) // and IE6 or earlier special case function to fix "fixed" position issue.
{
	//warning - for position bottom to work on absolute - either have large parent div or add stage height
	var scl = this.managerRef.stageScrollOffset();
	var scrollOffset = (this.posArgs.type == "fixed") ? scl : {x:0,y:0,w:0,h:0};
	//if not bottom - zero out {w, h}
	scrollOffset = (this.posArgs.yEdge == "bottom") ? {x:scrollOffset.x,y:-scrollOffset.y,w:0,h:scl.h} : {x:scrollOffset.x,y:scrollOffset.y,w:0,h:0}; 
	scrollOffset = (this.posArgs.xEdge == "right") ? {x:-scrollOffset.x,y:scrollOffset.y,w:scl.w,h:scrollOffset.h} : {x:scrollOffset.x,y:scrollOffset.y,w:0,h:scrollOffset.h};
	//assign:
	this.contentDiv.style.position = (this.posArgs.type == "fixed" && this.contentDiv.style.position != "absolute") ? "absolute" : this.contentDiv.style.position;
	this.pos.x = position.x;
	this.pos.y = position.y;	
	this.contentDiv.style[this.posArgs.xEdge]= ((this.pos.x-scrollOffset.w)+scrollOffset.x) + this.posArgs.xUnit; // horiz
	this.contentDiv.style[this.posArgs.yEdge]= ((this.pos.y-scrollOffset.h)+scrollOffset.y) + this.posArgs.yUnit; // vert
}
generalOverlay.prototype.randomPosition = function(axis,posVal)
{
	if(axis == "x"){
		
		var scl = this.managerRef.stageScrollOffset();
		var xVal = this.size.w+(Math.random()*(scl.w-(this.size.w*2)));
		return ({x:xVal,y:posVal.y});
	}else{
		var scl = this.managerRef.stageScrollOffset();
		var y = this.size.h+(Math.random()*(scl.h-(this.size.h*2)));
		return ({x:posVal.x,y:yVal});
	}
}
generalOverlay.prototype.centerPosition = function(axis,posVal)
{
	if(axis == "x"){
		
		var scl = this.managerRef.stageScrollOffset();
		var xVal = (scl.w/2)-(this.size.w/2);
		return ({x:xVal,y:posVal.y});
	}else{
		var scl = this.managerRef.stageScrollOffset();
		var yVal = (scl.h/2)-(this.size.h/2);
		return ({x:posVal.x,y:yVal});
	}
}
generalOverlay.prototype.positionStand = function()//TEMP - IE6 and less require active interval for scroll update
{
	if(this.managerRef.browser != null && this.managerRef.browser.type =="Explorer")// && this.managerRef.browser.versionMajor<=6)
	{
		this.managerRef.createInterval(this.uniqueID,"positionStandInt()",this.managerRef.moveTimeStep);
	}
}
generalOverlay.prototype.positionMove = function(position,deltaValues,condition)
{
	if(this.overlayBehaviour != "move")
	{
		this.overlayBehaviour = "move";
		this.pos.x = position.x;
		this.pos.y = position.y;
		this.deltaValues.vx = deltaValues.vx;
		this.deltaValues.vy = deltaValues.vy;
		this.conditions.move = condition;
		//call setInterval from manager - provide id, fnCode, time
		this.managerRef.createInterval(this.uniqueID,"positionMoveInt()",this.managerRef.moveTimeStep);
	}
}
generalOverlay.prototype.performAct = function()
{
	//swf will now stop moving than perform a act, before moving off again	
	if(this.overlayBehaviour != "performAct")
	{
		this.overlayBehaviour = "performAct";
		this.managerRef.removeInterval(this.uniqueID);
		
		var swfObj = this.managerRef.collectEmbedObj(this.uniqueID);
	
		//alert(fixExternalInterface(swfObj,"sendToActionScript"));
		swfObj.sendToActionScript({result:"performAct"});
	}
}
generalOverlay.prototype.positionStandInt = function()
{
	this.positionSet({x:(this.pos.x),y:(this.pos.y)});
}

generalOverlay.prototype.positionMoveInt = function()
{
	this.positionSet({x:(this.pos.x+this.deltaValues.vx),y:(this.pos.y+this.deltaValues.vy)});
	//test condition
	if(this.managerRef[this.conditions.move.functionName] != undefined && this.managerRef[this.conditions.move.functionName](this.uniqueID,this.conditions.move))
	{
		//run onComplete function
		if(this.conditions.move.onComplete != undefined)
		{
			this[this.conditions.move.onComplete]()	;
		}
	}
	else
	{
		//default condition	
	}
}
generalOverlay.prototype.startLiving = function() // for future ideas only!!!!!!!
{
	this.managerRef.createInterval(this.uniqueID,"growOlder()",1000);
}
generalOverlay.prototype.growOlder = function() // for future ideas only!!!!!!!
{
	this.age ++;
	// do condition test (i.e. then kill itself......)
}
swfOverlay.prototype = new generalOverlay();        
swfOverlay.prototype.constructor=swfOverlay;    
swfOverlay.prototype.parent = generalOverlay.prototype;
function swfOverlay(manager, uniqueID, url)
{ 
	//inherits parent values, but need to define passed values here - is no super call
	this.managerRef = manager;
	this.uniqueID = uniqueID;
	this.embedStr = undefined;
	//new values
	this.fileUrl = url;//TEMP - could be an array or sourced from directory via php
}
swfOverlay.prototype.init = function()//overide with super function
{
	this.parent.init.call(this);//the 'this' specifies the object scope the function will be called on.
	
	//if firefox browser scrolled, position fixed has no focus and div is off screen, so move container into focus
	//in firefox - if swf div not in view area, no externalInterface calls work.
	var scl = this.managerRef.stageScrollOffset();
	this.contentDiv.style.position = "absolute";
	this.contentDiv.style.left= (scl.w + scl.x-500) + "px"; // horiz
	this.contentDiv.style.top= 0 + "px"; // vert	
	this.contentDiv.style.width = 500+"px";
	this.contentDiv.style.minWidth = 500+"px";
	this.contentDiv.style.maxWidth = 500+"px";
	this.contentDiv.style.height = 500+"px";
	this.contentDiv.style.minHeight = 500+"px";
	this.contentDiv.style.maxHeight = 500+"px";
	//this.filename = this.fileUrl.match(/([^\/]*?)(\.[^\.\/]*)?$/)[1];//check cross plarform usage
	//construct flash embed
	//this.embedObject();
	//this.contentDiv.innerHTML=this.embedStr;
	this.contentDiv.innerHTML ="<div id=\"swfObj"+this.uniqueID+"\"></div>";//;
	swfobject.embedSWF(this.fileUrl, "swfObj"+this.uniqueID, '100%', '100%', '9.0.45',null, {uniqueID: this.uniqueID}, {allowscriptaccess: 'always', bgcolor: '#000000', menu: 'false', wmode: 'transparent'}, {allowscriptaccess: 'always', bgcolor: '#000000', menu: 'false', wmode: 'transparent',uniqueID: this.uniqueID});
}
swfOverlay.prototype.embedObject = function()
{
	var requiredMajorVersion = 9;
	var requiredMinorVersion = 0;
	var requiredRevision = 0;
	var id = "swf"+this.uniqueID;
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	if(hasRightVersion)
	{
		
		//AC_RunContent performs a similar thing but uses document.write which replaces page after it has loaded
		var str ="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='100%'";
		str +="	height='100%' id='"+id+"' align='middle'>	<param name='allowScriptAccess' value='always' />";
		str +="	<param name='allowFullScreen' value='false' />";
		str +="	<param name='wmode' value='transparent' />";
		str +=" <param name='menu' value='false' />";
		str +="	<param name='movie' value='"+this.fileUrl+"' />";
		str +="	<param name='FlashVars' value='uniqueID="+this.uniqueID+"' />";
		str +="	<param name='quality' value='high' /><param name='bgcolor' value='#000000' />";		
		str +="	<embed src='"+this.fileUrl+"' FlashVars='uniqueID="+this.uniqueID+"'"; 
		str +="	id='"+id+"' ";
		str +="	quality='high' ";
		str +="	bgcolor='#000000'"; 
		str +="	width='100%' ";
		str +="	height='100%' name='"+id+"' align='middle' allowScriptAccess='always' ";
		str +="	allowFullScreen='false' type='application/x-shockwave-flash' ";
		str +="	pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='transparent'/>";
		str +="</object>";
		this.embedStr = str;
	}
	else
	{
		
		//swf overlay not supported by browser	
	}
}//External Interface Memory leak fixees
swfOverlay.prototype.build = function(buildArgs)
{
	this.parent.build.call(this,buildArgs);
	var id = "swf"+this.uniqueID;
	//var swfObj = document.getElementById(id);
	//var swfObj = this.managerRef.collectEmbedObj(this.uniqueID);
	//alert(swfObj)
	//makeCallable(swfObj, "sendToActionScript");
}
swfOverlay.prototype.remove = function()
{
	var swfObj = this.managerRef.collectEmbedObj(this.uniqueID);
	/*__flash__removeCallback(swfObj,"sendToActionScript");
	swfObj["sendToActionScript"] = null;
	__flash__arrayToXML = null;
	__flash__argumentsToXML = null;
	__flash__objectToXML = null;
	__flash__escapeXML = null;
	__flash__addCallback = null;
	__flash__removeCallback = null;*/
	this.parent.remove.call(this);
}
//-----------------------------------------------------------------------------------------------------------------------------END MANAGER
function receivedFromActionScript(data)
{
	//!!!!!! data will include function name.
	//WARNING - each call is called twice in firefox due to setting position="fixed";
	var returnVal = false;	
	switch(data.functionName)
	{
		case "build":	
			
			overlayController.overlays[data.uniqueID].build(data.buildArgs);			
			return ({result:data.buildArgs.functionName});//?
		break;
		case "newRandomOverlay":
			overlayController.overlays[data.uniqueID].remove();	
			overlayController.newRandomOverlay(data.urls);					
		break;
		case "positionStand":
			overlayController.overlays[data.uniqueID].positionStand();
		break;
		case "positionMove":
			var overlay = overlayController.overlays[data.uniqueID];
			overlay.positionMove(overlay.pos,overlay.deltaValues,overlay.conditions.move);
		break;
		case "positionMoveToEdge":			
			var overlay = overlayController.overlays[data.uniqueID];
			overlay.conditions.move = data.conditions;
			//overlay.pos.x += 150;//data.offset.x;
			overlay.positionMove(overlay.pos,overlay.deltaValues,overlay.conditions.move);
		break;
		case "disableTimeout":
			var overlayInst = overlayController.overlays[data.uniqueID];
			overlayInst.positionSet({x:0,y:0});
			overlayInst.dimensionsSet({w:0,h:0});
		break;
	}
}
function onLoadEvent(funcToAppend) 
{ 
	//does not reconize object prototype scope - runs on global object
	var oldonload = window.onload; 
	if (typeof window.onload != 'function')//a previous onload event has not been defined 
	{ 
		window.onload = funcToAppend;
	} 
	else//append new function to old functions in onload event
	{ 
		window.onload = function() 
		{ 
			if (oldonload) 
			{ 
				oldonload(); 
			} 
			funcToAppend(); 
		} 
	} 
} 
var str = String(window.location);
if((str.indexOf("admin") == -1))
{
//initialize manager
	var overlayController = new overlayManager();
	onLoadEvent(function(){overlayController.init("new")});
//overlayController.init();
}
// -->
