n = (document.layers) ? 1:0 ie = (document.all) ? 1:0 browserVer = parseInt(navigator.appVersion); // get the user out of any frames they might be stuck in if (top != self) { top.location = self.location; } |
function WM_netscapeCssFix() { |
if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) { document.location = "puzzleb.htm"; } } |
function WM_netscapeCssFixCheckIn() { |
if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) { if (typeof document.WM == 'undefined'){ document.WM = new Object; } if (typeof document.WM.WM_scaleFont == 'undefined') { document.WM.WM_netscapeCssFix = new Object; document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth; document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight; } window.onresize = WM_netscapeCssFix; } } |
WM_netscapeCssFixCheckIn() |
function makeLayer(id,left,top,width,height,content,visibility) { |
if (n) { var newLayer = document.layers[id] = new Layer(width) eval("document."+id+" = newLayer") newLayer.left = left newLayer.top = top newLayer.name= id if (height!=null) newLayer.clip.height = height newLayer.visibility = (visibility=='hidden')? 'hide' : 'show' if (content) { newLayer.document.open() newLayer.document.write(content) newLayer.document.close() } } else if (ie) { var str = '\n<DIV id='+id+' style="position:absolute; left:'+left+'; top:'+top+'; width:'+width if (height!=null) { str += '; height:'+height str += '; clip:rect(0,'+width+','+height+',0)' } if (visibility) str += '; visibility:'+visibility str += ';">'+((content)?content:'')+'</DIV>' document.body.insertAdjacentHTML("BeforeEnd",str) } } |
function hideLayer(layerName){ |
if (n) { document.layers[layerName].visibility="hidden" } else if (ie) { document.all[layerName].style.visibility="hidden" } } |
function squareLayer(id) { |
if (n) { this.css = document.layers[id] this.x = this.css.left this.y = this.css.top } else if (ie) { this.css = document.all[id].style this.x = this.css.pixelLeft this.y = this.css.pixelTop } this.obj = id + "Object" eval(this.obj + "=this") this.moveBy = squareLayerMoveBy this.moveTo = squareLayerMoveTo this.slideBy = squareLayerSlideBy this.slideTo = squareLayerSlideTo this.slide = squareLayerSlide } |
function squareLayerMoveBy(x,y) { |
this.x += x this.css.left = this.x this.y += y this.css.top = this.y } |
function squareLayerMoveTo(x,y) { |
this.x = x this.css.left = this.x this.y = y this.css.top = this.y } |
function squareLayerSlideBy(distx,disty,inc,speed,fn) { |
if (!this.slideActive) { var endx = this.x + distx var endy = this.y + disty var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc var dx = distx/num var dy = disty/num this.slideActive = 1 this.slide(dx,dy,endx,endy,speed,fn) } } |
function squareLayerSlideTo(inc,speed,fn) { |
if (!this.slideActive) { endx = this.endx endy = this.endy var distx = this.endx - this.x var disty = this.endy - this.y var num = (Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc)+Math.round(Math.random()*(50-1))+1 var dx = distx/num var dy = disty/num this.slideActive = 1 this.slide(dx,dy,endx,endy,speed,fn) } } |
function squareLayerSlide(dx,dy,endx,endy,speed,fn) { |
if (this.slideActive && (Math.floor(Math.abs(dx))+1<Math.floor(Math.abs(endx-this.x)) || Math.floor(Math.abs(dy))+1<Math.floor(Math.abs(endy-this.y)))) { this.moveBy(dx,dy) setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+speed+",\""+fn+"\")",speed) } else { this.slideActive = 0 this.moveTo(endx,endy) eval(fn) } } |
function init() { |
// initialize squares for (var i=0;i<=15;i++) { eval('square'+i+' = new squareLayer("square'+i+'DIV")') } } |
function closeIt() { close();} |
function clicsquare(rang) |
{ if ( no < 0 ) { return } lasuite[no] = rang var modulox = (rang - 1) % 4 eval('square'+no+'.endx = 100 * modulox') eval('square'+no+'.endy = lestops[rang -1]') eval('square'+no+'.slideTo(40,20,"")') if ( no == 0 ) { for (var i=0;i<=15;i++) { if ( lasuite[i] != suiteok[i] ) { eval('makeLayer("perdu'+jeu+'",475,200,150,200,"<IMG SRC=perdu.jpg WIDTH=150 HEIGHT=50 BORDER=0><BR> <A HREF=javascript:rejouer();><B>GAME OVER </B>!</A>")') return } } eval('makeLayer("gagne",475,200,150,50,"<IMG SRC=gagne.jpg WIDTH=150 HEIGHT=50 BORDER=0>")') } no-- } |
function rejouer() |
{ for (no=0;no<16;no++) { eval('square'+no+'.endx = 500') eval('square'+no+'.endy = 300') eval('square'+no+'.slideTo(40,20,"")') } eval('hideLayer("perdu'+jeu+'")') no = 15 jeu++ } |