
// JavaScript Document
/*
 * 2009-10-24 
 * 小凯工作室(地瓜)
 * QQ：648173085
 * Show={transparent:,hide:,show:,showTo:,down:,up:,move:,moveOut:,moveIn:,}
 * @param {Object} id
 * @param {Object} speed
 * @param {Object} stayT
 */
 
 function fadeUO()
 {
     Show.mySpeed=Tween.Expo.easeIn;
	 Show.showTo("Scontent",90,200);
	 Show.moveOut('Scontent',200);
    
 }
 function fadeUI0()
 {
    Show.mySpeed=Tween.Back.easeIn; 	
	Show.moveIn("Scontent",200);
	Show.showTo("Scontent",0,500);
 }
 window.onload=function(){fadeUO()}
 var Tween = {
 Linear: function(t,b,c,d){ return c*t/d + b; },
 Quad: {
  easeIn: function(t,b,c,d){
   return c*(t/=d)*t + b;
  },
  easeOut: function(t,b,c,d){
   return -c *(t/=d)*(t-2) + b;
  },
  easeInOut: function(t,b,c,d){
   if ((t/=d/2) < 1) return c/2*t*t + b;
   return -c/2 * ((--t)*(t-2) - 1) + b;
  }
 },
 Cubic: {
  easeIn: function(t,b,c,d){
   return c*(t/=d)*t*t + b;
  },
  easeOut: function(t,b,c,d){
   return c*((t=t/d-1)*t*t + 1) + b;
  },
  easeInOut: function(t,b,c,d){
   if ((t/=d/2) < 1) return c/2*t*t*t + b;
   return c/2*((t-=2)*t*t + 2) + b;
  }
 },
 Quart: {
  easeIn: function(t,b,c,d){
   return c*(t/=d)*t*t*t + b;
  },
  easeOut: function(t,b,c,d){
   return -c * ((t=t/d-1)*t*t*t - 1) + b;
  },
  easeInOut: function(t,b,c,d){
   if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
   return -c/2 * ((t-=2)*t*t*t - 2) + b;
  }
 },
 Quint: {
  easeIn: function(t,b,c,d){
   return c*(t/=d)*t*t*t*t + b;
  },
  easeOut: function(t,b,c,d){
   return c*((t=t/d-1)*t*t*t*t + 1) + b;
  },
  easeInOut: function(t,b,c,d){
   if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
   return c/2*((t-=2)*t*t*t*t + 2) + b;
  }
 },
 Sine: {
  easeIn: function(t,b,c,d){
   return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  },
  easeOut: function(t,b,c,d){
   return c * Math.sin(t/d * (Math.PI/2)) + b;
  },
  easeInOut: function(t,b,c,d){
   return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  }
 },
 Expo: {
  easeIn: function(t,b,c,d){
   return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  },
  easeOut: function(t,b,c,d){
   return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  },
  easeInOut: function(t,b,c,d){
   if (t==0) return b;
   if (t==d) return b+c;
   if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
   return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  }
 },
 Circ: {
  easeIn: function(t,b,c,d){
   return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  },
  easeOut: function(t,b,c,d){
   return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  },
  easeInOut: function(t,b,c,d){
   if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
   return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  }
 },
 Elastic: {
  easeIn: function(t,b,c,d,a,p){
   if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
   if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
   else var s = p/(2*Math.PI) * Math.asin (c/a);
   return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  },
  easeOut: function(t,b,c,d,a,p){
   if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
   if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
   else var s = p/(2*Math.PI) * Math.asin (c/a);
   return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
  },
  easeInOut: function(t,b,c,d,a,p){
   if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
   if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
   else var s = p/(2*Math.PI) * Math.asin (c/a);
   if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
   return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  }
 },
 Back: {
  easeIn: function(t,b,c,d,s){
   if (s == undefined) s = 1.70158;
   return c*(t/=d)*t*((s+1)*t - s) + b;
  },
  easeOut: function(t,b,c,d,s){
   if (s == undefined) s = 1.70158;
   return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  },
  easeInOut: function(t,b,c,d,s){
   if (s == undefined) s = 1.70158; 
   if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
   return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  }
 },
 Bounce: {
  easeIn: function(t,b,c,d){
   return c - Tween.Bounce.easeOut(d-t, 0, c, d) + b;
  },
  easeOut: function(t,b,c,d){
   if ((t/=d) < (1/2.75)) {
    return c*(7.5625*t*t) + b;
   } else if (t < (2/2.75)) {
    return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
   } else if (t < (2.5/2.75)) {
    return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
   } else {
    return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
   }
  },
  easeInOut: function(t,b,c,d){
   if (t < d/2) return Tween.Bounce.easeIn(t*2, 0, c, d) * .5 + b;
   else return Tween.Bounce.easeOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
  }
 }
}

var Show = {
    transparent: function(id, speed, stayT){
        var ob = this.get(id);
        if (ob.style.display == "none") {
            this.show(ob, speed);
        }else {
            this.hide(ob, speed);
        }
    },
	move:function(ob,speed,isOut,OpNum,step, _Arg){
		ob = this.get(ob);
		speed = speed || 200;
		step=step|this.getStep(speed); //步长
		var step_H=150;// 距离
		var stepNum=step_H/step;//步数
		if(typeof(_Arg)=='undefined')
		{
		   _Arg={top:0,left:0};
		   _Arg.top=getBodycenter().ctop-(ob.offsetHeight/2);
		   _Arg.left=getBodycenter().cleft-(ob.offsetWidth/2);	
		   ob.style.top=_Arg.top+"px";
		   ob.style.left=_Arg.left+"px";		   
		}		
		if (typeof(OpNum) == 'undefined') {
			OpNum = isOut ? step_H : 0;
		}
		else {
			if (isOut) {
				OpNum -= step;
			    OpNum=OpNum<0?0:OpNum;
			}else
			{
				OpNum+=step;
				OpNum=OpNum>step_H?step_H:OpNum;
			}
		}
		var oo=this.mySpeed(OpNum,0,step_H,step_H);
		ob.style.top=isOut?Math.round(_Arg.top+oo)+"px":Math.round(_Arg.top-oo)+"px";
		var bo=isOut?(OpNum>0):(OpNum<step_H);
		if(bo){
				setTimeout(function(){
					Show.move(ob,speed,isOut,OpNum,step,_Arg)
				},speed/stepNum);	
		}
	},
	moveOut:function(ob, speed, OpNum,step, _Arg){
		this.move(ob,speed,true);
	},
	moveIn: function(ob, speed, OpNum, step, _Arg){
	this.move(ob,speed,false);
	},
    down: function(){
    
    },
    up: function(){
    
    },
    hide: function(ob, speed, OpNum,step, star){
		this.showTo(ob,0,speed);
    },
    show: function(ob, speed, OpNum,step, star){
		this.showTo(ob,100,speed);
    },
	showTo:function(ob,opacity,speed,OpNum,step,starOp){
		ob = this.get(ob);
		 speed=speed||700;
		 step=step|this.getStep(speed);//步长
		 if(typeof(starOp)=='undefined'){//首次
		   if (this.isIE) {
			   try {
			    	starOp= parseFloat(ob.filters.alpha.opacity);
				} catch (e) {
				    if(ob.offsetWidth>0)//可见
						starOp=100;
					else
					    starOp=0;
				}
	        }
	        else {
				starOp = parseFloat(ob.style.opacity) * 100;
				if(isNaN(starOp))
				{
				   if(ob.offsetWidth>0)//可见
						starOp=100;
					else
					    starOp=0;				
				}			
	        };
		 }
		 var isToShow=(starOp<opacity);
		 var stepN=Math.abs(starOp-opacity);
		 var stepNum=stepN/step;//步数
	        this.showing = true;
	        if (typeof(OpNum) == 'undefined') {
	            OpNum =starOp;
	        }
	        else {
				if(isToShow)
				   OpNum += step;
				else
				   OpNum-=step;
	        }
			
	        ob.style.display = 'block';
			if (this.isIE) {
	            ob.style.filter = "alpha(opacity:" + OpNum + ")";
	        }
	        else {
	            ob.style.opacity = OpNum / 100;
	        };
			var boo=isToShow?(OpNum < opacity):(OpNum > opacity);
			if (boo) {
				setTimeout(function(){
					Show.showTo(ob,opacity, speed, OpNum,step,starOp)
				}, speed /stepNum);
			}
			else {
				this.showing = false;
			}

	},
    getStep:function(speed){
		if(speed<=300)
			return 10;
	    else if(speed<=500)
			return 8;
		else if(speed<=800)
	        return 5;
		else 
	        return 2;     
	},
    fixE: function(e){    
    },
    Test: function(obj, tt){
    },
    showing: false,
    get: function(id){
        return "string" == typeof id ? document.getElementById(id) : id;
    },
    isIE: (document.all) ? true : false,
	mySpeed:function(t,b,c,d){return Tween.Linear(t,b,c,d)}
    //End
}

function getBodycenter(){var B_center=[]; with(document.documentElement){var W1=clientWidth;var sl1=scrollLeft;B_center['left']=W1/2+sl1;var H1=clientHeight; var st1=scrollTop;B_center['top']=H1/2+st1;}return {cleft:B_center['left'],ctop:B_center['top']};}
