/*
    Very Versatile Electronic Document Javascript Toolkit v0.9.2
    http://novatvmedia.com/vved

    Copyright (c) 2010 Ezrad I.A.T. Lionel
    http://novatvmedia.com/vved/license

    Revision: 1-555

*/

// VVED GLOBAL VARIABLES
var VVED_START_TIME=new Date().getTime();
var SYS_CLOCK_RUNTIME="";
var SYS_STATS="";
var SHOW_FPS=true;
var SHOW_STATS=true;
var SHOW_EXTRA_STATS=true;
var SYS_STATS_FPS=7;
var SYSTEM_FPS=60;
var DEBUG=true;
var TWEENINFO=true;
var TWEEN_DROP_FRAME=1;
var TWEEN_INFO_CONTAINER="tweendisplay";
var FPS_DISPLAY_CONTAINER="fpsdisplay";
var DEBUG_CONTAINER="debugcontainer";
var VVED_COPYRIGHT="ver. <b>"+_versionstring()+"</b><br/>Copyright &#169; 2008 - 2010, <b>Novatv Media</b><br/><font style='color:#000000;background:#3399FF;font-size:12px;' onmousedown=_goto('http://novatvmedia.com/vved')>&nbsp;http://<b>novatvmedia</b>.com/<b>vved</b>&nbsp;</font>";
var NORMAL=1;
var SLOW=1.5;
var SLOWER=2;
var SLOWEST=3;
var FAST=0.75;
var FASTER=0.5;
var FASTEST=0.25;
// initialize vved interfaces
function _versionstring(){
    return "0.9.2.041910";
}
// DEBUG slim
var _msgcount=0;
function _msg(t,o){
    o=o||{};
    if(!o.dontcount)_msgcount++;
    if(!o.nofrills)t="<font style='background:#F4FFDD;color:#004FC6;font-weight:bold;font-size:14px;'>&nbsp;"+_msgcount+".</font>&nbsp;"+t;
    if(!o.reverse)$(DEBUG_CONTAINER).innerHTML=t+"<br/>"+$(DEBUG_CONTAINER).innerHTML;
    else $(DEBUG_CONTAINER).innerHTML+=t+"<br/>";
}
//debug functions
function setdebugenv(){
  if(SHOW_FPS){
    _togglr.add("stats",[function(){_tweenr.addtween(FPS_DISPLAY_CONTAINER,{p:'top',v:-500,d:.5,cf:'easeInExp'})},function(){_tweenr.addtween(FPS_DISPLAY_CONTAINER,{p:'top',v:5,d:1,cf:'easeOutExp'});}]);
    _togglr.add("vvedruntime",[function(){_tweenr.addtween(TWEEN_INFO_CONTAINER,{pb:.25,p:'top',v:-700,d:.5,cf:'easeInExp'});TWEENINFO=false;},function(){_tweenr.addtween(TWEEN_INFO_CONTAINER,{pb:0,p:'top',v:5,d:1,cf:'easeOutExp'});TWEENINFO=true;}]);
    _pollkey("r,t,m",function(){toggle("vvedruntime");},"keydown");
    _pollkey("v,v,e,d",function(){toggle("stats");},"keydown");
    _pollkey("f,p,s",function(){
        if(SHOW_EXTRA_STATS===false){
            SHOW_EXTRA_STATS=true;
        } else {
            SHOW_EXTRA_STATS=false;
        }
            var dbg=$(FPS_DISPLAY_CONTAINER);
				_tweenr.addtween(dbg,{p:'left',v:(screen.width-(SHOW_EXTRA_STATS?325:175)),d:.5,cf:'easeOutExp'});
				_tweenr.addtween(dbg,{p:'width',v:(SHOW_EXTRA_STATS?275:125),d:.5,cf:'easeOutExp'});
				_tweenr.addtween(dbg,{p:'height',v:(SHOW_EXTRA_STATS?240:30),d:.5,cf:'easeOutExp'});
				
    },"keydown");
  }
  if(DEBUG){
    if(DEBUG){_togglr.add("debug",[function(){
        _animate(DEBUG_CONTAINER,{c:"",seq:[['top/-500/.5/cycle,1/easeInBack'],['height/0/.05/cycle,1/easeOut////'],['left/'+(screen.width+200)+'/.05/cycle,1/easeOutBack']],d:3,useglobaltime:false});
      },function(){
        _animate(DEBUG_CONTAINER,{c:"",seq:[['top/128/.05/cycle,1/easeOutBack'],['left/'+(screen.width-(parseInt(_getcss(DEBUG_CONTAINER,'width'))+30))+'/.25/cycle,1/easeOut////'],['height/250/.5/cycle,1/easeOutBack////']],d:.25,useglobaltime:false});
    }]);}
    _pollkey("d,b,g",function(){toggle("debug");},"keydown");
  }
}

//create vved elements
function createvvedelements(){
    var dbg;
    dbg = createElement("div");
    dbg.id=FPS_DISPLAY_CONTAINER;
    dbg.style.overflow="hidden";
    dbg.style.position="absolute";
    dbg.className="draggable usemask:true copybackground:true confine:none";
    dbg.style.top="-600px";
    dbg.style.left=(screen.width-(SHOW_EXTRA_STATS?325:175))+"px";
    dbg.style.width=SHOW_EXTRA_STATS?"275px":"125px";
    dbg.style.height=SHOW_EXTRA_STATS?"240px":"30px";
    dbg.style.backgroundColor="#000000";
    dbg.style.color="#FFFFFF";
    dbg.style.fontSize="10px";
    dbg.style.fontWeight="";
    dbg.style.fontFamily="lucida sans unicode,verdana";
    dbg.style.cursor="pointer";
    dbg.style.cursor="hand";
    dbg.style.border="0px solid #FFFFFF";
    dbg.style.zIndex=9999;
    dbg.style.padding="5px";
    dbg.style.paddingRight="10px";
    if(_isbrowser("iexplorer")){
        dbg.style.filter="alpha(opacity=90)";
    }else dbg.style.opacity=0.9;
    document.body.appendChild(dbg);

	if(TWEENINFO){

    dbg = createElement("div");
    dbg.id=TWEEN_INFO_CONTAINER;
    dbg.style.overflowY="auto";
    dbg.style.overflowX="hidden";
    dbg.style.position="absolute";
    dbg.className="draggable resizable usemask:true copybackground:true confine:none";
    dbg.style.top="-700px";
    dbg.style.left=(screen.width-(500)-(20)-(SHOW_EXTRA_STATS?325:175))+"px";
    dbg.style.width="500px";
    dbg.style.height="400px";
    dbg.style.backgroundColor="#000000";
    dbg.style.color="#FFFFFF";
    dbg.style.fontSize="10px";
    dbg.style.fontWeight="";
    dbg.style.fontFamily="lucida sans unicode,verdana";
    dbg.style.cursor="pointer";
    dbg.style.cursor="hand";
    dbg.style.border="0px solid #FFFFFF";
    dbg.style.zIndex=9999;
    dbg.style.padding="5px";
    dbg.style.paddingRight="10px";
    if(_isbrowser("iexplorer")){
        dbg.style.filter="alpha(opacity=90)";
    }else dbg.style.opacity=0.9;
    document.body.appendChild(dbg);	
	
	}
	
    if(DEBUG){
        dbg = createElement("div");
        dbg.id=DEBUG_CONTAINER;
        dbg.style.overflow="";
        dbg.style.position="absolute";
        dbg.className="draggable resizable usemask:true copybackground:true";
        dbg.style.top="-500px";
        dbg.style.left=(screen.width+50)+"px";
        dbg.style.width=(500)+"px";
        dbg.style.height="0px";
        dbg.style.backgroundColor="#FFFFFF";
        dbg.style.color="#000000";
        dbg.style.fontSize="12px";
        dbg.style.fontWeight="";
        dbg.style.fontFamily="georgia,lucida sans unicode,verdana";
        dbg.style.cursor="pointer";
        dbg.style.cursor="hand";
        dbg.style.border="0px solid #FFFFFF";
        dbg.style.zIndex=9998;
        dbg.style.padding="5px";
        dbg.style.paddingRight="10px";
        if(_isbrowser("iexplorer")){
            dbg.style.filter="alpha(opacity=90)";
        }else dbg.style.opacity=0.9;
        document.body.appendChild(dbg);
        $(DEBUG_CONTAINER).style.overflowY="auto";

        VVEDobj.onload(function(){
            VVEDobj.add(DEBUG_CONTAINER,{syncimage:true,usepivot:"0,50"});
        });
    }
	
    dbg = createElement("div");
    dbg.id="anchorx";
    dbg.style.overflow="hidden";
    dbg.style.position="absolute";
    dbg.style.top="0px";
    dbg.style.left="0px";
    dbg.style.width="100%";
    dbg.style.height="1px";
    dbg.style.backgroundColor="#FFFFFF";
    if(_isbrowser("iexplorer")){
        dbg.style.filter="alpha(opacity=1)";
    }else dbg.style.opacity=0.01;
    document.body.appendChild(dbg);

    dbg = createElement("div");
    dbg.id="anchory";
    dbg.style.overflow="hidden";
    dbg.style.position="absolute";
    dbg.style.top="0px";
    dbg.style.left="0px";
    dbg.style.width="1px";
    dbg.style.height="100%";
    dbg.style.backgroundColor="#FFFFFF";
    if(_isbrowser("iexplorer")){
        dbg.style.filter="alpha(opacity=1)";
    }else dbg.style.opacity=0.01;
    document.body.appendChild(dbg);
}

function startVVED(o){
    // configure vved debug state
    createvvedelements();
    o=o||{};
    sysClock.start();
    //events
    if(!o.dontuseglobalcaptures){
        addEvent(document,'mousedown',_mousedown);
        addEvent(document,'mouseup',_mouseup);
        addEvent(document,'mouseover',_mouseover);
        addEvent(document,'mouseout',_mouseout);
        if(!o.dontuseglobalmousemove)addEvent(document,'mousemove',_mousemove);
      if(_isbrowser("firefox")){
      window.addEventListener('DOMMouseScroll', _mousewheel, false);
      }else addEvent(document,'mousewheel',_mousewheel);
        addEvent(document,'keydown',_keydown);
        addEvent(document,'keyup',_keyup);
    }


    if(o.systemfps)SYSTEM_FPS=o.systemfps;
    var clock_cores=1;
    if(o.clock_cores)clock_cores=o.clock_cores;

clock_cores=1;
for(var i=0,j=clock_cores;i<j;i++){
    sysClock.addtask({id:"Tweenr Output "+i,task:function(){
            _tweenr.output();
        },fps:((clock_cores>1)?_randomseed(SYSTEM_FPS/clock_cores):SYSTEM_FPS)});
}

if(SHOW_FPS){
    sysClock.addtask({id:"System Stats",task:function(){
            $(FPS_DISPLAY_CONTAINER).innerHTML=SYS_STATS;
        },fps:SYS_STATS_FPS});
}

    VVEDobj.start(o);
    if(SHOW_FPS||DEBUG)setdebugenv();
//flush..
addEvent(window,'unload',EventCache.flush);
}
// vved object
var VVEDobj=function(){
    var objqueue=[];
    return {
        selectorEngine:$,
        objqueue:[],
        start:function(o){
            this.runstart();
            if(o.usedomextensions||(o.usedomextendsets&&o.usedomextendsets!==""))_defaultdomextensions(o);
            if(o.selectorengine)this.setSelectorEngine(o.selectorengine);
        },
        setSelectorEngine:function(e){
            this.selectorEngine=e;
        },
        startfunc:[],
        onload:function(f){
            this.startfunc.push(f);
        },
        runstart:function(){
            for(var i=0,j=this.startfunc.length;i<j;i++){
                this.startfunc[i](this);
            }
            this.startanim();
        },
        startanimfunc:[],
        startanimation:function(f,t){
            this.startanimfunc.push({f:f,t:t});
        },
        startanim:function(){
            var _v=this;
            for(var i=0,j=this.startanimfunc.length;i<j;i++)(function(indx){
                setTimeout(function(){
                    _v.startanimfunc[indx].f(_v);
                },_v.startanimfunc[indx].t);
            })(i);
        },
        add:function(r,o){
            for(var i=0,j=this.objqueue.length;i<j;i++){
                if(this.objqueue[i].status!=="active"){
                    this.objqueue[i]=_vvedobj(r,i,o);
                    this.objqueue[i].init();
                    return i;
                }else{
                    if(typeof(r)==="object"){
                        if(this.objqueue[i].ref===r){
                            return i;
                        }
                    }else if(typeof(r)==="string"){
                        if(this.objqueue[i].id===r){
                            return i;
                        }
                    }
                }
            }
            this.objqueue.push(_vvedobj(r,this.objqueue.length,o));
            this.objqueue[this.objqueue.length-1].init();
            return this.objqueue.length-1;
        },
        remove:function(r){
            this.objqueue[_getref(r)].status="inactive";
        },
        getref:function(r){
            for(var i=this.objqueue.length-1,j=0;i>=j;i--){
                if(typeof(r)==="object"){
                    if(this.objqueue[i].ref===r){
                        return i;
                    }
                }else if(typeof(r)==="string"){
                    if(this.objqueue[i].id===r){
                        return i;
                    }
                }
            }
            this.add(r);
            return this.getref(r);
            //return this.add(r);
        },
        attach:function(o){
            o.a.processing=false;
            for(var i=0,j=this.objqueue[this.getref(o.r)].ochildren[o.p].length;i<j;i++){
                if(this.objqueue[this.getref(o.r)].ochildren[o.p][i]==="x"){
                    this.objqueue[this.getref(o.r)].ochildren[o.p][i]=o.a;
                    return i;
                }
            }
            this.objqueue[this.getref(o.r)].ochildren[o.p].push(o.a);
            return this.objqueue[this.getref(o.r)].ochildren[o.p].length-1;
        },
        dettachobj:function(r,c,p){
            for(var i=0,j=this.objqueue[this.getref(r)].ochildren[p].length;i<j;i++){
                if(this.objqueue[this.getref(r)].ochildren[p][i].e===c.e && this.objqueue[this.getref(r)].ochildren[p][i].p===c.p){
                    this.objqueue[this.getref(r)].ochildren[p][i]="x";
                    return i;
                }
            }
        },
        addmethod:function(m,f){
            this[m]=f;
        },
        addobjectmethod:function(o,m,f){
            this.objqueue[_getref(o)].addmethod(m,f);
        }
    };
}();
// get vved index wrapper
function _getref(r,i){
    return VVEDobj.getref(r);
}

//vved core object
function _vvedobj(r,i,o){
    return {
        status:"active",
        ref:r,
        id:"",
        index:i,
        options:o?o:{},
        init:function(){
            if(typeof(this.ref)==="string"){
                this.id=this.ref;
                this.ref=$(this.ref);
            }else if(typeof(this.ref)==="object"){
                this.id=this.ref.id;
            }

            this.img._resize=this.options.syncimage?true:false;
            if(this.ref!==document){
                this.img.ref=this.ref;
                this.img.resize();
                if(this.options.usepivot){
                  var pp=this.options.usepivot.split(",");
                  var xp=parseInt(pp[0]?pp[0]:0,10);
                  var yp=parseInt(pp[1]?pp[1]:0,10);
                  this.anchorpct=[xp,yp];
                  var ax=_percentagevalue(xp,parseInt(_getcss(this.ref,"width"),10))+parseInt(_getcss(this.ref,"left"),10);
                  var ay=_percentagevalue(yp,parseInt(_getcss(this.ref,"height"),10))+parseInt(_getcss(this.ref,"top"),10);
                  this.anchorpoint.x=ax;
                  this.anchorpoint.y=ay;
                }
            }
        },
        anchorpct:[0,0],
        anchorpoint:point(),
        pivot:point(),
        updateanchor:function(){
        },
        img:{ref:"",_resize:false,maintainratio:false,lvl:1,scaleby:"width",
            resize:function(){
                if(this.maintainratio){
                    this.adjust(this.scaleby);
                }else{
                    this.adjust("width");
                    this.adjust("height");
                }
            },
            adjust:function(a){
                if(this._resize){
                    for(var i=0,j=this.lvl;i<j;i++){
                        if(this.ref.getElementsByTagName('img')[i]){
                            this.ref.getElementsByTagName('img')[i].style[a]=_getcss(this.ref,a);
                        }
                    }
                }
            },
            setscale:function(p){
                this.scaleby=p;
            },
            setresize:function(r){
                this._resize=r;
            },
            setratio:function(a){
                this.maintainratio=a;
            },
            setlvl:function(l){
                this.lvl=l;
            }
        },
        ochildren:{
            parentAll:[],
            width:[],
            height:[],
            left:[],
            top:[],
            opacity:[],
            backgroundColor:[],
            borderColor:[],
            borderLeftColor:[],
            borderRightColor:[],
            borderTopColor:[],
            borderBottomColor:[],
            color:[],
            text:[],
            fontSize:[],
            padding:[],
            paddingLeft:[],
            paddingRight:[],
            paddingTop:[],
            paddingBottom:[],
            margin:[],
            marginLeft:[],
            marginRight:[],
            marginTop:[],
            marginBottom:[],
            letterSpacing:[],
            lineHeight:[],
            textIndent:[],
            zIndex:[],
            borderWidth:[],
            borderLeftWidth:[],
            borderRightWidth:[],
            borderTopWidth:[],
            borderBottomWidth:[],
            scrollTop:[],
            scrollLeft:[],
            wordSpacing:[]
        },
        orbit:function(t){
            orbit(t.orbit,this.ref,t.deg,t,t.func);
        },
        play:function(t){
            t.obj=this.ref;
            playFrames(t);
        },
        to:function(t){
            if(t.p.find("olor")){
                t.duration=t.d;
                t.cycle=t.c;
                t.startcolor=t.sc?t.sc:"";
                t.mode=t.m?t.m:"";
                _colortween(this.ref,t.v,t.p,t);
            }else if(t.p.find("play")){
                this.play(t);
            }else if(t.p.find("orbit")){
                this.orbit(t);
            }else{
                var index=this.index;
                if(this.options.usepivot){
                    var pv=this.options.usepivot;
                    var ap=this.anchorpoint;
                    var apct=this.anchorpct;
                    var rf=this.ref;
                        t.rt=0;
                        t.t=_stacktweenfunction(t.t,function(o){
                            VVEDobj.objqueue[_getref(rf)].syncattached(t.p,o);
                        });

                    if(t.p==="left"||t.p==="top"){
                        if(t.p==="left"){
                            t.st=ap.x;
                            t.t=_stacktweenfunction(t.t,function(o){
                                ap.x=o.curval;
                                var x=o.curval-_percentagevalue(apct[0],parseInt(_getcss(rf,"width"),10))+_getunit(_getcss(rf,"left"));
                                _setcss(rf,"left",x);
                            });
                        }
                        if(t.p==="top"){
                            t.st=ap.y;
                            t.t=_stacktweenfunction(t.t,function(o){
                                ap.y=o.curval;
                                var y=o.curval-_percentagevalue(apct[1],parseInt(_getcss(rf,"height"),10))+_getunit(_getcss(rf,"top"));
                                _setcss(rf,"top",y);
                            });
                        }
                        return _tweenr.addtween("counter",t);
                    }
                    if(t.p==="width"||t.p==="height"){
                        if(t.p==="width"){
                            t.t=_stacktweenfunction(t.t,function(o){
                                var x=ap.x-_percentagevalue(apct[0],parseInt(_getcss(rf,"width"),10))+_getunit(_getcss(rf,"left"));
                                _setcss(rf,"left",x);
                                VVEDobj.objqueue[_getref(o.elem)].img.resize();
                            });
                        }
                        if(t.p==="height"){
                            t.t=_stacktweenfunction(t.t,function(o){
                                var y=ap.y-_percentagevalue(apct[1],parseInt(_getcss(rf,"height"),10))+_getunit(_getcss(rf,"top"));
                                _setcss(rf,"top",y);
                                VVEDobj.objqueue[_getref(o.elem)].img.resize();
                            });
                        }
                        return _tweenr.addtween(this.ref,t);
                    }
                }else{
                    var tickfunc=function(o){
                        VVEDobj.objqueue[_getref(o.elem)].syncattached(t.p,o);
                        if(t.p==="width"||t.p==="height")VVEDobj.objqueue[_getref(o.elem)].img.resize();
                    };
                    t.t=_stacktweenfunction(t.t,tickfunc);
                    return _tweenr.addtween(this.ref,t);
                }

            }
        },
        reverseanimator:[],
        animator:[],
        animate:function(a){
            if(a.seq.length===0)return;
            a.c=a.c?a.c:"";
            a.cf=a.cf?a.cf:"";
            a.d=a.d?a.d:0;
                if(!a.block)a.block=0;
            if(!a.cycling){
                this.animator=[].concat(a.seq);
                a.cycling=true;
            }
            var rar=_traversearray(a.seq,[]);
            var endanim=(rar.a.length>0)?false:true;
            a.seq=[].concat(rar.a);
            if(!a.reversecopied){
                this.reverseanimator=([].concat(this.animator)).reverse();
            }
            var r=this;
            if(endanim && (a.c.find("loop")||a.c.find("cycle"))){
                a.reversecopied=true;
                if(a.c.find(",")){
                    var cycnt=a.c.split(",");
                    if(parseInt(cycnt[1],10)>1){
                        a.c=cycnt[0]+","+(parseInt(cycnt[1],10)-1);
                        endanim=false;
                        a.block=0;
                    }else{
                        endanim=true;
                    }
                }else{
                    endanim=false;
                }
                if(a.c.find("loop")){
                    a.seq=[].concat(this.animator);
                }else{
                    if(!a.reversecycle){
                        a.seq=[].concat(this.reverseanimator);
                    }else{
                        a.seq=[].concat(this.animator);
                    }
                    a.reversecycle=(a.reversecycle)?false:true;
                }
            }
                if(!endanim && a.useglobaltime){
                    a.globaltimer=setTimeout(function(){
                        r.animate(a);
                    },a.d*1000);
                }


                for(var i=0,j=rar.o.length;i<j;i++){
                    var options={},t=[],prop="";
                    if(_isstring(rar.o[i])){
                        t=rar.o[i].split("/");
                        prop=t[0];
                    }else{
                        options=rar.o[i];
                        prop=options.p;
                    }

                    if(a.seq.length>0 && !a.useglobaltime && !endanim){
                        if(i===j-1){
                            options.e=_stacktweenfunction(options.e,function(o){
                                r.animate(a);
                            });

                            if(prop.find("olor")){
                                var tmout=0;
                                if(options.p){
                                    tmout=options.d;
                                }else{
                                    tmout=t[1];
                                }
                                tmout*=1000;
                                a.globaltimer=setTimeout(function(){
                                    r.animate(a);
                                },tmout);
                            }
                        }
                    }

        var twnstate=-1;
                    if(prop.find("olor")){
                      if(options.p){

                      }else{
                        options.p=t[0];
                        options.v=t[1];
                        options.sc=t[2];
                        options.d=t[3]?t[3]:a.d;
                        options.c=t[4]?t[4]:"";
                      }
                        twnstate=this.to(options);
                    }else if(prop.find("orbit")){

                    }else{
                        if(options.p){

                        }else{
                          options.p=t[0];
                          options.v=t[1];
                          options.d=t[2]?t[2]:a.d;
                          options.c=t[3]?t[3]:"";
                          options.cf=t[4]?t[4]:(a.cf?a.cf:"");
                          options.st=t[5]?t[5]:(a.st?a.st:"");
                          options.of=t[6]?t[6]:(a.of?a.of:0);
                          options.pb=t[7]?t[7]:(a.pb?a.pb:0);
                          options.pa=t[8]?t[8]:(a.pa?a.pa:0);
                          options.rt=t[9]?t[9]:(a.rt?a.rt:0);
                        }

                        twnstate=this.to(options);
                    }
                }
        },
        syncattached:function(p,t){
            for(var i=0,j=this.ochildren[p].length;i<j;i++){
                var obj=this.ochildren[p][i];
                var syncok=true;
                if(obj.cond){
                    if(obj.cond(t,this)){
                        syncok=true;
                    }else syncok=false;
                }
                //syncok=(obj.p===p)||false;
                if(syncok){
                    var v;
                    if(obj.value){
                        v=obj.value.val(t,this,p);
                    }else if(obj.mult){
                        if(obj.p==="opacity" && _isbrowser("iexplorer")){
                            v=this.ref.filters.alpha.opacity*obj.mult;
                        }else v=parseFloat(_getcss(this.ref,p))*obj.mult;
                        if(obj.offset)v+=obj.offset;
                    }else if(obj.offset){
                        if(obj.p==="opacity" && _isbrowser("iexplorer")){
                            v=this.ref.filters.alpha.opacity+obj.offset;
                        }else v=parseFloat(_getcss(this.ref,p))+obj.offset;
                    }else{
                        if(obj.p==="opacity" && _isbrowser("iexplorer")){
                            v=this.ref.filters.alpha.opacity;
                        }else v=parseFloat(_getcss(this.ref,p));
                    }
                    v=((obj.p==="width"||obj.p==="height"||obj.p==="fontSize"||obj.p==="opacity")&&v<0)?0:v;

                    if(obj.delay){
                        var lastsync;
                        if(!t.mode){
                            if(t.loopcycle){
                                lastsync=(t.timepercent()>=100 && t.loopcycles!==0 && !isNaN(t.loopcycles) && t.count===(t.loopcycles-1) )||false;
                            }else lastsync=(t.timepercent()>=100)||false;
                        }
                        if(!obj.processing || lastsync){
                            this.ochildren[p][i].processing=true;
                            var td=obj.df;
                            td.p=obj.p;
                            td.v=v;
                            td.d=td.d?td.d:1;
                            td.lo=((obj.p==="width"||obj.p==="height"||obj.p==="fontSize"))?true:false;
                            var func=obj.df.t?obj.df.t:"";
                            var tickfunc=function(o){
                                VVEDobj.objqueue[_getref(o.elem)].syncattached(obj.p,o);
                                VVEDobj.objqueue[_getref(o.elem)].img.resize();
                            };
                                if(obj.df.t){
                                    if(typeof(obj.df.t)==="object"){
                                        obj.df.t.push(tickfunc);
                                        td.t=obj.df.t;
                                    }else{
                                        td.t=[obj.df.t,tickfunc];
                                    }
                                }else{
                                    td.t=tickfunc;
                                }
                                _tweenr.addtween(obj.e,td);

                            var refindex=_getref(this.ref),indx=i;
                            setTimeout(function(){
                                VVEDobj.objqueue[refindex].resetsync(p,indx);
                            },obj.delay*1000);
                        }
                    }else{
                        if(obj.p==="opacity"){
                            if(_isbrowser("iexplorer")){
                                $(obj.e).filters.alpha.opacity=v;
                            }else $(obj.e).style[obj.p]=v;
                        }else $(obj.e).style[obj.p]=v+"px";
                        VVEDobj.objqueue[_getref(obj.e)].img.resize();
                        VVEDobj.objqueue[_getref(obj.e)].syncattached(obj.p,{loopcycle:true,loopcycles:0,count:0,mode:true});
                    }
                    // run function
                    if(obj.f)obj.f(t,this);
                }
            }
        },
        resetsync:function(p,i){
            this.ochildren[p][i].processing=false;
        },
        addmethod:function(m,f){
            this[m]=f;
        }
    };
}
// reset attachmentdelay must be id 4 now
function _resetattachdelay(r,p,i){
    VVEDobj.objqueue[_getref(r)].ochildren[p][i].processing=false;
}
// THE TWEENER
var _tweenr=function(){
    var tweenqueue=[];
    var counter=[];
    return {
        tweenqueue:[],
        counter:[],
        addtween:function(e,o){
        if(e!== "counter"){
        var cssprop=_getcss(e,o.p);
          if(!o.u){
              var u=_getunit(cssprop);
              o.u=u;
          }
          if(typeof(o.v)==='string'&&(o.v).find("=")){
            var vstr=o.v;
            var vnum=parseFloat(vstr.split("=")[1]);
                if(vstr.find('offset')){
                  if(vstr.find("+"))o.of=vnum;
                  if(vstr.find("-"))o.of=-1*vnum;
                }else{
                  if(vstr.find("+"))o.v=(parseFloat(cssprop))+vnum;
                  if(vstr.find("-"))o.v=(parseFloat(cssprop))-vnum;
                }
                if(vstr.find("*"))o.v=(parseFloat(cssprop))*vnum;
                if(vstr.find("/"))o.v=(parseFloat(cssprop))/vnum;
          }

        }else{
          if(typeof(o.v)==='string'&&(o.v).find("=")){
            var cssprop=o.st;
            var vstr=o.v;
            var vnum=parseFloat(vstr.split("=")[1]);
                if(vstr.find('offset')){
                  if(vstr.find("+"))o.of=vnum;
                  if(vstr.find("-"))o.of=-1*vnum;
                  if(vstr.find("*"))o.of=(parseFloat(cssprop))*vnum;
                  if(vstr.find("/"))o.of=(parseFloat(cssprop))/vnum;
                }else{
                  if(vstr.find("+"))o.v=(parseFloat(cssprop))+vnum;
                  if(vstr.find("-"))o.v=(parseFloat(cssprop))-vnum;
                  if(vstr.find("*"))o.v=(parseFloat(cssprop))*vnum;
                  if(vstr.find("/"))o.v=(parseFloat(cssprop))/vnum;
                }
          }
        }

            if(e==="counter"){
                var freecounter=-1,fcq=[];
                    for(var q=this.tweenqueue.length-1,r=0;q>=r;q--){
                        if(this.tweenqueue[q].active && this.tweenqueue[q].id!==undefined){
                            var id=this.tweenqueue[q].id;
                            if(id.find("_tweenr.counter[")){
                                fcq.push(parseInt((id.split("_tweenr.counter[")[1]).split("]")[0],10));
                            }
                            if(o.ty){
                                if(this.tweenqueue[q].type){
                                    if(typeof(this.tweenqueue[q].type)===typeof(o.ty)){
                                        var type=this.tweenqueue[q].type,match=true;
                                            if(typeof(o.ty)==="object"){
                                                for(var a in type){
                                                    if(type[a]!==o.ty[a])match=false;
                                                }
                                            }else{
                                                if(type!==o.ty)match=false;
                                            }
                                        if(match){
                                            this.tweenqueue[q].stop();
                                        }
                                    }
                                }
                            }
                        }
                    }
                        for(var i=this.counter.length-1,j=0;i>=j;i--){
                            if(fcq.find(i)===-1){
                                freecounter=i;
                                break;
                            }
                        }
                e=o.st?o.st:0;
                if(freecounter>-1){
                    this.counter[freecounter]=o.st?o.st:0;
                    o.id="_tweenr.counter["+freecounter+"]";
                }else{
                    this.counter.push(o.st?o.st:0);
                    o.id="_tweenr.counter["+(this.counter.length-1)+"]";
                }
            }
            var chk=(typeof(e)==="string")?$(e):e;
            if(!o.st){
                if(typeof(chk)==="object"){
                    if(parseFloat(_getcss(e,o.p))===o.v){
                        return "REDUNDANT TWEEN";
                    }
                }else{
                    if(e===o.v){
                        return "REDUNDANT TWEEN";
                    }
                }
            }
            var tweeninstance=-1;
            for(var i=this.tweenqueue.length-1,j=0;i>=j;i--){
                if(!this.tweenqueue[i].active){
                    if(tweeninstance===-1)tweeninstance=i;
                }else{
                    if(o.ty){
                        if(this.tweenqueue[i].type){
                            if(typeof(this.tweenqueue[i].type)===typeof(o.ty)){
                                var type=this.tweenqueue[i].type,match=true;
                                    if(typeof(o.ty)==="object"){
                                        for(var a in type){
                                            if(type[a]!==o.ty[a])match=false;
                                        }
                                    }else{
                                        if(type!==o.ty)match=false;
                                    }
                                if(match){
                                    tweeninstance=i;
                                    break;
                                }
                            }
                        }
                    }else if(typeof(e)==="number"){
                        if(o.id===this.tweenqueue[i].prop){
                            tweeninstance=i;
                            break;
                        }
                    }else if(typeof(e)==="string"){
                        if(e===this.tweenqueue[i].elem.id && o.p===this.tweenqueue[i].prop){
                            tweeninstance=i;
                            break;
                        }
                    }else{
                        if(e===this.tweenqueue[i].elem && o.p===this.tweenqueue[i].prop){
                            tweeninstance=i;
                            break;
                        }
                    }
                }
            }
            if(tweeninstance>-1){
                this.tweenqueue[tweeninstance].update(e,o);
                return tweeninstance;
            }else{
                this.tweenqueue.push(_obj(e,o));
                this.tweenqueue[this.tweenqueue.length-1].init();
                return this.tweenqueue.length-1;
            }
        },
        cpuse:0,
        lstcnt:0,
        output:function(){
            var c=0,pcpuse=this.cpuse,ostr="";
            this.cpuse=0;
            for(var i=this.tweenqueue.length-1,j=0;i>=j;i--){
                if(this.tweenqueue[i].active){
                    sysClock.rawticks++;
                    this.tweenqueue[i].process();
					if(TWEENINFO)ostr+=this.tweenqueue[i].output()+"<br/>";
                    this.cpuse+=this.tweenqueue[i].tickpcnt();
                    c++;
                }
            }
			
			//var twnfoupdate=((_randomtruth(99)&&_randomtruth(99))&&(_randomtruth(99)||_randomtruth(99)));

			this.twndrpcnt++;			
			if(TWEENINFO && this.twndrpcnt>(this.twndrplmt*TWEEN_DROP_FRAME)){
				this.twndrpcnt=0;
				if(ostr.length>0){
					_html(TWEEN_INFO_CONTAINER,sysClock.tasklist+"<br/>"+"<font style='color:#FFFFFF;background:;font-size:12px;padding-right:10px;line-height:200%;'><b>&nbsp;&nbsp;Active Tweens</b></font><br/>"+ostr);
				}else {
					_html(TWEEN_INFO_CONTAINER,sysClock.tasklist);
				}
			}
			
            this.lstcnt=c;
            if(c>0){
                this.cpuse/=c;
            }else{
                this.cpuse="idle";
            }
        },
		twndrplmt:5,
		twndrpcnt:0,
        activecount:function(){
            var c=0;
            for(var i=this.tweenqueue.length-1,j=0;i>=j;i--){
                if(this.tweenqueue[i].active){
                    c++;
                }
            }
            return c;
        },
        inactivecount:function(){
            var c=0;
            for(var i=this.tweenqueue.length-1,j=0;i>=j;i--){
                if(!this.tweenqueue[i].active){
                    c++;
                }
            }
            return c;
        },
        display:function(){
        },
        find:function(e,p){
            for(var q=this.tweenqueue.length-1,r=0;q>=r;q--){
                if(!this.tweenqueue[q].id.find("_tweenr.counter")){
                    if(this.tweenqueue[q].elem===$(e) && this.tweenqueue[q].prop===p){
                        return q;
                    }
                }
            }
            return -1;
        },
        stop:function(e){
            for(var q=this.tweenqueue.length-1,r=0;q>=r;q--){
                if(!this.tweenqueue[q].id.find("_tweenr.counter")){
                    if(this.tweenqueue[q].elem===$(e)){
                        this.tweenqueue[q].stop();
                    }
                }
            }
        },
        reset:function(e,p){
            for(var q=this.tweenqueue.length-1,r=0;q>=r;q--){
                if(!this.tweenqueue[q].id.find("_tweenr.counter")){
                    if(this.tweenqueue[q].elem===$(e)){
                        this.tweenqueue[q].remaptime(p?p:0);
                    }
                }
            }
        },
        addmethod:function(m,f){
            this[m]=f;
        }
    };
}();
// tween object
function _obj(e,o){
    return {
        id:e.id?e.id:"no id",
        strref:o.id?o.id:"no ref",
        elem:e,
        options:o?o:{},
        prop:o.p?o.p:"",
        endval:(o.v||o.v===0)?o.v:0,
        offset:o.of?o.of:0,
        strtval:0,
        curval:0,
        dstval:0,
        strttime:0,
        endtime:0,
        dur:o.d?o.d:1,
        active:false,
        curvefunc:o.cf?o.cf:"linear",
        lmtoutput:o.lo?o.lo:false,
        unit:o.u?o.u:"px",
        roundtweento:(o.rt||o.rt===0)?o.rt:2,
        preval:"*",
        cycle:o.c?o.c:"normal",
        rdntcnt:0,
        ticks:0,
        alticks:0,
        lastickpercent:0,
        startfrom:(o.st||o.st===0)?o.st:-1,
        count:0,
        onstart:o.s?o.s:"",
        ontick:o.t?o.t:"",
        onend:o.e?o.e:"",
        onloopstart:o.ls?o.ls:"",
        onloopend:o.le?o.le:"",
        waiting:false,
        pausebefore:o.pb?o.pb:0,
        pauseonafter:o.pa?o.pa:0,
        waitend:0,
        waitstart:0,
        ci:0,
        cdata:o,
        loopcycles:0,
        loopcycle:false,
        notes:o.nt?o.nt:"",
        type:o.ty?o.ty:"",
        persist:o.ps?o.ps:false,
        cyclev:false,
        update:function(e,o){
            this.id=e.id?e.id:"no id";
            this.strref=o.id?o.id:"no ref";
            this.elem=e;
            this.options=o?o:{};
            this.prop=o.p?o.p:"";
            this.endval=(o.v||o.v===0)?o.v:0;
            this.offset=o.of?o.of:0;
            this.strtval=0;
            this.curval=0;
            this.dstval=0;
            this.strttime=0;
            this.endtime=0;
            this.dur=o.d?o.d:1;
            this.active=false;
            this.curvefunc=o.cf?o.cf:"linear";
            this.lmtoutput=o.lo?o.lo:false;
            this.unit=o.u?o.u:"px";
            this.roundtweento=(o.rt||o.rt===0)?o.rt:2;
            this.preval="*";
            this.cycle=o.c?o.c:"normal";
            this.rdntcnt=0;
            this.ticks=0;
            this.alticks=0;
            this.lastickpercent=0;
            this.startfrom=(o.st||o.st===0)?o.st:-1;
            this.count=0;
            this.onstart=o.s?o.s:"";
            this.ontick=o.t?o.t:"";
            this.onend=o.e?o.e:"";
            this.onloopstart=o.ls?o.ls:"";
            this.onloopend=o.le?o.le:"";
            this.waiting=false;
            this.pausebefore=o.pb?o.pb:0;
            this.pauseonafter=o.pa?o.pa:0;
            this.waitend=0;
            this.waitstart=0;
            this.ci=0;
            this.cdata=o;
            this.loopcycles=0;
            this.loopcycle=false;
            this.notes=o.nt?o.nt:"";
            this.type=o.ty?o.ty:"";
            this.persist=o.ps?o.ps:false;
            this.cyclev=false;

            this.init();
        return this;
        },
        init:function(){
            this.waitbefore();
            if(!this.waiting){
                if(this.count<1){
                    switch(typeof(this.elem)){
                        case "string":
                            if(typeof($(this.elem))==="object")this.elem=$(this.elem);
                        break;
                        case "number":
                            this.prop=this.strref;
                            this.id=this.strref;
                        break;
                    default:
                    break;
                    }
                this.loopcycles=parseInt(this.cycle.split(",")[1],10);
                this.loopcycle=(this.cycle.split(",")[0]==="cycle"||this.cycle.split(",")[0]==="loop")||false;

                    switch(this.prop){
                            case "width":
                            case "height":
                            case "opacity":
                            case "lineHeight":
                            case "fontSize":
                                if(!this.lmtoutput){
                                    this.lmtoutput=true;
                                }
                            break;
                        default:
                        break;
                    }
                }

                this.unit=(this.prop==="opacity" || this.prop==="zIndex" || typeof(this.elem)==="number")?"":"px";
                if(this.startfrom!==-1 && this.count<1){
                    this.curval=this.startfrom;
                    this.updtprop();
                }
                switch(typeof(this.elem)){
                    case "number":
                        this.strtval=this.setprop();
                        this.roundtweento=(this.roundtweento!==2)?this.roundtweento:3;
                    break;
                    case "object":
                        if(this.prop!=="opacity"){
                            this.roundtweento=0;
                            this.strtval=this.setprop();
                        }else{
                            this.roundtweento=2;
                            this.strtval=this.setprop();
                            if(_isbrowser("iexplorer")){

                            }else{
                                this.endval=(this.endval>1)?this.endval/=100:this.endval;
                            }
                        }
                        this.id=(this.id==="no id")?this.elem.id:this.id;
                    break;
                default:
                break;
                }

                this.endval=this.offset?this.strtval+this.offset:this.endval;
                this.endval=(this.lmtoutput&&this.endval<0)?0:this.endval;

                this.curval=this.strtval;
                this.dstval=this.endval-this.strtval;
                this.strttime=new Date().getTime();
                this.endtime=this.strttime + this.dur*1000;
                this.reseticker();
                if(this.count<1)this.processevent(this.onstart);
                if(this.count>0)this.processevent(this.onloopstart);
            }
            this.active=true;
            this.processevent(this.ontick);
        return this;
        },
        setprop:function(){
            switch(typeof(this.elem)){
                case "number":
                    return eval(this.prop);
                break;
                case "object":
                    if(this.prop==="opacity"){
                        return _getcss(this.elem,this.prop);
                    }else return parseInt(_getcss(this.elem,this.prop),10);
                break;
            default:
            break;
            }
        return this;
        },
        process:function(){
            if(!this.waiting){
                if(this.timepercent() <=100){
                    this.lastickpercent=this.timepercent();
                    this.preval=this.curval;
                    this.curval=this.tweeneqn();
                    if(this.preval!==this.curval){
                        this.updtprop();
                        this.processevent(this.ontick);
                        this.ticks++;
                        sysClock.execticks++;
                    }else this.rdntcnt++;
                    this.alticks++;
                    if(this.timepercent()===100)this.endprocess();
                }
            }else{
                if((this.waitend - new Date().getTime())<=this.waitindex){
                    this.waiting=false;
                    this.init();
                }
            }
        return this;
        },
        waitindex:0,
        element:function(){
            return this.elem;
        },
        stop:function(){
            this.active=false;
        return this;
        },
        start:function(){
            this.active=true;
        return this;
        },
        pausetimeout:null,
        pause:function(t){
            this.active=this.active?false:true;
            if(t){
                clearTimeout(this.pausetimeout);
                var twn=this;
                this.pausetimeout=setTimeout(function(){
                    twn.pause();
                },t);
            }
        return this;
        },
        waitbefore:function(){
            if(this.pausebefore){
                this.waitstart=new Date().getTime();
                this.waitend=new Date().getTime()+(this.pausebefore*1000);
                this.waiting=true;
                this.pausebefore=0;
            }
        },
        waitafter:function(){
            if(this.pauseonafter){
                this.waitstart=new Date().getTime();
                this.waitend=new Date().getTime()+(this.pauseonafter*1000);
                this.waiting=true;
            }
        },
        endprocess:function(){
            switch(this.cycle.split(",")[0]){
                case "cycle":
                    this.count++;
                    if(this.count<this.loopcycles || this.loopcycles===0 || isNaN(this.loopcycles)){
                      this.endval=this.strtval;
                        this.processevent(this.ontick);
                      this.processevent(this.onloopend);
                      this.waitafter();
                      this.cyclev=(this.cyclev)?false:true;
                      this.init();
                    }else{
                      this.active=false;
                        this.processevent(this.ontick);
                      this.processevent(this.onloopend);
                      this.processevent(this.onend);
                    }
                break;
                case "loop":
                    this.count++;
                    if(this.count<this.loopcycles || this.loopcycles===0 || isNaN(this.loopcycles)){
                      this.curval=this.strtval;
                      this.updtprop();
                        this.processevent(this.ontick);
                      this.processevent(this.onloopend);
                      this.waitafter();
                      this.init();
                    }else{
                      this.active=false;
                        this.processevent(this.ontick);
                      this.processevent(this.onloopend);
                      this.processevent(this.onend);
                    }
                break;
            default:
                this.waitafter();
                this.active=false;
                this.processevent(this.ontick);
                this.processevent(this.onend);
            break;
            }
        return this;
        },
        updtprop:function(){
            switch(typeof(this.elem)){
                case "object":
                    _setcss(this.elem,this.prop,this.curval+this.unit);
                break;
                case "number":
                    //this.elem=this.curval;
                    eval(this.prop+"="+this.curval);
                break;
            default:
            break;
            }
        return this;
        },
        processevent:function(f){
            if(f !==""){
                if(typeof(f)!=="object"){
                    f.run(this);
                }else{
                    for(var i=f.length-1,j=0;i>=j;i--){
                        if(typeof(f[i])==="function"){
                            f[i].run(this);
                        }else{
                        }
                    }
                }
            }
        return this;
        },
        reseticker:function(){
            this.rdntcnt=this.ticks=this.alticks=0;
        },
        rdntpcnt:function(){
            return _mathround(_percentageindex(this.rdntcnt,this.alticks),2);
        },
        tickpcnt:function(){
            return _mathround(_percentageindex(this.ticks,this.alticks),2);
        },
        fmtbzr:function(cv,jn){
            var ctrlpnt;
            if(jn){
                ctrlpnt=[],cvi=cv.split(",");
                for(var i=0,j=cvi.length;i<j;i+=2){
                    ctrlpnt.push({x:parseInt(cvi[i],10),y:parseInt(cvi[i+1],10)});
                }
            }else{
                ctrlpnt=[{x:0,y:0}],cvi=cv.split(",");
                for(var i=0,j=cvi.length;i<j;i+=2){
                    ctrlpnt.push({x:parseInt(cvi[i],10),y:parseInt(cvi[i+1],10)});
                }
                ctrlpnt.push({x:100,y:100});
            }
        return ctrlpnt;
        },
        geteqnindex:function(p){
            if(p.find("|")){
                var ep=p.split("|"),ei=0,cp,indx="",tp;
                for(var i=0,j=ep.length;i<j;i++){
                    cp=ep[i].split(",");
                    tp=(this.timepercent()>100)?100:this.timepercent();
                    if(tp>=parseInt(cp[0],10) && tp<=parseInt(cp[cp.length-2],10)){
                        ei=i;
                        indx=_percentageindex(tp-parseInt(cp[0],10),parseInt(cp[cp.length-2],10)-parseInt(cp[0],10));
                        break;
                    }
                }
                this.ci=ei;
            return _mathround(_percentagevalue(999,indx),5);
            }else return _mathround(_percentagevalue(999,this.timepercent()),5);
        },
        tweeneqn:function(){
            var ctrlpnts=getbzrCurve(this.curvefunc);
            if(!this.curvefunc.find(",") && ctrlpnts!==bzrPreset[this.curvefunc]){
                this.curvefunc=bzrPreset["defaultPreset"];
            }
            var eqnindx=this.geteqnindex(ctrlpnts);
            if(ctrlpnts.find("|")){
                ctrlpnts=this.fmtbzr(ctrlpnts.split("|")[this.ci],true);
            } else ctrlpnts=this.fmtbzr(ctrlpnts);
            var eqnout=_bezier(eqnindx/999,ctrlpnts);
            eqnout={y:_percentagevalue(this.dstval,eqnout.y)+parseFloat(this.strtval,10)};
            eqnout.y=(this.lmtoutput && eqnout.y<0)?0:eqnout.y;
        return this.approxoutput(eqnout.y);
        },
        approxoutput:function(v){
            if(this.roundtweento!==0){
                return _mathround(parseFloat(v,10),this.roundtweento);
            } else return Math.round(parseFloat(v,10));
        },
        curtime:function(){
            return new Date().getTime();
        },
        timediff:function(){
            return Math.round(this.curtime() - this.strttime);
        },
        timeleft:function(){
            return Math.round(this.endtime - this.curtime());
        },
        timepercent:function(){
                var tp = _percentageindex(this.timediff(),this.dur*1000);
            return (tp>100)?100:tp;
        },
        output:function(){
		
			var o="";
			if(!this.waiting){			
				o+="<font style='color:#000000;background:#FFFFFF;font-size:12px;'>";
                o+="<b>&nbsp;&nbsp;"+this.id+" "+(typeof(this.elem)==="object"?("["+this.prop+"]"):"")+"</b> = </font>";
                o+="<font style='color:#FFFFFF;'>&nbsp;&nbsp;";
                o+=this.curval+"<b>"+(this.unit).sub()+"</b>&nbsp;";
                o+="&#8658;&nbsp; "+this.endval+"<b>"+(this.unit).sub()+"</b>&nbsp;&nbsp;|</font>&nbsp;&nbsp;";
                o+="<font style='color:#99FF66;'><b>"+_mathround(this.timepercent(),this.roundtweento)+"</b> "+("%")+"</font><br/>";			          
			}else if(this.waiting){
                var o="<font class='debugtweenwaiting'><b>&nbsp;"+this.id+" waiting "+_mathround(((this.waitend - new Date().getTime())/1000),5)+"</b>"+("sec ..".sub())+" / &nbsp;<b>"+_mathround(((this.waitend - this.waitstart)/1000),3)+"&nbsp;&nbsp;</b></font><br/>";
            }
				
                var cycstr=(this.cycle.find(",")?this.cycle.split(",")[1]:this.cycle);
                cycstr=(cycstr==="cycle"||cycstr==="loop"||cycstr==="0")?"&#8734;":cycstr;
                cycstr=cycstr.sub();
				
            o+="<font style='color:#FFFFFF;background:#363636;margin-left:1em;'>";
            o+="&nbsp;&nbsp;&nbsp;"+((this.offset)?this.offset:this.dstval)+this.unit+" / ";
            o+=""+_mathround(this.dur,3)+"sec".sub()+" / "+this.count+""+cycstr+" / "+(this.cyclev?"&#8593;":"&#8595;")+" / "+this.alticks+((this.rdntpcnt()+"%").sub())+"&nbsp;</font>";
            o+="<b>&nbsp;&nbsp;"+(typeof(this.elem))+" / "+this.curvefunc+"</b><br/>";
			
            if(this.notes){
                var op=this.notes.val(this);
                o+="<i>note :</i><br/><div style='margin-left:3em;'>&nbsp;"+op+"&nbsp;<br/></div>";
            }			
		return o;
        },
        datatypedata:function(){
            var o="";
                for(var i in this)o+="<b>"+i+"</b>:"+((typeof this[i]!=="function")?this[i]:"")+" / ";
        return o;
        },
        valueat:function(p){
            var eqnout={x:0,y:p};
            eqnout={y:_percentagevalue(this.dstval,eqnout.y)+parseFloat(this.strtval,10)};
            eqnout.y=(this.lmtoutput && eqnout.y<0)?0:eqnout.y;
        return this.approxoutput(eqnout.y);
        },
        remaptime:function(p){
            var rmpvl=_percentagevalue(this.dur,p);
            var rmpstrt=this.curtime()-(rmpvl*1000);
            this.strttime=rmpstrt;
        return this;
        }
    };
}

// stack tween functions for multiple injection.. you lost me at functions
function _stacktweenfunction(t,n){
    if(typeof t === 'undefined'){
        t=[n];
    }else if(typeof t === "object"){
        t.push(n);
    }else if(typeof t === "string"){
        t=[t,n];
    }else if(typeof t === "function"){
        t=[t,n];
    }
return t;
}
// recursive bezier function
function _bezier(t,cv){
var l=[];
    for(var i=0,j=cv.length-1;i<j;i++)l[i]=linint(cv[i],cv[i+1],t);
    if(cv.length===2){
      return {x:l[0].x,y:l[0].y};
    }else return _bezier(t,l);
}
// linear interpolation
function linint(a,b,t){
    var dest=point();
    dest.x=a.x + (b.x - a.x)*t;
    dest.y=a.y + (b.y - a.y)*t;
    return { x:dest.x, y:dest.y };
}
// extend bezier presets
function addBezierPreset(n,d){
    bzrPreset[n]=d;
}
// modify bezier presets
function setBezierPreset(n,d){
    bzrPreset[n]=d;
}
// bezier curve presets c1[0,0]..p[n]..c1[100,100] OR c1[]|c2[]|...|cn[]
var bzrPreset={
defaultPreset:"linear",
linear:"33,33,66,66",
easeIn:"60,0,60,20",
easeOut:"40,80,40,100",
easeInOut:"80,0,20,100",
easeInSoft:"60,0,80,40",
easeOutSoft:"0,60,40,80",
easeInOutSoft:"60,0,40,100",
easeInStrong:"100,0,80,0",
easeOutStrong:"20,100,0,100",
easeInOutStrong:"80,0,20,100",
easeInSine:"40,0,40,20",
easeOutSine:"60,80,60,100",
easeInOutSine:"40,0,60,100",
easeInExp:"100,0,100,0",
easeOutExp:"0,100,0,100",
easeInOutExp:"100,0,0,100",
easeInCirc:"60,20,100,60",
easeOutCirc:"0,40,40,80",
easeInOutCirc:"100,40,0,60",
easeInBack:"35,0,80,-30",
easeOutBack:"20,130,65,100",
easeInOutBack:"24.5,0,30,40,70,140,75.5,100",
easeInElastic:"0,0,20,0,16,3.5,25,-7,35,5,50,0|50,0,78.5,-28,75,150,91.5,-175,92,-70,100,100",
easeOutElastic:"0,0,8,170,8.5,275,25,-50,22.5,128,50,100|50,100,65,95,75,107,84,96.5,90,100,100,100",
easeInBounce:"0,0,3,2.4,6,2.4,9.08,0|9.08,0,12,9.6,24.5,9.6,27.24,0|27.24,0,25,39.6,56.3,39.6,63.56,0|63.56,0,70,40,80,100,100,100",
easeOutBounce:"0,0,20,0,30,60,36.34,100|36.34,100,43.7,60.4,65,60.4,72.76,100|72.76,100,75.5,90.4,88,90.4,90.92,100|90.92,100,94,97.6,97,97.6,100,100"
};
// retrieve bezier preset
function getbzrCurve(c){
    if(c.find(",")){
        return c;
    }else if(bzrPreset[c]){
        return bzrPreset[c];
    }else return bzrPreset[bzrPreset.defaultPreset];
}
// 3d point object
function point(x,y,z){
    return {
        x:x?x:0,
        y:y?y:0,
        z:z?z:0
    };
}
// SYSTEM CLOCK
var sysClock=function(){
    return {
      taskqueue:[],
      fpshistory:[],
      fpscount:0,
      maxfps:0,
      minfps:100,
      taskstarttime:0,
      totalticks:0,
      rawticks:0,
      execticks:0,
      avgfps:0,
      clockcycles:0,
	  tasklist:"",
      addtask:function(task){
        task.count=0;
        for(var i=this.taskqueue.length-1,j=0;i>=j;i--){
            if(task.id ===this.taskqueue[i].id){
                return i;
            }
            if(this.taskqueue[i].id==="disabled"){
                this.taskqueue[i]=task;
                this.runtask(this.taskqueue.length-1);
                return i;
            }
        }
        this.taskqueue.push(task);
        this.runtask(this.taskqueue.length-1);
      },
      taskindex:function(task){
        for(var i=this.taskqueue.length-1,j=0;i>=j;i--){
            if(task ===this.taskqueue[i].id){
                return i;
            }
        }
      },
      setfps:function(task,fps){
        task=(typeof task==="string")?this.taskindex(task):task;
        this.taskqueue[task].fps=fps;
      },
      removetask:function(t){
        for(var i=this.taskqueue.length-1,j=0;i>=j;i--){
            if(this.taskqueue[i].id===t){
                this.taskqueue[i].id="disabled";
            }
        }
      },
      runtask:function(index){
        if(this.taskqueue[index].id !=="disabled"){
          this.taskqueue[index].task.run();
          setTimeout("sysClock.runtask("+index+");",this.gettimeout(((this.taskqueue[index].fps)*((this.taskqueue[index].smooth)?(this.taskqueue[index].factor?this.taskqueue[index].factor:1.01123581325):1))));
        }
      },
      gettimeout:function(f){
        return 1000/f;
      },
      cyclepercent:function(){
        return _percentageindex(new Date().getTime()-this.taskstarttime,1000);
      },
      cycleclock:function(){
        this.fpshistory.push(this.fpscount);
        //looks better on paper, marketing strategy from the oh so corrupt Sony
        //this.fpshistory.push(_tweenr.lstcnt?(this.fpscount+((this.rawticks+this.execticks)/2))/2:this.fpscount);
        //this.fpshistory.push(this.fpscount+this.rawticks);
        this.output();
        this.totalticks+=this.fpscount;
        this.maxfps=(this.fpscount>this.maxfps)?this.fpscount:this.maxfps;
        this.minfps=(this.fpscount<this.minfps)?this.fpscount:this.minfps;
        this.fpscount=0;
        this.rawticks=0;
        this.execticks=0;
        this.clockcycles++;
        this.taskstarttime=new Date().getTime();
        setTimeout("sysClock.cycleclock();",1000);
 
		this.tasklist="<font style='color:#FFFFFF;background:;font-size:12px;padding-right:10px;line-height:200%;'><b>&nbsp;&nbsp;System Clock Tasks</b></font><br/>";
		for(var i=this.taskqueue.length-1,j=0;i>=j;i--){
			if(this.taskqueue[i].id !=="disabled"){
				this.tasklist+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>-</b> "+this.taskqueue[i].id+"<b> / </b>"+this.taskqueue[i].fps+"<b> fps</b><br/>";  
			}
        }
		

		this.tasklist+="<br/><font style='color:#FFFFFF;background:;font-size:12px;padding-right:10px;line-height:200%;'><b>&nbsp;&nbsp;Key List</b></font><br/>";		
				this.tasklist+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>down char [</b> "+(_keystatus.downcharlist)+" <b>]</b><br/>";  
				this.tasklist+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>down code [</b> "+(_keystatus.downcodelist)+" <b>]</b><br/>";  
		
  
 },
      fpsdisplayoptions:{
        show_raw_ticks:true,
        show_cpu_use:true,
        show_data:true
      },
      pfps:0,
      cfps:new Date().getTime(),
      displayrealtimefps:true,
      realtimemode:"",
      fpsclock:function(){
        this.fpscount++;
        var ctime=new Date().getTime();
        switch(this.realtimemode){
            case "eratic":
                var REALTIMEFPS=_mathround(_randomseed(ctime-this.cfps,(ctime-this.cfps)/2),1);
            break;
            case "learning":
                var REALTIMEFPS=_mathround(_randomseed(ctime-this.cfps),1);
            break;
        default:
            var REALTIMEFPS=ctime-this.cfps;
        break;
        }
        this.pfps=this.cfps;
        this.cfps=ctime;
        var f="";
        if(SHOW_FPS){
          if(SHOW_STATS){
              f+="<font style='color:#FFFFFF;font-size:12px;'>"+(REALTIMEFPS.toString().sup())+"</font>"+"&nbsp;&nbsp;";
              f+="<font style='font-style:italic;color:#CCFF66;background:;font-size:24px;'><b>"+this.avgfps+"</b></font>&nbsp;&nbsp;";
              if(this.displayrealtimefps){
                  f+="<font style='color:#FFFFFF;font-size:12px;'>"+(_mathround((1000/REALTIMEFPS),1)).toString().sub()+"</font>&nbsp;";
              }else f+="<font style='color:#FFFFFF;font-size:12px;'>"+((this.fpsdisplayoptions.show_raw_ticks&&_tweenr.lstcnt)?(""+this.execticks+" / "+this.rawticks).toString().sub()+"</font>&nbsp;":(""+this.fpscount+"").sub()+"</font>&nbsp;");
          }
          f+="<br/>";
          if(SHOW_EXTRA_STATS){
            f+="<center style='text-align:right;'>";
            f+="//<b> System Statistics</b><br/>";
            f+=((this.fpsdisplayoptions.show_raw_ticks&&_tweenr.lstcnt)?("<b>Ticks/Processed/Count</b> - "+this.execticks+" / "+this.rawticks).toString()+" / "+this.fpscount+"</font>&nbsp;":(""+this.fpscount+"")+"");
            f+="<br/><b>CPU</b> - "+((!isNaN(_tweenr.cpuse))?_mathround(_tweenr.cpuse,3)+"%":"idle")+"&nbsp;";
            f+="<br/><b>Run Time</b> - "+Math.floor(this.clockcycles/3600)+"h : "+_mod(Math.floor(this.clockcycles/60),60)+"m : "+_mod(this.clockcycles,60)+"s "+" <br/><b>Max/Min/Avg FPS</b> - "+this.maxfps+" / "+this.minfps+" / "+_mathround((this.totalticks/this.clockcycles),2)+" <br/><b>Frames Rendered</b> - "+this.totalticks+"";
            f+="<br/>[ "+this.prettyhist+" ]";
            f+="<br/><b>Active Tweens</b> - "+_tweenr.activecount();
            f+="<br/><b>Client</b> - "+_browsername()+" "+_browserversion();
            f+="<br/><b>System Clock tasks</b> - "+this.numtasks()+"";
            f+="<br/><br/>";
            f+="<b style='font-align:left;'>Very Versatile Electronic Document&#8482</b><br/>"+VVED_COPYRIGHT;
            f+="</center>";
          }
        }
        SYS_STATS=f;
        setTimeout("sysClock.fpsclock();",0);
      },
      setsystemclocks:function(){
        this.fpscount=60;
        this.cycleclock();
        this.fpsclock();
      },
      start:function(){
        this.setsystemclocks();
      },
      showqueue:function(){
        return taskqueue.length;
      },
      prettyhist:"",
      fpscope:5,
      output:function(){
        var histcode="fps history..<br/>",avgdiv=0,total=0,_fh=[];
        for(var i=this.fpshistory.length-1,j=this.fpshistory.length-this.fpscope;i>=j;i--){
            if(this.fpshistory[i]){
                total+=this.fpshistory[i];
                avgdiv++;
                _fh.push(this.fpshistory[i]);
            }
        }
        if(this.fpshistory.length>this.fpscope){
            _fh.reverse();
            this.fpshistory=_fh;
        }
        this.prettyhist="";
        for(var i=0,j=this.fpshistory.length;i<j;i++){
            this.prettyhist+=this.fpshistory[i]+((i<j-1)?", ":"");
        }
        this.avgfps=_mathround((total/(avgdiv)),1);
      },
      numtasks:function(){
        return this.taskqueue.length;
      }

   };
}();
// COMMON FUNCTIONS --------------------------------------------------------------------------------------------------------------------
// selector engine delegation
function select(){
    var ret=VVEDobj.selectorEngine.apply(this,arguments);
      var a=[];
      for(var i=0,j=ret.length;i<j;i++){
          a[i]=ret[i];
      }
return a;
}
// Dollar element - return  document.documentElement method/property
function $d(m){
    return m?document.documentElement[m]:document.documentElement;
}
// Extend document.documentElement
function $xd(m,f){
    document.documentElement[m]=function(){
        f.apply(document.documentElement,arguments);
    };
}
// DOLLAR function
var _domtag="a,abbr,acronym,address,applet,area,b,base,basefont,bdo,big,blockquote,body,button,caption,center,cite,code,col,colgroup,dd,del,dir,div,dfn,dl,document,dt,em,fieldset,font,form,frame,frameset,head,h1,h2,h3,h4,h5,h6,hn,head,hr,html,i,iframe,img,input,ins,label,legend,li,link,listing,map,marquee,menu,meta,noframes,noscript,object,ol,optgroup,option,p,param,pre,plaintext,q,s,samp,script,select,small,span,strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,var,xmp";
function $(){
    if(arguments.length<1)return document;
    if(arguments.length===1 && (typeof arguments[0]==='string')){
        var argref=arguments[0].toString();
        var tagged=_domtag.find(argref);
        if(argref.find('*')||argref.find('#')||argref.find('|')||argref.find('~')||argref.find("=")||argref.find(":")||argref.find("+")||argref.charAt(0)==='.'||tagged){
            return select(arguments[0]);
        }
    }
	var e=[];
	for(var i=0; i < arguments.length; i++){
		var el=arguments[i];
		if (typeof el==='string')
			el=document.getElementById(el);
		if (arguments.length===1)
			return el;
		e.push(el);
	}
	return e;
}
// Add Event
function addEvent(obj,type,fn){
	if(obj.addEventListener){
		obj.addEventListener(type,fn,false);
		EventCache.add(obj,type,fn);
	}
	else if(obj.attachEvent){
		obj["e"+type+fn]=fn;
		obj[type+fn]=function(){obj["e"+type+fn](window.event);}
		obj.attachEvent("on"+type,obj[type+fn]);
		EventCache.add(obj,type,fn);
	}
}
// Remove Event
function removeEvent(obj,type,fn){
	if(obj.removeEventListener){
		obj.removeEventListener(type,fn,false);
	}
	else if(obj.detachEvent){
		obj.detachEvent("on"+type,obj[type+fn]);
		obj["e"+type+fn]=null;
        obj[type+fn]=null;
	}
}
// Event Cache to avoid leaks
var EventCache=function(){
	var listEvents=[];
	return {
		listEvents:listEvents,
		add:function(node,sEventName,fHandler,idHandle){
			for(var i=listEvents.length-1,j=0;i>=j;i--){
                if (listEvents[i][0]===node && listEvents[i][1]===sEventName){
                    listEvents[i]=arguments;
                    return;
                }
            }
			listEvents.push(arguments);
		},
		flush:function(){
			var item,rmvd="";
			for(var i=listEvents.length-1,j=0;i>=j;i--){
				item=listEvents[i];
                rmvd +="removing item "+item[0]+", "+item[1]+"<br/>";
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) !="on"){
					item[1]="on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]]=null;
			}
        }
	};
}();
// DOM element wrapper
function _domext(n,f,a){

    if(a){
      Array.prototype[n]=function(arg){
          this.each(function(){
            var o=_isbrowser("iexplorer")?this.id:this;
             $(o)[n](arg);
          });
          return this;
      };
    }

    DOMElement.extend(n,f);
}
// extend document object
var DOMElement={
	extend: function(name,fn){
		if(!document.all){
			eval("HTMLElement.prototype." + name + " = fn");
        }
		else
		{
			// copy document.createElement then override
			var _createElement = document.createElement;
			document.createElement = function(tag){
				var _elem = _createElement(tag);
				eval("_elem." + name + " = fn");
				return _elem;
			}

			// copy document.getElementById then override
			var _getElementById = document.getElementById;
			document.getElementById = function(id){
				var _elem = _getElementById(id);
				eval("_elem." + name + " = fn");
				return _elem;
			}

			// copy document.getElementsByTagName then override
			var _getElementsByTagName = document.getElementsByTagName;
			document.getElementsByTagName = function(tag){
				var _arr = _getElementsByTagName(tag);
				for(var _elem=0;_elem<_arr.length;_elem++)
					eval("_arr[_elem]." + name + " = fn");
				return _arr;
			}
		}
	}
};
// DATA type helpers
// is object a number
function _isnumber(e){
    return _type(e).find("number")||false;
}
// is object a string
function _isstring(e){
    return _type(e).find("string")||false;
}
// is object a boolean expression
function _isboolean(e){
    return _type(e).find("boolean")||false;
}
// is object an array
function _isarray(e){
    return _type(e).find("array")||false;
}
// is object a function
function _isfunction(e){
    return _type(e).find("function")||false;
}
// is object an object
function _isobject(e){
    return _type(e).find("object")||false;
}
// get element type
function _type(t){
    return t.constructor.toString().replace(/function /i,'').split("(")[0].toLowerCase();
}
// STRING prototypes
// test string regexp
String.prototype.test=function(re,flags){
 if(typeof(re)==="string"){
  re=new RegExp(re, flags);
 }
 return re.test(this);
};
// find in string
String.prototype.find=function(srchstr){
    return (this.indexOf(srchstr)>=0) || false;
};
// eval code contained in string
String.prototype.run=function(){
    eval(this.toString());
};
// return value in string
String.prototype.val=function(){
    return this.toString();
};
// fill string with character sequenece
String.prototype.fill=function(n,c){
var s="";
    for(var i=n,j=0;i>=j;i--){
        s+=c;
    }
    return s;
};
// insert character every n char
String.prototype.fillin=function(n,c,o){
var s="",o=o?o:{};
    for(var i=0,j=this.length/n;i<j;i++){
        s+=(o.post?c:"")+this.substr(i*n,n)+(o.post?"":c);
    }
    return s;
};
// mask characters
String.prototype.mask = function(m){
    var m, l = (m = m.split("")).length, s = this.split(""), j = 0, h = "";
    for(var i = -1; ++i < l;)
        if(m[i] != "#"){
            if(m[i] == "\\" && (h += m[++i])) continue;
            h += m[i];
            i + 1 == l && (s[j - 1] += h, h = "");
        }
        else{
            if(!s[j] && !(h = "")) break;
            (s[j] = h + s[j++]) && (h = "");
        }
    return s.join("") + h;
};
// trim sequence
String.prototype.trim = function(c, t){
    return c = "[" + (c == undefined ? " " : c.replace(/([\^\]\\-])/g, "\\\$1")) + "]+",
    this.replace(new RegExp((t != 2 ? "^" : "") + c + (t != 1 ? "|" + c + "$" : ""), "g"), "");
};
// NUMBER prototypes
// round number to fixed decimal place (for show)
Number.prototype.toFixedRound=function(n){
    var v=this;
return (Math.round(v*Math.pow(10,n))/Math.pow(10,n)).toFixed(n);
}
// format trailing 0s, converts to string
Number.prototype.zeroFormat = function(n,p){
    return this.toString().length<n-1?(p==="f"?"".fill(n-this.toString().length,"0")+this.toString():this.toString()+"".fill(n-this.toString().length,"0")):this.toString();
};
// return value contained in number
Number.prototype.val=function(){
    return this;
};
//NODELIST prototypes
// convert NodeList to Array
if(typeof NodeList!=='undefined'){
    NodeList.prototype.toArray = function(){
        return Array.prototype.slice.call(this,0);
    };
}
// ARRAY prototypes
// iterate arguments in object scope
Array.prototype.each=function(f,o){
    if(!o){
        for(var i=0,j=this.length;i<j;i++)f.apply(this[i],arguments);
    }else for(var i=this.length-1,j=0;i>=j;i--)f.apply(this[i],arguments);
};
// iterate arguments pass to function .. similar to foreach
Array.prototype.iter=function(f,o){
    if(!o){
        for(var i=0,j=this.length;i<j;i++)f(this[i],arguments);
    }else for(var i=this.length-1,j=0;i>=j;i--)f(this[i],arguments);
};
// return array of function results .. similar to map
Array.prototype.results=function(f,o){
    var results=[];
    if(!o){
        for(var i=0,j=this.length;i<j;i++)results.push(f.apply(this[i],arguments));
    }else for(var i=this.length-1,j=0;i>=j;i--)results.push(f.apply(this[i],arguments));
return results;
}
// return array of indexes that returned false
Array.prototype.negativeresult=function(f,o){
    var results=[];
    if(!o){
        for(var i=0,j=this.length;i<j;i++)if(!f.apply(this[i],arguments))results.push(this[i]);
    }else for(var i=this.length-1,j=0;i>=j;i--)if(!f.apply(this[i],arguments))results.push(this[i]);
return results;
}
// return array of indexes that returned true .. similar to filter
Array.prototype.result=function(f,o){
    var results=[];
    if(!o){
        for(var i=0,j=this.length;i<j;i++)if(f.apply(this[i],arguments))results.push(this[i]);
    }else for(var i=this.length-1,j=0;i>=j;i--)if(f.apply(this[i],arguments))results.push(this[i]);
return results;
}
// return true if no index returns false
Array.prototype.test=function(f,o){
    var test=true;
    if(!o){
        for(var i=this.length-1,j=0;i>=j;i--)if(!f.apply(this[i],arguments))test=false;
    }else for(var i=0,j=this.length-1;i<j;i++)if(!f.apply(this[i],arguments))test=false;
return test;
}
//Array copy new syntax
Array.prototype.copy = function(m){
    if(!m){
      return this.slice();
    }else return [].concat(this);
};
// Array.shift() - Remove and return the first element
// get first array element
Array.prototype.first = function(){
    return this[0];
};
// get last array element
Array.prototype.last = function(){
    return this[this.length-1];
};
// get array size
Array.prototype.size = function(){
    return this.length;
};
// get random array element
Array.prototype.random = function(){
    var r=parseInt(_randomseed(this.length),10)-1;
    return this[r];
};
// clear array
Array.prototype.clear=function(){
    this.length = 0;
};
// find in array return index*
Array.prototype.find=function(e){
    for(var i=this.length-1,j=0;i>=j;i--)if(this[i] === e)return i;
return -1;
};
// find sum of array elements, assumes all integers
Array.prototype.sum=function(){
	for (var s=0,i=this.length; i;s +=this[--i]);
	return s;
};
// return max index
Array.prototype.max=function(){
	return Math.max.apply({},this)
};
// return min index
Array.prototype.min=function(){
	return Math.min.apply({},this)
};
// return every other element
Array.prototype.everyother=function(n,d){
  var r=[];
	for (var s=(!falsey(d)?d:n-1),i=this.length;s<i;s+=n){
	  r.push(this[s]);
	}
	return r;
};
// get odd array elements
Array.prototype.odd=function(){
    return this.everyother(2,true);
};
// get even array elements
Array.prototype.even=function(){
    return this.everyother(2);
};
// average mean,standard deviation,variance
Array.prototype.avrg = function(){
    var r = {mean: 0, variance: 0, deviation: 0}, t = this.length;
    for(var m, s = 0, l = t; l--; s += this[l]);
    for(m = r.mean = s / t, l = t, s = 0; l--; s += Math.pow(this[l] - m, 2));
    return r.deviation = Math.sqrt(r.variance = s / t), r;
};
// remove by index
Array.prototype.removeindex=function(i){
    this.splice(i,1);
return this;
};
// remove element occurence
Array.prototype.remove=function(s){
	for (i=0; i < this.length; i++){
		if (s ===this[i])this.splice(i,1);
	}
};
// shuffle values
Array.prototype.shuffle = function(){
    for(var j, x, i = this.length; i; j = parseInt(Math.random() * i,10), x = this[--i], this[i] = this[j], this[j] = x);
    return this;
};
// FUNCTION extender
Function.prototype.method=function(name,fn){
    this.prototype[name] = fn;
return this;
};
// run function
Function.prototype.run=function(){
    return this.apply(this,arguments);
};
// return value contained in function, yes.. its identical to run.. if i remember why i'll quit the drugs
Function.prototype.val=function(){
    return this.apply(this,arguments);
};
// Document prototypes

// create element
function createElement(e){
    return (document.createElement(e));
}
//define browser version
function _browserversion(){
var ver=navigator.appVersion;
    if(_isbrowser("iexplorer")){
        return ver.split("MSIE")[1].split(";")[0];
    }else if(_isbrowser("firefox")){
        return navigator.userAgent.split("Firefox/")[1].split(" ")[0];
    }else if(_isbrowser("opera")){
        return ver.split(" ")[0];
    }else if(_isbrowser("safari")){
        if(navigator.userAgent.find("Chrome")){
            return navigator.userAgent.split("Chrome/")[1].split(" ")[0];
        }else return navigator.userAgent.split("Version/")[1].split(" ")[0];
    }
}
// define user browser
var _brwsrnm="";
function _browsername(){
    if(_brwsrnm!=="")return _brwsrnm;
    var ub=navigator.userAgent;
    if (ub.indexOf("Firefox") !==-1){
        _brwsrnm="firefox";
    }else if (ub.indexOf("Opera") !==-1){
        _brwsrnm="opera";
    }else if (ub.indexOf("Safari") !==-1){
        _brwsrnm="safari";
    }else if (ub.indexOf("Mozilla") !==-1){
        _brwsrnm="iexplorer";
    }else _brwsrnm=(ub+"\n\nnot supported");
return _brwsrnm;
}
// browser comparison
function _isbrowser(b){
    return (_browsername()===b.toLowerCase()) || false;
}
// url redirect
function _goto(u){
  window.location = u;
}
// get mouse coordinates
function _mousecoord(event,o){
var x,y;
    if(event.pageX){
        if(!_isbrowser("safari")){
            x=event.pageX-(o?document.documentElement.scrollLeft:0);
            y=event.pageY-(o?document.documentElement.scrollTop:0);
        }else{
            x=event.pageX-(o?document.body.scrollLeft:0);
            y=event.pageY-(o?document.body.scrollTop:0);
        }
    }else{
       x=event.clientX+(o?0:document.documentElement.scrollLeft);
       y=event.clientY+(o?0:document.documentElement.scrollTop);
    }
return {x:x,y:y};
}
// check if element is a child of another element
function _childof(e,p){
    if($(e).parentNode===$(p)){
        return true;
    }else{
        if($(e).parentNode && $(e).parentNode.nodeName!=="#document"){
            return _childof($(e).parentNode,p);
        }else return false
    }
}
// check if element is the parent of another element
function _parentof(p,e){
    return _childof(e,p);
}
// check if integer is falsey and allow 0
function falsey(v){
    return (typeof v==='undefined'||v<0)||false;
}
// select a node based on css attribute matches
function _selectparentnode(e,c,o){
  o=o?o:e;
    if(e.parentNode&&e.parentNode.nodeName!=='BODY'){
        if(_nodematch(e.parentNode,c)){
           return e.parentNode;
        }else{
           return _selectparentnode(e.parentNode,c,o);
        }
    }else{
      return o;
    }
}
// match node according to specific css attributes
function _nodematch(n,c){
var s=c.split(" "),m=true,t;
    for(var i=0;i<s.length;i++){
        t=s[i].split(":");
        if(!_getcss(n,t[0]).find(t[1]))m=false;
    }
return m;
}
//set css attributes the wrong way
function _setcss(e,a,v){
    if(a==="opacity" && v>1 && (!_isbrowser("iexplorer")))v/=100;
    if(a==="opacity" && _isbrowser("iexplorer")){
        $(e).filters.alpha.opacity=v;
    }else if(a==="scrollTop" || a==="scrollLeft"){
        if(e===document){
            if(_isbrowser("safari")){
                document.body[a]=parseInt(v,10);
            }else document.documentElement[a]=parseInt(v,10);
        }else return $(e)[a]=parseInt(v,10);
    }else if(a==="innerHTML"){
        $(e)[a]=v;
    }else if(a==="className"){
        $(e)[a]=v;
    }else{
        if(e.toString().find("document.body")){
            document.body.style[a]=v;
        }else{
			$(e).style[a]=v;
        }
    }
}
// return object dimensions
function _dimensions(e){
e=$(e);
    var lt=_absoluteposition(e);
    var wh={w:e.offsetWidth,h:e.offsetHeight};
    var rb={r:lt.x+wh.w,b:lt.y+wh.h};
    return {
        l:lt.x,
        r:rb.r,
        t:lt.y,
        b:rb.b,
        w:wh.w,
        h:wh.h
    };
}
// get css value.. the right way!
function _getcss(e,p){
    if(p==="scrollTop" || p==="scrollLeft"){
        if(e===document){
            return _isbrowser("safari")?document.body[p]:document.documentElement[p];
        }else return $(e)[p];
    }else if(p==="offsets"){
        return{
            left:$(e).offsetLeft,
            top:$(e).offsetTop,
            width:$(e).offsetWidth,
            height:$(e).offsetHeight
        };
    }else if(p==="className"){
        return $(e)[p];
    }else{
        if(window.getComputedStyle){
            return window.getComputedStyle($(e),null)[p];
        }else if($(e).currentStyle){
            //return $(e).runtimeStyle[p];
            if(p==="opacity"){
              return $(e).filters.alpha.opacity;
            }else return $(e).currentStyle[p];
        }
    }
}
// get property from user defined class
function _propertyfromclass(e,c,d){
    return $(e).className.find(c)?$(e).className.split(c)[1].split(" ")[0]:(falsey(d))?0:d;
}
// does element contain class
function _hasclass(r,c){
    return ($(r).className.find(c))||false;
}
// add classname
function _addclassname(r,c){
    if(!_hasclass(r,c))$(r).className+=" "+c+" ";
}
// remove classname
function _removeclassname(r,c){
    var cn=$(r).className.split(c);
    cn=cn[0]+cn[1];
    $(r).className=" "+cn+" ";
}
// toggle classname
function _toggleclass(r,c){
    if(typeof r!=='string')r=r.id;
    var tgid="toggle"+r+"Class",fl=c,ref=r;
    if(typeof c !== 'undefined'){
        var fs=[];
        for(var i=0,j=c.length;i<j;i++){
            fs.push(function(s){
                $(ref).className=fl[s];
            });
        }
        _togglr.add(tgid,fs,true);
    }else{
      toggle(tgid);
    }
}
// min of 2 numbers
function _min(a,b){
    return(a<=b)?a:b;
}
// max of 2 numbers
function _max(a,b){
    return(a>=b)?a:b;
}
// HELPER FUNCTIONS
// it is indeed empty
function _isEmpty(obj){
}
// update object contents
function _updateobject(obj,o){
    for(var a in o){
        if(!obj.hasOwnProperty(a))obj[a]=o[a];
    }
}
// apply style set to element
function _applystyles(e,s,t){
    for(var a in s){
        switch(a){
            case 'style':
                var attr=s[a];
                for(var k in attr){
                    var v=attr[k];
                    if(_isnumber(parseInt(v,10))&&!v.find(' ')){
                        t.p=k;
                        t.v=parseInt(v,10);
                        tweento(e,t);
                    }else e.style[k]=v;
                }
            break;
            case 'attributes':
                var attr=s[a];
                for(var k in attr){
                    e.setAttribute(k,attr[k]);
                }
            break;
        default:
            e[a]=s[a];
        break;
        }
    }
return e;
}
// wrap element
function _elementwrap(e,t,o){
    var _w=createElement(t);
    _w=_applystyles(_w,o);
    _w.appendChild($(e));
    document.body.appendChild(_w);
}
// wrap element with href link
function _linkwrap(e,o){
    _elementwrap(e,'a',{id:o.id?o.id:"",style:{cursor:'hand',cursor:'pointer'},className:'example',attributes:{href:o.href?o.href:"#"}});
}
// link tween
function _link(a,o){
    o=o?o:{};
    var incs=0,inc=o.inc?o.inc:1,index=0;
    inc=o.autoinc?100/a.length:inc;
    for(var i=1,j=a.length;i<j;i++)(function(index){
        incs+=inc;
        var tmout=(_percentagevalue(incs,(o.d?o.d:o.duration))*1000);
        setTimeout(function(){
            tweento(a[index],o);
        },tmout);
    })(i);
    tweento(a[0],o);
}
//insert after node
function _insertafter(ne,te) {
	var parent = te.parentNode;
	if(parent.lastchild === te){
		parent.appendChild(ne);
	} else {
		parent.insertBefore(ne,te.nextSibling);
	}
}
// set inner html to ajax result
function _datafill(obj,u,o){
    $(obj).html("retrieving data..");
    dataRequest(u,function(d){
        $(obj).html(d);
    },o);
}
// get/set css wrapper
function _css(o,p,v){
    if(typeof p === 'object'){
        for(var i in p)_setcss(o,i,p[i]);
    }else{
        if(v){
            _setcss(o,p,v);
        }else return _getcss(o,p);
    }
}
// get absolute position
function _absoluteposition(o,u){
var cl=ct=0;
    if(o.offsetParent){
        do{
          cl+=o.offsetLeft;
          ct+=o.offsetTop;
        }while(o=o.offsetParent);
    }
    if(u){
        var cssprop={x:_getcss(this,'left'),y:_getcss(this,'top')};
        var unit={x:_getunit(cssprop.x),y:_getunit(cssprop.y)};
    return {x:cl+unit.x,y:ct+unit.y};
    }else return {x:cl,y:ct};

}
// position absolutely
function _positionabsolutely(o,u,a){
    var ap=_absoluteposition($(o));
    var cssprop={x:_getcss(o,'left'),y:_getcss(o,'top')};
    var unit={x:_getunit(cssprop.x),y:_getunit(cssprop.y)};
        _setcss(o,"left",ap.x+(u?u:unit.x));
        _setcss(o,"top",ap.y+(u?u:unit.y));
        _setcss(o,"position","absolute");
    if(!a)document.body.appendChild($(o));
}
// get unit
function _getunit(p){
  return p.toString().split(parseFloat(p).toString())[1];
}
// inner html wrapper
function _html(e,d){
    if(d){
        d=d.toString();
        if(d.find("+=")){
          d=d.split("+=")[1];
          $(e).innerHTML+=d;
        }else $(e).innerHTML=d;
    }else return $(e).innerHTML;
}
// inner text wrapper
function _text(e,d){
    if(d){
        d=d.toString();
        if(d.find("+=")){
          d=d.split("+=")[1];
          $(e).innerText+=d;
        }else $(e).innerText=d;
    }else return $(e).innerText;
}
// cross browser load image (the image better be there)
function _imagehandler(img,f,e){
    if(_isbrowser("iexplorer")||_isbrowser("opera")){
        img.onreadystatechange=new function(){
            if(!img.complete){
                if(_isbrowser("iexplorer")&&img.width===28&&img.height===30){
                    if(e)e.apply(img,arguments);
                }else{
                  setTimeout(function(){
                      _imagehandler(img,f,e);
                  },500);
                }
            }else{
                if(_isbrowser("opera")&&img.width===0&&img.height===0){
                    if(e)e.apply(img,arguments);
                }else{
                    f.apply(img,arguments);
                }
            }
        }
    }else{
        img.onload=f;
        if(e)img.onerror=e;
    }
}

// normalize number to fit within a given range
function _normalize(n,l,u,nl,nu,a){
    var np=(_percentageindex(n,(u-l)));
    var nv=(_percentagevalue((nu-nl),np));
    if(nl<0&&l>=0)nv=nl<0?nv+nl:nv;
return _mathround(nv,(a?a:3));
}
// time stamp
function _timestamp(){
    this.st=new Date().getTime();
    this.lc=new Date().getTime();
    this.elapsed=function(){
      this.lc=new Date().getTime();
      return new Date().getTime()-this.st;
    }
    this.lap=function(){
      return new Date().getTime()-this.lc;
    }
}
// random truth ..or false
function _randomtruth(n){
    n=n?n:5;
    return _randomseed(n)>n/2;
}
// random seed generator
function _randomseed(r,m){
    return ((Math.random()*(m?m-r:r)))+(m?r:1);
}
// percentage index
function _percentageindex(i,d){
    return _mathround(i/(d/100),3);
}
// percentage value
function _percentagevalue(d,p){
    return (d/100)*p;
}
// modulus
function _mod(d,b){
	return d%b;
}
// round to n places
function _mathround(n,x){
    x=(x!==0&&!x)?2:x;
return Math.round(n*Math.pow(10,x))/Math.pow(10,x);
}
//Auxillary functions ----------------------------------------------------------------------------------------------------------------------------------


// full rgb
function _rgbfull2hex(x){
    var spltBG=x.split(",");
    var pFF=spltBG[0].split("(")[1]+","+spltBG[1]+","+spltBG[2].split(")")[0];
    var pFFcode=_dec2hex(pFF);
return pFFcode;
}
// hash rgb
function _hex2dec(hex){
    var decstr=[],indx=0;
    for(var i=0,j=6;i<j;i+=2){
        decstr[indx]=parseInt(hex.split("#")[1].charAt(i)+""+hex.split("#")[1].charAt(i+1),16);
        indx++;
    }
return decstr;
}
// dec to hex
function _dec2hex(dec){
    var hexValue=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];
return("#"+hexValue[dec.split(",")[0]>>4]+hexValue[dec.split(",")[0]&15]+hexValue[dec.split(",")[1]>>4]+hexValue[dec.split(",")[1]&15]+hexValue[dec.split(",")[2]>>4]+hexValue[dec.split(",")[2]&15]);
}
// random color + hue bias, lol hue bias. i'm biased!?!? what about hue?!
function _randomcolor(o){
    o=o?o:{r:"0/255",g:"0/255",b:"0/255"};
        o.r=(o.r?o.r:"0/255").split("/");
        o.g=(o.g?o.g:"0/255").split("/");
        o.b=(o.b?o.b:"0/255").split("/");
return _dec2hex(Math.round(_randomseed((o.r[1]-1)-o.r[0]))+","+Math.round(_randomseed((o.g[1]-1)-o.g[0]))+","+Math.round(_randomseed((o.b[1]-1)-o.b[0])));
}
// distance between two points on 2d plane
function _dist2d(dx,dy){
    return Math.sqrt(dx*dx+dy*dy);
}
// distance between two points on 3d plane
function _dist3d(dx,dy,dz){
    return Math.sqrt(dx*dx+dy*dy+dz*dz);
}
// wiggle values
function _wiggle(r,p,f,o,n,cf){
    var x=parseInt(_getcss(r,p),10);
    var xo=(parseInt(_randomseed(o),10)/2)+(parseInt(_randomseed(o),10)/2);
    var xm=(_randomseed(100)>50)?-1:1;
    xo*=xm;
    tweento(r,{pb:0,p:p,v:x+xo,d:1/f,cf:(cf?cf:'easeOutBack'),c:'cycle,'+n,le:function(t){
        //x=parseInt(_getcss(t.elem,p),10);
        xo=parseInt(_randomseed(o),10);
        //xm=(_randomseed(100)>50)?-1:1;
        xm=(xm===1)?-1:1;
        xo*=xm;
            t.dur=1*(_randomseed(f)+1)/(_randomseed(f*(_randomseed(f)))+f);
            t.endval=x+xo;
    }});
}
// tween color
function _colortween(e,c,attr,o){
    var crgb=(o.startcolor)?o.startcolor:_getcss(e,attr);
    crgb=((_isbrowser("firefox")||_isbrowser("safari"))&&!o.startcolor)?_rgbfull2hex(crgb):crgb;
    crgb=_hex2dec(crgb);
    var dur=o.duration?o.duration:1;
    var cyc=o.cycle?o.cycle:"";
    var pause=o.pause?o.pause:0;
    var pauseafter=o.pauseafter?o.pauseafter:0;
    var cfunc=o.curvefunc?o.curvefunc:"";
    var mfunc=o.cf?o.cf:{};
    var mlt=[1,1,1];
    if(o.mode){
        var sclc=o.scalecycle?o.scalecycle:[.5,1,1.5];
        switch(o.mode){
            case "/":
                mlt=[sclc[0],sclc[1],sclc[2]];
            break;
            case "\\":
                mlt=[sclc[2],sclc[1],sclc[0]];
            break;
            case ">":
                mlt=[sclc[0],sclc[2],sclc[0]];
            break;
            case "<":
                mlt=[sclc[2],sclc[1],sclc[2]];
            break;
        default:
            if(o.mode.find("r+"))mlt[0]=sclc[2];
            if(o.mode.find("g+"))mlt[1]=sclc[2];
            if(o.mode.find("b+"))mlt[2]=sclc[2];
            if(o.mode.find("r-"))mlt[0]=sclc[0];
            if(o.mode.find("g-"))mlt[1]=sclc[0];
            if(o.mode.find("b-"))mlt[2]=sclc[0];
        break;
        }
    }
    var clrinstnc=[crgb[0],crgb[1],crgb[2]];
    _tweenr.addtween("counter",{v:_hex2dec(c)[0],d:dur*mlt[0],st:crgb[0],c:cyc,pb:pause,pa:pauseafter,rt:0,cf:cfunc,t:function(o){
        clrinstnc[0]=eval(o.prop);
        _mapColor(e,clrinstnc,attr);
    },ty:{a:attr+"0",b:e}});
    _tweenr.addtween("counter",{v:_hex2dec(c)[1],d:dur*mlt[1],st:crgb[1],c:cyc,pb:pause,pa:pauseafter,rt:0,cf:cfunc,t:function(o){
        clrinstnc[1]=eval(o.prop);
        _mapColor(e,clrinstnc,attr);
    },ty:{a:attr+"1",b:e}});
    _tweenr.addtween("counter",{v:_hex2dec(c)[2],d:dur*mlt[2],st:crgb[2],c:cyc,pb:pause,pa:pauseafter,rt:0,cf:cfunc,t:function(o){
        clrinstnc[2]=eval(o.prop);
        _mapColor(e,clrinstnc,attr);
    },ty:{a:attr+"2",b:e}});
}
// map color
function _mapColor(e,clrsrc,attr){
    $(e).style[attr]=_dec2hex(clrsrc[0]+","+clrsrc[1]+","+clrsrc[2]);
}
// do coordinates fall in bounding box
function _isin(p,b){
    return (p.x>=b.l && p.x<=b.r && p.y>=b.t && p.y<=b.b) || false;
}
// did bounding boxes collide
function _collide(o,c){
    var ce=(typeof o.l==='undefined')?_boundingbox(o):o;
    var co=(typeof c.l==='undefined')?_boundingbox(c):c;
        if(ce.obj===co.obj)return {hit:false,obj:ce.obj,obj2:co.obj};
    var cld={left:false,right:false,bottom:false,top:false};
    var ofst={left:-1,right:-1,bottom:-1,top:-1};
    with(cld){
        if(ce.l<co.r)left=true;
        if(ce.r>co.l)right=true;
        if(ce.b>co.t)bottom=true;
        if(ce.t<co.b)top=true;
        var collide=left&&right&&bottom&&top;
    }
    if(collide){
        with(ofst){
          ofst.left=Math.abs(ce.l-co.r);
          ofst.right=Math.abs(ce.r-co.l);
          ofst.bottom=Math.abs(co.t-ce.b);
          ofst.top=Math.abs(co.b-ce.t);
        }
    }
        var cvg=[ofst.left,ofst.right,ofst.bottom,ofst.top];
        var cli1=cvg.min();
            cvg.remove(cli1);
        var cli2=cvg.min();
            cvg.remove(cli2);
        var cli3=cvg.min();
            cvg.remove(cli3);
        var cli4=cvg.min();
        var clfc1="",clfc2="",clfc3="",clfc4="";
        if(collide){
            for(var i in ofst){
              if(ofst[i]===cli1)clfc1=i;
              if(ofst[i]===cli2)clfc2=i;
              if(ofst[i]===cli3)clfc3=i;
              if(ofst[i]===cli4)clfc4=i;
            }
        }
return {hit:collide,impact:[cli1,cli2,cli3,cli4],side:[clfc1,clfc2,clfc3,clfc4],obj:ce.obj,obj2:co.obj};
}
// create bounding box from element
function _boundingbox(e,a){
var ra=(parseInt(_getcss(e,'paddingLeft'),10))+(parseInt(_getcss(e,'paddingRight'),10));
var ba=(parseInt(_getcss(e,'paddingTop'),10))+(parseInt(_getcss(e,'paddingBottom'),10));
    if(!a){
        var abspos=_absoluteposition($(e));
        return{
          l:abspos.x,
          r:abspos.x+parseInt(_getcss($(e),'width'),10)+ra,
          t:abspos.y,
          b:abspos.y+parseInt(_getcss($(e),'height'),10)+ba,
          obj:$(e)
        };
    }else{
      return {
          l:parseInt(_getcss(e,'left'),10),
          r:parseInt(_getcss(e,'left'),10)+parseInt(_getcss(e,'width'),10)+ra,
          t:parseInt(_getcss(e,'top'),10),
          b:parseInt(_getcss(e,'top'),10)+parseInt(_getcss(e,'height'),10)+ba,
          obj:$(e)
      };
    }
}
// set background image position
function _setbgpos(e,p,v){
    if(_isbrowser("iexplorer")){
        var cp=[];
        cp[0]=_getcss(e,'backgroundPositionX');
        cp[1]=_getcss(e,'backgroundPositionY');
        $(e).style['backgroundPositionX']=(p==="left")?v+"px":cp[0];
        $(e).style['backgroundPositionY']=(p==="top")?v+"px":cp[1];
    }else{
        var cp=_getcss(e,'backgroundPosition');
        cp=cp.split(" ");
        var cv=(p==="left")?v+"px "+parseInt(cp[1],10)+"px":parseInt(cp[0],10)+"px"+" "+v+"px";
        $(e).style['backgroundPosition']=cv;
    }
}
// get angle offset
function _getangleoffset(p,o){
    var x1=p.x,y1=p.y,x2=o.x,y2=o.y;
    var dx=x2-x1,dy=y2-y1;
    var ang=Math.atan2(dx,dy);
    ang=(ang/Math.PI)*180;
    //ang=ang<0?ang+360:ang;
    //ang=ang<180?ang+180:ang+180;
    ang+=180;
    ang=360-ang;
return {angle:ang,dx:dx,dy:dy};
}
// orbit around object or point
function orbit(p,o,a,v,f){
    f=f?f:{};
    v=v?v:{};
    var ref=o,center=p,refhist={};
    var ptype=(typeof(p)==="string"||typeof($(p).id)==="string");
    var otype=(typeof(o)==="string"||typeof($(o).id)==="string");
    var pv={},ov={};
    pv.x=(ptype)?parseInt(_getcss(p,"left"),10)+(v.orbitobjcenter?parseInt(_getcss(p,"width"),10)/2:0):p.x;
    pv.y=(ptype)?parseInt(_getcss(p,"top"),10)+(v.orbitobjcenter?parseInt(_getcss(p,"height"),10)/2:0):p.y;
    ov.x=(otype)?parseInt(_getcss(o,"left"),10)+(v.orbitbycenter?parseInt(_getcss(o,"width"),10)/2:0):o.x;
    ov.y=(otype)?parseInt(_getcss(o,"top"),10)+(v.orbitbycenter?parseInt(_getcss(o,"height"),10)/2:0):o.y;
    var dx=_getangleoffset(pv,ov).dx;
    var dy=_getangleoffset(pv,ov).dy;
        var angleround=1;
        var ao=_mathround(_getangleoffset(pv,ov).angle,angleround);
        var anglediff1=(a>ao)?_mathround((a-ao),angleround):_mathround((360-ao)+a,angleround);
        var anglediff2=(a>ao)?_mathround(-1*((360-a)+ao),angleround):_mathround(-1*(ao-a),angleround);
        var rot=anglediff2<0?-1:1;
        var trns=v.scale?v.scale:[1,1];
        var fctr=v.factor?v.factor:[1,1];
        var axis=v.axis?v.axis:"all";
        var spcr="".fill(5,"&nbsp;");
        refhist.x=pv.x;
        refhist.y=pv.y;
        refhist.w=(ptype)?parseInt(_getcss(center,"width"),10):pv.x;
        refhist.h=(ptype)?parseInt(_getcss(center,"height"),10):pv.y;
            f.st=0;
            if(v.mode==="rotate"){
                if(v.motion){
                    f.v=a*((v.motion==="clockwise")?1:-1);
                }else f.v=a;
            }else{
                if(v.motion){
                    f.v=(v.motion==="clockwise")?anglediff1:anglediff2;
                    if(v.motion==="close"){
                        f.v=(_min(Math.abs(anglediff1),Math.abs(anglediff2))===Math.abs(anglediff1))?anglediff1:anglediff2;
                    }else if(v.motion==="far"){
                        f.v=(_max(Math.abs(anglediff1),Math.abs(anglediff2))===Math.abs(anglediff1))?anglediff1:anglediff2;
                    }
                }else f.v=anglediff2;
            }
            f.d=v.duration?v.duration:1;
            f.cf=v.curve?v.curve:"";
            f.c=v.cycle?v.cycle:"";
            var scl=1;
            var tickfunc=function(t){
                var canvas = new mmo(20);
        		canvas.matrix = canvas.translate(canvas.width/2,canvas.height/2,0);
                canvas.addPoint(dx,dy,0,scale(1,1,1,identity()));
                var value=canvas.getrotA(t.curval);
                var x,y,w,h,x1,y1,w1,h1;
                    if(center.x){
                        x1=refhist.x;
                        y1=refhist.y;
                        w1=refhist.x;
                        h1=refhist.y;
                    }else{
                        x1=(v.realtimex||v.realtime)?parseInt(_getcss(center,"left"),10)+(v.orbitobjcenter?parseInt(_getcss(center,"width"),10)/2:0):refhist.x;
                        y1=(v.realtimey||v.realtime)?parseInt(_getcss(center,"top"),10)+(v.orbitobjcenter?parseInt(_getcss(center,"height"),10)/2:0):refhist.y;
                        w1=(v.realtimew||v.realtime)?parseInt(_getcss(center,"width"),10)+(v.orbitobjcenter?parseInt(_getcss(center,"width"),10)/2:0):refhist.w;
                        h1=(v.realtimeh||v.realtime)?parseInt(_getcss(center,"height"),10)+(v.orbitobjcenter?parseInt(_getcss(center,"height"),10)/2:0):refhist.h;
                    }
                    x=parseInt(x1+(value[0]/trns[0]),10);
                    y=parseInt(y1+(value[1]/trns[1]),10);
                    w=parseInt(w1+(value[0]/trns[0]),10);
                    h=parseInt(h1+(value[1]/trns[1]),10);
                        trns[0]*=fctr[0];
                        trns[1]*=fctr[1];
                            if(axis.find("x")||axis==="allp"||axis==="all"){
                                _setcss(ref,"left",x-(v.orbitbycenter?parseInt(_getcss(ref,"width"),10)/2:0)+"px");
                                VVEDobj.objqueue[_getref(ref)].syncattached("left",t);
                            }
                            if(axis.find("y")||axis==="allp"||axis==="all"){
                                _setcss(ref,"top",y-(v.orbitbycenter?parseInt(_getcss(ref,"height"),10)/2:0)+"px");
                                VVEDobj.objqueue[_getref(ref)].syncattached("top",t);
                            }
                            if(axis.find("w")||axis==="alls"||axis==="allp")_setcss(ref,"width",x+"px");
                            if(axis.find("h")||axis==="alls"||axis==="allp")_setcss(ref,"height",y+"px");
                if(axis.find("w")||axis.find("h")||axis==="alls"||axis==="allp"){
                    VVEDobj.objqueue[_getref(ref)].img.resize();
                }
            };

        f.t=_stacktweenfunction(f.t,tickfunc);
        f.ty={a:ref};
_tweenr.addtween("counter",f);
}
// play frames
function playFrames(o){
    if(!o.list.ready){
            var tmo=o;
            setTimeout(function(){
                playFrames(o);
            },500);
        return;
    }
    var f=o.f?o.f:{};
    var frameRate=o.fps?o.fps:30;
    var fc=o.list.imgcount();
    fc=o.endframe?o.endframe-1:fc-1;
    fc=(o.endframe||o.endframe>=0)?o.endframe:fc;
    var t=fc/frameRate;
    var fl=o.list;
    var ro=o.obj;
    var cy=o.cycle?o.cycle:"";
    var cfnc=o.curve?o.curve:"";
    var stval=o.startframe?o.startframe:0;
    var st=(o.playorder==="reverse")?fc-1:stval;
    fc=(o.playorder==="reverse")?stval:fc;
    var frameblending=o.blending?o.blending:false;
    var numframes=o.frames?o.frames:1;
    var blend={_in:o.blendin,_out:o.blendout};
    if(o.scatter){
      var ofstx=((!o.scatterdata.by)||o.scatterdata.by==="x")?o.list.tiledata.w:0;
      var ofsty=(o.scatterdata.by==="y")?o.list.tiledata.h:0;
      var cntrx=((!o.scatterdata.by)||o.scatterdata.by==="x")?2:0;
      var cntry=(o.scatterdata.by==="y")?2:0;
      var cntrxlmt=o.scatterdata.x;
      var cntrylmt=o.scatterdata.y;
    }

    var prvfrms=0;

    if(frameblending){
        for(var k=0,j=numframes;k<j;k++){
            var bfr = createElement("div");
            bfr.id=(ro+"_FrmBffr"+k);
            bfr.className="draggable playframe";
            bfr.style.overflow="hidden";
            bfr.style.position="absolute";
            bfr.style.width=o.list.output(0).p.x+"px";
            bfr.style.height=o.list.output(0).p.y+"px";
                if(o.scatter){
                    bfr=_copyobj(bfr,ro,"left/+"+(ofstx)+"|top/+"+(ofsty)+"|backgroundColor|zIndex/+"+((k*1)+1)+"|opacity");
                    if(o.scatterdata.by==="y"){
                      ofsty=(cntry<cntrylmt)?ofsty+o.list.tiledata.h:0;
                      ofstx=(ofsty==0)?(ofstx+o.list.tiledata.w):ofstx;
                      cntry=(cntry<cntrylmt)?cntry+1:1;
                    }else if(((!o.scatterdata.by)||o.scatterdata.by==="x")){
                      ofstx=(cntrx<cntrxlmt)?ofstx+o.list.tiledata.w:0;
                      ofsty=(ofstx==0)?(ofsty+o.list.tiledata.h):ofsty;
                      cntrx=(cntrx<cntrxlmt)?cntrx+1:1;
                    }
                }else{
                    bfr=_copyobj(bfr,ro,"left|top|backgroundColor|zIndex/+"+((k*1)+1)+"|opacity");
                }
                bfr.innerHTML="<img src='"+o.list.output(0).s+"' class='draggable'/>";
            document.body.appendChild(bfr);
        }
    var blendframe=0;
    }
    f.st=st;
    f.v=fc;
    f.d=t;
    f.c=cy;
    f.cf=cfnc;
    f.rt=0;
    f.ty=ro;
    var tickfunc=function(o){
        if(o.timepercent()<=100){
            var framecontext=ro;
            if(frameblending){
                framecontext=(blendframe===0)?ro:ro+"_FrmBffr"+(blendframe-1);
                var fd=(blendframe>0)?false:ro+"_FrmBffr"+(numframes-1);
                if(!fd)fd=(blendframe===1)?ro:(ro+"_FrmBffr"+(blendframe-2))
                blendframe=(blendframe<numframes)?++blendframe:0;
                _tweenr.addtween(fd,{p:"opacity",cf:"easeOut",v:0,d:blend._out});
                _tweenr.addtween(framecontext,{p:"opacity",cf:"easeOut",v:100,d:blend._in});
            }
        fl.display(parseInt(o.curval,10),framecontext);
        }
    };
    f.t=_stacktweenfunction(f.t,tickfunc);

    _tweenr.addtween("counter",f);
}
// generic event handler class
var _Event={
mousecoords:{x:0,y:0},
mouseoveron:"",
mouseoverrelated:"",
mouseovercoords:{x:0,y:0},
mouseouton:"",
mouseoutrelated:"",
mouseoutcoords:{x:0,y:0},
mousemoveon:"",
mousemovecoords:{x:0,y:0},
mousedownon:"",
mousedownbtn:"",
mousedowncode:-1,
mousedowncoords:{x:0,y:0},
mouseupon:"",
mouseupbtn:"",
mouseupcode:-1,
mouseupcoords:{x:0,y:0},
keydownon:"",
mousewheeldownon:"",
mousewheeldownrotations:0,
mousewheelupon:"",
mousewheeluprotations:0,
keyupon:"",
events:[],
addevent:function(e){
    this.events.push(e);
},
doevent:function(v,e,s,b){
    for(var i=0,j=this.events.length;i<j;i++){
        if(this.events[i].e){
            if(b === true){				
                if(this.events[i].v===v && s===this.events[i].e){
                    this.events[i].f(e,s);
                }
            }else{
                if(this.events[i].v===v && (this[v+"on"]===this.events[i].e || (this.events[i].e.id && (this[v+"on"]===this.events[i].e.id)) )){
                    this.events[i].f(e,s);
                }
            }
        }else{
            if(this.events[i].v===v)this.events[i].f(e,s);
        }
    }
}
};
// mouse down handler
function _mousedown(e){
    e=e?e:window.event;
    var tg=(window.event)?e.srcElement:e.target;
    var bt=(e.which)?e.which:e.button;
    var btn="";
    if(_browsername()==="iexplorer"){
        if(bt===1)btn="left";
        else if(bt===4)btn="middle";
        else btn="right";
    }else{
        if(bt===1)btn="left";
        else if(bt===2)btn="middle";
        else btn="right";
    }
    _Event.mousedownon=(tg.id!=="")?tg.id:tg;
    _Event.mousedownbtn=btn;
    _Event.mousedowncode+=parseInt(bt,10);
    var mc=_mousecoord(e);
        _Event.mousedowncoords={x:mc.x,y:mc.y};
    _Event.doevent("mousedown",e,tg);
}
// mouse up handler
function _mouseup(e){
    e=e?e:window.event;
    var tg=(window.event)?e.srcElement:e.target;
    var bt=(e.which)?e.which:e.button;
    var btn="";
    if(_browsername()==="iexplorer"){
        if(bt===1)btn="left";
        else if(bt===4)btn="middle";
        else btn="right";
    }else{
        if(bt===1)btn="left";
        else if(bt===2)btn="middle";
        else btn="right";
    }
    _Event.mouseupon=(tg.id!=="")?tg.id:tg;
    _Event.mouseupbtn=btn;
    _Event.mouseupcode=bt;
    _Event.mousedownbtn="";
    _Event.mousedowncode=-1;
    var mc=_mousecoord(e);
        _Event.mouseupcoords={x:mc.x,y:mc.y};
    _Event.doevent("mouseup",e,tg);
}
// mouse move handler
function _mousemove(e){
    e=e?e:window.event;
    var tg=(window.event)?e.srcElement:e.target;
    var mc=_mousecoord(e);
    _Event.mousecoords={x:mc.x,y:mc.y};
    _Event.mousemoveon=(tg.id!=="")?tg.id:tg;
    _Event.doevent("mousemove",e,tg);
}
// mouse move over
function _mouseover(e){
    e=e?e:window.event;
    var tg=(window.event)?e.srcElement:e.target;
    var mc=_mousecoord(e);
    _Event.mouseovercoords={x:mc.x,y:mc.y};
    _Event.mouseoveron=(tg.id!=="")?tg.id:tg;
    _Event.mouseoverrelated=e.relatedTarget||e.fromElement;
    _Event.doevent("mouseover",e,tg);
}
// mouse move out
function _mouseout(e){
    e=e?e:window.event;
    var tg=(window.event)?e.srcElement:e.target;
    var mc=_mousecoord(e);
    _Event.mouseoutcoords={x:mc.x,y:mc.y};
    _Event.mouseouton=(tg.id!=="")?tg.id:tg;
    _Event.mouseoutrelated=e.relatedTarget||e.toElement;
    _Event.doevent("mouseout",e,tg);

    if(_mslv.length>0){
        for(var a=_mslv.length-1,b=0;a>=b;a--){
            if(_mslv[a]!==tg && _childof(tg,_mslv[a])){
                var reltg=(e.relatedTarget)?e.relatedTarget:e.toElement;
                if(reltg!==null && reltg!==_mslv[a]){
                    if(!_childof(reltg,_mslv[a])){
                        _Event.doevent("mouseout",e,_mslv[a],true);
                    }
                }

            }
        }
    }

}
// mouse wheel handler
function _mousewheel(e){
    e=e?e:window.event;
    var tg=(window.event)?e.srcElement:e.target;
    var wr=e.detail?e.detail*-1/3:e.wheelDelta/120;
    wr=(_isbrowser("safari")&&(!navigator.userAgent.find("Chrome")))?wr/3:wr;
    if(wr>0){
        _Event.mousewheelupon=(tg.id!=="")?tg.id:tg;
        _Event.mousewheeluprotations=Math.abs(wr);
        _Event.doevent("mousewheelup",e,tg);
    }else{
        _Event.mousewheeldownon=(tg.id!=="")?tg.id:tg;
        _Event.mousewheeldownrotations=Math.abs(wr);
        _Event.doevent("mousewheeldown",e,tg);
    }
}
// cancel event bubbling
function _cancelbubble(e){
    e=e?e:window.event;
    if(e.stopPropagation)e.stopPropagation();
    if(e.preventDefault)e.preventDefault();
    e.cancelBubble = true;
    e.returnValue = false;
    e.cancel = true;
return false;
}
// key status class
var _keystatus={
downcode:"",
downchar:"",
downcharlist:"",
downcodelist:[],
down:false,
upcode:"",
upchar:"",
upcharlist:"",
upcodelist:[],
up:false,
resetactive:function(){
this.downchar="";
this.downcode="";
},
resetrelease:function(){
this.upchar="";
this.upcode="";
},
resetdown:function(){
this.downcharlist="";
this.downcodelist.clear();
},
resetup:function(){
this.upcharlist="";
this.upcodelist.clear();
}
};
// key down handler
function _keydown(e){
var r=e;
    e=e?e:window.event;
    var tg=(window.event)?e.srcElement:e.target;
    if(typeof(e.keyCode)==='number'){
        e=e.keyCode;
    }else if(typeof(e.which)==='number'){
        e=e.which;
    }else if(typeof(e.charCode)==='number'){
        e=e.charCode;
    }

    _keystatus.downcode=e;
    _keystatus.downchar=_getkeychar(e);
    _keystatus.downcharlist+=_getkeychar(e)+",";
    _keystatus.downcodelist.push(e);
    _keystatus.down=true;
    _keystatus.up=false;
    _keystatus.resetrelease();
    _Event.keydownon=(tg.id!=="")?tg.id:tg;
    _Event.doevent("keydown",r,tg);
}
// key up handler
function _keyup(e){
var r=e;
    e=e?e:window.event;
    var tg=(window.event)?e.srcElement:e.target;
    if(typeof(e.keyCode)==='number'){
        e=e.keyCode;
    }else if(typeof(e.which)==='number'){
        e=e.which;
    }else if(typeof(e.charCode)==='number'){
        e=e.charCode;
    }
    _keystatus.upcode=e;
    _keystatus.upchar=_getkeychar(e);
    _keystatus.upcharlist+=_getkeychar(e)+",";
    _keystatus.upcodelist.push(e);
    _keystatus.up=true;
    _keystatus.down=false;
    _keystatus.resetactive();
    _Event.keyupon=(tg.id!=="")?tg.id:tg;
    _Event.doevent("keyup",r,tg);
}
// poll key
function _pollkey(k,f,m,c){
var findstr="";
    if(k.find(":") || m.find("keydown")){
        findstr=k.find(":")?k.split(":")[0]:k;
        _Event.addevent({f:function(e,s){
            if(_keysequence(findstr,"down")){
                if(c)_cancelbubble(e);
                f(e,s);
                _keystatus.resetdown();
            }
        },v:"keydown"});
    }
    if(k.find(":") || m.find("keyup")){
        findstr=k.find(":")?k.split(":")[1]:k;
        _Event.addevent({f:function(e,s){
            if(_keysequence(findstr,"up")){
                if(c)_cancelbubble(e);
                f(e,s);
                _keystatus.resetup();
            }
        },v:"keyup"});
    }
}
// search keys for sequence
function _keysequence(s,m){
    if(m==="down"){
        return _keystatus.downcharlist.find(s)||false;
    }else if(m==="up"){
        return _keystatus.upcharlist.find(s)||false;
    }else{
        return (_keystatus.downcharlist.find(s.d)&&_keystatus.upcharlist.find(s.u))||false;
    }
}
// check for active key
function _activekey(k,h){
    return (_keystatus.downchar.find(k)&&(h?true:(!_freekey(k))))||false;
}
// check for released key
function _freekey(k){
    return _keystatus.upchar.find(k)||false;
}
// return human readable keys
function _getkeychar(c){
    if(c>=48 && c<=90){
        return String.fromCharCode(c).toLowerCase();
    }else if(c>=8 && c<=46){
        switch(c){
            case 8:return "backspace";
            case 9:return "tab";
            case 13:return "enter";
            case 16:return "shift";
            case 17:return "ctrl";
            case 18:return "alt";
            case 19:return "pause";
            case 20:return "caps";
            case 27:return "esc";
            case 32:return "space";
            case 33:return "pgup";
            case 34:return "pgdn";
            case 35:return "end";
            case 36:return "home";
            case 37:return "left";
            case 38:return "up";
            case 39:return "right";
            case 40:return "down";
            case 45:return "ins";
            case 46:return "del";
        }
    }else if(c>=91 && c<=222){
        switch(c){
            case 91:return "lwin";
            case 92:return "rwin";
            case 93:return "select";
            case 96:return "num0";
            case 97:return "num1";
            case 98:return "num2";
            case 99:return "num3";
            case 100:return "num4";
            case 101:return "num5";
            case 102:return "num6";
            case 103:return "num7";
            case 104:return "num8";
            case 105:return "num9";
            case 106:return "*";
            case 107:return "+";
            case 109:return "-";
            case 110:return "dec.";
            case 111:return "/";
            case 144:return "numlock";
            case 145:return "scrolllock";
            case 186:return ";";
            case 187:return "=";
            case 188:return ",";
            case 189:return "dash";
            case 190:return ".";
            case 191:return "foward slash";
            case 192:return "`";
            case 219:return "[";
            case 220:return "back slash";
            case 221:return "]";
            case 222:return "'";
        }
    }else return String.fromCharCode(c);
}
// poll condition class
var _pollr=function(){
    var pollqueue=[];
    return {
        pollqueue:pollqueue,
        addpoll:function(p){
            p.tmout=null;
			p.tmr=0;
            this.pollqueue.push(p);
            var i=_pollr.pollqueue.length-1;
            sysClock.addtask({
                id:p.id?p.id:"poll #"+i.toString(),
                task:function(){
                    _pollr.output(i);
                },
                fps:p.f
            });
        },
        removepoll:function(t){
            sysClock.removetask(t);
        },
        delaypoll:function(p,t){
            var pr=this.pollref(p);
			if(_pollr.pollqueue[pr].tmr===0){
				_pollr.pollqueue[pr].tmr=new Date().getTime()+t;
			}
        },
        pollref:function(t){
            for(var a=0,b=this.pollqueue.length;a<b;a++){
                if(t===this.pollqueue[a].id)return a;
            }
        },
        pollobj:function(i){
            return this.pollqueue[i];
        },
        output:function(i){
			if(_pollr.pollqueue[i].tmr > 0 && _pollr.pollqueue[i].tmr > new Date().getTime()){
				return;
			}else{
				_pollr.pollqueue[i].tmr=0;
			}
			
            if(this.pollqueue[i].tst.run()){
                this.pollqueue[i].tf.run();
            }else{
                if(this.pollqueue[i].ff){
                    this.pollqueue[i].ff.run();
                }
            }
        }
    };
}();
// image list sequential, tile
function _imageList(o){
    var imgList=[];
    return {
        ready:false,
        imagelist:[],
        tile:null,
        tiledata:{},
        data:o,
        imgsloaded:0,
        load:function(){
            var strt=new Date().getTime();
            if(this.data.t==="seq"){
                var f=_makeimagelist(this.data.i,this.data.s,this.data.e,this.data.f);
                for(var i=0,j=f.length;i<j;i++){
                    this.imagelist[i]=new Image();
                    this.imagelist[i].src=this.data.r+f[i];
                    var l=function(o,i){
                        o.imgsloaded++;
                        var c=o.data.s.split(",");
                        if((c[1]-c[0])===o.imgsloaded){
                            o.ready=true;
                        }
                    }
                    this.imagelist[i].onload=new l(this,i);
                }
            }else if(this.data.t==="tile"){
                this.tile=new Image();
                var img=this.data.r+this.data.i+"."+this.data.e;
                this.tile.src=img;
                var imga=this;

                    _imagehandler(this.tile,function(){
                        imga.data.x=this.width;
                        imga.data.y=this.height;
                                var rc=imga.data.s?imga.data.s.split(","):[0,0];
                                var to=imga.data.o?imga.data.o.split(","):[0,0];
                                var pj=imga.data.j?imga.data.j.split(","):[0,0];
                                var rows=parseInt(((imga.data.y+parseInt(to[0],10))/parseInt(rc[0],10)),10);
                                var cols=parseInt(((imga.data.x+parseInt(to[1],10))/parseInt(rc[1],10)),10);
                                imga.tiledata.w=cols;
                                imga.tiledata.h=rows;
                                var c=0;
                                for(var k=0,m=parseInt(rc[0],10);k<m;k++){
                                    for(var i=0,j=parseInt(rc[1],10);i<j;i++){
                                        imga.imagelist[c]={y:parseInt(pj[0],10)+(k*rows),x:parseInt(pj[0],10)+(i*cols)};
                                        c++;
                                    }
                                }
                        imga.ready=true;
                    });
            }
            addEvent(window,'unload',this.flush);
        },
        display:function(i,o){
            if(this.ready){
                if(this.data.t==="seq"){
                    if($(o).getElementsByTagName("img")[0].src!==this.imagelist[i].src){
                        $(o).getElementsByTagName("img")[0].src=this.imagelist[i].src;
                    }
                }else if(this.data.t==="tile"){
                    if(parseInt(_getcss(o,"width"),10)!==this.tiledata.w)_setcss(o,"width",this.tiledata.w+"px");
                    if(parseInt(_getcss(o,"height"),10)!==this.tiledata.h)_setcss(o,"height",this.tiledata.h+"px");
                    if($(o).getElementsByTagName("img")[0]){
                        var imgref=$(o).getElementsByTagName("img")[0];
                    }else{
                       $(o).innerHTML="<img/>";
                       var imgref=$(o).getElementsByTagName("img")[0];
                    }
                    if(imgref.width!==this.data.x)_setcss(imgref,"width",this.data.x+"px");
                    if(imgref.height!==this.data.y)_setcss(imgref,"height",this.data.y+"px");
                        if(imgref.src!==this.output(i).s)imgref.src=this.output(i).s;
                        if(imgref.style.position!=="relative")imgref.style.position="relative";
                        _setcss(imgref,"left",-1*this.output(i).p.x+"px");
                        _setcss(imgref,"top",-1*this.output(i).p.y+"px");
                }
            }
        },
        output:function(i){
            if(this.ready){
                if(this.data.t==="seq"){
                    return this.imagelist[i].src;
                }else if(this.data.t==="tile"){
                    return {s:this.tile.src,p:this.imagelist[i]};
                }
            }
        },
        imgcount:function(){
            return this.imagelist.length;
        },
        flush:function(){
        }
    };
}
// make image list (sequential)
function _makeimagelist(p,n,e,f){
var t=[],z="",fc=0;
var start=parseInt(n.split(",")[0],10);
var num=parseInt(n.split(",")[1],10);
    for(var i=start,j=num;i<=j;i++){
        for(var x=10,y=Math.pow(10,f-1);x<=y;x*=10){
            if(i<x){
                z="".fill(f-(x.toString().length),"0");
                break;
            }
        }
        t[i-start]=p+z+i+"."+e;
    }
return t;
}
// Follow bezier Path
function _followpath(obj,tmr,attr,path,o){
    var a=o?o:{};
    var pathref=path,objref=obj,objattr=attr;
    a.cf=(a.curve?a.curve:"");
    a.c=(a.cycle?a.cycle:"");
    a.v=999;
    a.st=0;
    a.d=tmr;
    if(_isarray(obj)){
          a.t=function(o){
              updateObjpath(objref[0],o.curval,pathref,objattr,o);
          };
        _tweenr.addtween("counter",a);
        var incs=0,inc=a.inc?a.inc:1,index=0;
        for(var i=0,j=obj.length-1;i<j;i++){
            incs+=inc;
            var tmout=(_percentagevalue(incs,tmr)*1000);
            setTimeout(function(){
                var indx=++index;
                a.t=function(o){
                    updateObjpath(objref[indx],o.curval,pathref,objattr,o);
                };
            _tweenr.addtween("counter",a);
            },tmout);
        }
    }else{
          a.t=function(o){
              updateObjpath(objref,o.curval,pathref,objattr,o);
          };
        _tweenr.addtween("counter",a);
    }
}
// bezier patching
function _bzreqnindx(p,tw){
    var t=(tw.timepercent()>100)?100:tw.timepercent();
    t=tw.cyclev?(100-t):t;
    if(p.find("/")){
        var ep=p.split("/"),ei=0,cp,indx="",tp=0;
        var slc=100/ep.length;
        for(var i=0,j=ep.length;i<j;i++){
            cp=ep[i].split(",");
            if(t>i*slc && t<=((i*slc)+slc)){
                ei=i;
                indx=(_mathround(_percentagevalue(999,_percentageindex((t-(i*slc)),slc)),5));
                break;
            }
        }
        return {i:indx,a:ei};
    }else return {i:_mathround(_percentagevalue(999,t),5)};
}
// format bezier curve
function _fmtbzreqn(p){
    var ctrlpnt=[],vi=p.split(",");
    for(var i=0,j=vi.length;i<j;i+=2){
        ctrlpnt.push({x:parseInt(vi[i],10),y:parseInt(vi[i+1],10)});
    }
return ctrlpnt;
}
// update path object
function updateObjpath(obj,v,path,attr,t){
    var steps=999;
    var eqn=_bzreqnindx(path,t);
    var ctrlpnt = (path.find("/"))?_fmtbzreqn(path.split("/")[eqn.a]):_fmtbzreqn(path);
    var eqnout=_bezier(eqn.i/steps,ctrlpnt);

        if(attr.split(",")[0]){
            $(obj).style[attr.split(",")[0]]=Math.round(eqnout.x,2)+"px";
        }
        if(attr.split(",")[1]){
            $(obj).style[attr.split(",")[1]]=Math.round(eqnout.y,2)+"px";
        }
}
// State toggle wrapper
function toggle(i,s){
    _togglr.output(i,s);
}
// toggler class
var _togglr=function(){
    return {
        tgl:{},
        add:function(i,a,s){
            this.tgl[i]={state:s?-1:0,action:a};
        },
        output:function(i,s){
            if(!falsey(s)){
                this.tgl[i]['state']=s;
            }else{
              if(this.tgl[i]['action'][(this.tgl[i]['state']+1)]){
                  this.tgl[i]['state']++;
              }else this.tgl[i]['state']=0;
            }
            this.tgl[i]['action'][(this.tgl[i]['state'])](this.tgl[i]['state']);
        }
    };
}();
// recursive traverse/shift multi dimensional array
function _traversearray(a,e){
 if(_isstring(a[0])||_isobject(a[0])){
return {o:a,a:[]};
}
    var arri=a.copy();
    var retarr=[].concat(arri.shift());
        if(_isarray(retarr[0])){
            if(e.length===0){
                e=arri.copy();
            }else{
                e=[].concat(arri.concat(e));
            }
            _traversearray(retarr,e);
        }else{
            var retval=retarr.copy();
            var tyms=arri.copy();
        return {o:retval,a:tyms};
        }
}
// GET time string
function timestring(){
    return new Date().getHours().zeroFormat(2,"f")+" : "+new Date().getMinutes().zeroFormat(2,"f")+" : "+new Date().getSeconds().zeroFormat(2,"f")+"."+new Date().getMilliseconds().zeroFormat(2,"f");
}
// quicktime format
function qwiktime(){
    return new Date().getSeconds().zeroFormat(2,"f")+"."+new Date().getMilliseconds();
}
// xmlobject request functions
// xml object
function _httpobject(){
  var xhObj;
    if(window.XMLHttpRequest) {
        xhObj = new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        xhObj = new ActiveXObject("Microsoft.XMLHTTP");
    }
return xhObj;
}
// data request
function dataRequest(url,processdata,options){
var dtaReq = new _httpobject();
    if (!dtaReq){
        alert("Could not make data request!");
    } else {
       if (url != ""){
         if (_isbrowser("firefox")){
           try {
             netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
           } catch (e) {
             //alert("Permission UniversalBrowserRead denied.");
           }
         }
        options=(options)?options:{};
        var method=(options.method)?options.method:"GET";
        var async=(options.async!==false)||false;
        var datatype=(options.datatype)?options.datatype:"text";
        var strt=new Date().getTime();
        dtaReq.open(method,url,async);
        dtaReq.onreadystatechange = function(){
            if(dtaReq.readyState == 4){
        		if (dtaReq.status == 200){
                    if(datatype==="xml"){
                        processdata(dtaReq.responseXML);
                    }else if(method==="HEAD"){
                        processdata(dtaReq.getAllResponseHeaders());
                    }else processdata(dtaReq.responseText);
        		}else if(dtaReq.status == 401){
		            alert("Access to data resource was denied!");
        		}else{
                    if(window.location.href.indexOf("http") === -1){
                        processdata(dtaReq.getAllResponseHeaders());
                    }else{
                        processdata(dtaReq.status);
                    }
                }
            }
        }
        dtaReq.send(null);
        }
    }
}
// copy object properties, functions, etc? lol, what etc?..
function _copyobj(d,s,e){
    var r=e.split("|");
    for(var i=0,j=r.length;i<j;i++){
        var c=r[i].split("/");
        var pxa=_getcss(s,c[0]);
        if(r[i].find("/")){
            var npxa=parseInt(pxa,10);
            var unt=eval("pxa.toString().replace(/"+npxa+"/,'')");
            if(c[0]!=='zIndex')d.style[c[0]]=eval(npxa+c[1])+unt;
        }else{
            var blst="left,top,width,height";
            if(_isbrowser("iexplorer")&&c[0]==="opacity"){
                d.style["filter"]="alpha(opacity="+pxa+")";
            }else if(typeof($(s)[c[0]])==="function" && !blst.find(c[0])){
                d[c[0]]=$(s)[c[0]];
            }else if(c[0]==="innerHTML"){
                d.innerHTML=s.innerHTML;
            }else{
                d.style[c[0]]=pxa;
            }
        }
    }
return d;
}
//mmo class
mmo.prototype.rotate = rotateO;
mmo.prototype.getrotA = getrotA;
mmo.prototype.scale = scale;
mmo.prototype.translate = translate;
mmo.prototype.addPoint = addPoint;
mmo.prototype.clearPoints = clearPoints;
mmo.prototype.drawPoint = drawPoint;
mmo.prototype.paint = paint;
mmo.prototype.resetMatrix = resetMatrix;
var PHI = 1.61803398874989484820458683;
var PHI_INV = 1/PHI;
function identity() {
	return [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];
}
function multV(m,v0,v1,v2,v3) {
	var result = [];
	result[0] = m[0][0]*v0 + m[0][1]*v1 + m[0][2]*v2 + m[0][3]*v3;
	result[1] = m[1][0]*v0 + m[1][1]*v1 + m[1][2]*v2 + m[1][3]*v3;
	result[2] = m[2][0]*v0 + m[2][1]*v1 + m[2][2]*v2 + m[2][3]*v3;
	result[3] = m[3][0]*v0 + m[3][1]*v1 + m[3][2]*v2 + m[3][3]*v3;
return result;
}
function mult(m1, m2) {
	var result = [];
	for (var i = 0; i<4;i++){result[i] = new Array(4);}
    for(var i = 0; i < 3; i++){
		result[i][0] = m1[i][0] * m2[0][0] + m1[i][1] * m2[1][0] + m1[i][2] * m2[2][0] + m1[i][3] * m2[3][0];
		result[i][1] = m1[i][0] * m2[0][1] + m1[i][1] * m2[1][1] + m1[i][2] * m2[2][1] + m1[i][3] * m2[3][1];
		result[i][2] = m1[i][0] * m2[0][2] + m1[i][1] * m2[1][2] + m1[i][2] * m2[2][2] + m1[i][3] * m2[3][2];
		result[i][3] = m1[i][0] * m2[0][3] + m1[i][1] * m2[1][3] + m1[i][2] * m2[2][3] + m1[i][3] * m2[3][3];
	}
return result;
}
function Point(x, y, z, text) {
	this.x = x;
	this.y = y;
	this.z = z;
	this.W = 1;
    this.rX=0;
    this.rY=0;
}
function paint() {
	for(var i = 0; i<this.points.length; i++) {
		this.drawPoint(i);
	}
}
function getrotA(r){
    r=(r/180)*Math.PI;
    this.matrix = this.rotate(r);
    var tPoint = multV(this.matrix,this.points[0].x,this.points[0].y,this.points[0].z,this.points[0].W);
        var wo=this.width/2;
        var ho=this.height/2;
        this.points[0].rX=tPoint[0]-wo;
        this.points[0].rY=tPoint[1]-ho;
return [this.points[0].rX,this.points[0].rY];
}
function drawPoint(index){
}
function rotateO(angle,m) {
	if(!m) m = this.matrix;
	var c = Math.cos(angle);
	var s = Math.sin(angle);
	return mult(m,[[c, -s, 0, 0],[s, c, 0, 0],[0, 0, 1, 0],[0, 0, 0, 1]]);
}
function scale(scaleX,scaleY,scaleZ,m) {
	if(!m) m = this.matrix;
	return mult(m,[[scaleX,0,0,0],[0,scaleY,0,0],[0,0,scaleZ,0],[0,0,0,1]]);
}
function translate(dX, dY, dZ,m) {
	if(!m) m = this.matrix;
    var mtrx=mult(m,[[1,0,0,0],[0,1,0,0],[0,0,0,1/-.003],[0,0,0,1]]);
    return mult(mtrx,[[1,0,0,dX],[0,1,0,dY],[0,0,1,dZ],[0,0,0,1]]);
}
function addPoint(x,y,z,m) {
	if(!m) m=identity();
	var v = multV(m,x,y,z,1);
	var l = this.points.length;
	this.points[l]=new Point(v[0],v[1],v[2]);
	return this.points[l];
}
function mmo(maxZ) {
	this.maxZ = maxZ || 0;
    this.width = 5;
    this.height = 5;
    this.resetMatrix();
	this.points = [];
}
function clearPoints() {
	this.points.length=0;
}
function resetMatrix() {
	this.matrix = identity();
}

// VVED WRAPPERS
//animate
function _animate(r,a){
    VVEDobj.objqueue[_getref(r)].animate(a);
}
// tween
function tweento(r,a){
   return VVEDobj.objqueue[_getref(r)].to(a);
}
// add method to vved
function _addmethod(m,f){
    VVEDobj.addmethod(m,f);
}
// add method to vved object
function _addobjectmethod(o,m,f){
    VVEDobj.addobjectmethod(o,m,f);
}
// get vved ref
function vved(r){
    return VVEDobj.objqueue[_getref(r)];
}
// get tween ref
function _tweenbyindex(i){
    return _tweenr.tweenqueue[i];
}
// stop all tweens on element
function _stoptweens(e){
    return _tweenr.stop(e);
}
// stop all tweens on element
function _resettweens(e,p){
    return _tweenr.reset(e,p);
}
// get tween ref
function _tween(e,p){
    return _tweenr.tweenqueue[_tweenr.find(e,p)];
}
// attach wrapper
function _attach(o){
  if(!o.a.offset||o.a.autooffset){
    o.a.offset=(-1*(parseInt(_getcss(o.r,o.p),10)-parseInt(_getcss(o.a.e,o.p),10)));
  }
  VVEDobj.attach(o);
}
// tween counter wrapper - bezier iterator
function _counter(o){
    return _tweenr.addtween("counter",o);
}
// End Wrappers

// mouse enter leave
function _mouseenterleave(e,c){
    if(!_childof(c,e)){
        return true;
    }else return false;
}
var _mslv=[];
var _hvtmout={objs:[],index:[]};
var _httmout={objs:[],index:[]};
// CORE VVED dom extensions
function _defaultdomextensions(vvedoptions){

var sstup=vvedoptions.usedomextendsets||"";
// node functions
if((sstup!==""&&sstup.find("iterators"))||(sstup==="")){
    _domext("not",function(s){
        var fs=('#'+this.id+' > *');
        var ns=('#'+this.id+' > '+s);
        var fsl=$(fs);
        var nsl=$(ns);
        var nl=fsl.negativeresult(function(){
            return nsl.find(this)>-1;
        });
        return nl;
    });

    _domext("select",function(s){
        return $('#'+this.id+' > '+s);
    });
    _domext("parent",function(){
        return this.parentNode;
    });
    _domext("next",function(){
        return this.nextSibling;
    });
    _domext("previous",function(){
        return this.previousSibling;
    });
    _domext("firstchild",function(){
        return this.firstChild;
    });
    _domext("lastchild",function(){
        return this.lastChild;
    });
}

if((sstup!==""&&sstup.find("operators"))||(sstup==="")){
    _domext("clone",function(o,a){
        var cn=this.cloneNode(true);
        if(o){
            if(!a){
              $(o).appendChild(cn);
            } else cn.insertafter($(o));
        }else cn.insertafter(this);
        return cn;
    },true);
    _domext("clonez",function(i,c){
        var cn=this.cloneNode(true);
        cn.id=i;
        cn.className=c;
        cn.insertafter(this);
        return this;
    },true);
    _domext("destroy",function(){
        this.parentNode.removeChild(this);
        return this;
    },true);
    _domext("replace",function(n){
        $(n).parentNode.insertBefore(this,$(n));
        $(n).parentNode.removeChild($(n));
        return this;
    },true);
    _domext("replacewith",function(n){
        this.parentNode.insertBefore($(n),this);
        this.parentNode.removeChild(this);
        return $(n);
    });
    _domext("append",function(c){
        this.appendChild($(c));
        return this;
    },true);
    _domext("appendbefore",function(c,s){
        this.insertBefore($(c),$(s));
        return this;
    },true);
    _domext("appendafter",function(c,s){
        _insertafter($(c),$(s));
        return this;
    },true);
    _domext("insertinto",function(p){
        $(p).appendChild(this);
        return this;
    },true);
    _domext("insertbefore",function(s){
        $(s).parentNode.insertBefore(this,$(s));
        return this;
    },true);
    _domext("insertafter",function(c){
        _insertafter(this,$(c));
        return this;
    },true);
}


// events
if((sstup!==""&&sstup.find("events"))||(sstup==="")){
    _domext("attn",function(f,f2){
        var o=this;
        addEvent(this,'focus',function(){
            f.apply(o,arguments);
        });
        addEvent(this,'blur',function(){
            f2.apply(o,arguments);
        });
        return this;
    },true);

    _domext("focused",function(f){
        var o=this;
        addEvent(this,'focus',function(){
            f.apply(o,arguments);
        });
        return this;
    },true);
    _domext("blurred",function(f){
        var o=this;
        addEvent(this,'blur',function(){
            f.apply(o,arguments);
        });
        return this;
    },true);
    _domext("selected",function(f){
        var o=this;
        addEvent(this,'select',function(){
            f.apply(o,arguments);
        });
        return this;
    },true);
    _domext("changed",function(f){
        var o=this;
        addEvent(this,'change',function(){
            f.apply(o,arguments);
        });
        return this;
    },true);

    _domext("events",function(e,f){
        var o=this;
        var ev=e.split(",");
        for(var a=0,b=ev.length;a<b;a++){
          addEvent(this,ev[a],function(){
            f.apply(o,arguments);
          });
        }
        return this;
    },true);

    _domext("tie",function(e,f,c){
        var o=this;
        var ev=e.split(",");
        for(var a=0,b=ev.length;a<b;a++){
          addEvent(this,ev[a],function(){
            if(c.apply(o,arguments))f.apply(o,arguments);
          });
        }
        return this;
    },true);

}

if((sstup!==""&&sstup.find("mouse"))||(sstup==="")){
    _domext("mouseover",function(f,l){
        var o=this;
        _Event.addevent({f:function(e,s){
          if(!l){
            var reltg=(e.relatedTarget)?e.relatedTarget:e.fromElement;
            if(reltg!==null){
                if(!_mouseenterleave(s,reltg))return false;
            }
          }
          _mslv.push(o);
            f.apply(o,arguments);
        },v:"mouseover",e:this});
        return this;
    },true);
    _domext("mouseout",function(f,l){
        var o=this;
        _Event.addevent({f:function(e,s){
          if(!l){
            var reltg=(e.relatedTarget)?e.relatedTarget:e.toElement;
            if(reltg!==null){
                if(!_mouseenterleave(s,reltg))return false;
            }
          }

            for(var a=0,b=_mslv.length;a<b;a++){
                if(_mslv[a]===o){
                    _mslv.removeindex(a);
                }
            }

            f.apply(o,arguments);
        },v:"mouseout",e:this});
        return this;
    },true);
    _domext("hover",function(e,l,d,d2,ovrd){
        if(!d){
          this.mouseover(e);
        }else{
          var _e=e;
          if(_hvtmout.objs.find(this)===-1){
            _hvtmout.objs.push(this);
            _hvtmout.index.push(null);
          }
          e=function(){
            var o=this,r=function(){
                _e.apply(o,arguments);
            }
              clearTimeout((_hvtmout.index[_hvtmout.objs.find(o)]));
              if(!ovrd)clearTimeout((_httmout.index[_httmout.objs.find(o)]));
              _hvtmout.index[_hvtmout.objs.find(o)]=setTimeout(r,d);
          };
          this.mouseover(e);
        }
        if(!d2){
          if(l)this.mouseout(l);
        }else{
          if(l){
            var _l=l;
              if(_httmout.objs.find(this)===-1){
                _httmout.objs.push(this);
                _httmout.index.push(null);
              }
            l=function(){
              var o=this,r=function(){
                  _l.apply(o,arguments);
              }
                clearTimeout((_httmout.index[_httmout.objs.find(o)]));
                if(!ovrd)clearTimeout((_hvtmout.index[_hvtmout.objs.find(o)]));
                _httmout.index[_httmout.objs.find(o)]=setTimeout(r,d2);
            };
            this.mouseout(l);
          }
        }
    },true);
    _domext("mousedown",function(f){
        var o=this;
        _Event.addevent({f:function(){
            f.apply(o,arguments);
        },v:"mousedown",e:this});
        return this;
    },true);
    _domext("click",function(f,l){
        var o=this;
        _Event.addevent({f:function(){
            f.apply(o,arguments);
        },v:(l?"mouseup":"mousedown"),e:this});
        return this;
    },true);
    _domext("mouseup",function(f){
        var o=this;
        _Event.addevent({f:function(){
            f.apply(o,arguments);
        },v:"mouseup",e:this});
        return this;
    },true);

    _domext("mousemove",function(f){
        var o=this;
        _Event.addevent({f:function(){
            f.apply(o,arguments);
        },v:"mousemove",e:this});
        return this;
    },true);

    _domext("mousewheeldown",function(f){
        var o=this;
        _Event.addevent({f:function(){
            f.apply(o,arguments);
        },v:"mousewheeldown",e:this});
        return this;
    },true);
    _domext("mousewheelup",function(f){
        var o=this;
        _Event.addevent({f:function(){
            f.apply(o,arguments);
        },v:"mousewheelup",e:this});
        return this;
    },true);
}
// helpers

if((sstup!==""&&sstup.find("helpers"))||(sstup==="")){
    _domext("attach",function(o){
        o=o?o:{};
        var a={};
        a.a=o.actions;
        a.a.e=o.e;
        a.p=o.rf;
        a.a.p=o.tp?o.tp:o.rf;
        a.r=this;
        _attach(a);
        return this;
    },true);
    _domext("highlight",function(o){
      if(!o.v){
          o.v=_randomcolor(o.randomgenerator?o.randomgenerator:{r:"0/255",g:"0/255",b:"0/255"});
      }
      if(o.type){
        var ov=_getcss(this,o.p);
        ov=(_isbrowser("firefox")||_isbrowser("safari"))?_rgbfull2hex(ov):ov;
        if(o.type.find('random'))o.v=_randomcolor(o.randomgenerator?o.randomgenerator:{r:"0/255",g:"0/255",b:"0/255"});
        if(o.type.find('once'))o.sc=o.v,o.v=ov,o.c='';
      }
      tweento(this,o);
      return this;
    },true);
}

if((sstup!==""&&sstup.find("http"))||(sstup==="")){
    _domext("ajax",function(u,o){
        _datafill(this,u,o);
        return this;
    },true);
}

if((sstup!==""&&sstup.find("animation"))||(sstup==="")){
    _domext("leftto",function(o){
        if(typeof o !== "string"){
            o.p="left";
            tweento(this,o);
        }else _css(this,"left",o);
        return this;
    },true);
    _domext("topto",function(o){
        if(typeof o !== "string"){
            o.p="top";
            tweento(this,o);
        }else _css(this,"top",o);
        return this;
    },true);
    _domext("widthto",function(o){
        if(typeof o !== "string"){
            o.p="width";
            tweento(this,o);
        }else _css(this,"width",o);
        return this;
    },true);
    _domext("heightto",function(o){
        if(typeof o !== "string"){
            o.p="height";
            tweento(this,o);
        }else _css(this,"height",o);
        return this;
    },true);
    _domext("orbit",function(o){
        o.p="orbit";
        tweento(this,o);
        return this;
    },true);
    _domext("link",function(a,o){
        var _a=[this];
        _a=_a.concat(a);
        _link(_a,o)
        return this;
    },true);

    _domext("animate",function(o){
        _animate(this,o);
        return this;
    },true);
    _domext("tween",function(o){
        tweento(this,o);
        return this;
    },true);
    _domext("twn",function(p){
        return _tween(this,p);
    });
    _domext("fade",function(o){
        o.p="opacity";
        tweento(this,o);
        return this;
    },true);
    _domext("fontsize",function(o){
        o.p="fontSize";
        tweento(this,o);
        return this;
    },true);
    _domext("color",function(c){
        tweento(this,c);
        return this;
    },true);

    _domext("stop",function(c){
        _tweenr.stop(this);
        return this;
    },true);
    _domext("reset",function(p){
        _tweenr.reset(this,p);
        return this;
    },true);

    _domext("show",function(o){
        if(o){
            _setcss(this,"display","");
            tweento(this,o);
        }else _setcss(this,"display","");
        return this;
    },true);

    _domext("hide",function(o){
        if(o){
            o.v=0;
            o.e=function(t){
              _setcss(t.elem,"display","none");
            }
            tweento(this,o);
        }else _setcss(this,"display","none");
        return this;
    },true);


    _domext("wiggle",function(p,f,o,n,cf){
        _wiggle(this,p,f,o,n,cf);
        return this;
    },true);

}

if((sstup!==""&&sstup.find("css"))||(sstup==="")){
    _domext("css",function(p,v){
        var c=_css(this,p,v);
        if(!c){
          return this;
        }else return c;
    },true);
    _domext("dimensions",function(){
        return _dimensions(this);
    });
    _domext("absoluteposition",function(u){
        return _absoluteposition(this,u);
    });
    _domext("positionabsolutely",function(u,a){
        _positionabsolutely(this,u,a);
    return this;
    },true);

   _domext("html",function(d){
        var r=_html(this,d);
        if(r){return r}else return this;
    },true);
    _domext("text",function(d){
        var r=_text(this,d);
        if(r){return r}else return this;
    },true);
    _domext("attr",function(s,t){
        _applystyles(this,s,t);
        return this;
    },true);

    _domext("hasclass",function(c){
        return _hasclass(this,c);
    });

    _domext("addclass",function(c){
        _addclassname(this,c);
        return this;
    },true);
    _domext("removeclass",function(c){
        _removeclassname(this,c);
        return this;
    },true);
    _domext("toggleclass",function(c){
        _toggleclass(this,c);
        return this;
    },true);

    _domext("linkwrap",function(o){
        _linkwrap(this,o);
        return this;
    },true);
    _domext("wrap",function(t,o){
        _elementwrap(this,t,o);
        return this;
    },true);
}

    _domext("vved",function(o){
        VVEDobj.add(this,o);
        return this;
    },true);

    _domext("extend",function(fn,f){
        _domext(fn,f);
        return this;
    },true);


// end dom extensions
}

// document ready function, slower in ie
(function () {
	var ie  = !!(window.attachEvent && !window.opera);
	var wk  = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);
	var fn  = [];
	var run = function(){  for(var i = 0; i < fn.length; i++) fn[i](); };
	var d   = document;
	d.ready = function(f){
		if(!ie && !wk && d.addEventListener)
			return d.addEventListener('DOMContentLoaded',f,false);
		if(fn.push(f) > 1) return;
		if(ie)
			(function () {
				try { d.documentElement.doScroll('left'); run(); }
				catch (err) { setTimeout(arguments.callee, 0); }
			})();
		else if(wk)
			var t = setInterval(function () {
				if (/^(loaded|complete)$/.test(d.readyState))
					clearInterval(t), run();
			},0);
	};
})();
