




function isnewvele(ele) {
	if(!isobject(ele)) return false;
	else if(!isdefined(ele.eletype)) return false;
	else if(ele.eletype>=2) return true;
	return false;
}

function newvele(ele) {
	ele=newele(ele); if(!ele) return false;
	if(ele.eletype>=2) return ele;
	ele.eletype=2;

	ele.show=veleshow;
	ele.hide=velehide;
	ele.isvisible=veleisvisible;

	ele.getnextancestor=velegetnextancestor;
	ele.getabsx=velegetabsx;
	ele.getabsy=velegetabsy;
	
	ele.getx=velegetx;
	ele.gety=velegety;
	ele.setx=velesetx;
	ele.sety=velesety;
	ele.setpos=velesetpos;
	
	ele.getw=velegetw;
	ele.geth=velegeth;
	ele.setw=velesetw;
	ele.seth=veleseth;
	ele.setdim=velesetdim;
	ele.velezwhhidden=-1;
	
	ele.geta=velegeta;
	ele.seta=veleseta;
	
	ele.iidmove=-1;
	ele.mpaused=0;
	ele.mismoving=0;
	ele.mxdir=0;
	ele.mydir=0;
	ele.mtype=0;
	ele.mbeginx=0;
	ele.mprevx=0;
	ele.mcurrentx=0;
	ele.mendx=0;
	ele.mstepx=0;
	ele.mratex=0;
	ele.mbeginy=0;
	ele.mprevy=0;
	ele.mcurrenty=0;
	ele.mendy=0;
	ele.mstepy=0;
	ele.mratey=0;
	ele.moncomplete=0;
	ele.move=velemove;
	ele.movenext=velemovenext;
	ele.pausemove=velepausemove;
	ele.resumemove=veleresumemove;
	ele.stopmove=velestopmove;
	
	ele.iidresize=-1;
	ele.rspaused=0;
	ele.rsisresizing=0;
	ele.rswdir=0;
	ele.rshdir=0;
	ele.rstype=0;
	ele.rsbeginw=0;
	ele.rsprevw=0;
	ele.rscurrentw=0;
	ele.rsendw=0;
	ele.rsstepw=0;
	ele.rsratew=0;
	ele.rsbeginh=0;
	ele.rsprevh=0;
	ele.rscurrenth=0;
	ele.rsendh=0;
	ele.rssteph=0;
	ele.rsrateh=0;
	ele.rsoncomplete=0;
	ele.resize=veleresize;
	ele.resizenext=veleresizenext;
	ele.pauseresize=velepauseresize;
	ele.resumeresize=veleresumeresize;
	ele.stopresize=velestopresize;

	ele.iidfade=-1;
	ele.fpaused=0;
	ele.fisfading=0;
	ele.fdir=0;
	ele.ftype=0;
	ele.fbegina=0;
	ele.fpreva=0;
	ele.fcurrenta=0;
	ele.fenda=0;
	ele.fstepa=0;
	ele.fratea=0;
	ele.foncomplete=0;
	ele.fade=velefade;
	ele.fadenext=velefadenext;
	ele.pausefade=velepausefade;
	ele.resumefade=veleresumefade;
	ele.stopfade=velestopfade;

	ele.setfinger=velesetfinger;
	ele.fixdim=velefixdim;
	
	return ele;
}

function veleshow(disp,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(isie()) if(typeof(ele.velezwhhidden)!='undefined') if(ele.velezwhhidden==1){ ele.velezwhhidden=0; ele.velezwhodisp=''; }
	if(!disp) disp=''/*'block'*/; ele.style.display=disp; ele.style.visibility='visible';
}
function velehide(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(isie()) if(typeof(ele.velezwhhidden)!='undefined') if(ele.velezwhhidden==1){ ele.velezwhhidden=0; ele.velezwhodisp=''; }
	ele.style.visibility='hidden'; ele.style.display='none';
}
function veleisvisible(both,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(!both) both=0;
	if(isie()) if(typeof(ele.velezwhhidden)!='undefined') if(ele.velezwhhidden==1) return true;
	if(both&&ele.style.display=='none'&&ele.style.visibility=='hidden') return false;
	else if(!both&&(ele.style.display=='none'||ele.style.visibility=='hidden')) return false;
	else return true;
}

function velegetnextancestor(oele) {
	if(!oele) oele=this;
	var actualStyle;
	if(window.getComputedStyle) actualStyle=getComputedStyle(oele,null).position;
	else if(oele.currentStyle) actualStyle=oele.currentStyle.position;
	//fallback for browsers with low support - only reliable for inline styles
	else actualStyle=oele.style.position;
	//the offsetParent of a fixed position element is null so it will stop
	if(actualStyle=='absolute'||actualStyle=='fixed') return oele.offsetParent;
	return oele.parentNode;
}
function velegetabsx(oElement) {
	if(!oElement) oElement=this; else if(typeof(oElement)=='string') oElement=document.getElementById(oElement);
	if(typeof(oElement.offsetParent)!='undefined') {
		var originalElement=oElement;
		for(var posX=0;oElement;oElement=oElement.offsetParent) posX+=oElement.offsetLeft;
		if(!originalElement.parentNode||!originalElement.style||typeof(originalElement.scrollLeft)=='undefined') return posX;/*older browsers cannot check element scrolling*/
		oElement=velegetnextancestor(originalElement);
		while(oElement&&oElement!=document.body&&oElement!=document.documentElement) {
			posX-=oElement.scrollLeft;
			oElement=velegetnextancestor(oElement);
		}
		return posX;
	} else return oElement.x;
}
function velegetabsy(oElement) {
	if(!oElement) oElement=this; else if(typeof(oElement)=='string') oElement=document.getElementById(oElement);
	if(typeof(oElement.offsetParent)!='undefined') {
		var originalElement=oElement;
		for(var posY=0;oElement;oElement=oElement.offsetParent) posY+=oElement.offsetTop;
		if(!originalElement.parentNode||!originalElement.style||typeof(originalElement.scrollTop)=='undefined') return posY;/*older browsers cannot check element scrolling*/
		oElement=velegetnextancestor(originalElement);
		while(oElement&&oElement!=document.body&&oElement!=document.documentElement) {
			posY-=oElement.scrollTop;
			oElement=velegetnextancestor(oElement);
		}
		return posY;
	} else return oElement.y;
}
/*function geteleabsxv1(eleid) {
	var ele=document.getElementById(eleid);
	if (document.getBoxObjectFor) return document.getBoxObjectFor(ele).x;
	else return ele.getBoundingClientRect().left;
}
function geteleabsyv1(eleid) {
	var ele=document.getElementById(eleid);
	if (document.getBoxObjectFor) return document.getBoxObjectFor(ele).y;
	else return ele.getBoundingClientRect().top;
}
function geteleabsxv2(elemID) {
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        if (offsetTrail.scrollLeft) offsetLeft-=offsetTrail.scrollLeft;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
    }
    return offsetLeft;
}
function geteleabsyv2(elemID) {
    var offsetTrail = document.getElementById(elemID);
    var offsetTop = 0;
    while (offsetTrail) {
        offsetTop += offsetTrail.offsetTop;
        if (offsetTrail.scrollTop) offsetTop-=offsetTrail.scrollTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetTop += document.body.topMargin;
    }
	return offsetTop;
}
function geteleabsxv3(eleid) {
	var oElement=document.getElementById(eleid);
	if( typeof( oElement.offsetParent ) != 'undefined' ) {
		var originalElement = oElement;
		for( var posX = 0; oElement; oElement = oElement.offsetParent ) {
			posX += oElement.offsetLeft;
			if( oElement != originalElement && oElement != document.body && oElement != document.documentElement ) { posX -= oElement.scrollLeft; }
		}
		return posX;
	} else { return oElement.x; }
}
function geteleabsyv3(eleid) {
	var oElement=document.getElementById(eleid);
	if( typeof( oElement.offsetParent ) != 'undefined' ) {
		var originalElement = oElement;
		for( var posY = 0; oElement; oElement = oElement.offsetParent ) {
			posY += oElement.offsetTop;
			if( oElement != originalElement && oElement != document.body && oElement != document.documentElement ) { posY -= oElement.scrollTop; }
		}
		return posY;
	} else { return oElement.y; }
}*/

function velegetx(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	return parseInt(ele.style.left);
}
function velegety(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	return parseInt(ele.style.top);
}
function velesetx(x,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(isNaN(x)) ele.style.left=x;
	else ele.style.left=Math.round(x)+'px';
}
function velesety(y,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(isNaN(y)) ele.style.top=y;
	else ele.style.top=Math.round(y)+'px';
}
function velesetpos(x,y,ele) {
	velesetx(x,ele); velesety(y,ele);
}

function velegetw(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	return ele.offsetWidth;
}
function velegeth(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	return ele.offsetHeight;
}
function velesetw(w,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(isie()&&w) if(typeof(ele.velezwhhidden)!='undefined') if(ele.velezwhhidden==1){
		ele.style.display=ele.velezwhodisp;
		if(velegeth(ele)>0){ ele.style.visibility='visible'; ele.velezwhhidden=0;
		}else{ ele.style.display='none'; }
	}
	if(isNaN(w)) ele.style.width=w;
	else if(w>=0) {
		ele.style.width=Math.round(w)+'px';
		if(isie()&&w==0) if(ele.style.display!='none'&&ele.style.visibility!='hidden'){
			ele.velezwhhidden=1; ele.velezwhodisp=ele.style.display?ele.style.display:'';
			ele.style.display='none'; ele.style.visibility='hidden';
		}
	}
}
function veleseth(h,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(isie()&&h) if(typeof(ele.velezwhhidden)!='undefined') if(ele.velezwhhidden==1){
		ele.style.display=ele.velezwhodisp;
		if(velegetw(ele)>0){ ele.style.visibility='visible'; ele.velezwhhidden=0;
		}else{ ele.style.display='none'; }
	}
	if(isNaN(h)) ele.style.height=h;
	else if(h>=0) {
		ele.style.height=Math.round(h)+'px';
		if(isie()&&h==0) if(ele.style.display!='none'&&ele.style.visibility!='hidden'){
			ele.velezwhhidden=1; ele.velezwhodisp=ele.style.display?ele.style.display:'';
			ele.style.display='none'; ele.style.visibility='hidden'; 
		}
	}
}
function velesetdim(w,h,ele) {
	velesetw(w,ele); veleseth(h,ele);
}

function velegeta(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(typeof(ele.style.opacity)!='undefined') return ele.style.opacity*100;
	else if(typeof(ele.style.MozOpacity)!='undefined') return ele.style.MozOpacity*100;
	else if(typeof(ele.style.filter)!='undefined') {
		if(typeof(ele.filters.alpha)=='undefined') ele.style.filter='alpha(opacity=100)';
		return +(ele.filters.alpha.opacity);
	}
}
function veleseta(alpha,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(alpha<0) alpha=0;
	if(typeof(ele.style.opacity)!='undefined') ele.style.opacity=alpha/100;
	else if(typeof(ele.style.MozOpacity)!='undefined') ele.style.MozOpacity=alpha/100;
	else if(typeof(ele.style.filter)!='undefined') {
		if(typeof(ele.filters.alpha)=='undefined') ele.style.filter='alpha(opacity='+alpha+')';
		else ele.filters.alpha.opacity=alpha;
	}
}

function velemove(mms,mt,sx,rx,bx,ex,sy,ry,by,ey,oncomplete) {
	var ele=this;
	ele.mtype=mt;
	ele.mbeginx=bx;
	ele.mendx=ex;
	ele.mxdir='r'; if(ele.mbeginx>ele.mendx) ele.mxdir='l';
	if(sx=='at') {
		//ele.mtype==1?sx=1:sx=Math.abs(ele.mendx-ele.mbeginx)/17.33; // earlier version
		if(ele.mtype==1||ele.mtype==2) sx=1;
		//else sx=Math.abs(ele.mendx-ele.mbeginx)*30/100; // quick version
		else if(Math.abs(ele.mendx-ele.mbeginx)<=20) sx=Math.abs(ele.mendx-ele.mbeginx)*8.5/100;
		else if(Math.abs(ele.mendx-ele.mbeginx)<=30) sx=Math.abs(ele.mendx-ele.mbeginx)*8.0/100;
		else if(Math.abs(ele.mendx-ele.mbeginx)<=40) sx=Math.abs(ele.mendx-ele.mbeginx)*7.5/100;
		else if(Math.abs(ele.mendx-ele.mbeginx)<=50) sx=Math.abs(ele.mendx-ele.mbeginx)*7.0/100;
		else if(Math.abs(ele.mendx-ele.mbeginx)<=80) sx=Math.abs(ele.mendx-ele.mbeginx)*6.5/100;
		else if(Math.abs(ele.mendx-ele.mbeginx)<=100) sx=Math.abs(ele.mendx-ele.mbeginx)*6.1/100;
		else sx=Math.abs(ele.mendx-ele.mbeginx)*5.75/100;
	}
	ele.mstepx=sx;
	if(rx=='at') {
		//ele.mtype==1?rx=0:rx=0.05; // earlier version
		if(ele.mtype==1) { rx=0; }
		else if(ele.mtype==2) { rx=0.15; }
		else if(ele.mtype==3) { rx=0.05; /*rx=0.23;//quick version*/ }
	}
	ele.mratex=rx;
	ele.mbeginy=by;
	ele.mendy=ey;
	ele.mydir='d'; if(ele.mbeginy>ele.mendy) ele.mydir='u';
	if(sy=='at') {
		//ele.mtype==1?sy=1:sy=Math.abs(ele.mendy-ele.mbeginy)/17.33; // earlier version
		if(ele.mtype==1||ele.mtype==2) sy=1;
		//else sy=Math.abs(ele.mendy-ele.mbeginy)*30/100; // quick version
		else if(Math.abs(ele.mendy-ele.mbeginy)<=20) sy=Math.abs(ele.mendy-ele.mbeginy)*8.5/100;
		else if(Math.abs(ele.mendy-ele.mbeginy)<=30) sy=Math.abs(ele.mendy-ele.mbeginy)*8.0/100;
		else if(Math.abs(ele.mendy-ele.mbeginy)<=40) sy=Math.abs(ele.mendy-ele.mbeginy)*7.5/100;
		else if(Math.abs(ele.mendy-ele.mbeginy)<=50) sy=Math.abs(ele.mendy-ele.mbeginy)*7.0/100;
		else if(Math.abs(ele.mendy-ele.mbeginy)<=80) sy=Math.abs(ele.mendy-ele.mbeginy)*6.5/100;
		else if(Math.abs(ele.mendy-ele.mbeginy)<=100) sy=Math.abs(ele.mendy-ele.mbeginy)*6.1/100;
		else sy=Math.abs(ele.mendy-ele.mbeginy)*5.75/100;
	}
	ele.mstepy=sy;
	if(ry=='at') {
		//ele.mtype==1?ry=0:ry=0.05; // earlier version
		if(ele.mtype==1) { ry=0; }
		else if(ele.mtype==2) { ry=0.15; }
		else if(ele.mtype==3) { ry=0.05; /*ry=0.23;//quick version*/ }
	}
	ele.mratey=ry;
	ele.mcurrentx=ele.mbeginx;
	ele.mcurrenty=ele.mbeginy;
	ele.setx(ele.mcurrentx);
	ele.sety(ele.mcurrenty);
	ele.mprevx=ele.getx();
	ele.mprevy=ele.gety();
	if(typeof(oncomplete)!='function') oncomplete=0; ele.moncomplete=oncomplete;
	//if(oncomplete&&oncomplete!=''&&oncomplete!=null) ele.moncomplete=oncomplete;
	ele.stopmove();
	ele.mismoving=1;
	if(mms=='at') mms=1;
//ele.iidmove=setInterval(function(){velemovenext(ele);},mms);
	ele.iidmove=setInterval(function(){ele.movenext();},mms);
}
function velemovenext() {
	var ele=this;
	if(ele.mpaused) return;
	if(ele.mtype==1) { // constant
		ele.mstepx+=ele.mratex;
		ele.mstepy+=ele.mratey;
	} else if(ele.mtype==2) { // accelerated
		ele.mstepx+=ele.mstepx*ele.mratex;
		ele.mstepy+=ele.mstepy*ele.mratey;
	} else if(ele.mtype==3) { // decelerated
		ele.mstepx-=ele.mstepx*ele.mratex;
		ele.mstepy-=ele.mstepy*ele.mratey;
	}
	if(ele.mxdir=='r') ele.mcurrentx+=ele.mstepx;
	else if(ele.mxdir=='l') ele.mcurrentx-=ele.mstepx;
	if(ele.mydir=='d') ele.mcurrenty+=ele.mstepy;
	else if(ele.mydir=='u') ele.mcurrenty-=ele.mstepy;
	ele.setx(ele.mcurrentx);
	ele.sety(ele.mcurrenty);
	var curx=ele.getx();
	var cury=ele.gety();
	if (
		 ( ((ele.mxdir=='r'&&ele.mcurrentx>=ele.mendx) || (ele.mxdir=='l'&&ele.mcurrentx<=ele.mendx)) && 
			((ele.mydir=='d'&&ele.mcurrenty>=ele.mendy) || (ele.mydir=='u'&&ele.mcurrenty<=ele.mendy)) ) || 
		(curx==ele.mprevx&&cury==ele.mprevy)
	) {
		ele.stopmove();
		ele.mcurrentx=ele.mendx;
		ele.mcurrenty=ele.mendy;
		ele.setx(ele.mcurrentx);
		ele.sety(ele.mcurrenty);
		if(typeof(ele.moncomplete)=='function') ele.moncomplete();
		//ele.moncomplete=0;
		return;
	}
	ele.mprevx=curx;
	ele.mprevy=cury;
}
function velepausemove() {
	var ele=this;
	ele.mpaused=1;
}
function veleresumemove() {
	var ele=this;
	ele.mpaused=0;
}
function velestopmove() {
	var ele=this;
	if(ele.iidmove!=-1) {
		clearInterval(ele.iidmove);
		ele.iidmove=-1;
		ele.mpaused=0;
		ele.mismoving=0;
	}
}

function veleresize(rsms,rst,sw,rw,bw,ew,sh,rh,bh,eh,oncomplete) {
	var ele=this;
	ele.rstype=rst;
	ele.rsbeginw=bw;
	ele.rsendw=ew;
	ele.rswdir='e'; if(ele.rsbeginw>ele.rsendw) ele.rswdir='s';
	if(sw=='at') {
		//ele.rstype==1?sw=1:sw=Math.abs(ele.rsendw-ele.rsbeginw)/17.33; //earlier version
		if(ele.rstype==1||ele.rstype==2) sw=1;
		//else sw=Math.abs(ele.rsendw-ele.rsbeginw)*30/100; //quick version
		else if(Math.abs(ele.rsendw-ele.rsbeginw)<=20) sw=Math.abs(ele.rsendw-ele.rsbeginw)*8.5/100;
		else if(Math.abs(ele.rsendw-ele.rsbeginw)<=30) sw=Math.abs(ele.rsendw-ele.rsbeginw)*8.0/100;
		else if(Math.abs(ele.rsendw-ele.rsbeginw)<=40) sw=Math.abs(ele.rsendw-ele.rsbeginw)*7.5/100;
		else if(Math.abs(ele.rsendw-ele.rsbeginw)<=50) sw=Math.abs(ele.rsendw-ele.rsbeginw)*7.0/100;
		else if(Math.abs(ele.rsendw-ele.rsbeginw)<=80) sw=Math.abs(ele.rsendw-ele.rsbeginw)*6.5/100;
		else if(Math.abs(ele.rsendw-ele.rsbeginw)<=100) sw=Math.abs(ele.rsendw-ele.rsbeginw)*6.1/100;
		else sw=Math.abs(ele.rsendw-ele.rsbeginw)*5.75/100;
	}
	ele.rsstepw=sw;
	if(rw=='at') {
		//ele.rstype==1?rw=0:rw=0.05; //earlier version
		if(ele.rstype==1) { rw=0; }
		else if(ele.rstype==2) { rw=0.15; }
		else if(ele.rstype==3) { rw=0.05; /*rw=0.23;//quick version*/ }
	}
	ele.rsratew=rw;
	ele.rsbeginh=bh;
	ele.rsendh=eh;
	ele.rshdir='e'; if(ele.rsbeginh>ele.rsendh) ele.rshdir='s';
	if(sh=='at') {
		//ele.rstype==1?sh=1:sh=Math.abs(ele.rsendh-ele.rsbeginh)/17.33; //earlier version
		if(ele.rstype==1||ele.rstype==2) sh=1;
		//else sh=Math.abs(ele.rsendh-ele.rsbeginh)*30/100; //quick version
		else if(Math.abs(ele.rsendh-ele.rsbeginh)<=20) sh=Math.abs(ele.rsendh-ele.rsbeginh)*8.5/100;
		else if(Math.abs(ele.rsendh-ele.rsbeginh)<=30) sh=Math.abs(ele.rsendh-ele.rsbeginh)*8.0/100;
		else if(Math.abs(ele.rsendh-ele.rsbeginh)<=40) sh=Math.abs(ele.rsendh-ele.rsbeginh)*7.5/100;
		else if(Math.abs(ele.rsendh-ele.rsbeginh)<=50) sh=Math.abs(ele.rsendh-ele.rsbeginh)*7.0/100;
		else if(Math.abs(ele.rsendh-ele.rsbeginh)<=80) sh=Math.abs(ele.rsendh-ele.rsbeginh)*6.5/100;
		else if(Math.abs(ele.rsendh-ele.rsbeginh)<=100) sh=Math.abs(ele.rsendh-ele.rsbeginh)*6.1/100;
		else sh=Math.abs(ele.rsendh-ele.rsbeginh)*5.75/100;
	}
	ele.rssteph=sh;
	if(rh=='at') {
		//ele.rstype==1?rh=0:rh=0.05; //earlier version
		if(ele.rstype==1) { rh=0; }
		else if(ele.rstype==2) { rh=0.15; }
		else if(ele.rstype==3) { rh=0.05; /*rh=0.23;//quick version*/ }
	}
	ele.rsrateh=rh;
	ele.rscurrentw=ele.rsbeginw;
	ele.rscurrenth=ele.rsbeginh;
	ele.setw(ele.rscurrentw);
	ele.seth(ele.rscurrenth);
	ele.rsprevw=ele.getw();
	ele.rsprevh=ele.geth();
	if(typeof(oncomplete)!='function') oncomplete=0; ele.rsoncomplete=oncomplete;
	//if(oncomplete&&oncomplete!=''&&oncomplete!=null) ele.rsoncomplete=oncomplete;
	ele.stopresize();
	ele.rsisresizing=1;
	if(rsms=='at') rsms=1;
	ele.iidresize=setInterval(function(){ele.resizenext();},rsms);
}
function veleresizenext() {
	var ele=this;
	if(ele.rspaused) return;
	if(ele.rstype==1) { // constant
		ele.rsstepw+=ele.rsratew;
		ele.rssteph+=ele.rsrateh;
	} else if(ele.rstype==2) { // accelerated
		ele.rsstepw+=ele.rsstepw*ele.rsratew;
		ele.rssteph+=ele.rssteph*ele.rsrateh;
	} else if(ele.rstype==3) { // decelerated
		ele.rsstepw-=ele.rsstepw*ele.rsratew;
		ele.rssteph-=ele.rssteph*ele.rsrateh;
	}
	if(ele.rswdir=='e') ele.rscurrentw+=ele.rsstepw;
	else if(ele.rswdir=='s') ele.rscurrentw-=ele.rsstepw;
	if(ele.rshdir=='e') ele.rscurrenth+=ele.rssteph;
	else if(ele.rshdir=='s') ele.rscurrenth-=ele.rssteph;
	ele.setw(ele.rscurrentw);
	ele.seth(ele.rscurrenth);
	var curw=ele.getw();
	var curh=ele.geth();
	if (
		 ( ((ele.rswdir=='e'&&ele.rscurrentw>=ele.rsendw) || (ele.rswdir=='s'&&ele.rscurrentw<=ele.rsendw)) && 
			((ele.rshdir=='e'&&ele.rscurrenth>=ele.rsendh) || (ele.rshdir=='s'&&ele.rscurrenth<=ele.rsendh)) ) || 
		(curw==ele.rsprevw&&curh==ele.rsprevh)
	) {
		ele.stopresize();
		ele.rscurrentw=ele.rsendw;
		ele.rscurrenth=ele.rsendh;
		ele.setw(ele.rscurrentw);
		ele.seth(ele.rscurrenth);
		if(typeof(ele.rsoncomplete)=='function') ele.rsoncomplete();
		//ele.rsoncomplete=0;
		return;
	}
	ele.rsprevw=curw;
	ele.rsprevh=curh;
}
function velepauseresize() {
	var ele=this;
	ele.rspaused=1;
}
function veleresumeresize() {
	var ele=this;
	ele.rspaused=0;
}
function velestopresize() {
	var ele=this;
	if(ele.iidresize!=-1) {
		clearInterval(ele.iidresize);
		ele.iidresize=-1;
		ele.rspaused=0;
		ele.rsisresizing=0;
	}
}

function velefade(fms,ft,fs,fr,ba,ea,oncomplete) {
	var ele=this;
	//if(ele.style.display=='none') ele.style.display=''/*'block'*/;
	//if(ele.style.visibility=='hidden') ele.style.visibility='visible';
	ele.ftype=ft;
	if(fs=='at') {
		if(ele.ftype==1) { fs=1; }
		else if(ele.ftype==2) { fs=1; }
		else if(ele.ftype==3) { fs=8; }
	}
	//if(fs=='at') ele.ftype==1?fs=1:fs=8;
	ele.fstepa=fs;
	if(fr=='at') {
		if(ele.ftype==1) { fr=0; }
		else if(ele.ftype==2) { fr=0.15; }
		else if(ele.ftype==3) { fr=0.05; }
	}
	//if(fr=='at') ele.ftype==1?fr=0:fr=0.05;
	ele.fratea=fr;
	ele.fbegina=ba;
	ele.fenda=ea;
	ele.fdir='i'; if(ele.fbegina>ele.fenda) ele.fdir='o';
	ele.fcurrenta=ele.fbegina;
	ele.seta(ele.fcurrenta);
	ele.fpreva=ele.fcurrenta;
	if(typeof(oncomplete)!='function') oncomplete=0; ele.foncomplete=oncomplete;
	//if(oncomplete&&oncomplete!=''&&oncomplete!=null) ele.foncomplete=oncomplete;
	ele.stopfade();
	ele.fisfading=1;
	if(fms=='at') fms=15;
	ele.iidfade=setInterval(function(){ele.fadenext();},fms);
}
function velefadenext() {
	var ele=this;
	if(ele.fpaused) return;
	if(ele.ftype==1) ele.fstepa+=ele.fratea; // constant
	else if(ele.ftype==2) ele.fstepa+=ele.fstepa*ele.fratea; // accelerated
	else if(ele.ftype==3) ele.fstepa-=ele.fstepa*ele.fratea; // decelerated
	if(ele.fdir=='i') ele.fcurrenta+=ele.fstepa;
	else if(ele.fdir=='o') ele.fcurrenta-=ele.fstepa;
	ele.seta(ele.fcurrenta);
	if( (ele.fdir=='i'&&ele.fcurrenta>=ele.fenda) || (ele.fdir=='o'&&ele.fcurrenta<=ele.fenda) || (Math.round(ele.fcurrenta)==Math.round(ele.fpreva)) ) {
		ele.stopfade();
		ele.fcurrenta=ele.fenda;
		ele.seta(ele.fcurrenta);
		if(typeof(ele.foncomplete)=='function') ele.foncomplete();
		//ele.foncomplete=0;
		/*if(ele.fcurrenta<=0&&ele.fenda<=0) {
			ele.style.display='none';
			ele.style.visibility='hidden';
		}*/
	}
	/*if(!al2h&&ele.fcurrenta<=0) {
		ele.style.display='none';
		ele.style.visibility='hidden';
	}*/
	ele.fpreva=ele.fcurrenta;
}
function velepausefade() {
	var ele=this;
	ele.fpaused=1;
}
function veleresumefade() {
	var ele=this;
	ele.fpaused=0;
}
function velestopfade() {
	var ele=this;
	if(ele.iidfade!=-1) {
		clearInterval(ele.iidfade);
		ele.iidfade=-1;
		ele.fpaused=0;
		ele.fisfading=0;
		/*if(ele.geta()<=0) {
			ele.style.display='none';
			ele.style.visibility='hidden';
		}*/
	}
}

function velesetfinger(setstate,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(setstate) eleaddevent('mouseover',function(){this.style.cursor='pointer';},ele);
	else eleremoveevent('mouseover',function(){this.style.cursor='pointer';},ele);
}

function velefixdim(w,h,oflow,ele) {
	if(!eleistable(ele)||!eleistd(ele)||!eleisdiv(ele)) return -1;
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	velesetw(w,ele);
	veleseth(h,ele);
	ele.style.overflow=oflow;
}





/**********************************************************************
TERMS OF USE - EASING EQUATIONS
Open source under the BSD License.
Copyright (c) 2001 Robert Penner
JavaScript version copyright (C) 2006 by Philippe Maegerman
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

   * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
   * Neither the name of the author nor the names of contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*****************************************/



/*****************************************
The Tween class
CONSTRUCTOR
var t = new Tween(object,property,easing,start,end,duration,suffixe);

object:
type:Object
The object you want to modify. It can be any object, a visual object that you want to animate ( document.body.style ) or an anymous object ( new Object() ).
property:
type:String
The property that is updated on the target object, it can be empty ('')
easing:
type:Function
The easing that will be applied to motion. ( I have listed the functions below and created a sample to allow you to try them )
start:
type:Number
Start value
end:
type:Number
End value
duration:
type:Number
Animation duration in seconds
suffixe:
type:String
A string to append to the updated property ('%','pt','em' ...).
METHODS

    * start()
    * rewind()
    * fforward()
    * stop()
    * resume()
    * continueTo( end, duration )
    * yoyo()
    * addListener( listenerObject )
    * removeListener( listenerObject )
	
	
Easing functions
About Easing Classes and Methods
The default easing functions are methods of the Tween.as class.

    * Tween.regularEaseIn
    * Tween.regularEaseOut
    * Tween.regularEaseInOut
    * Tween.strongEaseIn
    * Tween.strongEaseOut
    * Tween.strongEaseInOut
    * Tween.backEaseOut
    * Tween.backEaseIn
    * Tween.backEaseInOut
    * Tween.bounceEaseOut
    * Tween.bounceEaseIn
    * Tween.bounceEaseInOut
    * Tween.elasticEaseIn
    * Tween.elasticEaseOut
    * Tween.elasticEaseInOut



EVENTS AND LISTENERS
onMotionStarted( eventObject )
onMotionChanged( eventObject )
onMotionFinished( eventObject )
onMotionStopped( eventObject )
onMotionLooped( eventObject )
onMotionResumed( eventObject )

the eventObject passed contains 2 properties:

    * target : the Tween instance (object)
    * type : the event name (string, ex: 'onMotionChanged')

2 ways to use events :

1- adding a method on your Tween instance with the same name as the event you want to listen.

Example:
t1A = new Tween(document.getElementById('sqA').style,'left',Tween.elasticEaseOut,0,500,1,'px');
t1A.onMotionFinished = function(){alert( 'onMotionFinished' )};
t1A.start();

Example:
using the yoyo() method, the following code will create an endless animation:
t1C = new Tween(document.getElementById('sqC').style,'left',Tween.elasticEaseOut,0,500,1,'px');
t1C.onMotionFinished = function(){this.yoyo()};
t1C.start();

If, for example you wanted the yoyo() to perform only once, you would write code like
t1C.onMotionFinished = function(){
   this.yoyo();
   this.onMotionFinished = undefined;
}

2- using the addListener method:

Example:
t1A = new Tween(document.getElementById('sqA').style,'left',Tween.elasticEaseOut,0,500,1,'px');
var a = new Object();
a.onMotionFinished = function(){
   alert( 'onMotionFinished' )
};
a.onMotionStarted = function(){
   alert( 'onMotionStarted' )
}
t1A.addListener(a)
t1A.start();




The advantage of this is that you can add as many listeners as desired.
If you want to remove a listener, you can use the method 'removeListener( listenerObject )', where the listenerObject is the reference to the object that was added as listener.

Because we are tweening values, it is possible to instantiate a tween that won't directly apply changes to a visual object.

Example:
[textarea id="myTA" cols="40" rows="10"][/textarea]

[input type="button" value="tween from 1 to 100" onClick="
tweenTA = new Tween(new Object(),'xyz',Tween.bounceEaseOut,1,100,1);
var myTA = document.getElementById('myTA');
myTA.value='';
tweenTA.onMotionChanged = function(event){
   myTA.value += event.target._pos + '\n';
};
tweenTA.start();"]


Same example, but more 'creative':
[textarea id="myTA2" cols="40" rows="8"][/textarea]

[input type="button" value="tween text" onClick="
myText='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
tweenTA2 = new Tween(new Object(),'xyz',Tween.bounceEaseOut,0,myText.length,3);
var myTA2 = document.getElementById('myTA2');
myTA2.value='';
tweenTA2.onMotionChanged = function(event){
   myTA2.value = myText.substr(0,event.target._pos);
};
tweenTA2.start();"]
/*******************************************/
function Delegate(){}
Delegate.create=function(o,f){
	var a=new Array();
	var l=arguments.length;
	for(var i=2;i<l;i++) a[i-2]=arguments[i];
	return function(){
		var aP=[].concat(arguments,a);
		f.apply(o,aP);
	}
}
anim=function(obj,prop,func,begin,finish,duration,suffixe){
	this.init(obj,prop,func,begin,finish,duration,suffixe);
}
anim.prototype.obj=new Object();
anim.prototype.prop='';
anim.prototype.func=function(t,b,c,d){ return c*t/d+b; };
anim.prototype.begin=0;
anim.prototype.change=0;
anim.prototype.prevTime=0;
anim.prototype.prevPos=0;
anim.prototype.looping=false;
anim.prototype._duration=0;
anim.prototype._time=0;
anim.prototype._pos=0;
anim.prototype._position=0;
anim.prototype._startTime=0;
anim.prototype._finish=0;
anim.prototype.name='';
anim.prototype.suffixe='';
anim.prototype._listeners=new Array();	
anim.prototype.setTime=function(t){
	this.prevTime=this._time;
	if(t>this.getDuration()){
		if(this.looping){
			this.rewind(t-this._duration);
			this.update();
			this.broadcastMessage('onMotionLooped',{target:this,type:'onMotionLooped'});
		}else{
			this._time=this._duration;
			this.update();
			this.stop();
			this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'});
		}
	}else if(t<0){
		this.rewind();
		this.update();
	}else{
		this._time=t;
		this.update();
	}
}
anim.prototype.getTime=function(){
	return this._time;
}
anim.prototype.setDuration=function(d){
	this._duration=(d==null||d<=0)?100000:d;
}
anim.prototype.getDuration=function(){
	return this._duration;
}
anim.prototype.setPosition=function(p){
	this.prevPos=this._pos;
	var a=this.suffixe!=''?this.suffixe:'';
	this.obj[this.prop]=Math.round(p)+a;
	this._pos=p;
	this.broadcastMessage('onMotionChanged',{target:this,type:'onMotionChanged'});
}
anim.prototype.getPosition=function(t){
	if(t==undefined) t=this._time;
	return this.func(t,this.begin,this.change,this._duration);
};
anim.prototype.setFinish=function(f){
	this.change=f-this.begin;
};
anim.prototype.getFinish=function(){
	return this.begin+this.change;
};
anim.prototype.init=function(obj,prop,func,begin,finish,duration,suffixe){
	if(!arguments.length) return;
	this._listeners=new Array();
	this.addListener(this);
	if(suffixe) this.suffixe=suffixe;
	this.obj=obj;
	this.prop=prop;
	this.begin=begin;
	this._pos=begin;
	this.setDuration(duration);
	if(func!=null&&func!=''){
		this.func=func;
	}
	this.setFinish(finish);
}
anim.prototype.start=function(){
	this.rewind();
	this.startEnterFrame();
	this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});
	//alert('in');
}
anim.prototype.rewind=function(t){
	this.stop();
	this._time=(t==undefined)?0:t;
	this.fixTime();
	this.update();
}
anim.prototype.fforward=function(){
	this._time=this._duration;
	this.fixTime();
	this.update();
}
anim.prototype.update=function(){
	this.setPosition(this.getPosition(this._time));
}
anim.prototype.startEnterFrame=function(){
	this.stopEnterFrame();
	this.isPlaying=true;
	this.onEnterFrame();
}
anim.prototype.onEnterFrame=function(){
	if(this.isPlaying){
		this.nextFrame();
		setTimeout(Delegate.create(this,this.onEnterFrame),0);
	}
}
anim.prototype.nextFrame=function(){
	this.setTime((this.getTimer()-this._startTime)/1000);
}
anim.prototype.stop=function(){
	this.stopEnterFrame();
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}
anim.prototype.stopEnterFrame=function(){
	this.isPlaying=false;
}
anim.prototype.continueTo=function(finish,duration){
	this.begin=this._pos;
	this.setFinish(finish);
	if(this._duration!=undefined) this.setDuration(duration);
	this.start();
}
anim.prototype.resume=function(){
	this.fixTime();
	this.startEnterFrame();
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'});
}
anim.prototype.yoyo=function(){
	this.continueTo(this.begin,this._time);
}
anim.prototype.addListener=function(o){
	this.removeListener(o);
	return this._listeners.push(o);
}
anim.prototype.removeListener=function(o){
	var a=this._listeners;	
	var i=a.length;
	while(i--){
		if(a[i]==o){
			a.splice(i,1);
			return true;
		}
	}
	return false;
}
anim.prototype.broadcastMessage=function(){
	var arr=new Array();
	for(var i=0;i<arguments.length;i++){
		arr.push(arguments[i])
	}
	var e=arr.shift();
	var a=this._listeners;
	var l=a.length;
	for (var i=0;i<l;i++){
		if(a[i][e])
		a[i][e].apply(a[i],arr);
	}
}
anim.prototype.fixTime=function(){
	this._startTime=this.getTimer()-this._time*1000;
}
anim.prototype.getTimer=function(){
	return new Date().getTime()-this._time;
}
anim.backEaseIn=function(t,b,c,d,a,p){
	if(s==undefined) var s=1.70158;
	return c*(t/=d)*t*((s+1)*t-s)+b;
}
anim.backEaseOut=function(t,b,c,d,a,p){
	if(s==undefined) var s=1.70158;
	return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;
}
anim.backEaseInOut=function(t,b,c,d,a,p){
	if(s==undefined) var 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;
}
anim.elasticEaseIn=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;	
}
anim.elasticEaseOut=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);
}
anim.elasticEaseInOut=function(t,b,c,d,a,p){
	if(t==0) return b; if((t/=d/2)==2) return b+c; if(!p) var p=d*(.3*1.5);
	if(!a||a<Math.abs(c)){ var 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;
}
anim.bounceEaseOut=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;
	}
}
anim.bounceEaseIn=function(t,b,c,d){
	return c-anim.bounceEaseOut(d-t,0,c,d)+b;
}
anim.bounceEaseInOut=function(t,b,c,d){
	if(t<d/2) return anim.bounceEaseIn(t*2,0,c,d)*.5+b;
	else return anim.bounceEaseOut(t*2-d,0,c,d)*.5+c*.5+b;
}	
anim.strongEaseInOut=function(t,b,c,d){
	return c*(t/=d)*t*t*t*t+b;
}
anim.regularEaseIn=function(t,b,c,d){
	return c*(t/=d)*t+b;
}
anim.regularEaseOut=function(t,b,c,d){
	return -c*(t/=d)*(t-2)+b;
}
anim.regularEaseInOut=function(t,b,c,d){
	if((t/=d/2)<1) return c/2*t*t+b;
	return -c/2*((--t)*(t-2)-1)+b;
}
anim.strongEaseIn=function(t,b,c,d){
	return c*(t/=d)*t*t*t*t+b;
}
anim.strongEaseOut=function(t,b,c,d){
	return c*((t=t/d-1)*t*t*t*t+1)+b;
}
anim.strongEaseInOut=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;
}



/***************************************
The TextTween class
TextTween.js extends the Tween.js class, its purpose is to manage text effects.
Because it is a subclass of Tween you must include the Tween.as class before you include the TextTween.js class.

[script language="javascript" src="Tween.js"][/script]
[script language="javascript" src="TextTween.js"][/script]

Because TextTween.js is a subclass of Tween.js, all the Tween methods and events are available.

CONSTRUCTOR
var t = new TextTween(object,property,text,easing,duration);

Click here to see it in action.
I have added the interesting code below the example.

The Sequence class

The sequence.js class allows you to chain Tweens, it means that the Tweens that have been added via the 'addChild()' method will be executed in the sequence they have been added.
Besides, a Sequence can be a child of a Sequence, allowing you to build and reuse complex animations.

METHODS

    * addChild( Tween )
    * removeChild( Tween )
    * start()
    * rewind()
    * fforward()
    * stop()
    * resume()


EVENTS
onMotionStarted( eventObject )
onMotionFinished( eventObject )
onMotionStopped( eventObject )
onMotionLooped( eventObject )
onMotionResumed( eventObject )

Usage:
var my_seq = new Sequence();
my_seq.addChild(new Tween(elem1.style,'width',Tween.bounceEaseOut,25,100,0.5,'px'));
my_seq.addChild(new Tween(elem2.style,'width',Tween.bounceEaseOut,25,100,0.5,'px'));
my_seq.start()
****************************************/
textanim.prototype=new anim();
textanim.prototype.constructor=anim;
textanim.superclass=anim.prototype;
function textanim(obj,property,txt,func,duration){
	this.targetObject=obj;
	this.targetProperty=property;
	this.txt=txt;
	if(func!=null&&func!=''){
		this.func=func;
	}
	this.init(new Object(),'x',func,0,txt.length,duration);
}
textanim.prototype.targetObject={};
textanim.prototype.targetProperty={};
textanim.prototype.fromColor='';
textanim.prototype.toColor='';
textanim.prototype.currentColor='';
textanim.prototype.onMotionChanged=function(evt){
	var v=evt.target._pos;
	this.targetObject[this.targetProperty]=this.txt.substr(0,v);
}



/****************************************
The ColorTween class
ColorTween.js extends the Tween.js class, its purpose is to manage transitions between two colors.
Because it is a subclass of Tween you must include the Tween.as class before you include the ColorTween.js class.

[script language="javascript" src="Tween.js"][/script]
[script language="javascript" src="ColorTween.js"][/script]

Because ColorTween.js is a subclass of Tween.js, all the Tween methods and events are available.

CONSTRUCTOR
var colorTween = new ColorTween(object,property,easing,startColor,endColor,duration);

An example will be worth a thousand words:

[div id="square22" style="width:50px;height:50px;background-color:#FF0000;"][/div]
[input type="button" value="toggle Color (red-blue)" onClick="
colorTween = new ColorTween(document.getElementById('square22').style, 'backgroundColor', Tween.bounceEaseOut, 'FF0000', '0000FF', 3);
colorTween.start()"]


Example:

[input type="button" value="Click to animate the background color of this page" onclick="
bgTween = new ColorTween(document.body.style, 'backgroundColor', Tween.bounceEaseOut,'FFFFFF','000000',2);
bgTween.onMotionFinished = function(){
   this.yoyo();
   this.onMotionFinished = undefined;
};
bgTween.start();"]

Notice the code in bold, without it, the animation would play forever, which would be useful if we wanted to have an element that blinks or pulse. I'll let your imagination do the job.
*****************************************/
coloranim.prototype=new anim();
coloranim.prototype.constructor=anim;
coloranim.superclass=anim.prototype;
function coloranim(obj,prop,func,fromColor,toColor,duration){
	this.targetObject=obj;
	this.targetProperty=prop;	
	this.fromColor=fromColor;
	this.toColor=toColor;
	this.init(new Object(),'x',func,0,100,duration);
	this.listenerObj=new Object();
	this.listenerObj.onMotionChanged=Delegate.create(this,this.onColorChanged);
	this.addListener(this.listenerObj);
}
coloranim.prototype.targetObject={};
coloranim.prototype.targetProperty={};
coloranim.prototype.fromColor='';
coloranim.prototype.toColor='';
coloranim.prototype.currentColor='';
coloranim.prototype.listenerObj={};
coloranim.prototype.onColorChanged=function(){
	this.currentColor=this.getColor(this.fromColor,this.toColor,this._pos);
	this.targetObject[this.targetProperty]=this.currentColor;
}
/***********************************************
*
* Function    : getColor
*
* Parameters  :    start - the start color (in the form "RRGGBB" e.g. "FF00AC")
*            end - the end color (in the form "RRGGBB" e.g. "FF00AC")
*            percent - the percent (0-100) of the fade between start & end
*
* returns      : color in the form "#RRGGBB" e.g. "#FA13CE"
*
* Description : This is a utility function. Given a start and end color and
*            a percentage fade it returns a color in between the 2 colors
*
* Author      : www.JavaScript-FX.com
*
*************************************************/ 
coloranim.prototype.getColor=function(start,end,percent){
	var r1=this.hex2dec(start.slice(0,2));
    var g1=this.hex2dec(start.slice(2,4));
    var b1=this.hex2dec(start.slice(4,6));
    var r2=this.hex2dec(end.slice(0,2));
    var g2=this.hex2dec(end.slice(2,4));
    var b2=this.hex2dec(end.slice(4,6));
    var pc=percent/100;
    r= Math.floor(r1+(pc*(r2-r1))+.5);
    g= Math.floor(g1+(pc*(g2-g1))+.5);
    b= Math.floor(b1+(pc*(b2-b1))+.5);
    return("#"+this.dec2hex(r)+this.dec2hex(g)+this.dec2hex(b));
}
/*** These are the simplest HEX/DEC conversion routines I could come up with ***/
/*** I have seen a lot of fade routines that seem to make this a             ***/
/*** very complex task. I am sure somene else must've had this idea          ***/
/************************************************/  
coloranim.prototype.dec2hex=function(dec){return(this.hexDigit[dec>>4]+this.hexDigit[dec&15]);}
coloranim.prototype.hexDigit=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
coloranim.prototype.hex2dec=function(hex){return(parseInt(hex,16))};



/***********************************************
The OpacityTween class
OpacityTween.js extends the Tween.js class, its purpose is to manage opacity transitions on visual objects.
Because it is a subclass of Tween you must include the Tween.as class before you include the OpacityTween.js class.

[script language="javascript" src="Tween.js"][/script]
[script language="javascript" src="OpacityTween.js"][/script]

Because OpacityTween.js is a subclass of Tween.js, all the Tween methods and events are available.
CONSTRUCTOR
var opacityTween = new OpacityTween(Object,easing,startOpacity,endOpacity,duration);

Example:

[div id="square33" style="width:50px;height:50px;background-color:#FF0000;filter:Alpha(opacity=100);"][/div]
[input type="button" value="change Opacity (100 - 0)" onClick="
opacityTween = new OpacityTween(document.getElementById('square33'),Tween.bounceEaseOut, 100, 0, 3);
opacityTween.start()"]

You will notice the use of 'filter:Alpha(opacity=100);' on the square div. If you don't add this, IE will will throw an error 'filter.alpha is null or not an object'.
************************************************/
opacityanim.prototype=new anim();
opacityanim.prototype.constructor=anim;
opacityanim.superclass=anim.prototype;
function opacityanim(obj,func,fromOpacity,toOpacity,duration){
	this.targetObject=obj;
	this.init(new Object(),'x',func,fromOpacity,toOpacity,duration);
}
opacityanim.prototype.targetObject={};
opacityanim.prototype.onMotionChanged=function(evt){
	var v=evt.target._pos;
	var t=this.targetObject;
	if(typeof(t.style['opacity'])!='undefined') t.style['opacity']=v/100;
	else if(typeof(t.style['-moz-opacity'])!='undefined') t.style['-moz-opacity']=v/100;
	else if(typeof(t.filters)!='undefined') if(typeof(t.filters.alpha)!='undefined') t.filters.alpha['opacity']=v;
}



function animchain(){
	this.children=new Array();
	this.currentChildIndex=0;
	this._listeners=new Array();
	this.nextObject=new Object();
	this.addListener(this);
}
animchain.prototype.addChild=function(tween){
	this.children.push(tween)
}
animchain.prototype.removeChild=function(tween){
	var a=this.children;	
	var i=a.length;
	while(i--){
		if(a[i]==tween) {
			a.splice(i,1);
			return true;
		}
	}
	return false;
}
animchain.prototype.start=function(){
	this.rewind();
	this.play();
	this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});
}
animchain.prototype.next=function(){
	this.children[this.currentChildIndex].removeListener(this.nextObject);
	if(this.currentChildIndex<this.children.length-1){
		this.currentChildIndex++;
		this.play();
	}else{
		this.stop();
		this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'});
	}
}
animchain.prototype.play=function(){
	this.nextObject=new Object();
	this.nextObject.onMotionFinished=Delegate.create(this,this.next);
	this.children[this.currentChildIndex].addListener(this.nextObject);
	this.children[this.currentChildIndex].start();
}
animchain.prototype.stop=function(){
	this.children[this.currentChildIndex].stop();
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}
animchain.prototype.rewind=function(){
	this.children[this.currentChildIndex].removeListener(this.nextObject);
	this.currentChildIndex=0;
	for(var i=0;i<this.children.length;i++){
		this.children[i].rewind();
	}
}
animchain.prototype.fforward=function(){
	this.children[this.currentChildIndex].removeListener(this.nextObject);
	for(var i=0;i<this.children.length;i++){
		this.children[i].fforward();
	}
	this.currentChildIndex=this.children.length-1;
}
animchain.prototype.resume=function(){
	this.children[this.currentChildIndex].resume();
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionStopped'});
}
animchain.prototype.addListener=function(o){
	this.removeListener(o);
	return this._listeners.push(o);
}
animchain.prototype.removeListener=function(o){
	var a=this._listeners;	
	var i=a.length;
	while(i--){
		if(a[i]==o){
			a.splice(i,1);
			return true;
		}
	}
	return false;
}
animchain.prototype.broadcastMessage=function(){
	var arr=new Array();
	for(var i=0;i<arguments.length;i++){
		arr.push(arguments[i])
	}
	var e=arr.shift();
	var a=this._listeners;
	var l=a.length;
	for(var i=0;i<l;i++){
		if(a[i][e])
		a[i][e].apply(a[i], arr);
	}
}



function animpipe(){
	this.children=new Array();
	this.numChildren=0;
	this._listeners=new Array();
	this.addListener(this);
}	
animpipe.prototype.endObject=new Object();
animpipe.prototype.addChild=function(tween){
	this.children.push(tween);
	this.numChildren++;
}
animpipe.prototype.start=function(){
	this.play();
	this.broadcastMessage('onMotionStarted', {target:this, type:'onMotionStarted'});
}
animpipe.prototype.play=function(){
	for(var u=0;u<this.numChildren;u++){
		if(u==(this.numChildren-1)){
			this.endObject=new Object();
			this.endObject.onMotionFinished=Delegate.create(this,this.end);
			this.children[u].addListener(this.endObject);
		}
		this.children[u].start();
	}
}
animpipe.prototype.end=function(){
	this.children[this.numChildren-1].removeListener(this.endObject);
	this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'});
}
animpipe.prototype.stop=function(){
	this.enumAction('stop');
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}
animpipe.prototype.rewind=function(){
	this.enumAction('rewind');
}
animpipe.prototype.fforward=function(){
	this.enumAction('fforward');
}
animpipe.prototype.resume=function(){
	this.enumAction('resume');
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'});
}
animpipe.prototype.yoyo=function(){
	this.enumAction('yoyo');
}
animpipe.prototype.enumAction=function(action){
	for(var u=0;u<this.numChildren;u++){
		this.children[u][action]();
	}
}
animpipe.prototype.addListener=function(o){
	this.removeListener(o);
	return this._listeners.push(o);
}
animpipe.prototype.removeListener=function(o){
	var a=this._listeners;	
	var i=a.length;
	while(i--){
		if(a[i]==o){
			a.splice(i,1);
			return true;
		}
	}
	return false;
}
animpipe.prototype.broadcastMessage=function(){
	var arr=new Array();
	for(var i=0;i<arguments.length;i++){
		arr.push(arguments[i]);
	}
	var e=arr.shift();
	var a=this._listeners;
	var l=a.length;
	for(var i=0;i<l;i++){
		if(a[i][e])
		a[i][e].apply(a[i],arr);
	}
}





function getwinframew(win) {
	if(!win) win=window; var framew=0; var frameh=0; var testw=500; var testh=500;
	if(navigator.appName=="Netscape") framew=win.outerWidth-win.innerWidth; 
	else if(navigator.appName.indexOf("Microsoft")!=-1){
		var owinw=getscreenw(win); var owinh=getscreenh(win);
		win.resizeTo(testw,testh);
		framew=testw-getscreenw(win); frameh=testh-getscreenh(win);
		win.resizeTo(owinw+framew,owinh+frameh);
	}
	return framew;
}
function getwinframeh(win) {
	if(!win) win=window; var framew=0; var frameh=0; var testw=500; var testh=500;
	if(navigator.appName=="Netscape") frameh=win.outerHeight-win.innerHeight; 
	else if(navigator.appName.indexOf("Microsoft")!=-1){
		var owinw=getscreenw(win); var owinh=getscreenh(win);
		win.resizeTo(testw,testh);
		framew=testw-getscreenw(win); frameh=testh-getscreenh(win);
		win.resizeTo(owinw+framew,owinh+frameh);
	}
	return frameh;
}
function getscreenw(win) {
	if(!win) win=window; var winw=0; if(parseInt(navigator.appVersion)<=3) return 0;
	if(navigator.appName=="Netscape") winw=win.innerWidth-16; 
	else if(navigator.appName.indexOf("Microsoft")!=-1){
		if(win.document.documentElement&&win.document.documentElement.clientWidth) winw=win.document.documentElement.clientWidth-20;
		else if(win.document.body) winw=win.document.body.clientWidth-20;
	}
	return winw;
}
function getscreenh(win) {
	if(!win) win=window; var winh=0; if(parseInt(navigator.appVersion)<=3) return 0;
	if(navigator.appName=="Netscape") winh=win.innerHeight-16;
	else if(navigator.appName.indexOf("Microsoft")!=-1){
		if(win.document.documentElement&&win.document.documentElement.clientHeight) winh=win.document.documentElement.clientHeight-20;
		else if(win.document.body) winh=win.document.body.clientHeight-20;
	}
	return winh;
}
function getwinw(win) {
	if(!win) win=window; var winw=0;
	if(navigator.appName=="Netscape") winw=win.outerWidth; 
	else if(navigator.appName.indexOf("Microsoft")!=-1) winw=getscreenw(win)+getwinframew(win);
	return winw;
}
function getwinh(win) {
	if(!win) win=window; var winh=0;
	if(navigator.appName=="Netscape") winh=win.outerHeight;
	else if(navigator.appName.indexOf("Microsoft")!=-1) winh=getscreenh(win)+getwinframeh(win);
	return winh;
}
function getscreenx0() {
	if(window.pageXOffset) return window.pageXOffset; 
	else if(document.documentElement&&document.documentElement.scrollLeft) return document.documentElement.scrollLeft;
	else if(document.body) return document.body.scrollLeft;
	return 0;
}
function getscreeny0() {
	if(window.pageYOffset) return window.pageYOffset; 
	else if(document.documentElement&&document.documentElement.scrollTop) return document.documentElement.scrollTop;
	else if(document.body) return document.body.scrollTop;
	return 0;
}
function setscreenx0(tox) {
	var fromx=getscreenx0(); var obj=0; var prop=0;
	if(document.documentElement&&document.documentElement.scrollLeft){ obj=document.documentElement; prop='scrollLeft'; }
	else if(document.body){ obj=document.body; prop='scrollLeft'; }
	obj[prop]=tox;
	//var anim1=new anim(obj,prop,anim.regularEaseOut,fromx,tox,0.25,'');
	//anim1.start();
}
function setscreeny0(toy) {
	var fromy=getscreeny0(); var obj=0; var prop=0;
	if(document.documentElement&&document.documentElement.scrollTop){ obj=document.documentElement; prop='scrollTop'; }
	else if(document.body){ obj=document.body; prop='scrollTop'; }
	obj[prop]=toy;
	//var anim1=new anim(obj,prop,anim.regularEaseOut,fromy,toy,0.25,'');
	//anim1.start();
}
function getscreenctx() {
	return getscreenx0()+(getscreenw()/2);
}
function getscreencty() {
	return getscreeny0()+(getscreenh()/2);
}
function setscreenctx(tox) {
	setscreenx0(tox-getscreenw()/2);
}
function setscreencty(toy) {
	setscreeny0(toy-getscreenh()/2);
}





function hidelinkstatus(/*param list...*/) {
	var a=0;var c1=0;for(c1=0;c1<arguments.length;c1++){
		a=arguments[c1];if(typeof(a)=='string')a=document.getElementById(arguments[c1]);
		a.onmouseover=function(){window.status='';return true};
		a.onmouseout=function(){window.status='';return true};
	}
}
function hidealllinkstatus() {
	var a=document.body.getElementsByTagName('a');
	var c1=0;for(c1=0;c1<a.length;c1++){
		a[c1].onmouseover=function(){window.status='';return true};
		a[c1].onmouseout=function(){window.status='';return true};
	}
}





function ifgetch(id) {
	var iframe=0; if(typeof(id)=='string') iframe=document.getElementById(id); else iframe=id; if(!iframe) return -1;
	var doc=0; var ifh=-1;
	if(iframe.style) iframe.style.display='block';
	if(iframe.contentDocument) doc=iframe.contentDocument;	
	else if(iframe.contentWindow) doc=iframe.contentWindow.document;
	else return 0;
	if(doc.documentElement) ifh=doc.documentElement.scrollHeight;
	else ifh=doc.body.scrollHeight;
	return ifh;
}
function ifath(id) {
	var iframe=document.getElementById(id); if(!iframe) return;
	if(iframe.attachEvent){
		iframe.onload=iframe.onreadystatechange=function(){
			if(this.readyState&&this.readyState=='complete'){
				if(this.style) this.style.height=ifgetch(this)+'px';
			}
		}
	}else{
		iframe.onload=function(){
			if(this.style) this.style.height=ifgetch(this)+'px';
		};
	}
	iframe.src=iframe.src;
}





