//window.onload = function(){ // Puzzle.init(document.getElementById("puzzle"), "Puzzle/puzzle.jpg", {w:80, h:80}); // // // Puzzle.onTime = function(ms) // { // var txtTime = document.getElementById("txtTime"); // txtTime.value = GetTime(ms); // } // Puzzle.onComplete = function(ms) // { // alert("Gone in " + GetTime(ms)); // Puzzle.stop(); // } // Puzzle.start(); // }; var Puzzle = { puzFrame : null, c : 0, r : 0, fw : 0, fh : 0, bsz : null, blks : null, started : false, img : null, moves : 0, startTime : 0, timerID : null, bar : null, init : function(frame, puzFile, size) { if ((frame === null) && (Puzzle.puzFrame === null)) { return; } if (Puzzle.puzFrame === null) { Puzzle.fw = getW(frame); Puzzle.fh = getH(frame); Puzzle.puzFrame = document.createElement("div"); frame.appendChild(Puzzle.puzFrame); Puzzle.puzFrame.style.background = "transparent"; Puzzle.puzFrame.style.position = "relative"; Puzzle.puzFrame.style.width = Puzzle.fw + "px"; Puzzle.puzFrame.style.height = Puzzle.fh + "px"; Puzzle.onMove = new Function(); Puzzle.onComplete = new Function(); Puzzle.onTime = new Function(); } // Puzzle.bar = document.createElement("img"); // Puzzle.bar.src = "./images/bar.gif"; // Puzzle.puzFrame.appendChild(Puzzle.bar); // Puzzle.bar.style.marginLeft = "auto"; // Puzzle.bar.style.marginRight = "auto"; // Puzzle.bar.style.zIndex = "500"; // setX(Puzzle.bar, Puzzle.fw/2 - 110); // setY(Puzzle.bar, Puzzle.fh/2 - 10); // Puzzle.bar.style.position = "absolute"; // Puzzle.showTimeBar(true); Puzzle.img = puzFile; Puzzle.bsz = {w:size.w, h:size.h}; Puzzle.r = Math.floor(Puzzle.fh / Puzzle.bsz.h); Puzzle.c = Math.floor(Puzzle.fw / Puzzle.bsz.w); Puzzle.blks = [Puzzle.c*Puzzle.r]; for (var i = 0; i < Puzzle.r; i++) { for (var j = 0; j < Puzzle.c; j++) { var b = document.createElement("div"); Puzzle.puzFrame.appendChild(b); b.style.background = "url(" + puzFile + ") no-repeat top left"; b.style.position = "absolute"; b.style.borderTop= "solid 1px #c0c0c0"; b.style.borderLeft= "solid 1px #c0c0c0"; var by = i * Puzzle.bsz.h; var bx = j * Puzzle.bsz.w; b.style.zIndex = b.i = b.ci = i*Puzzle.c + j; Puzzle.blks[b.i] = {x : bx, y : by, blk : b}; b.style.backgroundPosition = (-bx) + "px " + (-by) + "px"; b.style.width = Puzzle.bsz.w + "px"; b.style.height = Puzzle.bsz.h + "px"; setX(b, bx); setY(b, by); } } if (window.opera) { document.body.style.background = document.body.style.background; } // Puzzle.showTimeBar(false); }, // showTimeBar : function(show) // { // if (show) // { // Puzzle.bar.style.display = "inline"; // Puzzle.bar.style.visibility = "visible"; // Puzzle.bar.style.zIndex = "500"; // } // else // { // Puzzle.bar.style.display = "none"; // Puzzle.bar.style.hidden = "visible"; // Puzzle.bar.style.zIndex = "0"; // } // }, dragStartEvt : function() { Drag.obj.style.zIndex = 400; }, dragEndEvt : function(nx, ny) { var ex = nx + Puzzle.bsz.w/2; var ey = ny + Puzzle.bsz.h/2; Drag.obj.style.zIndex = 0; var ii = 0; ii = Math.floor(ex / Puzzle.bsz.w); var jj = 0; jj = Math.floor(ey / Puzzle.bsz.h); var dropBlk = Puzzle.blks[jj*Puzzle.c + ii]; var dragBlk = Puzzle.blks[this.ci]; Puzzle.swop(dropBlk, dragBlk); Puzzle.moves++; if (Puzzle.onMove) Puzzle.onMove(Puzzle.moves); if (Puzzle.isSolved()) { Puzzle.stop(); Puzzle.onComplete(Puzzle.calcTime()); } }, isSolved : function() { for (var i = 0; i < Puzzle.blks.length; i++) { if (Puzzle.blks[i].blk.ci !== Puzzle.blks[i].blk.i) return false; } return true; }, swop : function(b1, b2) { var blk = {x: b1.x, y: b1.y, blk: b1.blk, ci : b1.blk.ci}; b1.blk.style.zIndex = b1.blk.ci = b2.blk.ci; setX(b1.blk, b2.x); setY(b1.blk, b2.y); b2.blk.style.zIndex = b2.blk.ci = blk.ci; setX(b2.blk, blk.x); setY(b2.blk, blk.y); b1.blk = b2.blk; b2.blk = blk.blk; }, start : function() { // Puzzle.showTimeBar(true); // Puzzle.started = false; Puzzle.scramble(); for (var i = 0; i < Puzzle.blks.length; i++) { var b = Puzzle.blks[i].blk; Drag.init(b, null, 0, Puzzle.fw - Puzzle.bsz.w, 0, Puzzle.fh - Puzzle.bsz.h); b.onDragStart = Puzzle.dragStartEvt; b.onDragEnd = Puzzle.dragEndEvt; } // Puzzle.scramble(); // Puzzle.scramble(); Puzzle.moves = 0; Puzzle.startTime = (new Date()).getTime(); Puzzle.doTimer(); Puzzle.started = true; // Puzzle.doTimer(); // Puzzle.showTimeBar(false); }, stop : function(cleanup) { window.clearTimeout(Puzzle.timerID); Puzzle.started = false; if (cleanup) { Puzzle.puzFrame.innerHTML =""; Puzzle.blks = []; } else { for (var i = 0; i < Puzzle.blks.length; i++) { var b = Puzzle.blks[i].blk; Drag.stop(b); b.onDragStart = new Function(); b.onDragEnd = new Function(); if (cleanup) Puzzle.puzFrame.removeChild(b); } } //if (cleanup) Puzzle.blks = []; }, doTimer : function() { Puzzle.calcTime(); Puzzle.timerID = window.setTimeout('Puzzle.doTimer()', 1000); }, calcTime : function() { var currTime = (new Date()).getTime(); var tm = currTime - Puzzle.startTime; Puzzle.onTime(tm); return tm; }, contains : function(array, value) { for (var i = 0; i < array.length; i++) { if (array[i] == value) return true; } return false; }, scramble : function() { var randoms = new Array(Puzzle.blks.length); for (var n = 0; n < Puzzle.blks.length; n++) { var value = Math.floor(Math.random() * Puzzle.blks.length); while (Puzzle.contains(randoms, value)) value = Math.floor(Math.random() * Puzzle.blks.length); randoms[n] = value; } for (var i = 0; i < Puzzle.blks.length; i++) { var b1 = Puzzle.blks[i]; var b2 = Puzzle.blks[randoms[i]]; Puzzle.swop(b1, b2); } }, change : function(sz) { // Puzzle.showTimeBar(true); // Puzzle.tempTimerID = window.setTimeout("Puzzle.realChange({w:" + sz.w + ",h:" + sz.h + "})", 50); Puzzle.stop(true); // for (var i = 0; i < Puzzle.blks.length; i++) // { // var b = Puzzle.blks[i]; // Puzzle.puzFrame.removeChild(b.blk); // } //Puzzle.puzFrame.innerHTML =""; Puzzle.init(document.getElementById("puzzle"), Puzzle.img, sz); // Puzzle.showTimeBar(false); }, // realChange : function(sz) // { // window.clearTimeout(Puzzle.tempTimerID); // Puzzle.stop(); // Puzzle.puzFrame.innerHTML =""; // Puzzle.init(document.getElementById("puzzle"), Puzzle.img, sz); // Puzzle.showTimeBar(false); // }, tempTimerID : 0, solve : function(restore) { if (!Puzzle.started) return; for (var i = 0; i < Puzzle.blks.length; i++) { var b = Puzzle.blks[i]; b.blk.style.zIndex = b.i; setX(b.blk, Puzzle.blks[b.blk.i].x); setY(b.blk, Puzzle.blks[b.blk.i].y); } if (restore) { Puzzle.tempTimerID = window.setTimeout('Puzzle.restore()', 3000); } }, restore : function() { window.clearTimeout(Puzzle.tempTimerID); for (var i = 0; i < Puzzle.blks.length; i++) { var b = Puzzle.blks[i]; b.blk.style.zIndex = b.ci; setX(b.blk, Puzzle.blks[b.blk.ci].x); setY(b.blk, Puzzle.blks[b.blk.ci].y); } }, onMove : null, onComplete : null, onTime : null }; var Drag = { obj : null, init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper) { o.onmousedown = Drag.start; o.hmode = bSwapHorzRef ? false : true ; o.vmode = bSwapVertRef ? false : true ; o.root = oRoot && oRoot !== null ? oRoot : o ; if (o.hmode && isNaN(parseInt(o.root.style.left, 10))) {o.root.style.left = "0px";} if (o.vmode && isNaN(parseInt(o.root.style.top, 10))) {o.root.style.top = "0px";} if (!o.hmode && isNaN(parseInt(o.root.style.right, 10))) {o.root.style.right = "0px";} if (!o.vmode && isNaN(parseInt(o.root.style.bottom, 10))) {o.root.style.bottom = "0px";} o.minX = typeof minX != 'undefined' ? minX : null; o.minY = typeof minY != 'undefined' ? minY : null; o.maxX = typeof maxX != 'undefined' ? maxX : null; o.maxY = typeof maxY != 'undefined' ? maxY : null; o.xMapper = fXMapper ? fXMapper : null; o.yMapper = fYMapper ? fYMapper : null; o.root.onDragStart = new Function(); o.root.onDragEnd = new Function(); o.root.onDrag = new Function(); }, stop : function(o) { o.onmousedown = new Function(); }, start : function(e) { var o = Drag.obj = this; e = Drag.fixE(e); var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom); var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right ); o.root.onDragStart(x, y); o.lastMouseX = e.clientX; o.lastMouseY = e.clientY; if (o.hmode) { if (o.minX != null) o.minMouseX = e.clientX - x + o.minX; if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX; } else { if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x; if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x; } if (o.vmode) { if (o.minY != null) o.minMouseY = e.clientY - y + o.minY; if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY; } else { if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y; if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y; } document.onmousemove = Drag.drag; document.onmouseup = Drag.end; return false; }, drag : function(e) { e = Drag.fixE(e); var o = Drag.obj; var ey = e.clientY; var ex = e.clientX; var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom); var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right ); var nx, ny; if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX); if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX); if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY); if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY); nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1)); ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1)); if (o.xMapper) nx = o.xMapper(y) else if (o.yMapper) ny = o.yMapper(x) Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px"; Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px"; Drag.obj.lastMouseX = ex; Drag.obj.lastMouseY = ey; Drag.obj.root.onDrag(nx, ny); return false; }, end : function() { document.onmousemove = null; document.onmouseup = null; Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"])); Drag.obj = null; }, fixE : function(e) { if (typeof e == 'undefined') e = window.event; if (typeof e.layerX == 'undefined') e.layerX = e.offsetX; if (typeof e.layerY == 'undefined') e.layerY = e.offsetY; return e; } }; function getStyle( elem, name ) { if (elem.style[name]) return elem.style[name]; else if (elem.currentStyle) return elem.currentStyle[name]; else if (document.defaultView && document.defaultView.getComputedStyle) { name = name.replace(/([A-Z])/g,"-$1"); name = name.toLowerCase(); var s = document.defaultView.getComputedStyle(elem,""); return s && s.getPropertyValue(name); } else return null; } function getW(elem) { return parseInt( getStyle( elem, "width" ) ); } function getH(elem) { return parseInt( getStyle( elem, "height" ) ); } function setX(elem, pos) { elem.style.left = pos + "px"; } function setY(elem, pos) { elem.style.top = pos + "px"; } function GetTime(ms) { var ss = Math.floor((ms)/1000); var mm = Math.floor(ss/60); ss = ss%60; var hh = Math.floor(mm/60); mm = mm%60; return (hh<10?'0':'') + hh.toString() + ':' + (mm<10?'0':'') + mm.toString() + ':' + (ss<10?'0':'') + ss.toString(); } function EvalSound(soundobj) { var thissound=LocalGetElementById(soundobj); try { if (thissound) thissound.Play(); } catch(Error) {/*alert("error playing sound " + Error.toString());*/} } var frame = LocalGetElementById("divPuzzuka"); var req; var PuzzukaForm = { form : null, puzzle : null, puzzleID : null, shown : false, shownOnce : false, divTimer : null, spnTimer : null, closeImage : null, startBtn : null, cheatBtn : null, create : function() { puzzukaFrame.style.backgroundColor = "transparent"; puzzukaFrame.style.backgroundImage = "url('http://www.puzzuka.com/images/" + imgName + "')"; //http://www.puzzuka.com/images/480x360.jpg')"; puzzukaFrame.style.cursor = "pointer"; puzzukaFrame.style.zIndex = "5000"; PuzzukaForm.form = document.createElement("div"); PuzzukaForm.form.id = "puzzBox"; PuzzukaForm.form.style.opacity = "0"; PuzzukaForm.form.style.filter = "alpha(opacity=100)"; PuzzukaForm.form.style.display = "none"; puzzukaFrame.appendChild(PuzzukaForm.form); PuzzukaForm.form.style.background = "#000000"; PuzzukaForm.form.style.border = "solid 1px #feab2e"; PuzzukaForm.form.style.position = "fixed"; PuzzukaForm.form.style.width = "404px"; PuzzukaForm.form.style.height = "382px"; PuzzukaForm.form.style.top = "50%"; PuzzukaForm.form.style.left = "50%"; PuzzukaForm.form.style.marginLeft = "-200px"; PuzzukaForm.form.style.marginTop = "-180px"; PuzzukaForm.form.style.zIndex = "10000"; PuzzukaForm.form.style.cursor = "default"; PuzzukaForm.form.onmouseover = function(e) { e = e || window.event; e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; }; // PuzzukaForm.form.onmouseout = function(e) { e = e || window.event; e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; hide(PuzzukaForm.form); }; puzzukaFrame.onmouseover = function(e) { if ((!PuzzukaForm.shown) && (!PuzzukaForm.shownOnce)) { show(PuzzukaForm.form); PuzzukaForm.shownOnce = PuzzukaForm.shown = true; } } puzzukaFrame.onclick = function(e) { if (!PuzzukaForm.shown) { show(PuzzukaForm.form); PuzzukaForm.shown = true; } } PuzzukaForm.divTimer = document.createElement("div"); //PuzzukaForm.divTimer.id = "divPuzukaTimer"; PuzzukaForm.divTimer.style.width = "100px"; PuzzukaForm.divTimer.style.height = "16px"; PuzzukaForm.divTimer.style.color = "#feab2e"; PuzzukaForm.divTimer.style.fontWeight = "bold"; PuzzukaForm.divTimer.style.fontFamily = "verdana, arial, sans-serif"; PuzzukaForm.divTimer.style.fontSize = "10pt"; //PuzzukaForm.divTimer.style.float = "left"; //PuzzukaForm.divTimer.style.background="red"; PuzzukaForm.divTimer.style.margin = "3px 0px 3px 3px"; //PuzzukaForm.divTimer.contentEditable = "true"; //PuzzukaForm.divTimer.innerHtml = "00.00.00"; PuzzukaForm.form.appendChild(PuzzukaForm.divTimer); PuzzukaForm.spnTimer = document.createElement("span"); PuzzukaForm.spnTimer.innerHTML = "00.00.00"; PuzzukaForm.divTimer.appendChild(PuzzukaForm.spnTimer); var linkHome = document.createElement("a"); linkHome.setAttribute("href", "http://www.puzzuka.com"); linkHome.setAttribute("title", "Join the challenge to solve the world's largest puzzle"); linkHome.setAttribute("target", "_blank"); linkHome.innerHTML = "Play on www.Puzzuka.com"; linkHome.style.width = "250px"; linkHome.style.height = "16px"; linkHome.style.color = "#feab2e"; linkHome.style.fontWeight = "bold"; linkHome.style.fontFamily = "verdana, arial, sans-serif"; linkHome.style.fontSize = "10pt"; linkHome.style.float = "right"; linkHome.style.marginLeft = "50px"; PuzzukaForm.divTimer.appendChild(linkHome); //var divImg = document.createElement("div"); //divImg.style.float = "right"; //divImg.style.margin = "3px 3px 3px 0px"; //PuzzukaForm.form.appendChild(divImg); PuzzukaForm.closeImage = document.createElement("img"); PuzzukaForm.form.appendChild(PuzzukaForm.closeImage); PuzzukaForm.closeImage.style.position = "absolute"; PuzzukaForm.closeImage.style.top = "3px"; PuzzukaForm.closeImage.style.right = "3px"; PuzzukaForm.closeImage.style.zIndex = "10500"; PuzzukaForm.closeImage.style.cursor = "pointer"; PuzzukaForm.closeImage.onclick = function(e) { if (PuzzukaForm.shown) { e = e || window.event; e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; hide(PuzzukaForm.form); PuzzukaForm.shown = false; } }; PuzzukaForm.closeImage.onmouseover = function(e) { e = e || window.event; e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; }; // PuzzukaForm.closeImage.onmouseout = function(e) { e = e || window.event; e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; }; //PuzzukaForm.closeImage.setAttribute("onclick", "javascript: var d = LocalGetElementById('divPuzzuka');if (d){d.style.display='none';"); PuzzukaForm.closeImage.setAttribute("src", "http://www.puzzuka.com/images/Closesml.png"); PuzzukaForm.closeImage.setAttribute("alt", "Close"); PuzzukaForm.puzzle = document.createElement("div"); PuzzukaForm.form.appendChild(PuzzukaForm.puzzle); PuzzukaForm.puzzle.style.width = "400px"; PuzzukaForm.puzzle.style.height = "320px"; PuzzukaForm.puzzle.style.background = "transparent"; PuzzukaForm.puzzle.style.float = "left"; PuzzukaForm.puzzle.style.border = "solid 1px #303030"; PuzzukaForm.puzzle.onmouseover = function(e) { e = e || window.event; e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; }; // PuzzukaForm.puzzle.onmouseout = function(e) { e = e || window.event; e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; }; var bar = document.createElement("div"); PuzzukaForm.form.appendChild(bar); bar.style.width = "400px"; bar.style.height = "40px"; bar.style.float = "left"; bar.style.padding = "5px 5px 5px 5px"; PuzzukaForm.startBtn = document.createElement("input"); //PuzzukaForm.startBtn.value = "Start"; PuzzukaForm.startBtn.type = "button"; PuzzukaForm.startBtn.className = "button"; PuzzukaForm.startBtn.style.width = "100px"; PuzzukaForm.startBtn.style.height = "30px"; PuzzukaForm.startBtn.style.margin = "0px 10px 0px 0px"; PuzzukaForm.startBtn.style.color = "#81a4f6"; PuzzukaForm.startBtn.style.fontWeight = "bold"; PuzzukaForm.startBtn.style.background = "url(http://www.Puzzuka.com/App_Themes/Default/images/butorange.png)"; PuzzukaForm.startBtn.style.fontFamily = "verdana, arial, sans-serif"; PuzzukaForm.startBtn.style.fontSize = "10pt"; PuzzukaForm.startBtn.style.cursor = "pointer"; PuzzukaForm.startBtn.style.border = "solid 1px #25222d"; PuzzukaForm.startBtn.style.height = "25px"; PuzzukaForm.startBtn.onclick = function() { PuzzukaForm.startBtn.disabled = true; Puzzle.start(); } bar.appendChild(PuzzukaForm.startBtn); PuzzukaForm.cheatBtn = document.createElement("input"); //PuzzukaForm.cheatBtn.value = "Cheat"; PuzzukaForm.cheatBtn.type = "button"; PuzzukaForm.cheatBtn.className = "button"; PuzzukaForm.cheatBtn.style.width = "100px"; PuzzukaForm.cheatBtn.style.height = "30px"; PuzzukaForm.cheatBtn.style.color = "#81a4f6"; PuzzukaForm.cheatBtn.style.fontWeight = "bold"; PuzzukaForm.cheatBtn.style.background = "url(http://www.Puzzuka.com/App_Themes/Default/images/butred.png)"; PuzzukaForm.cheatBtn.style.fontFamily = "verdana, arial, sans-serif"; PuzzukaForm.cheatBtn.style.fontSize = "10pt"; PuzzukaForm.cheatBtn.style.cursor = "pointer"; PuzzukaForm.cheatBtn.style.border = "solid 1px #25222d"; PuzzukaForm.cheatBtn.style.height = "25px"; PuzzukaForm.cheatBtn.onclick = function() { // //PuzzukaForm.form.innerHTML =""; // PuzzukaForm.form.removeChild(PuzzukaForm.puzzle); // PuzzukaForm.startBtn.style.display = "none"; // PuzzukaForm.cheatBtn.style.display = "none"; //// PuzzukaForm.form.removeChild(PuzzukaForm.startBtn); //// PuzzukaForm.form.removeChild(PuzzukaForm.cheatBtn); // PuzzukaForm.form.style.background = "#000000"; // PuzzukaForm.form.style.backgroundImage = "url('http://www.puzzuka.com/images/300x250.jpg)"; // // var scr = document.createElement("script"); // scr.type = "text/javascript"; // scr.src = "http://www.puzzuka.com/GetPuzzle.ashx?post=someID"; // PuzzukaForm.form.appendChild(scr); Puzzle.solve(true); } bar.appendChild(PuzzukaForm.cheatBtn); Puzzle.init(PuzzukaForm.puzzle, "http://www.puzzuka.com/Puzzles/" + PuzzukaForm.puzzleID + ".jpg", {w:80, h:80}); Puzzle.onComplete = function(ms) { PuzzukaForm.startBtn.disabled = false; //PuzzukaForm.closeImage.click(); PuzzukaForm.form.style.display="none"; PuzzukaForm.shown = false; window.open("http://www.puzzuka.com/Complete.aspx?t=" + ms.toString()); } Puzzle.onTime = function(ms) { PuzzukaForm.spnTimer.innerHTML = GetTime(ms); } PuzzukaText.SetTextAll(); } } function LocalGetElementById(elementId) { if (document.getElementById) { return document.getElementById(elementId); } else if (document.all) { return document.all[elementId]; } else return null; } function LocalGetElementByTagName(element, tagName) { var elements = LocalGetElementsByTagName(element, tagName); if (elements && elements.length > 0) { return elements[0]; } else return null; } function LocalGetElementsByTagName(element, tagName) { if (element && tagName) { if (element.getElementsByTagName) { return element.getElementsByTagName(tagName); } if (element.all && element.all.tags) { return element.all.tags(tagName); } } return null; } function show( elem ) { //var elem = LocalGetElementById( id ); if( supportsOpacity( elem )) { // first set 0% opacity to make it completely transparent setOpacity( elem, 0 ); // when we set display = "block" it's still invisible elem.style.display = "block"; // call the function to gradually increase opacity fadeIn( elem.id ); } else { // can't modify opacity, so just make it visible... elem.style.display = "block"; } } function hide( elem ) { //var elem = LocalGetElementById( id ); if( supportsOpacity( elem )) { // call the function to gradually increase opacity fadeOut( elem.id ); } else { // can't modify opacity, so just make it visible... elem.style.display="none"; } } function supportsOpacity( el ) { if ( el.style.opacity != undefined ) return true; if( el.style.MozOpacity != undefined ) return true; if ( el.style.filter != undefined ) return true; return false; } function setOpacity( el, opaciLevel ) { if ( el.style.opacity ) { el.style.opacity = opaciLevel; } else if( el.style.MozOpacity != undefined ) { el.style.MozOpacity = opaciLevel; } else if ( el.style.filter != undefined ) { var oplvl = Math.round(opaciLevel*100); el.style.filter="alpha(opacity=" + oplvl + ")"; } } function fadeIn( id, currentOpacity ) { var counterLimit = 10; var el = LocalGetElementById( id ); if( !currentOpacity ) { currentOpacity = 1; } if( currentOpacity > 10 ) { return; } setOpacity( el, ( currentOpacity/counterLimit ) ); currentOpacity++; var func = "fadeIn( '" + id + "', " + currentOpacity + ")"; window.setTimeout( func, 50); } function fadeOut( id, currentOpacity ) { var counterLimit = 10; var el = LocalGetElementById( id ); if( !currentOpacity ) { currentOpacity = 10; } if( currentOpacity == 1 ) { el.style.display="none"; return; } setOpacity( el, ( currentOpacity/counterLimit ) ); currentOpacity--; var func = "fadeOut( '" + id + "', " + currentOpacity + ")"; window.setTimeout( func, 50); } var PuzzukaText = { SetTextAll : function() { PuzzukaForm.closeImage.title = "Close this box"; //PuzzukaForm.closeImage.setAttribute("title", "Close this box"); PuzzukaForm.startBtn.value = "Start"; PuzzukaForm.cheatBtn.value = "Cheat"; } } var puzzukaFrame = LocalGetElementById("divPuzzuka"); var req; if (puzzukaFrame){PuzzukaForm.puzzleID = "6cce3810-d0ad-4b39-afe0-48fa5ff0ba7d";var imgName='480x360.jpg';PuzzukaForm.create();}