
Function.prototype.inherits=function(baseClass)
{function Blank(){}
this.base=Blank.prototype=baseClass.prototype;this.prototype=new Blank();this.prototype.constructor=this;};function BaseEffect(){this.effectCurrentFrame=0;this.effectStartOnTime=0;this.effectFinishOnTime=0;this.effectFPS=25.0;this.effectDelay=0.0;this.effectDuration=0.5;this.effectInterval=null;this.effectFrom=0.0;this.effectTo=1.0;this.effectRenderedFramesCount=0;this.effectEndFunction=null;}
BaseEffect.prototype.startEffect=function(){if(this.effectInterval){clearInterval(this.effectInterval);}
var timestamp=new Date().getTime();this.effectCurrentFrame=0;this.effectStartOnTime=this.effectDelay*1000;this.effectFinishOnTime=this.effectStartOnTime+(this.effectDuration*1000);this.effectStartOnTime+=timestamp;this.effectFinishOnTime+=timestamp;this.effectRenderedFramesCount=0;var self=this;this.effectInterval=setInterval(function(){self.loop();},40);}
BaseEffect.prototype.loop=function(){var timePos=new Date().getTime();if(timePos>=this.effectStartOnTime){if(timePos>=this.effectFinishOnTime){this.effectRenderedFramesCount++;this.renderFrame(1.0,this.effectRenderedFramesCount);clearInterval(this.effectInterval);this.effectInterval=null;this.renderEffectDone();return;}
var pos=(timePos-this.effectStartOnTime)/(this.effectFinishOnTime-this.effectStartOnTime);var frame=Math.round(pos*this.effectFPS*this.effectDuration);if(frame>this.effectCurrentFrame){this.effectRenderedFramesCount++;this.renderFrame(pos,this.effectRenderedFramesCount);this.effectCurrentFrame=frame;}}}
BaseEffect.prototype.renderFrame=function(pos,cFrame){pos*=(this.effectTo-this.effectFrom);pos+=this.effectFrom;this.renderEffect(pos,cFrame);}
BaseEffect.prototype.renderEffect=function(pos,cFrame){}
BaseEffect.prototype.renderEffectDone=function(){if(this.effectEndFunction)
this.effectEndFunction();}
BaseEffect.prototype.isRunning=function(){return(this.effectInterval!=null);}
BaseEffect.prototype.setDuration=function(sDuration){this.effectDuration=sDuration;}
function OpacityFadeEffect(secDuration){this.maxOpacity=1.0;OpacityFadeEffect.base.constructor.call(this);if(secDuration)
this.effectDuration=secDuration;}
OpacityFadeEffect.inherits(BaseEffect);OpacityFadeEffect.prototype.startFadeEffect=function(el,image,fadeOut,callback,maxOpacity){this.el=el;this.effectImg=image;this.effectEndFunction=callback;this.fadeOut=fadeOut;if(maxOpacity)
this.maxOpacity=maxOpacity;this.startEffect();}
OpacityFadeEffect.prototype.renderEffect=function(pos,cFrame){var el=this.el;if(cFrame==1&&this.effectImg){el.width=this.effectImg.width;el.height=this.effectImg.height;el.src=this.effectImg.src;}
var opacity=this.fadeOut?1.0-pos*this.maxOpacity:pos*this.maxOpacity;if(opacity==1.0){opacity=0.999999;}
if(el.filters)
el.filters.alpha.opacity=opacity*100;el.style.opacity=opacity;}
function OpacityCrossFadeEffect(){OpacityCrossFadeEffect.base.constructor.call(this);}
OpacityCrossFadeEffect.inherits(BaseEffect);OpacityCrossFadeEffect.prototype.startFadeEffect=function(el,el2,image,callback){this.el=el;this.el2=el2;this.effectImg=image;this.effectElement2Hidden=false;this.effectEndFunction=callback;this.startEffect();}
OpacityCrossFadeEffect.prototype.renderEffect=function(pos,cFrame){var el=this.el;var el2=this.el2;if(cFrame==1){el.width=this.effectImg.width;el.height=this.effectImg.height;el.src=this.effectImg.src;}
var opacity=pos;var fEnd=false;if(opacity==1.0){opacity=0.999999;fEnd=true;}
if(!this.effectElement2Hidden&&!fEnd&&opacity>0.9){el2.style.visibility="hidden";el2.width=this.effectImg.width;el2.height=this.effectImg.height;el2.src=this.effectImg.src;this.effectElement2Hidden=true;}
if(fEnd){if(!this.effectElement2Hidden){el2.width=this.effectImg.width;el2.height=this.effectImg.height;el2.src=this.effectImg.src;}
if(el2.filters){el2.filters.alpha.opacity=100;}
el2.style.opacity="0.999999";el2.style.visibility="visible";el.style.visibility="hidden";el.style.opacity="0";if(el.filters){el.filters.alpha.opacity=0;}}else{if(el.filters){el.filters.alpha.opacity=opacity*100;}
el.style.opacity=opacity;if(!this.effectElement2Hidden){opacity=1.0-opacity;if(el2.filters){el2.filters.alpha.opacity=opacity*100;}
el2.style.opacity=opacity;}}}
function OpacityCrossFadeEffectTest(){OpacityCrossFadeEffectTest.base.constructor.call(this);}
OpacityCrossFadeEffectTest.inherits(BaseEffect);OpacityCrossFadeEffectTest.prototype.startFadeEffect=function(el,el2,callback){this.el=el;this.el2=el2;this.effectElement2Hidden=false;this.effectEndFunction=callback;this.startEffect();}
OpacityCrossFadeEffectTest.prototype.renderEffect=function(pos,cFrame){var el=this.el;var el2=this.el2;var opacity=pos;var fEnd=false;if(opacity==1.0){opacity=0.999999;fEnd=true;}
if(!this.effectElement2Hidden&&!fEnd&&opacity>0.9){el2.style.visibility="hidden";this.effectElement2Hidden=true;}
if(fEnd){if(el.filters){el.filters.alpha.opacity=100;}
el.style.opacity="0.999999";el2.style.visibility="hidden";el2.style.opacity="0";if(el2.filters){el2.filters.alpha.opacity=0;}}else{if(el.filters){el.filters.alpha.opacity=opacity*100;}
el.style.opacity=opacity;if(!this.effectElement2Hidden){opacity=1.0-opacity;if(el2.filters){el2.filters.alpha.opacity=opacity*100;}
el2.style.opacity=opacity;}}}
function SlideElementEffect(el,from,to,callback){SlideElementEffect.base.constructor.call(this);this.effectEndFunction=callback;this.effectDuration=0.3;this.el=el;this.from=from;this.to=to;}
SlideElementEffect.inherits(BaseEffect);SlideElementEffect.prototype.renderEffect=function(pos,cFrame){var scrollTop=document.body.scrollTop;if(scrollTop==0){if(window.pageYOffset)
scrollTop=window.pageYOffset;else
scrollTop=(document.body.parentElement)?document.body.parentElement.scrollTop:0;}
this.el.style.top=this.from+Math.round(pos*(this.to-this.from+scrollTop))+document.body.scrollTop+"px";}
function ScrollElementEffect(el,from,to,callback,callbackPostRender,fHasScrollTo){ScrollElementEffect.base.constructor.call(this);this.effectEndFunction=callback;this.callbackPostRender=callbackPostRender;this.effectDuration=0.5;this.el=el;this.from=from;this.to=to;this.fHasScrollTo=fHasScrollTo;}
ScrollElementEffect.inherits(BaseEffect);ScrollElementEffect.prototype.startScrollEffect=function(from,to,callback){this.from=from;this.to=to;if(callback)
this.effectEndFunction=callback;this.startEffect();}
ScrollElementEffect.prototype.renderEffect=function(pos,cFrame){var y=this.from+Math.round(pos*(this.to-this.from));if(this.fHasScrollTo)
this.el.scrollTo(0,y);else
this.el.style.marginTop=(-1*y)+"px";if(this.callbackPostRender){this.callbackPostRender();}}
function SetHeightDoubleElementEffect(el,fromHeight,toHeight,el2,fromHeight2,toHeight2,callback,setHidden,duration,setDisplayNone,keepCenteredWinHeight,centerOffsetTop){SetHeightDoubleElementEffect.base.constructor.call(this);this.effectDuration=duration?duration:0.3;this.el=el;this.el2=el2;this.fromHeight=fromHeight;this.toHeight=toHeight;this.fromHeight2=fromHeight2;this.toHeight2=toHeight2;this.effectEndFunction=callback;this.setHidden=setHidden;this.expanded=false;this.setDisplayNone=setDisplayNone;this.keepCenteredWinHeight=keepCenteredWinHeight;this.centerOffsetTop=centerOffsetTop;}
SetHeightDoubleElementEffect.inherits(BaseEffect);SetHeightDoubleElementEffect.prototype.setExpandedState=function(state){this.expanded=state;}
SetHeightDoubleElementEffect.prototype.isExpanded=function(){return this.expanded;}
SetHeightDoubleElementEffect.prototype.getElement=function(){return this.el;}
SetHeightDoubleElementEffect.prototype.quickCollapse=function(){if(this.expanded||this.effectInterval){if(this.effectInterval){clearInterval(this.effectInterval);this.effectInterval=null;}
if(this.setHidden)
this.el.style.visibility='hidden';if(this.setDisplayNone)
this.el.style.display="none";this.expanded=false;}}
SetHeightDoubleElementEffect.prototype.toggleExpansion=function(){if(this.effectInterval)
return;this.el.style.height=(this.expanded?this.toHeight:this.fromHeight)+"px";if(this.setHidden)
this.el.style.visibility='visible';var _expanded=this.expanded;this.startEffect();return _expanded;}
SetHeightDoubleElementEffect.prototype.renderEffect=function(pos,cFrame){if(this.expanded){this.el.style.height=this.toHeight+Math.round(pos*(this.fromHeight-this.toHeight))+"px";if(this.el2)
this.el2.style.height=this.toHeight2+Math.round(pos*(this.fromHeight2-this.toHeight2))+"px";}else{var height=this.fromHeight+Math.round(pos*(this.toHeight-this.fromHeight));this.el.style.height=height+"px";if(this.keepCenteredWinHeight){var y=Math.floor((this.keepCenteredWinHeight-height)/2);if(y<0)
y=0;this.el.style.top=(y+this.centerOffsetTop)+"px";}
if(this.el2)
this.el2.style.height=this.fromHeight2+Math.round(pos*(this.toHeight2-this.fromHeight2))+"px";}}
SetHeightDoubleElementEffect.prototype.renderEffectDone=function(){this.expanded=!this.expanded;if(this.setHidden&&!this.expanded){this.el.style.visibility='hidden';}
var self=this;if(this.effectEndFunction)
this.effectEndFunction(self);}
function SetWidthElementEffect(el,fromWidth,toWidth,callback,duration,keepCenteredWinWidth,centerOffsetLeft){SetWidthElementEffect.base.constructor.call(this);this.effectDuration=duration?duration:0.3;this.el=el;this.fromWidth=fromWidth;this.toWidth=toWidth;this.effectEndFunction=callback;this.expanded=false;this.keepCenteredWinWidth=keepCenteredWinWidth;this.centerOffsetLeft=centerOffsetLeft;}
SetWidthElementEffect.inherits(BaseEffect);SetWidthElementEffect.prototype.setExpandedState=function(state){this.expanded=state;}
SetWidthElementEffect.prototype.isExpanded=function(){return this.expanded;}
SetWidthElementEffect.prototype.getElement=function(){return this.el;}
SetWidthElementEffect.prototype.quickCollapse=function(){if(this.expanded||this.effectInterval){if(this.effectInterval){clearInterval(this.effectInterval);this.effectInterval=null;}
this.expanded=false;}}
SetWidthElementEffect.prototype.toggleExpansion=function(){if(this.effectInterval)
return;this.el.style.width=(this.expanded?this.toWidth:this.fromWidth)+"px";if(this.setHidden)
this.el.style.visibility='visible';var _expanded=this.expanded;this.startEffect();return _expanded;}
SetWidthElementEffect.prototype.renderEffect=function(pos,cFrame){if(this.expanded){this.el.style.width=this.toWidth+Math.round(pos*(this.fromWidth-this.toWidth))+"px";}else{var width=this.fromWidth+Math.round(pos*(this.toWidth-this.fromWidth));this.el.style.width=width+"px";if(this.keepCenteredWinWidth){var left=Math.floor((this.keepCenteredWinWidth-(width))/2)+this.centerOffsetLeft;if(left<0)
left=0;this.el.style.marginLeft=left+"px";}}}
SetWidthElementEffect.prototype.renderEffectDone=function(){var self=this;if(this.effectEndFunction)
this.effectEndFunction(self);}
function ElementShaker(idElement,repeats,arrayMovements,shakerDoneCallback,fSkipHorizontal){this.element=document.getElementById(idElement);this.repeats=repeats;this.arrayMovements=arrayMovements;this.fSkipHorizontal=fSkipHorizontal;this.cLength=arrayMovements.length/3;this.counter=-1;this.cCycle=0;this.shakerDoneCallback=shakerDoneCallback;this.callback();}
ElementShaker.prototype.callback=function(){this.counter++;if(this.counter*3>=this.arrayMovements.length){if(this.repeats!=0){this.cCycle++;if(this.cCycle==this.repeats){if(this.shakerDoneCallback)
this.shakerDoneCallback();return;}}
this.counter=0;}
var dx=this.arrayMovements[this.counter*3];var dy=this.arrayMovements[this.counter*3+1];var timeout=this.arrayMovements[this.counter*3+2];var oldX=this.element.offsetLeft;var oldY=this.element.offsetTop;if(!this.fSkipHorizontal)
this.element.style.marginLeft=(oldX+dx)+"px";this.element.style.top=(oldY+dy)+"px";var self=this;setTimeout(function(){self.callback();},timeout);}
