/***********************
*
*
*	PLEASE DO NOT MODIFY THIS WITHOUT SPEAKING WITH CHRIS (chrisf@infoex.com)
*	OR DANIEL (daniel@infoex.com) FIRST AS (a) WE WOULD LIKE TO KEEP IT IN SYNC AND 
*	(b) LICENSING HASN'T BEEN RESOLVED
*
*
************************/

//File Information:
//Version: $Revision: 974 $
//Last Changed By: $Author: cfrommann $ on $Date: 2007-07-02 23:19:51 -0400 (Sun, 02 Jul 2007) $

// lib/animate.js
//  JS animation library

/* iWebPress - A Newspaper Administration tool
 * http://www.iwebpress.com
 * Copyright (C) 2002-2009 iWebPress, Inc., et al except where otherwise noted
 *
 * This program is protected by copyright.  Redistribution 
 * is prohibited without express written consent of the
 * authors.  You can find contact information on iwebpress.com.
 *
 * This program is distributed in the hope that it will be 
 * useful, but WITHOUT ANY WARRANTY; without even the 
 * implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE.
 */

function Animator(obj) {
	this.obj = obj;
	
	this.changeDimensions = function(widthf, heightf, steps, intervals, powr, nextOp) {
		var curStep = 0;
		var obj = this.obj;
		var widthi = parseInt(getStyle(this.obj,'width'));
		var heighti = parseInt(getStyle(this.obj,'height'));
		
		if( !(widthi || widthf) && !(heighti || heightf) ) return false;
		
		if(obj.dimensionsInterval)
			window.clearInterval(obj.dimensionsInterval);
		obj.dimensionsInterval = window.setInterval(
			function() {
				if(widthi) 
					obj.style.width = _easeInOut(widthi,widthf,steps,curStep++,powr) + 'px';
				if(heighti)
					obj.style.height = _easeInOut(heighti,heightf,steps,curStep++,powr) + 'px';
				if (curStep > steps) {
					window.clearInterval(obj.dimensionsInterval);
					if(nextOp)
						setTimeout(nextOp,1);
				}
			} 
		,intervals);
	}
	
	this.changeHeight = function(heightf, steps, intervals, powr, nextOp) {
		var curStep = 0;
		var obj = this.obj;
		var heighti = parseInt(getStyle(this.obj,'height'));

		if(!(heighti || heightf)) return false;
		
		if(obj.dimensionsInterval)
			window.clearInterval(obj.dimensionsInterval);
		obj.dimensionsInterval = window.setInterval(
			function() {
				obj.style.height = _easeInOut(heighti,heightf,steps,curStep++,powr) + 'px';
				if (curStep > steps) {
					window.clearInterval(obj.dimensionsInterval);
					if(nextOp)
						setTimeout(nextOp,1);
				}
			} 
		,intervals);
	}
	
	this.changeWidth = function(widthf, steps, intervals, powr, nextOp) {
		var curStep = 0;
		var obj = this.obj;
		var widthi = parseInt(getStyle(this.obj,'width'));

		if(!(widthi || widthf)) return false;
		
		if(obj.dimensionsInterval)
			window.clearInterval(obj.dimensionsInterval);
		obj.dimensionsInterval = window.setInterval(
			function() {
				obj.style.width = _easeInOut(widthi,widthf,steps,curStep++,powr) + 'px';
				if (curStep > steps) {
					window.clearInterval(obj.dimensionsInterval);
					if(nextOp)
						setTimeout(nextOp,1);
				}
			} 
		,intervals);
	}
	
	this.changeMargin = function(marginf, margin, steps, intervals, powr, nextOp) {
		var curStep = 0;
		var obj = this.obj;
		var margini = parseInt(getStyle(this.obj,'margin-'+margin));
		if(!(margini || marginf)) return false;
		if(obj.dimensionsInterval)
			window.clearInterval(obj.dimensionsInterval);
		obj.dimensionsInterval = window.setInterval(
			function() {
				switch(margin) {
					case 'left':
						obj.style.marginLeft = _easeInOut(margini,marginf,steps,curStep++,powr) + 'px';
						break;
					case 'right':
						obj.style.marginRight = _easeInOut(margini,marginf,steps,curStep++,powr) + 'px';
						break;
					case 'top':
						obj.style.marginTop = _easeInOut(margini,marginf,steps,curStep++,powr) + 'px';
						break;
					case 'bottom':
						obj.style.marginBottom = _easeInOut(margini,marginf,steps,curStep++,powr) + 'px';
						break;
				}
				if (curStep > steps) {
					window.clearInterval(obj.dimensionsInterval);
					if(nextOp)
						setTimeout(nextOp,1);
				}
			} 
		,intervals);
	}
	
	this.setDimensions = function(width,height) {
		this.obj.style.width = width + 'px';
		this.obj.style.height = height + 'px';
	}
	
	this.setHeight = function(height) {
		this.obj.style.height = height + 'px';
	}

	this.changeOpacity = function(opacityf, steps, intervals, powr, nextOp) {
		if( opacityf < 0 && opacityf > 100 ) return false;
		
		var curStep = 0;
		var obj = this.obj;
		var opacityi = this.getOpacity()==null ? 100 : this.getOpacity();
		//Dirty IE 6 hack
		if(document.all && opacityf>=99) {
			opacityi = 0;
		}

		if(obj.opacityInterval) {
			window.clearInterval(obj.opacityInterval);
		}
		obj.opacityInterval = window.setInterval(
			function() {
				var opac = _easeInOut(opacityi,opacityf,steps,curStep++,powr);
				if(document.all) {
					obj.style.filter = 'alpha(opacity=' + opac + ')';
				} else {
					if(ua.indexOf("safari") != -1 || ua.indexOf("konqueror") != -1) {
						obj.style.opacity = opac / 100; //DOM3
					} else if(ua.indexOf("gecko") != -1) {
						obj.style.MozOpacity = opac / 100;
					}
				}
				if (curStep > steps) {
					window.clearInterval(obj.opacityInterval);
					if(nextOp)
						setTimeout(nextOp,1);
				}
			} 
		,intervals);
	}
	
	this.setOpacity = function(opac) {
		if(document.all) {
			this.obj.style.filter = 'alpha(opacity=' + opac + ')';
		} else {
			if(ua.indexOf("safari") != -1 || ua.indexOf("konqueror") != -1) {
				this.obj.style.opacity = opac / 100; //DOM3
			} else if(ua.indexOf("gecko") != -1) {
				this.obj.style.MozOpacity = opac / 100;
			}
		}
	}
	
	this.getOpacity = function() {
		if(document.all) {
			try { //Ahhhhh
				return this.obj.style.filter.alpha.opacity;
			} catch(e) {
				return 100;
			}
		} else {
			if(ua.indexOf("safari") != -1 || ua.indexOf("konqueror") != -1) {
				return getStyle(this.obj,'opacity') * 100;
			} else if(ua.indexOf("gecko") != -1) {
				return getStyle(this.obj,'MozOpacity') * 100;
			}
		}
	}
	
	this.movePositionCartesian = function(xf, yf, steps, intervals, powr, nextOp) {			
		var curStep = 0;
		var obj = this.obj;
		var xi = parseInt(getStyle(this.obj,'left'));
		var yi = parseInt(getStyle(this.obj,'top'));
		
		if(!getStyle(this.obj,'position'))
			this.obj.style.position = 'relative';

		if(obj.positionInterval)
			window.clearInterval(obj.positionInterval);
		obj.positionInterval = window.setInterval(
			function() {
				if(xi || xf)
					obj.style.left = _easeInOut(xi,xf,steps,curStep++,powr) + 'px';
				if(yi || yf)
					obj.style.top = _easeInOut(yi,yf,steps,curStep++,powr) + 'px';
				if (curStep > steps) {
					window.clearInterval(obj.positionInterval);
					if(nextOp)
						setTimeout(nextOp,1);
				}
			} 
		,intervals);
	}
	
	this.oscillateX = function(times, distance, steps, intervals, powr, nextOp) {
		var curTime = 0;
		var curStep = 0;
		var obj = this.obj;
		var xi = parseInt(getStyle(this.obj,'left'));
		var xf = xi - (distance / 2);
		
		if(!getStyle(this.obj,'position'))
			this.obj.style.position = 'relative';

		if(obj.positionInterval)
			window.clearInterval(obj.positionInterval);
		obj.positionInterval = window.setInterval(
			function() {
				obj.style.left = _easeInOut(xi,xf,steps,curStep++,powr) + 'px';
				if (curStep > steps) {
					if(curTime > times) {
						window.clearInterval(obj.positionInterval);
						if(nextOp)
							setTimeout(nextOp,1);
					} else {
						curTime++;	
						if(curTime % 2 == 0) {
							xi = xf;
							xf = xi - ((curTime>times) ? distance/2 : distance);
						} else {
							xi = xf;
							xf = xi + ((curTime>times) ? distance/2 : distance);
						}
						curStep = 0;
					}
					
				}
			}
		,intervals);
	}
	
	this.setPosition = function(x, y) {
		if(!getStyle(this.obj,'position'))
			this.obj.style.position = 'relative';
		this.obj.style.left = x + 'px';
		this.obj.style.top = y + 'px';
	}
	
	this.movePositionPolar = function(r, thetaf, steps, intervals, powr, nextOp) {
		var curStep = 0;
		var obj = this.obj;
		var xi = parseInt(getStyle(this.obj,'left'));
		var yi = parseInt(getStyle(this.obj,'top'));
		
		if(!getStyle(this.obj,'position'))
			this.obj.style.position = 'relative';

		if(obj.positionInterval)
			window.clearInterval(obj.positionInterval);
		obj.positionInterval = window.setInterval(
			function() {
				var theta = _easeInOut(1,thetaf*1000,steps,curStep++,powr)/1000;
				obj.style.left = ((eval(r) * Math.cos(theta))+xi) + 'px';
				obj.style.top = (-(eval(r) * Math.sin(theta))+yi) + 'px';
				
				if (curStep > steps) {
					window.clearInterval(obj.positionInterval);
					if(nextOp)
						setTimeout(nextOp,1);
				}
			} 
		,intervals);
	}
	
	this.hide = function(nextOp) {
		this.obj.style.visibility = 'hidden';
		if(nextOp)
			setTimeout(nextOp,1);
	}
	
	this.show = function(nextOp) {
		this.obj.style.visibility = 'visible';
		if(nextOp)
			setTimeout(nextOp,1);
	}
	
	this.collapse = function(nextOp) {
		this.obj.style.display = 'none';
		if(nextOp)
			setTimeout(nextOp,1);
	}
	
	this.expand = function(nextOp) {
		this.obj.style.display = 'block';
		if(nextOp)
			setTimeout(nextOp,1);
	}
	
	this.stop = function() {
		if(this.obj.dimensionsInterval)
			window.clearInterval(this.obj.dimensionsInterval);
		if(this.obj.positionInterval)
			window.clearInterval(this.obj.positionInterval);
		if(this.obj.opacityInterval)
			window.clearInterval(this.obj.opacityInterval);
	}
	
	_easeInOut = function(min,max,totalSteps,actualStep,powr) { 
		//Generic Animation Step Value Generator By www.hesido.com 
		var delta = max - min;
		var stepp = min + (Math.pow((actualStep / totalSteps), powr) * delta);
		return Math.ceil(stepp);
	} 
}

/****************************************************************************************
*			Methods below makes use of animation										*
*****************************************************************************************/


/*
* Modified from iWP Code to use divs instead of lis (I don't have time to tame them...again)
*/

function Paginate(node,instance) {
	this.node = node;
	this.current = null;
	this.expanding = false;
	
	var tab,contents,height,eContents;
	for(var i = 0; i < this.node.childNodes.length; i++) {
		if(this.node.childNodes[i].nodeName == 'DIV' && 
			this.node.childNodes[i].childNodes.length > 0 &&
			this.node.childNodes[i].firstChild.nodeName == 'A') {
				div = this.node.childNodes[i];
				anchor = this.node.childNodes[i].firstChild;
				contents = document.getElementById(anchor.getAttribute('tab'));
				if(contents) {
					height = parseInt(getStyle(contents,'height'));
					defineAttribute(anchor,'contentHeight',height);
					eContents = new Animator(contents);
					eContents.setHeight(document.all ? 3 : 1);
					eContents.setOpacity(0);
					
					div.onmouseover = function() {
						a = new Animator(this);
						if(!eval(instance).current)
							a.changeDimensions(220, 180, 50, 2, .5, function() {});
						a.setOpacity(99);
						//this.style.backgroundImage = getStyle(this,"background-image").replace(/\.gif/g,"l.gif");
					}
					div.onmouseout = function() {
						a = new Animator(this);
						if(!eval(instance).current)
							a.changeDimensions(150, 180, 50, 2, .5, function() {});
						a.setOpacity(85);
					}
					div.onclick = function() {
						a = new Animator(this);
						p = new Animator(this.parentNode);
						
						if(this == eval(instance).current) return;
						var anchor = this.firstChild;
						var height = parseInt(anchor.getAttribute('contentHeight')) + 20; //+20 for padding
						
						eContents = new Animator(document.getElementById(anchor.getAttribute('tab')));
						
						if(eval(instance).current) {
							prev = new Animator(eval(instance).current);
							prev.changeDimensions(150, 180, 50, 2, .5, function() {});
							a.changeDimensions(220, 180, 50, 2, .5, function() {});
							cContents = new Animator(document.getElementById(eval(instance).current.firstChild.getAttribute('tab')));
							cContents.changeOpacity(0,10,50,2,function() {
								cContents.setHeight(document.all ? 3 : 1);
								eContents.setHeight(height);
								eContents.changeOpacity(85,10,50,2);
							});
						} else {
							p.movePositionCartesian(0, 25, 10, 2, 1.5, function() {});
							//a.changeDimensions(150, 180, 50, 2, .5, function() {});
							a.setOpacity(99);
							eContents.setHeight(height);
							eContents.changeOpacity(85,10,50,2);
						}
						
						eval(instance).current = this;
						return false;
					}
				} 
			}
	}
}









function Tabinate(node, instance, tabs) {
	this.node = node;
	this.current = null;
	this.tabs = tabs==null ? null : tabs;
	this.first=true;
	
	this.onclickHandler = function(th) {
		this.focus(th,function() {
			//cContents.changeOpacity(0,10,50,2,function() {
			cContents.setOpacity(0);
			//cContents.setHeight(1);
			cContents.collapse();
			eContents.expand();
			//AS = new AlertSizing($(this.getAttribute('tab')),'AS');
			//eContents.setHeight(height);
			eContents.changeOpacity(99,10,50,2);
			//});
		});
	}
	
	this.focus = function(th, transition) {
		if(th == eval(instance).current) return;
		
		if(eval(instance).externalLoader) {
			eval(instance).externalLoader(th);
		}
		
		if(th.getAttribute("execute"))
			eval(th.getAttribute("execute"));
	
		var height = parseInt(th.getAttribute('contentHeight')) + 20; //+20 for padding
	
		eContents = new Animator($(th.getAttribute('tab')));
		cContents = new Animator($(eval(instance).current.getAttribute('tab')));
	
		th.className = 'current';
		eval(instance).current.className = '';
		eval(instance).current = th;
		
		if(!transition) {
			cContents.collapse();
			eContents.expand();
		} else {
			transition();
		}
			
	}
	
	this.attach = function(tab) {
		var contents,height,eContents;
		contents = $(tab.getAttribute('tab'));

		if(contents) {
			//height = parseInt(getStyle(contents,'height'));
			//defineAttribute(tab,'contentHeight',height);
			eContents = new Animator(contents);
			
			var currentHash = location.href.match(/#\_(\w.*)/);
			
			if((this.first && !this.current) || (this.current.getAttribute('tab') == tab.getAttribute('tab'))) {
				tab.className = 'current';
				this.current = tab;
				this.first=false;	
			} else if(currentHash && currentHash.length > 0 && currentHash[1] == tab.getAttribute('tab')) {
				if(this.current) {
					cContents = new Animator($(this.current.getAttribute('tab')));
					this.current.className = '';
					cContents.collapse();
				}
				eContents = new Animator($(tab.getAttribute('tab')));
				tab.className = 'current';
				this.current = tab;
				eContents.expand();			
			} else {
				//eContents.setHeight(1);
				eContents.setOpacity(0);
				eContents.collapse();
			}
			tab.onclick = function() {
				if(eval(instance).onclickHandler)
					eval(instance).onclickHandler(this);
			}
			tab.onmousedown = function() {
				if(eval(instance).onmousedownHandler)
					eval(instance).onmousedownHandler(this);
			}
			tab.onmouseup = function() {
				if(eval(instance).onmouseupHandler)
					eval(instance).onmouseupHandler(this);
			}
		}
	}
	
	this.build = function() {
		var tab,j=0;
		
		if(this.tabs==null || this.tabs.length < 1) {
			this.tabs = new Array(this.node.childNodes.length);
			for(var i = 0; i < this.node.childNodes.length; i++) {
				if(this.node.childNodes[i].nodeName == 'LI' && 
					this.node.childNodes[i].childNodes.length > 0 &&
					this.node.childNodes[i].firstChild.nodeName == 'A') {
						tab = this.node.childNodes[i].firstChild;
						this.tabs[j++] = tab;
						this.attach(tab);
				}
			}
		} else {
			for(var i = 0; i < this.tabs.length; i++) {
				this.attach(this.tabs[i]);
			}
		}
	}
	
	this.build();
}

function Modulate(node,instance,modules) {
	this.node = node;
	this.memory = ""+cookieRead("InfoExNav");
	this.memorySet = (this.memory!="" && this.memory!=null && this.memory!="null");
	this.editableTimeout;
	this.modules = modules==null ? null : modules;
	this.firstTime = true;

	this.onclickHandler = function(th) {
		var contents = $(th.getAttribute('module'));
		if(getStyle(contents,'display') == "none") {
			if(contents.parentNode.className.indexOf("-0")>0) {
				var count = 1;
				if(contents.parentNode.getAttribute("neighbours")) {
					var neighbours = contents.parentNode.getAttribute("neighbours").split(",");
				
					for(var j=0; j<neighbours.length; j++) {
						if($(neighbours[j]).className.indexOf("-0")<0)
							count++;
					}
					for(var j=0; j<neighbours.length; j++) {
						$(neighbours[j]).className = $(neighbours[j]).className.replace(/\-[1-9]/g,"-"+count);
					}
				}
				contents.parentNode.className = contents.parentNode.className.replace(/\-0/g,"-"+count);
			}
	
			//var height = parseInt(th.getAttribute('contentHeight'));
		
			eContents = new Animator(contents);
			eContents.expand();
			//eContents.setHeight(height);
			contents.style.overflow = "visible";
			eContents.changeOpacity(99,10,25,2);
		
			//eContents.setOpacity(99.9);
			//eContents.changeHeight(height,10,50,1,function() {
			//	contents.style.overflow = "visible";
			//});
		
			th.className = "active";
			if(eval(instance).memory.indexOf(":"+th.getAttribute('module')+":")<0) {
				eval(instance).memory += ":"+th.getAttribute('module')+":";
				cookieCreate("InfoExNav",eval(instance).memory,28);
			}
		} else {
			contents.style.overflow = "hidden";
			cContents = new Animator(contents);
			//cContents.changeOpacity(0,10,50,1);
		
			cContents.changeOpacity(0,10,25,2,function() {
			//cContents.changeHeight(1,10,50,2,function() {
				cContents.collapse();
				if(isCollapsed(contents.parentNode)) {
					if(contents.parentNode.getAttribute("neighbours")) {
						var neighbours = contents.parentNode.getAttribute("neighbours").split(",");
						var count = 0;
						for(var j=0; j<neighbours.length; j++) {
							if($(neighbours[j]).className.indexOf("-0")<0)
								count++;
						}
						for(var j=0; j<neighbours.length; j++) {
							$(neighbours[j]).className = $(neighbours[j]).className.replace(/\-[1-9]/g,"-"+count);
						}
					}
					contents.parentNode.className = contents.parentNode.className.replace(/\-[0-9]+/g,"-0");
				}
			});
		
		
			th.className = "";

			eval(instance).memory = eval(instance).memory.replace(":"+th.getAttribute('module')+":","");
			cookieCreate("InfoExNav",eval(instance).memory,28);
		}
		
	}
	
	this.attach = function(module) {
		var contents,height,itemCount,neighbours,count,eContents;
		
		contents = $(module.getAttribute('module'));

		if(contents) {
			//height = parseInt(getStyle(contents,'height'));
			itemCount = parseInt(contents.getAttribute('itemCount'));
			//defineAttribute(module,'contentHeight',height);
			
			var countDisplay = module.parentNode.childNodes[1];
			if(itemCount > 0) {
				//alert("A "+itemCount);
				//if(countDisplay.className == "alertSpacer") {
					countDisplay.className = "alertCount";
					if(itemCount<10)
						countDisplay.innerHTML = "<span>&nbsp;"+itemCount+"&nbsp; </span>";
					else
						countDisplay.innerHTML = "<span>"+itemCount+"</span>";
				//}
				if(!this.memorySet) {
					this.memory += ":"+module.getAttribute('module')+":";
				}
			} else {
				//alert("B "+itemCount);
				countDisplay.className = "alertSpacer";
				countDisplay.innerHTML = "";
			}
		
			if(getStyle(contents,'display') == "block" && (this.memory.indexOf(":"+module.getAttribute('module')+":") >= 0 || !this.firstTime)) {
				module.className = "active";
				if(this.memory.indexOf(":"+module.getAttribute('module')+":")<0) {
					this.memory += ":"+module.getAttribute('module')+":";
				}
			} else {
				module.className = "";
				cContents = new Animator(contents);
				cContents.setOpacity(1);
				cContents.collapse();
				this.memory = this.memory.replace(":"+module.getAttribute('module')+":","");
			
				if(isCollapsed(contents.parentNode)) {
					if(contents.parentNode.getAttribute("neighbours")) {
						neighbours = contents.parentNode.getAttribute("neighbours").split(",");
						count = 0;
						for(var j=0; j<neighbours.length; j++) {
							if($(neighbours[j]).className.indexOf("-0")<0)
								count++;
						}
						for(var j=0; j<neighbours.length; j++) {
							$(neighbours[j]).className = $(neighbours[j]).className.replace(/\-[1-9]/g,"-"+count);
						}
					}
					contents.parentNode.className = contents.parentNode.className.replace(/\-[0-9]+/g,"-0");
				}
			}
			
			cookieCreate("InfoExNav",this.memory,28);
			if(getElementsByClassName('closeButton', 'div', contents).length>0) { //there's a close button
				getElementsByClassName('closeButton', 'div', contents)[0].getElementsByTagName("A")[0].onclick = function() {
					if(eval(instance).onclickHandler)
						eval(instance).onclickHandler(module);
				}
			}
			
			module.onclick = function() {
				if(eval(instance).onclickHandler)
					eval(instance).onclickHandler(this);
			}
			module.onmousedown = function() {
				if(eval(instance).onmousedownHandler)
					eval(instance).onmousedownHandler(this);
			}
			module.onmouseup = function() {
				if(eval(instance).onmouseupHandler)
					eval(instance).onmouseupHandler(this);
			}
			contents.onclick = function() {
				if(eval(instance).contentsOnclickHandler)
					eval(instance).contentsOnclickHandler(this);
			}
			contents.onmousedown = function() {
				if(eval(instance).contentsOnmousedownHandler)
					eval(instance).contentsOnmousedownHandler(this);
			}
			contents.onmouseup = function() {
				if(eval(instance).contentsOnmouseupHandler)
					eval(instance).contentsOnmouseupHandler(this);
			}
		}
	}
		
		
	this.build = function() {
		var module,j=0;

		if(this.modules==null || this.modules.length < 1) {
			this.modules = new Array(this.node.childNodes.length);
			for(var i = 0; i < this.node.childNodes.length; i++) {
				if(this.node.childNodes[i].nodeName == 'LI' && 
					this.node.childNodes[i].childNodes.length > 0 &&
					this.node.childNodes[i].firstChild.nodeName == 'A') {

					module = this.node.childNodes[i].firstChild;
					this.modules[j++] = module;
					this.attach(module);
					
				}
			}
		} else {
			for(var i = 0; i < this.modules.length; i++) {
				this.attach(this.modules[i]);
			}
		}
		this.firstTime = false;
	}
	
	/*this.build = function() {
		var module,contents,height,itemCount,neighbours,count,eContents,j=0;
		this.modules = new Array(this.node.childNodes.length);
		try {
			for(var i = 0; i < this.node.childNodes.length; i++) {
				if(this.node.childNodes[i].nodeName == 'LI' && 
					this.node.childNodes[i].childNodes.length > 0 &&
					this.node.childNodes[i].firstChild.nodeName == 'A') {
					
						module = this.node.childNodes[i].firstChild;
						this.modules[j++] = module;
						contents = $(module.getAttribute('module'));
						if(contents) {
							//height = parseInt(getStyle(contents,'height'));
							itemCount = parseInt(contents.getAttribute('itemCount'));
							//defineAttribute(module,'contentHeight',height);
						
							if(itemCount > 0) {
								var countDisplay = module.parentNode.childNodes[1];
								if(countDisplay.className == "alertSpacer") {
									countDisplay.className = "alertCount";
									countDisplay.innerHTML = itemCount;
								}
								if(!this.memorySet) {
									this.memory += ":"+module.getAttribute('module')+":";
								}
							}
						
							if(getStyle(contents,'display') == "block" && this.memory.indexOf(":"+module.getAttribute('module')+":") >= 0) {
								module.className = "active";
							} else {
								module.className = "";
								cContents = new Animator(contents);
								cContents.setOpacity(1);
								cContents.collapse();
							
								if(isCollapsed(contents.parentNode)) {
									if(contents.parentNode.getAttribute("neighbours")) {
										neighbours = contents.parentNode.getAttribute("neighbours").split(",");
										count = 0;
										for(var j=0; j<neighbours.length; j++) {
											if($(neighbours[j]).className.indexOf("-0")<0)
												count++;
										}
										for(var j=0; j<neighbours.length; j++) {
											$(neighbours[j]).className = $(neighbours[j]).className.replace(/\-[1-9]/g,"-"+count);
										}
									}
									contents.parentNode.className = contents.parentNode.className.replace(/\-[0-9]+/g,"-0");
								}
							}
							module.onclick = function() {
								var contents = $(this.getAttribute('module'));
								if(getStyle(contents,'display') == "none") {
									if(contents.parentNode.className.indexOf("-0")>0) {
										var count = 1;
										if(contents.parentNode.getAttribute("neighbours")) {
											var neighbours = contents.parentNode.getAttribute("neighbours").split(",");
										
											for(var j=0; j<neighbours.length; j++) {
												if($(neighbours[j]).className.indexOf("-0")<0)
													count++;
											}
											for(var j=0; j<neighbours.length; j++) {
												$(neighbours[j]).className = $(neighbours[j]).className.replace(/\-[1-9]/g,"-"+count);
											}
										}
										contents.parentNode.className = contents.parentNode.className.replace(/\-0/g,"-"+count);
									}
							
									//var height = parseInt(this.getAttribute('contentHeight'));
								
									eContents = new Animator(contents);
									eContents.expand();
									//eContents.setHeight(height);
									contents.style.overflow = "visible";
									eContents.changeOpacity(99,10,25,2);
								
									//eContents.setOpacity(99.9);
									//eContents.changeHeight(height,10,50,1,function() {
									//	contents.style.overflow = "visible";
									//});
								
									this.className = "active";
									if(eval(instance).memory.indexOf(":"+this.getAttribute('module')+":")<0) {
										eval(instance).memory += ":"+this.getAttribute('module')+":";
										cookieCreate("InfoExNav",eval(instance).memory,28);
									}
								} else {
									contents.style.overflow = "hidden";
									cContents = new Animator(contents);
									//cContents.changeOpacity(0,10,50,1);
								
									cContents.changeOpacity(0,10,25,2,function() {
									//cContents.changeHeight(1,10,50,2,function() {
										cContents.collapse();
										if(isCollapsed(contents.parentNode)) {
											if(contents.parentNode.getAttribute("neighbours")) {
												var neighbours = contents.parentNode.getAttribute("neighbours").split(",");
												var count = 0;
												for(var j=0; j<neighbours.length; j++) {
													if($(neighbours[j]).className.indexOf("-0")<0)
														count++;
												}
												for(var j=0; j<neighbours.length; j++) {
													$(neighbours[j]).className = $(neighbours[j]).className.replace(/\-[1-9]/g,"-"+count);
												}
											}
											contents.parentNode.className = contents.parentNode.className.replace(/\-[0-9]+/g,"-0");
										}
									});
								
								
									this.className = "";
									//if(this.firstChild.firstChild.nodeName == "INPUT") {
									//	this.firstChild.firstChild.checked = "";
									//}
									eval(instance).memory = eval(instance).memory.replace(":"+this.getAttribute('module')+":","");
									cookieCreate("InfoExNav",eval(instance).memory,28);
								}
							}
							contents.onmousedown = function() {
								this.style.cursor = "move";
								this.editableTimeout = setTimeout("$('movableStyle').disabled = false;",300);
							}
							contents.onmouseup = function() {
								this.style.cursor = "auto";
								clearTimeout(this.editableTimeout);
								if(!editing)
									setTimeout("$('movableStyle').disabled = true;",100);
							}
						
							//this is the close button
							contents.getElementsByTagName("DIV")[0].getElementsByTagName("A")[0].onclick = function() {
								var contents = this.parentNode.parentNode;

								contents.style.overflow = "hidden";
								cContents = new Animator(contents);
							
								cContents.changeOpacity(0,10,25,2);
								cContents.changeHeight(1,10,50,2,function() {
									cContents.collapse();
									if(isCollapsed(contents.parentNode)) {
										if(contents.parentNode.getAttribute("neighbours")) {
											var neighbours = contents.parentNode.getAttribute("neighbours").split(",");
											var count = 0;
											for(var j=0; j<neighbours.length; j++) {
												if($(neighbours[j]).className.indexOf("-0")<0)
													count++;
											}
											for(var j=0; j<neighbours.length; j++) {
												$(neighbours[j]).className = $(neighbours[j]).className.replace(/\-[1-9]/g,"-"+count);
											}
										}
										contents.parentNode.className = contents.parentNode.className.replace(/\-[0-9]+/g,"-0");
									}
								});
							
								for(var i=0; i<getElementsByClassName('navSec','DIV',$("contents")).length; i++) {
									var navSec = getElementsByClassName('navSec','DIV',$("contents"))[i];
									for(var j = 0; j < navSec.getElementsByTagName("UL")[0].childNodes.length; j++) {
										if(navSec.getElementsByTagName("UL")[0].childNodes[j].nodeType == 1 &&
										navSec.getElementsByTagName("UL")[0].childNodes[j].getElementsByTagName("A")[0].getAttribute('module')!=null &&
										navSec.getElementsByTagName("UL")[0].childNodes[j].getElementsByTagName("A")[0].getAttribute('module') == this.parentNode.parentNode.id) {

											var module = navSec.getElementsByTagName("UL")[0].childNodes[j].getElementsByTagName("A")[0];
											module.className = "";
											//if(module.getElementsByTagName("SPAN")[0].firstChild.nodeName == "INPUT") {
											//	module.getElementsByTagName("SPAN")[0].firstChild.checked = "";
											//}
											eval(instance).memory = eval(instance).memory.replace(":"+module.getAttribute('module')+":","");
											cookieCreate("InfoExNav",eval(instance).memory,28);
											break;	
										}
									}
								}
								for(var i = 0; i < $("navSec").getElementsByTagName("UL")[0].childNodes.length; i++) {
										if($("navSec").getElementsByTagName("UL")[0].childNodes[i].nodeType == 1 &&
										$("navSec").getElementsByTagName("UL")[0].childNodes[i].getElementsByTagName("A")[0].getAttribute('module')!=null &&
										$("navSec").getElementsByTagName("UL")[0].childNodes[i].getElementsByTagName("A")[0].getAttribute('module') == this.parentNode.parentNode.id) {
												
											var module = $("navSec").getElementsByTagName("UL")[0].childNodes[i].getElementsByTagName("A")[0];
											module.className = "";
											//if(module.getElementsByTagName("SPAN")[0].firstChild.nodeName == "INPUT") {
												//module.getElementsByTagName("SPAN")[0].firstChild.checked = "";
											//}
											eval(instance).memory = eval(instance).memory.replace(":"+module.getAttribute('module')+":","");
											cookieCreate("InfoExNav",eval(instance).memory,28);
											break;	
										}
								}
							}
						} 
					}
			}
		} catch(e) {
			//something went wrong
		}
		cookieCreate("InfoExNav",this.memory,28);
	}*/
	
	this.build();
}

function buildDialogue(link,text) {
	if(text)
		$('dialogueText').innerHTML = text;
	return showDialogue(link);
}

function showDialogue(link) {
	hContents = (document.all ? new Animator($('content')) : new Animator($('container')));
	sContents = new Animator($('dialogueBox'));
	axContents = new Animator($('activeXHider'));
	hContents.setOpacity(99);
	var y;
	try {
		if(typeof link == 'string') {
			y = findPosY($(link))+'px';
		} else {
			y = findPosY(link)+'px';
		}
	} catch(E) {
		if($(link))
			y = findPosY($(link))+'px';
	}
	
	//DEBUG: Temp center of viewable window
	var top = self.pageYOffset ? self.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body ? document.body.scrollTop : null;
	var windowHeight = (typeof( window.innerWidth ) == 'number') ? window.innerHeight : ((document.documentElement &&  document.documentElement.clientHeight) ? document.documentElement.clientHeight : ((document.body && document.body.clientHeight) ? document.body.clientHeight : null));
	y = (top + (windowHeight / 2)-150) + 'px';

	
	$('dialogueBox').style.top = y;
	sContents.setOpacity(0);
	sContents.expand();
	if(document.all) {
		$('activeXHider').style.top = y;
		axContents.expand();
		$('activeXHider').style.height = getStyle($('dialogueBox'),'height') + 'px';
		$('activeXHider').style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
	}
	sContents.changeOpacity(90,5,25,2, function() {
		hContents.changeOpacity(30,5,25,2);
	});
	
	//IE jump fix
	$('dialogueBox').style.left = findPosX($('dialogueBox'))+'px';
	$('dialogueBox').style.position = 'absolute';
	
	$('dialogueCloseButton').onclick = function() {
		$('dialogueText').innerHTML = '&nbsp;';
		sContents.collapse();
		hContents.setOpacity(100);
		if(document.all) {
			$('activeXHider').style.top = '1px';
			$('activeXHider').style.height = '100px';
			axContents.collapse();
		}
	}
	return false;
}

function buildHint(text) {
	if(text)
		$('dialogueText').innerHTML = text;
	return showHint();
}

function showHint() {
	var cook = cookieRead('InfoExHint');
	if(!cook || cook != 'hide') {
		sContents = new Animator($('dialogueBox'));
		sContents.setOpacity(0);
		sContents.expand();
		sContents.changeOpacity(90,5,25,2, function() {
			hContents.changeOpacity(30,5,25,2);
		});
	}
	return false;
}

function buildFlash(text) {
	if(text)
		$('flashContent').innerHTML = text;
	return showFlash(link);
}

function showFlash() {
	fContents = new Animator($('flash'));
	fContents.expand(function() {
		fContents.changeHeight(65,20,25,.5);
	});
}

function hideFlash() {
	fContents = new Animator($('flash'));
	fContents.changeHeight(1,20,25,.5, function() {
		fContents.collapse();
	});
}
