var dropShow=false;
var currentID, currentLink;
var fadeTimer;
var isFadeIn=false;
function dropdown(el, el2){
	if(dropShow){
		dropFadeOut();
	}else{
		currentID=document.getElementById(el);
		currentLink=el2;
		currentID.style.visibility="visible"
		dropFadeIn();
		isFadeIn=true;
	}
}
function dropFadeIn(){//选单淡入
	if(Base.isIE()){
		if(currentID.filters.alpha.opacity<100){
			currentID.filters.alpha.opacity+=20;
			fadeTimer=setTimeout("dropFadeIn()",50);
			isFadeIn=true;
		}else{
			dropShow=true;
			clearTimeout(fadeTimer);
			isFadeIn=false;
		}
	}else if(Base.isMoz()){
		if(kStyle.getRealStyle(currentID).opacity<1){
		//	console.log('fade in: '+kStyle.getRealStyle(currentID).opacity);
			currentID.style.opacity=parseFloat(kStyle.getRealStyle(currentID).opacity)+0.1;
			clearTimeout(fadeTimer);
			fadeTimer=setTimeout("dropFadeIn()",30)
			isFadeIn=true;
		}else{
			dropShow=true;
			clearTimeout(fadeTimer);
			isFadeIn=false;
		}
	}
}
function dropFadeOut(){//选单淡出
	if(Base.isIE()){
		if(currentID.filters.alpha.opacity>0){
			clearTimeout(fadeTimer);
			currentID.filters.alpha.opacity-=20;
			fadeTimer=setTimeout("dropFadeOut()",50);
		}else{
			dropShow=false;
			currentID.style.visibility="hidden";
		}
	}else if(Base.isMoz()){
		if(kStyle.getRealStyle(currentID).opacity>0){
			clearTimeout(fadeTimer);
			currentID.style.opacity=parseFloat(kStyle.getRealStyle(currentID).opacity)-0.1;
		//	console.log('fade out: '+kStyle.getRealStyle(currentID).opacity);
			fadeTimer=setTimeout("dropFadeOut()",30);
		}else{
			dropShow=false;
			currentID.style.visibility="hidden";
		}
	}
}
function dropdownHide(){
	if(dropShow){
		dropFadeOut();
		dropShow=false;
		currentLink.className=currentLink.className.replace("_hover", "");
	}
}
function hiLight(el){//高亮度显示指标
	if (dropShow) {
		var elms=Dom.$tagInNode('div', currentID);
		var elm;
		for(var i=0;(elm=elms[i]);i++){
			Dom.setClass("link_record0", elm);
		}
		Dom.setClass("link_record1", el);
	}
}
//setInterval(function(){console.log(dropShow);},100);
function CheckMe(el){//替换显示内容
	currentLink.innerHTML=el.innerHTML;
}
document.onclick=function(ev){
	if(Base.isMoz() && isFadeIn){
		ev.stopPropagation();
	}
	dropdownHide();
}

function mm01(elmId, opt){
	var me=this.me=this;
	this.elmId=elmId;
	if(Dom.$id(elmId)){
		this.elmRoot=Dom.$id(elmId);
	}else{
		return;
	}
	this.lists=[];
	this.labels=[];
	this.contents=[];
	this.current=0;
	this.init=function(){
		this.lists=Dom.$tagInNodeChild('li', this.elmRoot);
		this.labels=Dom.$tagInNode('h3', this.elmRoot);
		this.contents=Dom.$tagHasClassInNode('div', 'tip_more', this.elmRoot);
		for(var i=0,list; (list=this.lists[i]); i++){
			if(Dom.hasClass('on', list)){
				this.current=i;
			}
			list.setAttribute('i', i);
			list.onmouseover=function(){
				Dom.addClass('hover', this);
			};
			list.onmouseout=function(){
				Dom.removeClass('hover', this);
			};
			list.onclick=function(){
				me.clickHandle(this.getAttribute('i'));
			};
		}
		//alert(this.lists.length);
	};
	this.clickHandle=function(ii){
		Dom.removeClass('on', this.lists[this.current]);
		Dom.addClass('on', this.lists[ii]);
		this.current=ii;
	};
	this.init();
	return me;
}

/**
基础部分
*/
var winLoadFuns=winLoadFuns||[];
var addWinLoadFuns=function(fn){//fn -> function 一个函数
	if(typeof fn=='function'){
		winLoadFuns.push(fn);
	}
}
kEvent.addEvent(
	window,
	"load",
	function(){
		if(winLoadFuns&&winLoadFuns.length){
			var i, fn;
			for(i=0; (fn=winLoadFuns[i]); i++){
				if(typeof fn=='function'){
					fn();
				}
			}
		}
	}
);

