﻿/*
By Auntion
QQ:82874972
Email:Auntion@Gmail.com

 * 动画效果库 - 需主语言包支持
 * 兼容性: ie5+ ; firefox1.5+ 

ver date-2007-02-01
请勿删除此部分注释.谢谢!
*/
var Animation = {
	//x = 0.25倍速
	p: {x:0.25,pix:0.02,speed:25},
	width:function(element){var status=false,gotos=null;var end=null,now,method;setMethod();function setMethod(){if(now>end){method=false}else if(now<end){method=true}else{return false}};function start(){now+=(end-now)*Animation.p["x"]+Animation.p["pix"];if((method)?(now<end):(now-1>end)){element.style.width=now+"px"}else{window.clearInterval(gotos);element.style.width=end+"px";status=true}}this.status=function(){return status};this.to=function(newNumber){now=element.offsetWidth;if(gotos!=null)window.clearInterval(gotos);status=false,end=newNumber;setMethod();gotos=window.setInterval(start,Animation.p["speed"])}},height:function(element){var status=false,gotos=null;var end=null,now,method;setMethod();function setMethod(){if(now>end){method=false }else if(now<end){method=true }else{return false}};function start(){now+=(end-now)*Animation.p["x"]+Animation.p["pix"];if((method)?(now<end):(now-1>end)){element.style.height=now+"px"}else{window.clearInterval(gotos);element.style.height=end+"px";status=true}}this.status=function(){return status};this.to=function(newNumber){now=element.offsetHeight;if(gotos!=null)window.clearInterval(gotos);status=false,end=newNumber;setMethod();gotos=window.setInterval(start,Animation.p["speed"])}},left:function(element){var status=false,gotos=null;var end=null,now,method;setMethod();function setMethod(){if(now>end){method=false}else if(now<end){method=true}else{return false}}function start(){now+=(end-now)*Animation.p["x"]+Animation.p["pix"];if((method)?(now<end):(now-1>end)){status=false;element.style.left=now+"px"}else{window.clearInterval(gotos);element.style.left=end+"px";status=true}}this.status=function(){return status};this.to=function(newNumber){now=(element.style.left.toInt()!=null)?element.style.left.toInt():element.offsetLeft;if(gotos!=null)window.clearInterval(gotos);status=false,end=newNumber;setMethod();gotos=window.setInterval(start,Animation.p["speed"])}},top: function(element){var status=false,gotos=null;var end=null,now,method;setMethod();function setMethod(){if(now>end){method=false}else if(now<end){method=true}else{return false}};function start(){now+=(end-now)*Animation.p["x"]+Animation.p["pix"];if((method)?(now<end):(now-1>end)){element.style.top=now+"px"}else{window.clearInterval(gotos);element.style.top=end+"px";status=true}}this.status=function(){return status};this.to=function(newNumber){now=getcurrentstyle(element,"top").toInt()||element.offsetTop;if(gotos!=null)window.clearInterval(gotos);status=false,end=newNumber;setMethod();gotos=window.setInterval(start,Animation.p["speed"])}},scrollLeft:function(element){var status=false,gotos=null;var end=null,now,method;setMethod();function setMethod(){if(now>end){method=false}else if(now<end){method=true}else{return false}}function start(){now+=(end-now)*Animation.p["x"]+Animation.p["pix"];if((method)?(now<end):(now-1>end)){element.scrollLeft=now}else{window.clearInterval(gotos);element.scrollLeft=end;status=true}} this.status = function(){ return status };this.to=function(newNumber){now=element.scrollLeft;if(gotos!=null)window.clearInterval(gotos);status=false,end=newNumber;setMethod();gotos=window.setInterval(start,Animation.p["speed"])}},scrollTop:function(element){var status=false,gotos=null;var end=null,now,method;setMethod();function setMethod(){if(now>end){method=false}else if (now<end){method=true}else{return false}};function start(){now+=(end-now)*Animation.p["x"]+Animation.p["pix"];if((method)?(now<end):(now-1>end)){element.scrollTop=now}else{window.clearInterval(gotos);element.scrollTop=end;status=true}};this.status=function(){return status};this.to=function(newNumber){now=element.scrollTop;if(gotos!=null)window.clearInterval(gotos);status=false,end=newNumber;setMethod();gotos=window.setInterval(start,Animation.p["speed"])}},alpha:function(element){var status=false,gotos=null;var end=null,now,method;now=Style.getAlpha(element);setMethod();function setMethod(){if(now>end){method=false}else if(now<end){method=true}else{return false}}function start(){now+=(end-now)*0.75;if((method)?(now<end):(now>end)){if(now>99){now=100;}else{Style.setAlpha(element,now)}}else{window.clearInterval(gotos);Style.setAlpha(element,end);status=true}}this.status=function(){return status};this.to=function(newNumber){if(gotos!=null)window.clearInterval(gotos);status=false,end=newNumber;setMethod();gotos=window.setInterval(start,40)}},marginTop:function(element){var status=false,gotos=null;var end=null,now,method;setMethod();function setMethod(){if(now>end){method=false}else if(now<end){method=true}else{return false}};function start(){now+=(end-now)*Animation.p["x"]+Animation.p["pix"];if((method)?(now<end):(now-1>end)){element.style.marginTop=now+"px"}else{window.clearInterval(gotos);element.style.marginTop=end+"px";status=true}}this.status=function(){return status};this.to=function(newNumber){now=getcurrentstyle(element,"marginTop").toInt();if(gotos!=null)window.clearInterval(gotos);status=false,end=newNumber;setMethod();gotos=window.setInterval(start,Animation.p["speed"])}},
	probe:function(a,step,delayed){var timeLine,evalStr="";if(typeof(a.length)=="number"&&typeof(a)=="object"){for(var i=0;i<a.length;i++){if(i==a.length-1){evalStr+="a["+i+"].status()==true"}else {evalStr+="a["+i+"].status()==true&&"}}}else{evalStr="a.status()==true"}if(typeof(delayed)=="number"){window.clearTimeout(timeLine);timeLine=window.setTimeout(step,delayed*1000)}else{if(eval(evalStr)){window.clearTimeout(timeLine);step()}else{timeLine=window.setTimeout(function(){Animation.probe(a,step,delayed)},100)}}}
}