/*###################################################
# siivv, inc. - siivv.com javascript                #
# @ scott                                           #
#                                                   #
###################################################*/

	var IE = document.all ? 1 : 0;
	var NS4 = document.layers ? 1 : 0;
	var DOM = document.getElementById ? 1 : 0;
	subMenu.Registry = [];
	subMenu.speed = 10;

	// SUBMENU CONSTRUCTOR
	function subMenu(layerName,h) {
		if (IE || NS4 || DOM) {
			this.layerName = layerName;
			this.TPos = h;
			this.newPos = -this.TPos;
			this.movDir = "down";
			this.hideTimer = false;
			this.aniTimer = false;
			this.startTime = 0;
			this.timeOut = 1500;
			this.open = false;
			this.active = false;
			this.layerRef = "subMenu."+layerName;
			eval(this.layerRef+'=this');
			subMenu.Registry[layerName] = this;
			this.load();
		}
	}
	
	// LOAD
	subMenu.prototype.load = function() {
		// get proper handler methods
		var methodHandler1 = (DOM) ? document.getElementById(this.layerName + "Container") : (IE) ? document.all[this.layerName + "Container"] : document.layers[this.layerName + "Container"];
		if (methodHandler1)
			var methodHandler2 = (NS4) ? methodHandler1.layers[this.layerName + "Content"] : (IE) ? document.all[this.layerName + "Content"] : document.getElementById(this.layerName + "Content");
	
		if (!methodHandler1 || !methodHandler2)
			window.setTimeout(this.layerRef + ".load()", 100)
		else {
			this.layerContainer = methodHandler1;
			this.layerContent = methodHandler2;
			
			this.styleContainer = (NS4) ? this.layerContainer : this.layerContainer.style;
			this.styleContent = (NS4) ? this.layerContent : this.layerContent.style;

			this.posOff = 0;
			this.posOn = -this.TPos;
			
			// set event handlers.
			if (NS4) this.layerContent.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
			this.layerContent.onmouseover = new Function("subMenu.menuShow('" + this.layerName + "')");
			this.layerContent.onmouseout = new Function("subMenu.menuHide('" + this.layerName + "')");
			// start it up
			this.menuStop();
		}
	}
	
	// MENUSHOW
	subMenu.menuShow = function(layerName) {
		var regObj = subMenu.Registry;
		var obj = subMenu.Registry[layerName];

		if (obj.layerContainer) {
			obj.active = true;
			for (layerElement in regObj) {
				if (layerElement != layerName)
					subMenu.menuClose(layerElement);
			}
			if (obj.hideTimer)
				regObj[layerName].hideTimer = window.clearTimeout(regObj[layerName].hideTimer);
			if (!obj.open && !obj.aniTimer)
				regObj[layerName].menuStart(true);
		}
	}

	// HIDE
	subMenu.menuHide = function(layerName) {
		var obj = subMenu.Registry[layerName];
		if (obj.layerContainer) {
			if (obj.hideTimer)
				window.clearTimeout(obj.hideTimer);
			obj.hideTimer = window.setTimeout("subMenu.menuClose('"+layerName+"')", obj.timeOut);
		}
	}

	// MENUCLOSE
	subMenu.menuClose = function(layerName) {
		var obj = subMenu.Registry[layerName];
		obj.active = false;

		if (obj.hideTimer)
			window.clearTimeout(obj.hideTimer);
		if (obj.open && !obj.aniTimer)
			obj.menuStart(false);
	}

	// MENUSTART
	subMenu.prototype.menuStart = function(open) {
		this.open = open;
		if (open)
			this.layerVis(true);
		this.aniTimer = window.setInterval(this.layerRef + ".menuMove()", subMenu.speed);
	}
	
	// MENUSTOP
	subMenu.prototype.menuStop = function() {
		this.aniTimer = window.clearTimeout(this.aniTimer);
		this.moveLayer((this.open) ? this.posOff : this.posOn);
		
		if (!this.open)
			this.layerVis(false);
		if ((this.open && !this.active ) || (!this.open && this.active))
			this.menuStart(this.active);
	}

	// MENUMOVE
	subMenu.prototype.menuMove = function() {
		if ((this.movDir == "down") ? this.newPos >= 0 : this.newPos <= -this.TPos) {
			(this.movDir == "down") ? this.movDir = "up" : this.movDir = "down";
			this.menuStop();
		}
		else {
			if (this.open && this.movDir == "down") this.newPos++;
			else if (!this.open && this.movDir == "up") this.newPos--;
			this.moveLayer(this.newPos);
		}
	}

	// LAYERVIS
	subMenu.prototype.layerVis = function(bool) { 
		this.styleContainer.visibility = bool ? "visible" : "hidden";
	}

	// MOVELAYER
	subMenu.prototype.moveLayer = function(newPos) { 
		this.styleContent["top"] = (NS4) ? newPos : newPos + "px";
	}
	
	// SUBMENU INITIALIZATIONS
	var aboutMenu = new subMenu("aboutMenu",72);
	var projectsMenu = new subMenu("projectsMenu",72);
	var servicesMenu = new subMenu("servicesMenu",72);
	var linksMenu = new subMenu("linksMenu",72);

	function winStat(word) {
		self.status = word;
	}

	function winOpen(path,typeSel){
		if (typeSel == 1)
			popWin = window.open(path, "_blank", "toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=no,width=900,height=535");
	}
	
	self.defaultStatus='siivv, inc.';