function nMenu(obj, config) {
	nDynamic(obj);
	obj.nName = 'nMenu';
	
	obj.configure({
		itemClassName: 'item'
	});
	
	
	obj.build = function() {
		var tmp = {};
		obj.items = $$(config.itemClassName, null, obj);
		for (var i in obj.items) {
			nMenuItem(obj.items[i]);
		}
	}
	
	obj.configure(config);
	obj.build();
}


function nMenuItem(obj) {
	nDynamic(obj);
	obj.nName = 'nMenuItem';
	
	obj.span = obj.motion({
		min: 0,
		max: -5,
		factor: 0.3,
		onLoop:function() {
			this.decelerate();
		},
		onUpdate:function() {
			this.obj.button.style.top = this.n + 'px';
			this.obj.reflection.style.marginTop = -1 * this.n + 'px';
			
			if (!nConfig.isIE) {
				this.obj.reflection.style.opacity = (100 - (this.n * 70/this.max)) / 100;
			}
		},
		rise:function() {
			this.activate(this.max);
		},
		unRise:function() {
			this.activate(this.min);
		}
	});
	
	obj.build = function() {
		var tmp = $$(null, 'img', obj);
		obj.button = tmp[0];
		obj.reflection = tmp[1];
		
		nConfig.addEvent(obj, 'mouseover', obj.hover);
		nConfig.addEvent(obj, 'mouseout', obj.unHover);
	}
	
	obj.hover = function(e) {
		obj.span.rise();
	}
	
	obj.unHover = function(e) {
		obj.span.unRise();
	}
	
	obj.build();
}


function nSubMenuItem(obj) {
	
}


// ------------------ nLogForm

function nExpandingBox(obj, leftCol, centerCol, rightCol, afterExpand) {
	nDynamic(obj);
	obj.nName = 'nExpandingBox';
	
	obj.leftCol = leftCol;
	obj.centerCol = centerCol;
	obj.rightCol = rightCol;
	obj.afterExpand = afterExpand;
	
	obj.expanded = false;
	
	obj.build = function() {
		nConfig.addEvent(obj.leftCol, 'click', obj.toggleExpanding);
	}
	
	obj.expanding = obj.motion({
		n: 0,
		start: 0,
		factor: 0.5,
		onLoop:function() {
			this.decelerate();
		},
		onUpdate:function() {
			this.obj.centerCol.style.width = this.n + 'px';
		},
		onDeactivate:function() {
			if (this.direction > 0) {
				this.obj.expanded = true;
			} else {
				this.obj.expanded = false;
			}
			
			if (typeof obj.afterExpand == 'function') {
				obj.afterExpand();
			}
		}
	});
	
	obj.flowing = obj.motion({
		n: 0,
		start: 0,
		factor: 0.2,
		onUpdate:function() {
			this.obj.rightCol.style.marginRight = -1 * this.n + 'px';
		}
	});
	
	obj.expand = function(event) {
		obj.expanding.activate(220);
		obj.flowing.activate(10);
	}
	
	obj.unExpand = function(event) {
		obj.expanding.activate(0);
		obj.flowing.activate(0);
	}
	
	obj.toggleExpanding = function() {
		if (obj.expanded) {
			obj.unExpand();
		} else {
			obj.expand();
		}
	}
	
	obj.build();
}


function nLogForm(obj) {
	var login = $$(null,  'input', obj.centerCol)[0];
	
	nExpandingBox(	obj,
						$$('leftCol', 'div', obj)[0],
						$$('centerCol', 'div', obj)[0],
						$$('rightCol', 'div', obj)[0],
						function() {
							if (this.expanded) {
								login.focus();
							} else {
								login.blur();
							}
						});
	obj.nName = 'nExpandingBox';
	
//	obj.onsubmit = function() { return false; };
	
	nConfig.addEvent($$(null, 'img', obj.rightCol)[0], 'click', function() {
		if (obj.expanded) {
			obj.submit();
			return true;
		} else {
			obj.expand();
			return false;
		}
	});
}


function nNeon(obj) {
	nDynamic(obj);
	obj.nName = 'nFader';
	
	obj.cssOpacity(0);
	
	obj.alpha = obj.motion({
		factor: 0.2,
		onUpdate:function() {
			this.obj.cssOpacity(this.n);
		}
	});
	
	obj.hover = function() {
		obj.alpha.activate(100);
	}
	
	obj.unHover = function() {
		obj.alpha.activate(0);
	}
	
	nConfig.addEvent(obj, 'mouseover', obj.hover);
	nConfig.addEvent(obj, 'mouseout', obj.unHover);
}