function getNodes(div,array){
	if(div){
	array.push(div);
	if(!array[0].mw){array[0].mw=array[0].offsetWidth;}
	if(!array[0].mh){array[0].mh=array[0].offsetHeight;}
	var elem=div.getElementsByTagName("*");
 for(var i =0; i<elem.length;i++){
		if(elem[i].id){
		var inn=document.getElementById(elem[i].id);
		if(array[0].mw<inn.offsetWidth){array[0].mw=inn.offsetWidth;}
		if(array[0].mh<inn.offsetHeight){array[0].mh=inn.offsetHeight;}
		array.push(inn);
		getNodes(inn,array);
		}
		}
		array[0].style.width=array[0].mw+'px';
		array[0].style.height=array[0].mh+'px';
		
	}
	}
function preloadPages(num){
	var img=new Image();
	var obj=this;
	if(obj.holder && obj.ph && !obj.preloadersetted){
		this.contoller=(this.sw/10);
		this.div.style.width=((this.contoller*2)+(obj.sw*2))+'px';
		var h=obj.ph/100*(100/obj.pw*obj.sw);
		this.div.style.height=h+'px';
		
		obj.holder.innerHTML+='<div id="bookmask'+obj.bnum+'" style="position:absolute; top:0px; left:'+this.contoller+'px; width:'+(obj.sw*2)+'px; height:'+h+'px; overflow:hidden;"></div>';
		obj.preloadersetted=true;
		var w=((this.pw*2)+(this.contoller*2))/100*(100/obj.pw*obj.sw);
		this.pageh=h;
		obj.holder.style.height=h+'px';
		obj.holder.style.top=(0)+'px';
		var newy=Number((h/2)-5);
		var newx=Number((w/2)-75)+this.contoller;
		animate('preloader'+obj.bnum,{top:newy,left:newx,easing:'regulareaseout'},2);
	}
	
	img.src=this.p[num];
	var lo=false;
	img.onload=function(){
		if(num==0){obj.pw=img.width; obj.ph=img.height; num++;}
		
	} 
	if(obj.ph){
		num++;
		}
	
	
	var prz=Math.round(100/obj.p.length*num);
	var w=Math.round(150/100*prz);
	if(document.getElementById('balk'+obj.bnum)){
		
		document.getElementById('balk'+obj.bnum).style.width=w+'px';
		document.getElementById('tx'+obj.bnum).innerHTML=prz+'% loaded';
		}
	
	if(num>=(obj.p.length)){
		document.getElementById('preloader'+obj.bnum).style.display='none';
		obj.setPages();
		
		}else{setTimeout(function(){obj.preloadPages(num);},10);}
		
		
		
	}
function getDiv(div){
	var obj=this;
	if(!div && !document.getElementById(div)){
		if (document.body && document.body.offsetHeight){
			this.div=document.body;
		}else if(window.innerHeight){
			this.div=window;
			}
		}else{
			if(div.id){this.div=div;}else{this.div=document.getElementById(div);
			
			}
			}
		if(this.div){
		this.div.innerHTML='<div id="holder'+this.bnum+'" style="position:absolute; top:0px; left:0px; width:200px; height:200px;"></div>';
		this.holder=document.getElementById('holder'+this.bnum);
		this.makePreloader();
		}else{			
			setTimeout(function(){obj.getDiv(div);},10);
			}
	}
function setPages(){
	var str='';
	var sha;
	var mozopa=this.shadowstrength/100;
	var obj=this;
	for(var i=0;i<this.p.length;i++){
		str+='<div id="P'+this.bnum+'id'+i+'" style="position:absolute; overflow:hidden; top:0px; left:'+Number(this.sw)+'px; width:'+this.sw+'px; height:'+this.pageh+'px; ';
		if(i==0){str+='display:block;'}else{str+='display:none;'}
		str+='">';
		str+='<img id="PIC'+this.bnum+'id'+i+'" style="position:absolute; top:0px; left:0px;" src="'+this.p[i]+'" width="'+this.sw+'">';
		if(i%2==0){sha='http://appcry.com/flipbook/jsfliper/shadr.png';}else{sha='http://appcry.com/flipbook/jsfliper/shadl.png';}
		str+='<img id="PICSHAD'+this.bnum+'id'+i+'" style="opacity:'+mozopa+'; -moz-opacity:'+mozopa+'; filter:alpha(opacity='+(this.shadowstrength/2)+'); position:absolute; top:0px; left:0px;" src="'+sha+'" width="'+this.sw+'">';
		str+='</div>';
		}
		var obj=this;
		var sta='<div id="toleft'+this.bnum+'" style=" cursor:pointer; position:absolute; top:0px; left:0px; width:'+this.contoller+'px; height:'+this.pageh+'px; background-color:#00FF00;"></div>';
		sta+='<div id="toright'+this.bnum+'" style=" cursor:pointer; position:absolute; top:0px; left:'+Number(this.contoller+(this.sw*2))+'px; width:'+this.contoller+'px; height:'+this.pageh+'px; background-color:#00FF00;"></div>';
	document.getElementById('bookmask'+this.bnum).innerHTML=str;
	this.holder.innerHTML+=sta;
	this.holder.style.width=this.sw+'px'; this.holder.style.height=this.pageh+'px';
	document.getElementById('toleft'+this.bnum).onclick=function(){obj.gotoPage('minus');}
	document.getElementById('toright'+this.bnum).onclick=function(){obj.gotoPage('plus');}
	document.getElementById('bookmask'+this.bnum).onclick=function(){
		
	obj.upScale(120);
	}
	
	}
function upScale(prz){
	
	var w=document.getElementById('P'+this.bnum+'id'+this.cur).offsetWidth/100*prz;
	var h=document.getElementById('P'+this.bnum+'id'+this.cur).offsetHeight/100*prz;
	var obj=this;
	if(w<=0 || h<=0){setTimeout(function(){obj.upScale(prz);},10);}else{
		
	if(!this.sprz || this.sprz!=prz){
		this.sprz=prz;
		if(!this.bookposition){this.bookposition=this.div.style.position; this.bookx=this.div.offsetLeft; this.booky=this.div.offsetTop;}
		var newLeft=document.getElementById('toleft'+this.bnum).offsetWidth/100*prz;
		if(prz==100){
			
			this.div.style.position=this.bookposition;
			var box=this.bookx;
			var boy=this.booky;
			}else{
				this.div.style.position='fixed';
				var cw=f_clientWidth();
				var ch=f_clientHeight();
				var bw=Number((newLeft*2)+(w*2));
				var bh=h;
			var box=((cw/2)-(bw/2));
			var boy=((ch/2)-(bh/2));
				}
				
				animate(this.div.id,{left:box,top:boy,easing:'regulareaseout'},0.5);
	var nehwX=this.holder.offsetLeft/100*prz;
	
	animate(this.holder,{scale:prz,left:nehwX,easing:'regulareaseout'},0.5);
	animate('bookmask'+this.bnum,{scale:prz,easing:'regulareaseout'},0.5);
	var newX=document.getElementById('toright'+this.bnum).offsetLeft/100*prz;
	animate('toright'+this.bnum,{scale:prz,left:newX,easing:'regulareaseout'},0.5);
	animate('toleft'+this.bnum,{scale:prz,easing:'regulareaseout'},0.5);
	if(document.getElementById('P'+this.bnum+'id'+this.cur)){
		document.getElementById('P'+this.bnum+'id'+this.cur).style.zIndex=4000;
		var nx=document.getElementById('P'+this.bnum+'id'+this.cur).offsetLeft/100*prz;
		animate('P'+this.bnum+'id'+this.cur,{scale:prz,left:nx,easing:'regulareaseout'},0.5);
		animate('PIC'+this.bnum+'id'+this.cur,{scale:prz,easing:'regulareaseout'},0.5);
		animate('PICSHAD'+this.bnum+'id'+this.cur,{scale:prz,easing:'regulareaseout'},0.5);
		}
	if(document.getElementById('P'+this.bnum+'id'+(this.cur-1))){
		document.getElementById('P'+this.bnum+'id'+(this.cur-1)).style.zIndex=3999;
		animate('P'+this.bnum+'id'+(this.cur-1),{scale:prz,easing:'regulareaseout'},0.5);
		animate('PIC'+this.bnum+'id'+(this.cur-1),{scale:prz,easing:'regulareaseout'},0.5);
		animate('PICSHAD'+this.bnum+'id'+(this.cur-1),{scale:prz,easing:'regulareaseout'},0.5);
		}
	
	for(var i=0; i<this.p.length;i++){
			if(i!=this.cur && i!=(this.cur-1)){
			if(document.getElementById('P'+this.bnum+'id'+i)){
			
			var pag=document.getElementById('P'+this.bnum+'id'+i);
			if(i<this.cur){
			pag.style.zIndex=i;
			}else{
				pag.style.zIndex=(this.p.length-i);
				}
			
			var pic=document.getElementById('PIC'+this.bnum+'id'+i);
			var picshad=document.getElementById('PICSHAD'+this.bnum+'id'+i);
			
			
			
			//pag.style.display='block';
			pag.style.width=w+'px';
			pag.style.height=h+'px';
			pic.style.width=w+'px';
			pic.style.height=h+'px';
			picshad.style.width=w+'px';
			picshad.style.height=h+'px';
			if(i%2==0){
				pag.style.left=w+'px';
				}else{
					pag.style.left=newLeft+'px';
					}
			}
			}}
	}
	}
	}
function openRight(num){
	if(!this.ani){
		this.ani=true;
		var obj=this;
		this.cur=num;
		
		for(var i=0; i<this.p.length;i++){
			if(document.getElementById('P'+this.bnum+'id'+i)){
			document.getElementById('P'+this.bnum+'id'+i).style.zIndex=this.p.length-i;
			}
			if(i!=(num) && i!=(num+2) && i !=(num+1) && i!=(num+3) && i!=(num-1)){
				if(document.getElementById('P'+this.bnum+'id'+i)){
				document.getElementById('P'+this.bnum+'id'+i).style.display='none';
				
				}
				}
			}
		if(document.getElementById('P'+this.bnum+'id'+num)){
				document.getElementById('P'+this.bnum+'id'+num).style.display='block';
				document.getElementById('P'+this.bnum+'id'+num).style.zIndex=5;
				}
			if(document.getElementById('P'+this.bnum+'id'+(num-1))){
				document.getElementById('P'+this.bnum+'id'+(num-1)).style.display='block';
				document.getElementById('P'+this.bnum+'id'+(num-1)).style.zIndex=3;
				
				}
		if(document.getElementById('P'+this.bnum+'id'+(num+1))){
				document.getElementById('P'+this.bnum+'id'+(num+1)).style.display='block';
				document.getElementById('P'+this.bnum+'id'+(num+1)).style.zIndex=4;
				var w=document.getElementById('P'+this.bnum+'id'+(num+1)).offsetWidth;
				animate('P'+this.bnum+'id'+(num),{left:[0,w],width:[0,w],easing:'easeoutregular'},this.fliptime);
				animate('P'+this.bnum+'id'+(num+1),{left:[0,w],easing:'easeoutregular'},this.fliptime);
				animate('PICSHAD'+this.bnum+'id'+(num+1),{left:[0,-w],easing:'easeoutregular'},this.fliptime);
				animate('PIC'+this.bnum+'id'+(num),{left:[-w,0],easing:'easeoutregular'},this.fliptime);
				animate('PIC'+this.bnum+'id'+(num+1),{left:[0,-w],easing:'easeoutregular',onfinish:function(){
				 document.getElementById('P'+obj.bnum+'id'+(num+1)).style.left=w+'px'; 
				 document.getElementById('PIC'+obj.bnum+'id'+(num+1)).style.left=0+'px';
				 document.getElementById('PICSHAD'+obj.bnum+'id'+(num+1)).style.left=0+'px';
				 obj.setIndex();
				 obj.ani=false;
				 }
				 },this.fliptime);
				
				
				}
		if(document.getElementById('P'+this.bnum+'id'+(num+2))){
				document.getElementById('P'+this.bnum+'id'+(num+2)).style.display='block';
				document.getElementById('P'+this.bnum+'id'+(num+2)).style.zIndex=2;
				
				}
		if(document.getElementById('P'+this.bnum+'id'+(num+3))){
				document.getElementById('P'+this.bnum+'id'+(num+3)).style.zIndex=1;
				
				}
			
		
		
		
		}
	
	
	}
function openLeft(num){
	if(!this.ani){
		this.ani=true;
		var obj=this;
		this.cur=num;
		for(var i=0; i<this.p.length;i++){
			if(document.getElementById('P'+this.bnum+'id'+i)){
			document.getElementById('P'+this.bnum+'id'+i).style.zIndex=i;
		}
					
			if(i!=(num) && i!=(num-2) && i !=(num-1) && i!=(num-3)){
				if(document.getElementById('P'+this.bnum+'id'+i)){
				document.getElementById('P'+this.bnum+'id'+i).style.display='none';
				
				}
				}
			}
		if(document.getElementById('P'+this.bnum+'id'+num)){
				document.getElementById('P'+this.bnum+'id'+num).style.display='block';
				document.getElementById('P'+this.bnum+'id'+num).style.zIndex=1;
				}
		if(document.getElementById('P'+this.bnum+'id'+(num-1))){
				document.getElementById('P'+this.bnum+'id'+(num-1)).style.display='block';
				document.getElementById('P'+this.bnum+'id'+(num-1)).style.zIndex=4;
				var w=document.getElementById('P'+this.bnum+'id'+(num-1)).offsetWidth;
				animate('PIC'+this.bnum+'id'+(num-1),{left:[w,0],easing:'easeoutregular'},this.fliptime);
				if(num==2){animate('PICSHAD'+this.bnum+'id'+(num-1),{left:[w,0],easing:'easeoutregular'},this.fliptime);}
				animate('P'+this.bnum+'id'+(num-1),{left:0,easing:'easeoutregular'},this.fliptime);
				animate('P'+this.bnum+'id'+(num-2),{width:0,easing:'easeoutregular',onfinish:function(){
																									  obj.setIndex();
																									  obj.ani=false;
				 document.getElementById('P'+obj.bnum+'id'+(num-2)).style.left=0+'px'; 
				 document.getElementById('P'+obj.bnum+'id'+(num-2)).style.width=w+'px';}},this.fliptime);
				
				}
		if(document.getElementById('P'+this.bnum+'id'+(num-2))){
				document.getElementById('P'+this.bnum+'id'+(num-2)).style.display='block';
				document.getElementById('P'+this.bnum+'id'+(num-2)).style.zIndex=2;
				
				}
		if(document.getElementById('P'+this.bnum+'id'+(num-3))){
				document.getElementById('P'+this.bnum+'id'+(num-3)).style.zIndex=3;
				
				}
			
		
		
		
		}
	}
function setIndex(){
	var num=this.cur;
	for(var i=0; i<num;i++){
			if(document.getElementById('P'+this.bnum+'id'+i)){
			document.getElementById('P'+this.bnum+'id'+i).style.zIndex=i;
			}
	}
	for(i=this.p.length; i>(num+3); i--){
		if(document.getElementById('P'+this.bnum+'id'+i)){
			document.getElementById('P'+this.bnum+'id'+i).style.zIndex=i;
			}	
		}
	}
function gotoPage(num){
	if(num=='plus'){var to=Number(this.cur+2); this.openLeft(to);}
	if(num=='minus'){var to=Number(this.cur-2); this.openRight(to);}
	if(!isNaN(num)){var to=num;
	if(to>this.cur){
		this.openLeft(to);
		}else{this.openRight(to);}
	}
	
	}
function makePreloader(){
	this.holder.innerHTML='<div id="preloader'+this.bnum+'" style="position:absolute; width:150px; height:10px; border:1px solid; border-color:#000000; top:50%; left:50%; margin-top:-5px; margin-left:-75px;"><div id="balk'+this.bnum+'" style="position:absolute; top:0px; left:0px; height:10px; width:1px; background-color:#0000FF;"></div><div align="center" id="tx'+this.bnum+'" style="position:absolute; top:0px; left:0px; height:10px; width:150px; color:#000000; font-size:8px;"></div></div>';
	}
var books=0;
function book(pages,div){
	this.preloadersetted=false;
	this.getDiv=getDiv;
	this.getDiv(div);
	this.p=pages;
	this.shadowstrength=15;
	this.makePreloader=makePreloader;
	this.preloadPages=preloadPages;
	this.preloadPages(0);
	this.setPages=setPages;
	this.sw=300;
	this.mw=600;
	this.bnum=books;
	this.cur=0;
	this.gotoPage=gotoPage;
	this.openLeft=openLeft;
	this.openRight=openRight;
	this.setIndex=setIndex;
	this.fliptime=1;
	this.ani=false;
	this.upScale=upScale;
	books++;
}
function getBounds(ele,div){

	if(ele=='_root'){ele=document.body;}
    if(!ele.offsetWidth){ele=document.getElementById(ele);}
    if(!div.Xmin){div.Xmin=div.offsetLeft;}
    if(!div.Ymin){div.Ymin=div.offsetTop;}
    if(!div.pare){div.pare=div.parentNode;}else{var pare=div.pare.parentNode; div.pare=pare;}
    if(div.pare!=ele){
	div.Xmin+=div.pare.offsetLeft;
    div.Ymin+=div.pare.offsetTop;
    div.W=div.offsetWidth;
    div.H=div.offsetHeight;
    div.Xmax=div.Xmin+div.W;
    div.Ymax=div.Ymin+div.H;
     getBounds(ele,div);
    }else{div.pare=false}
}
function startDrag(dragger,l,o,r,u,func){
	
 	
	if(document.getElementById(dragger)){dragger=document.getElementById(dragger);}
 	if(!dragger.style.position){dragger.style.position='absolute';}	
	if(!dragger.style.top){dragger.style.top=0+'px';}	
	if(!dragger.style.left){dragger.style.left=0+'px';}
	if(isNaN(l)){l=0;}
	if(isNaN(o)){o=0;}
	if(isNaN(r)){r=dragger.parentNode.offsetWidth-dragger.offsetWidth;}
	if(isNaN(u)){
		
		u=dragger.parentNode.offsetHeight-dragger.offsetHeight;
		if(u<=0){u=5000;}
		}
	
	dragger.xprz=0;
	dragger.yprz=0;
   
	getBounds('_root',dragger);
     
	dragger.divx=false;
	dragger.divy=false;
	dragger.drag=true;
    
		dragger.parentNode.onmousemove=function(e){
			dragger.onmouseup=document.onmouseup=function(){dragger.drag=false; dragger.parentNode.onmousemove=null;}	
      		if(!e){e=window.event;}
			var ymouse=Number(e.clientY-dragger.Ymin);
			var xmouse=Number(e.clientX-dragger.Xmin);
			if(!dragger.divx){dragger.divx=Number(xmouse-dragger.offsetLeft);}
			if(!dragger.divy){dragger.divy=Number(ymouse-dragger.offsetTop);}
			var tox=Number(xmouse-dragger.divx);
			var toy=Number(ymouse-dragger.divy);
			if(!isNaN(o) && toy<o){toy=o;}
			if(!isNaN(u) && toy>u){toy=u;}
			if(!isNaN(l) && tox<l){tox=l;}
			if(!isNaN(r) && tox>r){tox=r;}
			
			if(dragger.drag){	
				dragger.style.top=toy+'px';
				dragger.style.left=tox+'px';
				if(!isNaN(u) && !isNaN(o)){var rangey=u-o; dragger.yprz=Math.round(100/rangey*toy);}
				if(!isNaN(r) && !isNaN(l)){var rangex=r-l; dragger.xprz=Math.round(100/rangex*tox);}
				var x=dragger.offsetLeft;
   					var y=dragger.offsetTop;
                    var h=dragger.offsetHeight;
                    var w=dragger.offsetWidth;
					dragger.x=x;
					dragger.y=y;
					if(func){
								eval(func);
							
					
					
					}
					
   				
				
			}
			
			}
		
		
}
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function ajax_rem(dat,div){
if(document.getElementById(div)){
document.getElementById(div).innerHTML ='Lade Daten....';
}
	var req = null;

                try{
                    req = new XMLHttpRequest();
                }
                catch (ms){
                    try{
                        req = new ActiveXObject("Msxml2.XMLHTTP");
                    } 
                    catch (nonms){
                        try{
                            req = new ActiveXObject("Microsoft.XMLHTTP");
                        } 
                        catch (failed){
                            req = null;
                        }
                    }  
                }

               
                  req.open("GET", dat, true);
 
                
                req.onreadystatechange = function(){ 
                         
                    switch(req.readyState) {
                            case 4:
                                                         
								document.getElementById(div).innerHTML =evalScript(req.responseText);
                                                                  
                           
                            break;
                    
                            default:
                                return false;
                            break;     
                        }
                    };
                   req.send(null);
}
function evalScript(scripts)
{	try
	{	if(scripts != '')	
		{	var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
	       	                         if (scripts !== null) script += arguments[1] + '\n';
 	        	                        return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return scripts;
	}
	catch(e)
	{	alert(e)
	}
}
		
		
		
function getScrollXY() {
    
 
    if( typeof( window.pageYOffset ) == 'number' ) {
     
       var scrOfY = window.pageYOffset;
         var scrOfX = window.pageXOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
     
         var scrOfY = document.body.scrollTop;
         var scrOfX = document.body.scrollLeft;
    } else if( document.documentElement) {
        var scrOfY = document.documentElement.scrollTop;
        var scrOfX = document.documentElement.scrollLeft;
		
    }
    return [ scrOfX, scrOfY ];
}



function GetRandom( min, max ) {
	if( min > max ) {
		return( -1 );
	}
	if( min == max ) {
		return( min );
	}
 
        return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}
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);
	}
}

Tween = function(obj, prop, func, begin, finish, duration, suffixe){
	this.init(obj, prop, func, begin, finish, duration, suffixe)
}
var t = Tween.prototype;

t.obj = new Object();
t.prop='';
t.func = function (t, b, c, d) { return c*t/d + b; };
t.begin = 0;
t.change = 0;
t.prevTime = 0;
t.prevPos = 0;
t.looping = false;
t._duration = 0;
t._time = 0;
t._pos = 0;
t._position = 0;
t._startTime = 0;
t._finish = 0;
t.name = '';
t.suffixe = '';
t._listeners = new Array();	
t.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();
	}
}
t.getTime = function(){
	return this._time;
}
t.setDuration = function(d){
	this._duration = (d == null || d <= 0) ? 100000 : d;
}
t.getDuration = function(){
	return this._duration;
}
t.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'});
}
t.getPosition = function(t){
	if (t == undefined) t = this._time;
	return this.func(t, this.begin, this.change, this._duration);
};
t.setFinish = function(f){
	this.change = f - this.begin;
};
t.getFinish = function(){
	return this.begin + this.change;
};
t.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);
}
t.start = function(){
	this.rewind();
	this.startEnterFrame();
	this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});
	
}
t.rewind = function(t){
	this.stop();
	this._time = (t == undefined) ? 0 : t;
	this.fixTime();
	this.update();
}
t.fforward = function(){
	this._time = this._duration;
	this.fixTime();
	this.update();
}
t.update = function(){
	this.setPosition(this.getPosition(this._time));
	}
t.startEnterFrame = function(){
	this.stopEnterFrame();
	this.isPlaying = true;
	this.onEnterFrame();
}
t.onEnterFrame = function(){
	if(this.isPlaying) {
		this.nextFrame();
		setTimeout(Delegate.create(this, this.onEnterFrame), 0);
	}
}
t.nextFrame = function(){
	this.setTime((this.getTimer() - this._startTime) / 1000);
	}
t.stop = function(){
	this.stopEnterFrame();
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}
t.stopEnterFrame = function(){
	this.isPlaying = false;
}

t.continueTo = function(finish, duration){
	this.begin = this._pos;
	this.setFinish(finish);
	if (this._duration != undefined)
		this.setDuration(duration);
	this.start();
}
t.resume = function(){
	this.fixTime();
	this.startEnterFrame();
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'});
}
t.yoyo = function (){
	this.continueTo(this.begin,this._time);
}

t.addListener = function(o){
	this.removeListener (o);
	return this._listeners.push(o);
}
t.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;
}
t.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);
	}
}
t.fixTime = function(){
	this._startTime = this.getTimer() - this._time * 1000;
}
t.getTimer = function(){
	return new Date().getTime() - this._time;
}
Tween.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;
}
Tween.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;
}
Tween.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;
}
Tween.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;
	
}
Tween.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);
	}
Tween.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;
}

Tween.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;
	}
}
Tween.bounceEaseIn = function(t,b,c,d){
	return c - Tween.bounceEaseOut (d-t, 0, c, d) + b;
	}
Tween.bounceEaseInOut = function(t,b,c,d){
	if (t < d/2) return Tween.bounceEaseIn (t*2, 0, c, d) * .5 + b;
	else return Tween.bounceEaseOut (t*2-d, 0, c, d) * .5 + c*.5 + b;
	}

Tween.strongEaseInOut = function(t,b,c,d){
	return c*(t/=d)*t*t*t*t + b;
	}

Tween.regularEaseIn = function(t,b,c,d){
	return c*(t/=d)*t + b;
	}
Tween.regularEaseOut = function(t,b,c,d){
	return -c *(t/=d)*(t-2) + b;
	}

Tween.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;
	}
Tween.strongEaseIn = function(t,b,c,d){
	return c*(t/=d)*t*t*t*t + b;
	}
Tween.strongEaseOut = function(t,b,c,d){
	return c*((t=t/d-1)*t*t*t*t + 1) + b;
	}

Tween.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;
	}
ColorTween.prototype = new Tween();
ColorTween.prototype.constructor = Tween;
ColorTween.superclass = Tween.prototype;

function ColorTween(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);
}
var o = ColorTween.prototype;
o.targetObject = {};
o.targetProperty = {};
o.fromColor = '';
o.toColor = '';
o.currentColor = '';
o.listenerObj = {};
o.onColorChanged = function(){
	this.currentColor = this.getColor(this.fromColor,this.toColor,this._pos);
	if(this.currentColor.indexOf('undefined')>0){}else{
	this.targetObject[this.targetProperty] = this.currentColor;
	}
	
}


o.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));
}


o.dec2hex = function(dec){return(this.hexDigit[dec>>4]+this.hexDigit[dec&15]);}
o.hexDigit=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
o.hex2dec = function(hex){return(parseInt(hex,16))};


TextTween.prototype = new Tween();
TextTween.prototype.constructor = Tween;
TextTween.superclass = Tween.prototype;

function TextTween(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);
}
var o = TextTween.prototype;
o.targetObject = {};
o.targetProperty = {};
o.fromColor = '';
o.toColor = '';
o.currentColor = '';
o.onMotionChanged = function(evt){
	var v = evt.target._pos;
	this.targetObject[this.targetProperty] = this.txt.substr(0,v);	
}


function Sequence(){
	this.children = new Array();
	this.currentChildIndex = 0;
	this._listeners = new Array();
	this.nextObject = new Object();
	this.addListener(this);
}
var s = Sequence.prototype;
s.addChild = function(tween){
	this.children.push(tween)
}
s.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;
}
s.start = function(){
	this.rewind();
	this.play();
	this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});
}
s.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'});
	}
}
s.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();
}
s.stop = function(){
	this.children[this.currentChildIndex].stop();
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}
s.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();
	}
}
s.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;
}
s.resume = function(){
	this.children[this.currentChildIndex].resume();
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionStopped'});
}
s.addListener = function(o){
	this.removeListener (o);
	return this._listeners.push(o);

}
s.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;
}
s.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 Parallel(){
	this.children = new Array();
	this.numChildren = 0;
	this._listeners = new Array();
	this.addListener(this);
}
var s = Parallel.prototype;
s.endObject = new Object();
s.addChild = function(tween){
	this.children.push(tween)
	this.numChildren++;
}
s.start = function(){
	this.play();
	this.broadcastMessage('onMotionStarted', {target:this, type:'onMotionStarted'});
}
s.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();
	}
}

s.end = function(){
	this.children[this.numChildren-1].removeListener(this.endObject);
	this.broadcastMessage('onMotionFinished', {target:this, type:'onMotionFinished'});
}
s.stop = function(){
	this.enumAction('stop');
	this.broadcastMessage('onMotionStopped', {target:this, type:'onMotionStopped'});
	}
s.rewind = function(){
	this.enumAction('rewind');
	}
s.fforward = function(){
	this.enumAction('fforward');
	}
s.resume = function(){
	this.enumAction('resume');
	this.broadcastMessage('onMotionResumed', {target:this, type:'onMotionResumed'});
	}
s.yoyo = function(){
	this.enumAction('yoyo');
	}


s.enumAction = function(action){
	for(var u = 0; u < this.numChildren; u++){
		this.children[u][action]();
	}
}

s.addListener = function(o){
	this.removeListener (o);
	return this._listeners.push(o);

}
s.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;
}
s.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);
	}
}
OpacityTween.prototype = new Tween();
OpacityTween.prototype.constructor = Tween;
OpacityTween.superclass = Tween.prototype;

function OpacityTween(obj,func,fromOpacity,toOpacity,duration){
	this.targetObject = obj;
	this.init(new Object(),'x',func,fromOpacity,toOpacity,duration);
}
var o = OpacityTween.prototype;
o.targetObject = {};
o.onMotionChanged = function(evt){
	var v = evt.target._pos;
	var t = this.targetObject;
	t.style['opacity'] = v / 100;
	t.style['-moz-opacity'] = v / 100;
	//t.style.setAttribute('filter', 'alpha(opacity='+v+')', false);
	if(t.filters) t.filters.alpha['opacity'] = v;
}
function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}
function is_array(variable)

{

    return typeof(variable) == "object" && (variable instanceof Array);

}
Number.prototype.toHex = function () {var o = this.toString(16);return o[1] ? o : "0" + o;}
function rotate(obj,deg,IE){
				var deg2radians = Math.PI * 2 / 360;
				var rad = deg * deg2radians;
				var costheta = Math.cos(rad);
				var sintheta = Math.sin(rad);
			 
				
				var a = parseFloat(costheta).toFixed(8);
				var c = parseFloat(-sintheta).toFixed(8);
				var b = parseFloat(sintheta).toFixed(8);
				var d = parseFloat(costheta).toFixed(8);
				
				var matrix = "matrix(" + a + ", " + b + ", " + c + ", " + d + ", 0, 0);";
				
				if (obj.filters) {

					obj.style.filter = "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand');";
					obj.filters.item(0).M11 = costheta;
					obj.filters.item(0).M12 = -sintheta;
					obj.filters.item(0).M21 = sintheta;
					obj.filters.item(0).M22 = costheta;
					
				} else {
					
				obj.style['-webkit-transform'] = 'rotate('+deg+'deg)';
	obj.style.webkitTransform = 'rotate('+deg+'deg)';
   obj.style.WebkitTransform = 'rotate('+deg+'deg)';
	obj.style['-moz-transform'] = 'rotate('+deg+'deg)';
	obj.style['-transform'] = 'rotate('+deg+'deg)';
	obj.style['-ms-transform'] = 'rotate('+deg+'deg)';
	obj.style['OTransform'] = 'rotate('+deg+'deg)';
	obj.style['msTransform'] = 'rotate('+deg+'deg)';
	obj.style.MozTransform = 'rotate('+deg+'deg)';
														
				}
				obj.deg=deg;
				

}
function animate(div,properties,tim){

	var time=Number(tim*1000);
	
	if(!div.id){
	if(document.getElementById(div)){
	
				
	div=document.getElementById(div);
	if(!div.style.position){
		div.style.position='absolute';
	}
	
	var easa;
	var easb;
	var easestart;
	var easing=false;
	var from=new Array();
	var to=new Array();
	var action=new Array();
	var xscaleC=false;
	var yscaleC=false;
	var scaleC=false;
	var scale=false;
	var startfunc=false;
	var finishfunc=false;
	var whilefunc=false;
	div.twee=new Array();
	var IE = (navigator.appName == "Microsoft Internet Explorer");
	for(i in properties){
		
	if(i=='onaction'){
		whilefunc=properties[i];
		}
	if(i=='onstart'){
		startfunc=properties[i];
		}
	if(i=='onfinish'){
		finishfunc=properties[i];
		}
	if(i=='easing'){
			easestart=properties[i].toLowerCase();
			if(easestart.indexOf('strong')>=0){easa='strong';}
			if(easestart.indexOf('bounce')>=0){easa='bounce';}
			if(easestart.indexOf('elastic')>=0){easa='elastic';}
			if(easestart.indexOf('regular')>=0){easa='regular';}
			if(easestart.indexOf('back')>=0){easa='back';}
			if(easestart.indexOf('easein')>=0){easb='EaseIn';}
			if(easestart.indexOf('easeout')>=0){easb='EaseOut';}
			if(easestart.indexOf('easeinout')>=0){easb='EaseInOut';}
			if(easestart.indexOf('easeoutin')>=0){easb='EaseInOut';}
			easing=easa+easb;
			}
			if(i=='rotate'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(properties[i][0]);
			to.push(properties[i][1]);
			}else{
			from.push(0);
			to.push(properties[i]);
			}
			action.push('rot');
			}
		if(i=='left'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(properties[i][0]);
			to.push(properties[i][1]);
			}else{
			from.push(div.offsetLeft);
			to.push(properties[i]);
			}
			action.push('left');
			}
			if(i=='top'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(properties[i][0]);
			to.push(properties[i][1]);
			}else{
			from.push(div.offsetTop);
			to.push(properties[i]);
			}
			action.push('top');
			}
			if(i=='width'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(properties[i][0]);
			to.push(properties[i][1]);
			}else{
			from.push(div.offsetWidth);
			to.push(properties[i]);
			}
			action.push('width');
			}
			if(i=='color'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(properties[i][0]);
			to.push(properties[i][1]);
			}else{
			if(div.style.backgroundColor){
				
				var col=div.style.backgroundColor.replace(/rgb\((\d+)\,\s(\d+)\,\s(\d+)\)/g, function (a, b, c, d) {return parseInt(b).toHex() + parseInt(c).toHex() + parseInt(d).toHex();});
				}
			if(col){
			from.push(col);
			}else{
				from.push('FFFFFF');
				}
			
			to.push(properties[i]);
			}
			action.push('col');
			}
			if(i=='opacity'){
			
			
           if(IE)
       		 {
				 
        		  div.style.setAttribute('filter', 'alpha(opacity=100)', false);
       		}else {
			div.style.opacity=1;
			div.style.MozOpacity=1;
			}
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(properties[i][0]);
			to.push(properties[i][1]);
			}else{
				if(properties[i]>50){
			from.push(0);
				}else{
					from.push(100);
					}
			to.push(properties[i]);
			}
			action.push('opacity');
			}
			if(i=='xscale'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(div.offsetWidth/100*properties[i][0]);
			to.push(div.offsetWidth/100*properties[i][1]);
			}else{
			from.push(div.offsetWidth);
			to.push(div.offsetWidth/100*properties[i]);
			}
			action.push('width');
			}
			if(i=='xscaleC'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(div.offsetWidth/100*properties[i][0]);
			to.push(div.offsetWidth/100*properties[i][1]);
			}else{
			from.push(div.offsetWidth);
			to.push(div.offsetWidth/100*properties[i]);
			}
			var xdif=(to-div.offsetWidth);
			var aleft=div.offsetLeft;
			var bleft=(div.offsetLeft-(xdif/2));
			action.push('width');
			xscaleC=true;
			}
			if(i=='yscaleC'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(div.offsetHeight/100*properties[i][0]);
			to.push(div.offsetHeight/100*properties[i][1]);
			}else{
			from.push(div.offsetHeight);
			to.push(div.offsetHeight/100*properties[i]);
			}
			var ydif=(to-div.offsetHeight);
			var aleft=div.offsetTop;
			var bleft=(div.offsetTop-(ydif/2));
			action.push('height');
			yscaleC=true;
			}
			if(i=='height'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(properties[i][0]);
			to.push(properties[i][1]);
			}else{
			from.push(div.offsetHeight);
			to.push(properties[i]);
			}
			action.push('height');
			}
			
			if(i=='scale'){
				
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(div.offsetHeight/100*properties[i][0]);
			to.push(div.offsetHeight/100*properties[i][1]);
			}else{
			from.push(div.offsetHeight);
			to.push(div.offsetHeight/100*properties[i]);
			}
			action.push('height');
			if(is_array(properties[i]) && properties[i].length>1){
			fromB=div.offsetWidth/100*properties[i][0];
			toB=div.offsetWidth/100*properties[i][1];
			}else{
			fromB=div.offsetWidth;
			toB=div.offsetWidth/100*properties[i];
			}
			actionB='width';
			var scale=true;
			}
			if(i=='scaleC'){
			if(is_array(properties[i]) && properties[i].length>1){
			from.push(div.offsetHeight/100*properties[i][0]);
			to.push(div.offsetHeight/100*properties[i][1]);
			}else{
			from.push(div.offsetHeight);
			to.push(div.offsetHeight/100*properties[i]);
			}
			action.push('height');
			if(is_array(properties[i]) && properties[i].length>1){
			fromB=div.offsetWidth/100*properties[i][0];
			toB=div.offsetWidth/100*properties[i][1];
			}else{
			fromB=div.offsetWidth;
			toB=div.offsetWidth/100*properties[i];
			}
			actionB='width';
			var scaleC=true;
			var ydif=(to-div.offsetHeight);
			var yaleft=div.offsetTop;
			var ybleft=(div.offsetTop-(ydif/2));
			var xdif=(to-div.offsetWidth);
			var xaleft=div.offsetLeft;
			var xbleft=(div.offsetLeft-(xdif/2));
			}
			
	}
	var tweener;
	if(!easing){easing='strong';}
	if(xscaleC){
		div.tweeB = new Tween(div.style,'left',Tween[easing],aleft,bleft,tim,'px'); div.tweeB .start();
		tweener=div.tweeB;
	}
	if(yscaleC){
		div.tweeB = new Tween(div.style,'top',Tween[easing],aleft,bleft,tim,'px'); div.tweeB .start();
		tweener=div.tweeB;
	}
	if(scale){
		
		div.tweeB = new Tween(div.style,actionB,Tween[easing],fromB,toB,tim,'px'); div.tweeB .start();
		
		tweener=div.tweeB;	
	}
	if(scaleC){
		div.tweeB = new Tween(div.style,actionB,Tween[easing],fromB,toB,tim,'px'); div.tweeB .start();
		div.tweeC = new Tween(div.style,'left',Tween[easing],xaleft,xbleft,tim,'px'); div.tweeC.start();
		div.tweeD = new Tween(div.style,'top',Tween[easing],yaleft,ybleft,tim,'px'); div.tweeD.start();
		
				
			tweener=div.tweeB;
			
	}
	
	for(var i=0;i<action.length;i++){
    if(action[i]=='col'){
		div.twee[i] = new ColorTween(div.style, 'backgroundColor', Tween[easing],from[i].replace(/#/g,''),to[i].replace(/#/g,''),tim);
		div.twee[i] .start();
		tweener=div.twee[i];
		}else if(action[i]=='opacity'){
		
		div.twee[i] = new OpacityTween(div,Tween[easing],from[i],to[i],tim);
		div.twee[i] .start();
		tweener=div.twee[i];
		
		}else if(action[i]=='rot'){
			
			
				
			var change;
			var twe=new Tween('empty','left',Tween[easing],from[i],to[i],tim,'px'); twe.start();
			tweener=twe;
			twe.onMotionChanged=function(){
				for(var a in this){if(a=='_pos'){change=this[a];
				     rotate(div,change,IE);
				}
				}
				}
				
			}else{
	div.twee[i] = new Tween(div.style,action[i],Tween[easing],from[i],to[i],tim,'px');div.twee[i] .start();
	tweener=div.twee[i];
	
	}
	
	
	}
	
	if(finishfunc){
		
		tweener.onMotionFinished=function(){
			
			finishfunc();
		}
			
		}
		if(whilefunc){
		
		tweener.onMotionChanged=function(){
			
			whilefunc();
		}
			
		}
	if(startfunc){
		
			startfunc();
			
	}
	
	
	
			
		
	
	}else{
	setTimeout(function(){animate(div,properties,tim);},0);
	}
	}
	
}
function addPic(pic){
	this.pic.push(pic);
	}
function addMtime(time){
	this.mtime.push(time);
	}
function addStime(time){
	this.stime.push(time);
	}
function addWay(way){
	this.way.push(way);
	}
function addEasing(ease){
	this.easing.push(ease);
	}
function addHow(how){
	this.how.push(how);
	}

function Auto(){
	
	if(!this.moving){
		this.moving=true;
		var obj=this;
	var now=this.pic[this.st];
	if(document.getElementById(now)){
			var way=this.way[this.st];
			
			if(way=='leftright'){
				document.getElementById(now).style.display='block';
				var to=document.getElementById(now).offsetLeft;
				var wid=document.getElementById(now).offsetWidth;
				var from=(to-(wid*2));
				var tim=this.mtime[this.st];
				var stim=this.stime[this.st];
				var eas="'"+this.how[this.st]+''+this.easing[this.st]+"'";
			
				animate(now,{left:[from,(to+(wid/2))],easing:eas,onfinish:function(){
				setTimeout(function(){
									obj.moving=false;
									obj.st++;
									if(obj.st>(obj.pic.length-1)){obj.st=0;}
									
									obj.Auto();
									animate(now,{left:[(to-(wid/2)),from],easing:eas,onfinish:function(){
									document.getElementById(now).style.display='none';
									document.getElementById(now).style.left=(to+(wid/2))+'px';
									}},tim);
									
									},(stim*1000));
																								   }},tim);
				}
				
				if(way=='rightleft'){
				document.getElementById(now).style.display='block';
				var to=document.getElementById(now).offsetLeft;
				var wid=document.getElementById(now).offsetWidth;
				var from=(to+(wid*2));
				var tim=this.mtime[this.st];
				var stim=this.stime[this.st];
				var eas="'"+this.how[this.st]+''+this.easing[this.st]+"'";
			
				animate(now,{left:[from,(to+(wid/2))],easing:eas,onfinish:function(){
				setTimeout(function(){
									obj.moving=false;
									obj.st++;
									if(obj.st>(obj.pic.length-1)){obj.st=0;}
										obj.Auto();
									animate(now,{left:[(to+(wid/2)),from],easing:eas,onfinish:function(){
									document.getElementById(now).style.display='none';
									document.getElementById(now).style.left=(to+(wid/2))+'px';
									}},tim);
									
									},(stim*1000));
																								   }},tim);
				}
				
				if(way=='topbot'){
				document.getElementById(now).style.display='block';
				var to=document.getElementById(now).offsetTop;
				var wid=document.getElementById(now).offsetHeight;
				var from=(to-(wid*2));
				var tim=this.mtime[this.st];
				var stim=this.stime[this.st];
				var eas="'"+this.how[this.st]+''+this.easing[this.st]+"'";
			
				animate(now,{top:[from,to],easing:eas,onfinish:function(){
				setTimeout(function(){
									obj.moving=false;
									obj.st++;
									if(obj.st>(obj.pic.length-1)){obj.st=0;}
										obj.Auto();
									animate(now,{top:[to,from],easing:eas,onfinish:function(){
									document.getElementById(now).style.display='none';
									document.getElementById(now).style.top=to+'px';
									}},tim);
									
									},(stim*1000));
																								   }},tim);
				}
				if(way=='bottop'){
				document.getElementById(now).style.display='block';
				var to=document.getElementById(now).offsetTop;
				var wid=document.getElementById(now).offsetHeight;
				var from=(to+(wid*2));
				var tim=this.mtime[this.st];
				var stim=this.stime[this.st];
				var eas="'"+this.how[this.st]+''+this.easing[this.st]+"'";
			
				animate(now,{top:[from,to],easing:eas,onfinish:function(){
				setTimeout(function(){
									obj.moving=false;
									obj.st++;
									if(obj.st>(obj.pic.length-1)){obj.st=0;}
										obj.Auto();
									animate(now,{top:[to,from],easing:eas,onfinish:function(){
									document.getElementById(now).style.display='none';
									document.getElementById(now).style.top=to+'px';
									}},tim);
									
									},(stim*1000));
																								   }},tim);
				}
				if(way=='opacity'){
				document.getElementById(now).style.display='block';
				var to=100;
				var from=0;
				var tim=this.mtime[this.st];
				var stim=this.stime[this.st];
				var eas="'"+this.how[this.st]+''+this.easing[this.st]+"'";
			
				animate(now,{opacity:[from,to],easing:eas,onfinish:function(){
				setTimeout(function(){
									obj.moving=false;
									obj.st++;
									
									if(obj.st>(obj.pic.length-1)){obj.st=0;}
										obj.Auto();
									animate(now,{opacity:[to,from],easing:eas,onfinish:function(){
									document.getElementById(now).style.display='none';}},tim);
									
									},(stim*1000));
																								   }},tim);
				}
					
			}	
		
	}
	}
function fadeLast(){
	
	if(this.last){
			var way=this.way[this.lastnum];
			
			if(way=='leftright'){
				this.last.style.display='block';
				
				var to=this.last.pos;
				var wid=this.last.offsetWidth;
				var from=(to-(wid*2));
				var tim=this.mtime[this.lastnum];
				var stim=this.stime[this.lastnum];
				var eas="'"+this.how[this.lastnum]+''+this.easing[this.lastnum]+"'";
			
				animate(this.lastid,{left:[(to+(wid/2)),from],easing:eas},tim);
				
				
				}
				
				if(way=='rightleft'){
				this.last.style.display='block';
				var to=this.last.pos;
				var wid=this.last.offsetWidth;
				var from=(to+(wid*2));
				var tim=this.mtime[this.lastnum];
				var stim=this.stime[this.lastnum];
				var eas="'"+this.how[this.lastnum]+''+this.easing[this.lastnum]+"'";
			
				animate(this.lastid,{left:[(to+(wid/2)),from],easing:eas},tim);
				
									
				}
				
				if(way=='topbot'){
				this.last.style.display='block';
				var to=this.last.pos;
				var wid=this.last.offsetHeight;
				var from=(to-(wid*2));
				var tim=this.mtime[this.lastnum];
				var stim=this.stime[this.lastnum];
				var eas="'"+this.how[this.lastnum]+''+this.easing[this.lastnum]+"'";
			
				animate(this.lastid,{top:[to,from],easing:eas},tim);
									
									
									
				}
				if(way=='bottop'){
				this.last.style.display='block';
				var to=this.last.pos;
				var wid=this.last.offsetHeight;
				var from=(to+(wid*2));
				var tim=this.mtime[this.lastnum];
				var stim=this.stime[this.lastnum];
				var eas="'"+this.how[this.lastnum]+''+this.easing[this.lastnum]+"'";
			
				animate(this.lastid,{top:[to,from],easing:eas},tim);
									
				}
				if(way=='opacity'){
				this.last.style.display='block';
				var to=0;
				var from=100;
				var tim=this.mtime[this.lastnum];
				var stim=this.stime[this.lastnum];
				var eas="'"+this.how[this.lastnum]+''+this.easing[this.lastnum]+"'";
			
				animate(this.lastid,{opacity:[from,to],easing:eas},tim);
				
				}
					
			
		
	}
	}
function goGalNext(num){
	
	if(!this.moving){
		this.moving=true;
		var obj=this;
	var now=this.pic[num];
	
	if(document.getElementById(now)){
		this.fadeLast();
		this.last=document.getElementById(now);
		this.lastnum=num;
		this.lastid=now;
			var way=this.way[num];
			
			if(way=='leftright'){
				document.getElementById(now).style.display='block';
				if(document.getElementById(now).pos){var to=document.getElementById(now).pos;}else{
				var to=document.getElementById(now).offsetLeft;
				}
				var wid=document.getElementById(now).offsetWidth;
				var from=(to-(wid*2));
				var tim=this.mtime[num];
				var stim=this.stime[num];
				var eas="'"+this.how[num]+''+this.easing[num]+"'";
				animate(this.leftbtn.id,{left:(to-20),top:((document.getElementById(now).offsetHeight/2)-(this.leftbtn.offsetHeight/2))},1);
				animate(this.rightbtn.id,{left:(to+wid),top:((document.getElementById(now).offsetHeight/2)-(this.rightbtn.offsetHeight/2))},1);
				animate(now,{left:[from,(to+(wid/2))],easing:eas,onfinish:function(){obj.moving=false;} },tim);
				document.getElementById(now).kind='left';
				document.getElementById(now).pos=to;
				
				}
				
				if(way=='rightleft'){
				document.getElementById(now).style.display='block';
				if(document.getElementById(now).pos){var to=document.getElementById(now).pos;}else{
				var to=document.getElementById(now).offsetLeft;
				}
				var wid=document.getElementById(now).offsetWidth;
				var from=(to+(wid*2));
				var tim=this.mtime[num];
				var stim=this.stime[num];
				var eas="'"+this.how[num]+''+this.easing[num]+"'";
			animate(this.leftbtn.id,{left:(to-20),top:((document.getElementById(now).offsetHeight/2)-(this.leftbtn.offsetHeight/2))},1);
				animate(this.rightbtn.id,{left:(to+wid),top:((document.getElementById(now).offsetHeight/2)-(this.rightbtn.offsetHeight/2))},1);
				animate(now,{left:[from,(to+(wid/2))],easing:eas,onfinish:function(){obj.moving=false;} },tim);
				document.getElementById(now).kind='left';
				document.getElementById(now).pos=to;
				
									
				}
				
				if(way=='topbot'){
				document.getElementById(now).style.display='block';
				var to=0;
				var wid=document.getElementById(now).offsetHeight;
				var from=(to-(wid*2));
				var tim=this.mtime[num];
				var stim=this.stime[num];
				var eas="'"+this.how[num]+''+this.easing[num]+"'";
			animate(this.leftbtn.id,{left:(document.getElementById(now).offsetLeft-20),top:((document.getElementById(now).offsetHeight/2)-(this.leftbtn.offsetHeight/2))},1);
				animate(this.rightbtn.id,{left:(document.getElementById(now).offsetLeft+document.getElementById(now).offsetWidth),top:((document.getElementById(now).offsetHeight/2)-(this.rightbtn.offsetHeight/2))},1);
				animate(now,{top:[from,to],easing:eas,onfinish:function(){obj.moving=false;} },tim);
				document.getElementById(now).kind='top';
				document.getElementById(now).pos=to;
									
									
									
				}
				if(way=='bottop'){
				document.getElementById(now).style.display='block';
				var to=0;
				var wid=document.getElementById(now).offsetHeight;
				var from=(to+(wid*2));
				var tim=this.mtime[num];
				var stim=this.stime[num];
				var eas="'"+this.how[num]+''+this.easing[num]+"'";
				animate(this.leftbtn.id,{left:(document.getElementById(now).offsetLeft-20),top:((document.getElementById(now).offsetHeight/2)-(this.leftbtn.offsetHeight/2))},1);
				animate(this.rightbtn.id,{left:(document.getElementById(now).offsetLeft+document.getElementById(now).offsetWidth),top:((document.getElementById(now).offsetHeight/2)-(this.rightbtn.offsetHeight/2))},1);
				animate(now,{top:[from,to],easing:eas ,onfinish:function(){obj.moving=false;} },tim);
				document.getElementById(now).kind='top';
				document.getElementById(now).pos=to;
									
				}
				if(way=='opacity'){
				document.getElementById(now).style.display='block';
				var to=100;
				var from=0;
				var tim=this.mtime[num];
				var stim=this.stime[num];
				var eas="'"+this.how[num]+''+this.easing[num]+"'";
				animate(this.leftbtn.id,{left:(document.getElementById(now).offsetLeft-20),top:((document.getElementById(now).offsetHeight/2)-(this.leftbtn.offsetHeight/2))},1);
				animate(this.rightbtn.id,{left:(document.getElementById(now).offsetLeft+document.getElementById(now).offsetWidth),top:((document.getElementById(now).offsetHeight/2)-(this.rightbtn.offsetHeight/2))},1);
				animate(now,{opacity:[from,to],easing:eas,onfinish:function(){obj.moving=false;} },tim);
				
				}
					
			}	
		
	}
	}
function initiate(byuser){
		if(byuser=='auto'){
		this.Auto();
		}else{
			var obj=this;
			this.goGalNext(0);
			this.rightbtn.style.display="block";
			this.leftbtn.style.display="block";
			this.rightbtn.onclick=function(){
				obj.st++;
				if(obj.st>(obj.pic.length-1)){obj.st=0;}
				obj.goGalNext(obj.st);
				}
			this.leftbtn.onclick=function(){
				obj.st--;
				if(obj.st<0){obj.st=(obj.pic.length-1);}
				obj.goGalNext(obj.st);
				}
			}
		
		
	}
function gallery(){
	this.st=0;
	this.fadeLast=fadeLast;
	this.moving=false;
	this.pic=new Array();
	this.mtime=new Array();
	this.stime=new Array();
	this.way=new Array();
	this.how=new Array();
	this.easing=new Array();
	this.addPic=addPic;
	this.addMtime=addMtime;
	this.addStime=addStime;
	this.addWay=addWay;
	this.addEasing=addEasing;
	this.addHow=addHow;
	this.initiate=initiate;
	this.goGalNext=goGalNext;
	this.Auto=Auto;
	}

