1var down = false; 2function toggleDown() { 3 if(down==false){ 4 down=true; 5 t1 = new Tween(document.getElementById('menu_holder').style, 'top', Tween.strongEaseOut, -68, 0, .6, 'px'); 6 t1.start(); 7 } 8} 9function toggleUp() { 10 if(down==true){ 11 down=false; 12 t1 = new Tween(document.getElementById('menu_holder').style, 'top', Tween.strongEaseIn, 0, -68, .4, 'px'); 13 t1.start(); 14} 15} 16/********************************************************************** 17TERMS OF USE - EASING EQUATIONS 18Open source under the BSD License. 19Copyright (c) 2001 Robert Penner 20JavaScript version copyright (C) 2006 by Philippe Maegerman 21All rights reserved. 22 23Redistribution and use in source and binary forms, with or without 24modification, are permitted provided that the following conditions are 25met: 26 27 * Redistributions of source code must retain the above copyright 28notice, this list of conditions and the following disclaimer. 29 * Redistributions in binary form must reproduce the above 30copyright notice, this list of conditions and the following disclaimer 31in the documentation and/or other materials provided with the 32distribution. 33 * Neither the name of the author nor the names of contributors may 34be used to endorse or promote products derived from this software 35without specific prior written permission. 36 37THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 38"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 39LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 40A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 41OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 44DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 45THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 46(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 49*****************************************/ 50function Delegate() {} 51Delegate.create = function (o, f) { 52 var a = new Array() ; 53 var l = arguments.length ; 54 for(var i = 2 ; i < l ; i++) a[i - 2] = arguments[i] ; 55 return function() { 56 var aP = [].concat(arguments, a) ; 57 f.apply(o, aP); 58 } 59} 60 61Tween = function(obj, prop, func, begin, finish, duration, suffixe){ 62 this.init(obj, prop, func, begin, finish, duration, suffixe) 63} 64var t = Tween.prototype; 65 66t.obj = new Object(); 67t.prop=''; 68t.func = function (t, b, c, d) { return c*t/d + b; }; 69t.begin = 0; 70t.change = 0; 71t.prevTime = 0; 72t.prevPos = 0; 73t.looping = false; 74t._duration = 0; 75t._time = 0; 76t._pos = 0; 77t._position = 0; 78t._startTime = 0; 79t._finish = 0; 80t.name = ''; 81t.suffixe = ''; 82t._listeners = new Array(); 83t.setTime = function(t){ 84 this.prevTime = this._time; 85 if (t > this.getDuration()) { 86 if (this.looping) { 87 this.rewind (t - this._duration); 88 this.update(); 89 this.broadcastMessage('onMotionLooped',{target:this,type:'onMotionLooped'}); 90 } else { 91 this._time = this._duration; 92 this.update(); 93 this.stop(); 94 this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'}); 95 } 96 } else if (t < 0) { 97 this.rewind(); 98 this.update(); 99 } else { 100 this._time = t; 101 this.update(); 102 } 103} 104t.getTime = function(){ 105 return this._time; 106} 107t.setDuration = function(d){ 108 this._duration = (d == null || d <= 0) ? 100000 : d; 109} 110t.getDuration = function(){ 111 return this._duration; 112} 113t.setPosition = function(p){ 114 this.prevPos = this._pos; 115 var a = this.suffixe != '' ? this.suffixe : ''; 116 this.obj[this.prop] = Math.round(p) + a; 117 this._pos = p; 118 this.broadcastMessage('onMotionChanged',{target:this,type:'onMotionChanged'}); 119} 120t.getPosition = function(t){ 121 if (t == undefined) t = this._time; 122 return this.func(t, this.begin, this.change, this._duration); 123}; 124t.setFinish = function(f){ 125 this.change = f - this.begin; 126}; 127t.geFinish = function(){ 128 return this.begin + this.change; 129}; 130t.init = function(obj, prop, func, begin, finish, duration, suffixe){ 131 if (!arguments.length) return; 132 this._listeners = new Array(); 133 this.addListener(this); 134 if(suffixe) this.suffixe = suffixe; 135 this.obj = obj; 136 this.prop = prop; 137 this.begin = begin; 138 this._pos = begin; 139 this.setDuration(duration); 140 if (func!=null && func!='') { 141 this.func = func; 142 } 143 this.setFinish(finish); 144} 145t.start = function(){ 146 this.rewind(); 147 this.startEnterFrame(); 148 this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'}); 149 //alert('in'); 150} 151t.rewind = function(t){ 152 this.stop(); 153 this._time = (t == undefined) ? 0 : t; 154 this.fixTime(); 155 this.update(); 156} 157t.fforward = function(){ 158 this._time = this._duration; 159 this.fixTime(); 160 this.update(); 161} 162t.update = function(){ 163 this.setPosition(this.getPosition(this._time)); 164 } 165t.startEnterFrame = function(){ 166 this.stopEnterFrame(); 167 this.isPlaying = true; 168 this.onEnterFrame(); 169} 170t.onEnterFrame = function(){ 171 if(this.isPlaying) { 172 this.nextFrame(); 173 setTimeout(Delegate.create(this, this.onEnterFrame), 0); 174 } 175} 176t.nextFrame = function(){ 177 this.setTime((this.getTimer() - this._startTime) / 1000); 178 } 179t.stop = function(){ 180 this.stopEnterFrame(); 181 this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'}); 182} 183t.stopEnterFrame = function(){ 184 this.isPlaying = false; 185} 186 187t.continueTo = function(finish, duration){ 188 this.begin = this._pos; 189 this.setFinish(finish); 190 if (this._duration != undefined) 191 this.setDuration(duration); 192 this.start(); 193} 194t.resume = function(){ 195 this.fixTime(); 196 this.startEnterFrame(); 197 this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'}); 198} 199t.yoyo = function (){ 200 this.continueTo(this.begin,this._time); 201} 202 203t.addListener = function(o){ 204 this.removeListener (o); 205 return this._listeners.push(o); 206} 207t.removeListener = function(o){ 208 var a = this._listeners; 209 var i = a.length; 210 while (i--) { 211 if (a[i] == o) { 212 a.splice (i, 1); 213 return true; 214 } 215 } 216 return false; 217} 218t.broadcastMessage = function(){ 219 var arr = new Array(); 220 for(var i = 0; i < arguments.length; i++){ 221 arr.push(arguments[i]) 222 } 223 var e = arr.shift(); 224 var a = this._listeners; 225 var l = a.length; 226 for (var i=0; i<l; i++){ 227 if(a[i][e]) 228 a[i][e].apply(a[i], arr); 229 } 230} 231t.fixTime = function(){ 232 this._startTime = this.getTimer() - this._time * 1000; 233} 234t.getTimer = function(){ 235 return new Date().getTime() - this._time; 236} 237Tween.backEaseIn = function(t,b,c,d,a,p){ 238 if (s == undefined) var s = 1.70158; 239 return c*(t/=d)*t*((s+1)*t - s) + b; 240} 241Tween.backEaseOut = function(t,b,c,d,a,p){ 242 if (s == undefined) var s = 1.70158; 243 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 244} 245Tween.backEaseInOut = function(t,b,c,d,a,p){ 246 if (s == undefined) var s = 1.70158; 247 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 248 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 249} 250Tween.elasticEaseIn = function(t,b,c,d,a,p){ 251 if (t==0) return b; 252 if ((t/=d)==1) return b+c; 253 if (!p) p=d*.3; 254 if (!a || a < Math.abs(c)) { 255 a=c; var s=p/4; 256 } 257 else 258 var s = p/(2*Math.PI) * Math.asin (c/a); 259 260 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 261 262} 263Tween.elasticEaseOut = function (t,b,c,d,a,p){ 264 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 265 if (!a || a < Math.abs(c)) { a=c; var s=p/4; } 266 else var s = p/(2*Math.PI) * Math.asin (c/a); 267 return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b); 268 } 269Tween.elasticEaseInOut = function (t,b,c,d,a,p){ 270 if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) var p=d*(.3*1.5); 271 if (!a || a < Math.abs(c)) {var a=c; var s=p/4; } 272 else var s = p/(2*Math.PI) * Math.asin (c/a); 273 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 274 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; 275} 276 277Tween.bounceEaseOut = function(t,b,c,d){ 278 if ((t/=d) < (1/2.75)) { 279 return c*(7.5625*t*t) + b; 280 } else if (t < (2/2.75)) { 281 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 282 } else if (t < (2.5/2.75)) { 283 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 284 } else { 285 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 286 } 287} 288Tween.bounceEaseIn = function(t,b,c,d){ 289 return c - Tween.bounceEaseOut (d-t, 0, c, d) + b; 290 } 291Tween.bounceEaseInOut = function(t,b,c,d){ 292 if (t < d/2) return Tween.bounceEaseIn (t*2, 0, c, d) * .5 + b; 293 else return Tween.bounceEaseOut (t*2-d, 0, c, d) * .5 + c*.5 + b; 294 } 295 296Tween.strongEaseInOut = function(t,b,c,d){ 297 return c*(t/=d)*t*t*t*t + b; 298 } 299 300Tween.regularEaseIn = function(t,b,c,d){ 301 return c*(t/=d)*t + b; 302 } 303Tween.regularEaseOut = function(t,b,c,d){ 304 return -c *(t/=d)*(t-2) + b; 305 } 306 307Tween.regularEaseInOut = function(t,b,c,d){ 308 if ((t/=d/2) < 1) return c/2*t*t + b; 309 return -c/2 * ((--t)*(t-2) - 1) + b; 310 } 311Tween.strongEaseIn = function(t,b,c,d){ 312 return c*(t/=d)*t*t*t*t + b; 313 } 314Tween.strongEaseOut = function(t,b,c,d){ 315 return c*((t=t/d-1)*t*t*t*t + 1) + b; 316 } 317 318Tween.strongEaseInOut = function(t,b,c,d){ 319 if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; 320 return c/2*((t-=2)*t*t*t*t + 2) + b; 321 }