//行为捆绑
//depend on NIE UI
function evtBind(){	
	var con = NIE_UI.getChild("con-bg","div");	
	for(var i=0;i<con.length;i++){		
		con[i].style.height = (i==con.length-1)?"56px":"51px";		
		var child = NIE_UI.getChild(con[i],"div");
		var title = child[0];		
		(
		 	function(){
				var lastCon = (i==con.length-1)?true:false;
				if(lastCon){
					var span = title.getElementsByTagName("span")[0];
					span.style.marginTop = "-55px";
				}
				var text = child[1];
				var _con = con[i];
				var moveHeight = new ani();
				var moveOpacity = new ani();
				title.onclick = function(){		
								
					var fat = this.parentNode;
					moveHeight.obj = _con;					
					moveHeight.attr = "height";					
					moveOpacity.obj = text;					
					moveOpacity.attr = "opacity";
					/*
					try{
						test.style.filters["alpha"]["opacity"]=0;
						}
					catch(e){
						moveOpacity.attr = "opacity";
					}
					*/
					
					if(fat.className == "con"){
						if(lastCon){
							fat.getElementsByTagName("h2")[0].style.height = "49px";
							span.style.marginTop = "-48px";
							fat.className = "con open lastCon";
						}
						else {
							fat.className ="con open";
						}
						moveHeight.value = _con.getAttribute("ani_maxHeight");						
						moveHeight.play();
						moveOpacity.value = 1;						
						moveOpacity.play();
						for(var j=0;j<con.length;j++){
							if(fat!=con[j]&&con[j].className.indexOf("open")!=-1){
								NIE_UI.getChild(con[j],"div")[0].onclick();
							}
						}
					}
					else{
						if(lastCon){
							fat.getElementsByTagName("h2")[0].style.height = "56px";
							span.style.marginTop = "-55px";
							fat.className ="con open lastCon";
						}
						fat.className = "con";	
						moveHeight.value = _con.getAttribute("ani_minHeight");					
						moveHeight.play();		
						moveOpacity.value = 0;						
						moveOpacity.play();
					}
					
				}					
			}
		)();
		
	}
}
function ani(){	
	this.obj;
	this.attr;
	this.value;
	this.timer;

	this.play = function(){	
		clearTimeout(this.timer);
		var _self = this;
		this.timer = setInterval(function(){_self.replay()},100);		
	}
	this.replay = function(){
		var nowValue = parseFloat(NIE_UI.getStyle(this.obj,this.attr));		
		//if(this.attr!="height") alert(this.attr);
		var dis = parseFloat(Math.abs(nowValue - this.value));		
		if(dis>0.1){			
			dis = (nowValue > this.value)? -dis:dis;
			var temp = parseFloat(nowValue) + parseFloat(dis/2);
			this.obj.style[this.attr] = (this.attr=="opacity") ? temp : temp+"px";
		}			
		else{			
			clearTimeout(this.timer);			
		}
	}
}
function chkLevel(){
	var value = NIE_UI.$("level").value;
	if(!isNaN(value)){
		var con = NIE_UI.getChild("con-bg","div");		
		var level = parseInt(value);
		var _con;
		if(level<0) _con = con[0];
		else if(level>=0&&level<10) _con = con[3];
		else if(level>=10&&level<20) _con = con[4];
		else if(level>=20&&level<30) _con = con[5];
		else if(level>=30) _con = con[6];
		
		if(_con.className.indexOf("open")==-1) NIE_UI.getChild(_con,"div")[0].onclick();
		_con.scrollIntoView();
	}
	else alert("请正确输入等级！");
}
