/* Copyright (c) 2005-2009, Vadims Zemlanojs. All rights reserved. */
var tenplanets={};tenplanets.anim={};tenplanets.anim.Scene=function(d,c,a,g){var e=this;this.ontop=((g&1)==1)?true:false;this.quirks=(document.compatMode=="BackCompat")||(document.documentMode==5);this.w0=a,this.h0=c,this.x0=0,this.y0=0,this.shapes=[],this.animated=false;this.fps=50;var f=40;if(typeof d=="string"){this.scene=YAHOO.util.Dom.get(d);if(this.scene==null){throw new Error("Element not found!")}}else{if(d instanceof HTMLElement){this.scene=d}else{throw new Error("No element specified!")}}this.setDims();var b=(this.ontop||YAHOO.env.ua.gecko==0||YAHOO.env.ua.gecko>=1.8)?true:false;this.isReady=function(){return b};this.go=function(){var h=f;time=0,delta=Math.ceil(3*f/4);if(e.animated){time=new Date();e.run(e);time=new Date()-time;if(time>=h-delta){h=delta}else{h-=time}setTimeout(e.go,h)}};this.dispose=function(){this.animated=false;this.shapes.length=0;b=false;e=null}};tenplanets.anim.Scene.prototype.isAnimated=function(){return this.animated};tenplanets.anim.Scene.prototype.run=function(d){for(var c=0,a=d.shapes.length;c<a;++c){var b=d.shapes[c];if(b.frameNo<b.frames){b.frameNo+=1;b.fire()}else{b.frameNo=1;b.direction=-1*b.direction;b.fire()}}};tenplanets.anim.Scene.prototype.setDims=function(){if(typeof arguments.callee.offset!="number"){if(this.ontop&&(YAHOO.env.ua.ie>0)&&this.quirks){arguments.callee.offset=-2}else{arguments.callee.offset=0}}var b=arguments.callee.offset;var a=YAHOO.util.Dom.getRegion(this.scene);this.x=a.left,this.y=a.top;this.w=a.right-a.left,this.h=a.bottom-a.top;if(this.ontop&&YAHOO.env.ua.opera){this.x=this.scene.offsetLeft;this.y=this.scene.offsetTop}this.dx=this.x+b,this.dy=this.y+b,this.dw=this.w/this.w0,this.dh=this.h/this.h0};tenplanets.anim.Scene.prototype.rsz=function(){this.setDims();for(var b=0,a=this.shapes.length;b<a;++b){this.shapes[b].resizeShape(this.dx,this.dy,this.dw,this.dh)}};tenplanets.anim.Scene.prototype.start=function(){if(!this.isReady()){return}this.animated=true;for(var b=0,a=this.shapes.length;b<a;++b){YAHOO.util.Dom.setStyle(this.shapes[b].el,"visibility","visible")}this.go()};tenplanets.anim.Scene.prototype.stop=function(){this.animated=false;for(var b=0,a=this.shapes.length;b<a;++b){YAHOO.util.Dom.setStyle(this.shapes[b].el,"visibility","hidden")}};tenplanets.anim.Scene.prototype.appendShape=function(b){if(!this.isReady()){return}var d=b.el;b.frames=this.fps*b.duration;b.setScene(this);var a=(b.hold.w)?b.dims.w:Math.round(b.dims.w*this.dw);var c=(b.hold.h)?b.dims.h:Math.round(b.dims.h*this.dh);b.setValue("width",a,"px");b.setValue("height",c,"px");this.scene.appendChild(d);this.shapes[this.shapes.length]=b;b.setValue("left",(b.dims.x*this.dw+this.dx),"px");b.setValue("top",(b.dims.y*this.dh+this.dy),"px");d.style.visibility="visible"};tenplanets.anim.hLineFn=function(a,b){return function(c,g,l,k,j){var i=0,e=(l>k)?true:false;if(e){var h=l;l=k;k=h;g=j-g}if(c=="width"){g=(this.direction==1)?g*b.w0/j-a.forth:(j-g)*b.w0/j+a.back;if(g<l){i=(e)?(k-l):0}else{if((g>=l)&&(g<=k)){i=(e)?(k-g):(g-l)}else{i=(e)?0:(k-l)}}this.dims.w=Math.round(i);return Math.round(i*b.dw)}else{this.dims.x=(e)?(k-this.dims.w):Math.round(l+(k-l)/2-this.dims.w/2);return Math.round(this.dims.x*b.dw)+b.dx}}};tenplanets.anim.vLineFn=function(a,b){return function(c,g,l,k,j){var i=0,e=(l>k)?true:false;if(e){var h=l;l=k;k=h;g=j-g}if(c=="height"){g=(this.direction==1)?g*b.h0/j-a.forth:(j-g)*b.h0/j+a.back;if(g<l){i=(e)?(k-l):0}else{if((g>=l)&&(g<=k)){i=(e)?(k-g):(g-l)}else{i=(e)?0:(k-l)}}this.dims.h=Math.round(i);return Math.round(i*b.dh)}else{this.dims.y=(e)?(k-this.dims.h):Math.round(l+(k-l)/2-this.dims.h/2);return Math.round(this.dims.y*b.dh)+b.dy}}};tenplanets.anim.hShapeFn=function(a,b,c){return function(e,g,l,k,j){var i=0,h=(k-l),f=(e=="left")?a:b;if(this.direction==1){g=g*(k-l)/j;i=((g+f)>h)?2*h-(g+f):g+f}else{g=(j-g)*(k-l)/j;i=(g<f)?i=f-g:i=g-f}i=i+l;if(e=="left"){this.dims.x=Math.round(i);return Math.round(i*c.dw)+c.dx}else{this.dims.y=Math.round(i);return Math.round(i*c.dh)+c.dy}}};tenplanets.anim.Scene.prototype.createHLine=function(f,c,i,h,k,b,e,d,a){var j={};if(f==1){j.width={from:i,to:(b+i)}}else{if(f==2){j.left={from:i,to:(b+i)};j.width={from:i,to:(b+i)}}else{j.left={to:i,from:(b+i)};j.width={to:i,from:(b+i)}}}var g=tenplanets.anim.hLineFn(c,this);return new tenplanets.anim.Shape(i,h,0,k,j,e,d,g,a)};tenplanets.anim.Scene.prototype.createVLine=function(g,d,j,i,b,c,f,e,a){var k={};if(g==1){k.height={from:i,to:(c+i)}}else{if(g==2){k.top={from:i,to:(c+i)};k.height={from:i,to:(c+i)}}else{k.height={to:i,from:(c+i)};k.top={to:i,from:(c+i)}}}var h=tenplanets.anim.vLineFn(d,this);return new tenplanets.anim.Shape(j,i,b,0,k,f,e,h,a)};tenplanets.anim.Scene.prototype.createShape=function(e,h,g,b,k,d,c,a){var j=2;var i={};if(e==1){i.left={from:0,to:this.w0-b-j}}else{if(e==2){i.top={from:0,to:this.h0-k-j}}else{i.left={from:0,to:this.w0-b-j};i.top={from:0,to:this.h0-k-j}}}var f=tenplanets.anim.hShapeFn(h,g,this);return new tenplanets.anim.Shape(h,g,b,k,i,d,c,f,a)};tenplanets.anim.Shape=function(i,g,j,e,d,c,b,f,a){this.dims={x:i,y:g,h:e,w:j};this.hold=a;this.scene=null;this.direction=1;this.proc=f;this.duration=b;this.frameNo=0;this.frames=0;this.attrs=(d)?d:{};this.el=document.createElement("div");this.el.style.cssText="position:absolute;display:block;width:0px;height:0px;left:0px;top:0px;visibility:hidden;overflow:hidden;background-color:"+c+";";this.el.innerHTML="&nbsp;"};tenplanets.anim.Shape.prototype.setScene=function(a){this.scene=a};tenplanets.anim.Shape.prototype.doProc=function(a,c,b){if(this.proc){return this.proc(a,this.frameNo,c,b,this.frames)}else{return 0}};tenplanets.anim.Shape.prototype.fire=function(){for(var a in this.attrs){this.setValue(a,this.doProc(a,this.attrs[a].from,this.attrs[a].to),"px")}};tenplanets.anim.Shape.prototype.setValue=function(a,d,c){var b=this.el;if(/width|height/i.test(a)){d=(d>0)?d:0;if(this.scene.quirks&&(YAHOO.env.ua.ie>0)){if(d==0){YAHOO.util.Dom.setStyle(b,"visibility","hidden")}else{YAHOO.util.Dom.setStyle(b,"visibility","visible")}}}if(this.scene.ontop){if(a in b&&!("style" in b&&a in b.style)){b[a]=d}else{YAHOO.util.Dom.setStyle(b,a,d+c)}}else{if(a=="left"){YAHOO.util.Dom.setX(b,d)}else{if(a=="top"){YAHOO.util.Dom.setY(b,d)}else{if(a in b&&!(("style" in b)&&a in b.style)){b[a]=d}else{YAHOO.util.Dom.setStyle(b,a,d+c)}}}}};tenplanets.anim.Shape.prototype.resizeShape=function(c,b,d,f){var a=(this.hold.w)?this.dims.w:Math.round(this.dims.w*d);var e=(this.hold.h)?this.dims.h:Math.round(this.dims.h*f);this.setValue("width",a,"px");this.setValue("height",e,"px");this.setValue("left",(this.dims.x*d+c),"px");this.setValue("top",(this.dims.y*f+b),"px")};
