/////////////////////////////////////////////////////////////////////////////////////////////////////////// // *** **** //an object built on the // //{ * } PRESENTS //Dynamic Layer Object // // **OFT **** //sophisticated layer/element targeting and animation object // // } * RODUCT //which provides the core functionality needed in most DHTML applications/ // **** * // 19990604 // // http://daverwin.homepage.com // Copyright (C) 1999 Dan Steinman // // http://daverwin.homepage.com// Distributed under the terms of the GNU Library General Public License// // FREEWARE FREEWARE FREEWARE // Available at http://www.dansteinman.com/dynapi/ // /////////////////////////////////////////////////////////////////////////////////////////////////////// // see http://daverwin.homepage.com/ for details // // send comments to daverwin.hotmail.com // //////////////////////////////////////////////////////////////////////////////////////////////////// function Puzzle(n,g,W,H,q,v){this.ma=false var c = '#FFFFFF' this.mixem=null this.x=new Array() this.y=new Array() this.n=new Array() this.name=n this.f=false this.To="" this.g=0 this.w=W/3 this.h=H/3 this.css =css(n+"kDiv",q,v,W+20,H+60,c) + css(n+"mDiv",10,50,W,H,c) this.div ='
\n' this.x[8]=2 this.y[8]=2 this.move=PrivateMove this.mov=PuzzleMov this.scramble=PuzzleScramble this.solve=PuzzleSolve this.mixemup=PrivateMixemup this.stop=PrivateStop } function PuzzleMov(i){ if(this.ma)return this.ma=true this.f=false this.To=setTimeout(this.name+'.ma=false',300) eval(this.name+'.move(i)') if(!this.f){ clearTimeout(this.To) this.ma=false} } function PuzzleScramble(){ if(this.ma)return this.ma=true eval('setTimeout("'+this.name+'.stop()",8000)') eval('this.mixem=setInterval("'+this.name+'.mixemup()",300)') } function PuzzleSolve(){ if(this.ma)return this.ma=true setTimeout(this.name+'.ma=false',4000) for(i=0;i<3;i++){for(j=0;j<3;j++){ if(i*3+j<8)eval(this.n[i*3+j]+'.slideTo(this.w * j,this.h * i)') this.y[i*3+j]=i this.x[i*3+j]=j}} } function PrivateStop(){ eval('clearInterval('+this.mixem+')') this.ma=false } function PrivateMixemup(){ this.f=false while(!this.f){ eval(this.name+'.move('+this.g+++')') if(this.g==8)this.g=-1} } function PrivateMove(n){ var x = this.x[n] var y = this.y[n] var w = this.x[8] var z = this.y[8] if(((x==w)|(y==z))&(((x-1)==w)|((x+1)==w)|((y-1)==z)|((y+1)==z))){ this.f=true eval(this.n[n]+'.slideTo(this.w*w,this.h*z,20,40)') this.x[n] = w this.y[n] = z this.x[8] = x this.y[8] = y} }