﻿var $$ ={
	style:function(node){
		return node.currentStyle || document.defaultView.getComputedStyle(node,null) || node.style;
	},
	height:function(node){
		return parseInt($$.style(node).height) || parseInt(node.clientHeight);
	},
	id:function(node){
		return document.getElementById(node);
	}
}
function _toggle(node,speed,minheight){
    this.node = node;
    this.node.style.overflow = "hidden";
	var hidId=$$.id("hid"+this.node.id);
	switch(speed){
		case "fast":
			this.speed = 15;
			break;
		case "normal":
			this.speed = 12;
			break;
		case "slow":
			this.speed = 5;
			break;
		default:
			this.speed =8;
	}
	this.run = 1;
	this.min_height = parseInt(minheight);
	if(hidId.value=="")
	{	//记录初始最大高度
	    hidId.value = $$.height(this.node);
	}
	this.max_height=parseInt(hidId.value);
	this.node.style.height = this.min_height +"px";
	if(this.max_height <= this.min_height){
		$$.id("t_3").style.display='none';
		this.flag = -1;
	}else{
		$$.id("t_3").style.display='block';
		this.flag = 1;
}
}
_toggle.prototype.up_down = function() {
    this.box_height = parseInt($$.style(this.node).height);
    this.box_height -= this.speed * this.flag;
    //alert(this.box_height + ' - ' + this.max_height);
    if (this.box_height > this.max_height) {
        window.clearInterval(this.t);
        this.box_height = this.max_height;
        this.run = 1;
        $$.id("t_3").src = '/2010/images/icon_up.gif';
        $$.id("t_3").title = "折叠";
    }
    else if (this.box_height < this.min_height) {
        window.clearInterval(this.t);
        this.box_height = this.min_height;
        this.run = 1;
        $$.id("t_3").src = '/2010/images/icon_down.gif'
        $$.id("t_3").title = "展开";
		$$.id("divpinpai").className="pinpai_sys";
	    $$.id("pptitbor").className="pp_tit_bor";
    }
    this.node.style.height = this.box_height + "px";
}

_toggle.prototype.toggle = function(){
	var temp = this;
	if(this.run == 1){
		this.flag *= -1;
		this.run =0;
		this.t = window.setInterval(function(){temp.up_down();},10);
	}
}

function doClick(o,minheight){
	 o.className="ppc_bg";
	 $$.id("divpinpai").className="pinpai_sys";
	 $$.id("pptitbor").className="pp_tit_bor";
	 var j;
	 var id;
	 var b;
	 for(var i=1;i<=5;i++){
	   id ="bb"+i;
	   j = $$.id(id);
	   b = $$.id("b"+i);
	   if(id != o.id){
	   	 j.className="ppc_af";
	   	 b.style.display = "none";
	   }else{
			b.style.display = "block";
			var bc = new _toggle(b,"normal",minheight);
			$$.id("t_3").onclick = function(){
				$$.id("divpinpai").className="pinpai_sys_blue";
	    		$$.id("pptitbor").className="pp_tit_bor_blue";
				bc.toggle();
			} 
			$$.id("t_3").src='/2010/images/icon_down.gif';
			$$.id("t_3").title = "展开";
	   }
	 }
}

function HotClick(tab){
	for(var i=1;i<=4;i++){
		if(i==tab){
			$$.id("span"+i).className="nav_tag";
			$$.id("divHot1"+i).style.display="block";
			$$.id("divHot2"+i).style.display="block";
		}
		else{
			$$.id("span"+i).className="nav_tagno";
			$$.id("divHot1"+i).style.display="none";
			$$.id("divHot2"+i).style.display="none";
		}
	}
}

function TopClick(type){
	if(type==1){
		$$.id("divWeek").style.display="block";
		$$.id("divMonth").style.display="none";
		$$.id("liWeek").className='mtit_over'
		$$.id("liMonth").className='mtit_out'
	}
	else{
		$$.id("divWeek").style.display="none";
		$$.id("divMonth").style.display="block";
		$$.id("liWeek").className='mtit_out'
		$$.id("liMonth").className='mtit_over'
	}
}

function myGod(id, w, n) {
		var box = document.getElementById(id), can = true, w = w || 1500, fq = fq || 10, n = n == -1 ? -1 : 1;
		box.innerHTML += box.innerHTML;
		box.onmouseover = function() { can = false };
		box.onmouseout = function() { can = true };
		var max = parseInt(box.scrollHeight / 2);
		new function() {
			var stop = box.scrollTop % 25 == 0 && !can;
			if (!stop) {
				var set = n > 0 ? [max, 0] : [0, max];
				box.scrollTop == set[0] ? box.scrollTop = set[1] : box.scrollTop += n;
			};
			setTimeout(arguments.callee, box.scrollTop % 25 ? fq : w);
		};
	};
