if(typeof(HTMLElement)!="undefined"){
	HTMLElement.prototype.contains=function(obj){
		while(obj!=null&&typeof(obj.tagName)!="undefind"){
			if(obj==this) return true;
			obj=obj.parentNode;
		}
		return false;
	};
}
var ResizeMenuItem = Class.create();
ResizeMenuItem.prototype = {
	initialize: function(oTd,menuRoot){
		this.td = $(oTd);
		if(navigator.userAgent.indexOf("MSIE")>0){
			this.td.onmouseenter = this.onmouseenter.bindAsEventListener(this);
			this.td.onmouseleave = this.onmouseleave.bindAsEventListener(this);
		}else{
			this.td.onmouseover = this.onmouseover.bindAsEventListener(this);
			this.td.onmouseout = this.onmouseout.bindAsEventListener(this);
		}
		this.td.onclick = this.onclick.bindAsEventListener(this);
		this.menu = menuRoot;
		this.normalShow = this.td.firstChild.firstChild;
		this.zoomShow = this.td.firstChild.lastChild;
		if(navigator.userAgent.indexOf("MSIE")>0){
			this.zoomShowOWidth = parseFloat(this.zoomShow.style.width);
			this.zoomShowOHeight = parseFloat(this.zoomShow.style.height);
		}else{
			this.zoomShowOWidth = this.zoomShow.width;
			this.zoomShowOHeight = this.zoomShow.height;
		}
	},
	onmouseenter: function(entObj){
		this.menu.resizeReduce(this);
	},
	onmouseover: function(entObj){
		if(this.td.contains(entObj.relatedTarget)) return;
		this.menu.resizeReduce(this);
	},
	onmouseleave: function(entObj){
		this.menu.resizeNormal();
		this.normalShow.style.display="block";
		this.zoomShow.style.width = this.zoomShowOWidth+"px";
		this.zoomShow.style.height = this.zoomShowOHeight+"px";
		this.zoomShow.style.display="none";
	},
	onmouseout: function(entObj){
		if(this.td.contains(entObj.relatedTarget)) return;
		this.menu.resizeNormal();
		this.normalShow.style.display="block";
		this.zoomShow.style.width = this.zoomShowOWidth+"px";
		this.zoomShow.style.height = this.zoomShowOHeight+"px";
		this.zoomShow.style.display="none";
	},
	onclick : function() {
		window.location.href=this.td.firstChild.href;
	},
	onZoomShow:function(){
		this.normalShow.style.display="none";
		this.zoomShow.style.width= this.zoomShowOWidth/100 + "px";
		this.zoomShow.style.height= this.zoomShowOHeight/100 + "px";
		this.zoomShow.style.display="block";
	}
};
var ResizeMenu = Class.create();
ResizeMenu.prototype = {
	initialize: function(oDiv,oWidth,zSpeed){
		this.menu = $(oDiv);
		this.oWidth = oWidth;
		this.zoomSpeed = zSpeed;
		this.elements = this.menu.getElementsByTagName("td");
		for(var i=0;i<(this.elements.length);i++){
			new ResizeMenuItem(this.elements[i],this);
		}
		this.morphWidth = this.elements.length*this.oWidth/(this.elements.length+1);
		this.doubleWidth = this.oWidth*2;
		this.currentEffects = new Array();
	},
	resizeReduce:function(menuItem){
		if(this.currentEffects != null && this.currentEffects.length>0){
			for(var i1=0;i1<(this.currentEffects.length);i1++){
				this.currentEffects[i1].cancel();
			}
			this.currentEffects = new Array();
		}
		for(var i=0;i<(this.elements.length);i++){
			if(menuItem.td.id != this.elements[i].id)
				this.currentEffects.push(new Effect.Morph(this.elements[i],{style:'width:'+this.morphWidth+'px',duration: this.zoomSpeed}));
			else{
				menuItem.onZoomShow();
				this.currentEffects.push(
					new Effect.Parallel(
						[new Effect.Morph(menuItem.td,{style:'width:'+(this.doubleWidth-40)+'px',sync:true}),
							new Effect.Morph(menuItem.zoomShow,{style:"width:"+menuItem.zoomShowOWidth+"px;height:"+menuItem.zoomShowOHeight+"px",sync:true})],
					{fps:60,duration:this.zoomSpeed,delay:0}));
			}
		}
	},
	resizeNormal:function(){
		if(this.currentEffects != null && this.currentEffects.length>0){
			for(var i1=0;i1<(this.currentEffects.length);i1++){
				this.currentEffects[i1].cancel();
			}
			this.currentEffects = new Array();
		}
		for(var j=0;j<(this.elements.length);j++){
			this.currentEffects.push(new Effect.Morph(this.elements[j],{style:'width:'+this.morphWidth+'px',duration: this.zoomSpeed}));
		}
	}
};
//##############################
var resizeMenu = new ResizeMenu("resizeMenu",145,0.4);