/* 好伴时尚商务服务有限公司
 * Navgation Menu Slide
 * @Date:2010-01-12
 */
var headerObject = new Array();

function showHeaderMenu(i,status) {
	for (var k=1;k<9;k++) {
		var cStatus = (i == k) ? status : 0;
		if (null != $('childMenu'+k)) {
			headerObject[k] = new slideMenu(k,cStatus);
			headerObject[k].ON = (i == k) ? 1 : 0;
		}
	}
	headerObject[i].parentObj.navObj.onmouseover();
}

function slideMenu(i,status) {
	this.i          = i;
	this.ON         = 1;
	this.CreateObj = function(parentObj,i,status) {
		this.obj        = parentObj;
		this.i          = i;
		this.status     = status;
		this.downLock   = 0;
		this.upLock     = 0;
		this.navObj     = $('porSort-'+this.i);
		this.menuObj    = $('childMenu'+this.i);
		this.slideSpeed = 3;
		this.maxHeight  = 0;
		this.varHeight  = 30;
		this.navObj.parent = this;
		this.menuObj.parent= this;
		this.isIE       = navigator.userAgent.indexOf("compatible") > -1 && navigator.userAgent.indexOf("MSIE") > -1 && !(navigator.userAgent.indexOf("Opera") > -1) ;
		
		this.GetHeight=function() {
			with (this) {
				menuObj.style.visibility="hidden";
				menuObj.style.display = "block";
				maxHeight = parseInt(menuObj.offsetHeight);
				menuObj.style.display = "none";
				menuObj.style.visibility="visible";
			}
		}
		
		this.ShowHoverClass=function() {
			if (this.i < 8) {		
				var menuClass = this.navObj.className;//通用+类别+鼠标（选择）效果
				var cssN = menuClass.split(" ");
				var showClass = cssN[0] + ' ' + cssN[1] + ' ' + cssN[1]+'_hover';		
			} else {
				var showClass = "subChannel bbsCol";
				$('bbsChannel').className = 'bbsPos';
			}
			this.navObj.className = showClass;
		}
		
		this.ShowOutClass=function() {
			if (this.i < 8) {		
				var menuClass = this.navObj.className;//通用+类别+鼠标（选择）效果
				var cssN = menuClass.split(" ");
				var effectClass = (1 == status) ? cssN[1]+'_select' : '';
				var showClass = cssN[0] + ' ' + cssN[1] + ' ' + effectClass;		
			} else {
				var showClass = "subChannel";
				$('bbsChannel').className = '';
			}
			this.navObj.className = showClass;
		}
		
		this.HiddenMenu=function() {
			with (this) {
				for (var k=1;k<9;k++) {
					if ('object' == typeof(headerObject[k])) {
						headerObject[k].ON = (i == k) ? 1 : 0;
					}
				}
				downLock = 0;
				upLock   = 1;
				menuObj.style.overflow = 'hidden';
				SlideUpAct();
			}
		}
		
		this.SlideDownAct=function() {
			with(this) {
				if (obj.ON) {
					var divHeight  = parseInt(menuObj.offsetHeight) + varHeight;
					//var divWidth   = parseInt(menuObj.offsetWidth) + varHeight;
					if (divHeight > maxHeight) {
						menuObj.style.height = maxHeight + 'px';
						downLock = 0;
					} else {
						menuObj.style.display = "block";
						menuObj.style.height = divHeight + 'px';
						(downLock) ? setTimeout('headerObject['+i+'].parentObj.SlideDownAct();',slideSpeed) : menuObj.style.display = "none";
					}
				} else {
					menuObj.style.display = "none";
					ShowOutClass();
					downLock = 0;
				}
			}
		}
		
		this.SlideUpAct=function() {
			with(this) {
				if (obj.ON) {
					var divHeight  = parseInt(menuObj.offsetHeight) - varHeight;
					//var divWidth   = parseInt(menuObj.offsetWidth) - varHeight;
					if (divHeight > 0) {
						menuObj.style.display = "block";
						menuObj.style.height = divHeight + 'px';
						(upLock) ? setTimeout('headerObject['+i+'].parentObj.SlideUpAct();',slideSpeed) : menuObj.style.display = "none";
					} else {
						menuObj.style.display = "none";
						ShowOutClass();
						upLock = 0;
					}
				} else {
					menuObj.style.display = "none";
					ShowOutClass();
					upLock = 0;
				}
			}
		}
		
		this.GetHeight();
		this.navObj.onmouseover=function() {
			for (var k=1;k<9;k++) {
				if ('object' == typeof(headerObject[k])) {
					headerObject[k].ON = (this.parent.i == k) ? 1 : 0;
				}
			}
			this.parent.downLock = 1;
			this.parent.upLock   = 0;
			this.parent.ShowHoverClass();
			//this.parent.menuObj.style.overflow = 'hidden';
			this.parent.SlideDownAct();
			//this.parent.menuObj.style.overflow = 'visible';
		}
		
		this.navObj.onmouseout=function() {
			if (this.parent.isIE) {
				var e = window.event;
				var toObj = e.toElement.id;
			} else {
				var e=arguments[0];
				var toObj = e.relatedTarget.id;
			}
			//alert(toObj);
			if ('' != toObj) {//toObj 本应==('childMenu'+this.parent.i),由于CSS的原因感应区为空
				this.parent.HiddenMenu();
			} else {
				this.parent.menuObj.style.overflow = 'visible';
			}
		}
		
		/*this.menuObj.onmouseover=function() {
			if (this.parent.isIE) {
				var e = window.event;
				var toObj = e.fromElement.id;
				e.cancelBubble=true;
			} else {
				var e=arguments[0];
				var toObj = e.relatedTarget.id;
				e.stopPropagation();
			}
			if (('childMenu'+this.parent.i) == toObj || '' == toObj) {
				this.parent.menuObj.style.overflow = 'visible';
			}
			$('ff').innerHTML+=' OVE';
		}*/
		
		/*this.menuObj.onmouseout=function() {
			setTimeout('this.parent.HiddenMenu();',100)
		}*/
		
	}
	
	this.parentObj  = new this.CreateObj(this,i,status);
	
}

closeChildMenu=function(i,status){
	headerObject[i].parentObj.menuObj.style.overflow = 'hidden';
	headerObject[i].parentObj.downLock = 0;
	headerObject[i].parentObj.upLock   = 1;
	//headerObject[i].parentObj.SlideUpAct();
	headerObject[i].parentObj.ShowOutClass();
	headerObject[i].parentObj.menuObj.style.display = "none";
}

signChildMenu=function(i) {
	headerObject[i].parentObj.ShowHoverClass();
	headerObject[i].parentObj.menuObj.style.display = "block";
	headerObject[i].parentObj.menuObj.style.overflow = 'visible';
}