├── steam_appid.txt ├── bin ├── compile_js_file.bat ├── cwebp.exe ├── dwebp.exe ├── nwjc.exe ├── freeglut.dll └── convert_to_cwebp.bat ├── graphics ├── logo.psd └── camera │ └── static_test5.webm ├── script ├── lib │ ├── steam_api.dll │ ├── steam_api.lib │ ├── steam_api64.lib │ ├── greenworks-osx32.node │ ├── greenworks-win32.node │ ├── greenworks-win64.node │ ├── greenworks-linux32.node │ └── greenworks-linux64.node ├── save.js ├── ScriptLoader.js ├── sound.js ├── debug.js ├── jquery.timer.js ├── SeamlessLoop.js ├── loading.js ├── variables.js ├── animation.js ├── ui.js ├── ai.js └── main.js ├── 1080.css ├── package.json ├── 640.css ├── .gitattributes ├── _gitattributes ├── README.md ├── LICENSE ├── feed.css ├── changelog.txt ├── feed.html └── jquery.min.js /steam_appid.txt: -------------------------------------------------------------------------------- 1 | 319510 -------------------------------------------------------------------------------- /bin/compile_js_file.bat: -------------------------------------------------------------------------------- 1 | nwjc %1 %1.bin 2 | pause -------------------------------------------------------------------------------- /bin/cwebp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/bin/cwebp.exe -------------------------------------------------------------------------------- /bin/dwebp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/bin/dwebp.exe -------------------------------------------------------------------------------- /bin/nwjc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/bin/nwjc.exe -------------------------------------------------------------------------------- /bin/freeglut.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/bin/freeglut.dll -------------------------------------------------------------------------------- /graphics/logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/graphics/logo.psd -------------------------------------------------------------------------------- /script/lib/steam_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/script/lib/steam_api.dll -------------------------------------------------------------------------------- /script/lib/steam_api.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/script/lib/steam_api.lib -------------------------------------------------------------------------------- /script/lib/steam_api64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/script/lib/steam_api64.lib -------------------------------------------------------------------------------- /graphics/camera/static_test5.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/graphics/camera/static_test5.webm -------------------------------------------------------------------------------- /script/lib/greenworks-osx32.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/script/lib/greenworks-osx32.node -------------------------------------------------------------------------------- /script/lib/greenworks-win32.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/script/lib/greenworks-win32.node -------------------------------------------------------------------------------- /script/lib/greenworks-win64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/script/lib/greenworks-win64.node -------------------------------------------------------------------------------- /script/lib/greenworks-linux32.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/script/lib/greenworks-linux32.node -------------------------------------------------------------------------------- /script/lib/greenworks-linux64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Slynchy/FNAF-JS/HEAD/script/lib/greenworks-linux64.node -------------------------------------------------------------------------------- /1080.css: -------------------------------------------------------------------------------- 1 | #map{ 2 | zoom: 1; 3 | } 4 | 5 | #power{ 6 | zoom: 1.7; 7 | } 8 | 9 | #record{ 10 | zoom: 1; 11 | } 12 | 13 | #timekeeper{ 14 | zoom: 1.2; 15 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FNAF-JS", 3 | "main": "feed.html", 4 | "window": { 5 | "toolbar": false, 6 | "width": 1920, 7 | "height": 1080 8 | } 9 | } -------------------------------------------------------------------------------- /640.css: -------------------------------------------------------------------------------- 1 | #map{ 2 | zoom: 0.49; 3 | } 4 | 5 | #power{ 6 | zoom: 0.69; 7 | } 8 | 9 | #record{ 10 | zoom: 0.5; 11 | } 12 | 13 | #timekeeper{ 14 | zoom: 0.7; 15 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /_gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /bin/convert_to_cwebp.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Source: oX Triangle & echo.https://groups.google.com/a/webmproject.org/forum/#!msg/webp-discuss/pakZCY0J6Qw/8mYUac2t6OgJ 3 | pause 4 | pushd %1 5 | for /f "delims=" %%n in ('dir /b /s /a-d-h-s') do IF NOT ".webp" == "%%~xn" ( 6 | "%~dp0cwebp.exe" -q 80 -mt -m 6 -sharpness 0 -hint graph "%%n" -o "%%n.webp") 7 | popd 8 | for %%i in (%1\*.*) do IF NOT ".webp" == "%%~xi" del "%%i" 9 | Rename %1\* *. 10 | Rename %1\* *. 11 | Rename %1\* *.webp -------------------------------------------------------------------------------- /script/save.js: -------------------------------------------------------------------------------- 1 | // 2 | // save.js 3 | // The JS for saves 4 | // 5 | // Last updated - 05/08/2015 6 | // 7 | // Most save stuff is handled by the code that needs it. 8 | // This is mainly for constants. 9 | 10 | debuglog("Initializing save.js..."); 11 | 12 | /* Comment this out if neeeded */ // if(DEBUG_MODE) localStorage["fnaf-js-savegame.night"] = "7"; 13 | 14 | /* Set save for first time */ 15 | if((typeof localStorage["fnaf-js-savegame.night"])=="undefined") localStorage["fnaf-js-savegame.night"]="1"; 16 | if((typeof localStorage["fnaf-js-savegame.stars"])=="undefined") localStorage["fnaf-js-savegame.stars"]="0"; 17 | 18 | console.log("Saved game loaded! Night is #"+localStorage["fnaf-js-savegame.night"]+" and has "+localStorage["fnaf-js-savegame.stars"]+" achievements"); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FNAF-JS 2 | The first FNAF game in JavaScript/HTML. 3 | 4 | Ported without reverse engineering of the MMF code; port was done entirely by "reflection" 5 | 6 | Pretty much finished, just needs method of auth. 7 | 8 | Will use NW.js for distribution as executable for Windows, Mac and Linux, as well as Greenworks for DRM to verify the user owns FNAF on Steam. Alternatively, a PHP script. 9 | 10 | Includes used: 11 | - JQuery 12 | - NW.js 13 | - Greenworks 14 | - JQuery timer 15 | - WebP converter 16 | - SeamlessLoop.js 17 | - Script loader by chrysls 18 | - JSDoc3 (for documentation) 19 | 20 | # How to run 21 | 22 | - ~~Click "Download Zip" on the right hand side~~ 23 | - ~~Extract the zip file somewhere.~~ 24 | - ~~Open feed.html in Google Chrome (other browsers may work but are unsupported).~~ 25 | 26 | In an effort to "clean" my Github repositories of copyrighted content, this is no longer playable as the graphics/sounds are no longer provided. The code is still there, however. 27 | 28 | # Documentation 29 | Preliminary documentation can be found here: http://slynch.ovh/FNAF-JS-Doc/ 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Sam Lynch, Amduat Games 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of FNAF-JS nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /script/ScriptLoader.js: -------------------------------------------------------------------------------- 1 | // 2 | // SpriptLoader.js 3 | // The JS for loading JS 4 | // by chrysls on Github 5 | // 6 | // Last updated - 04/08/2015 7 | 8 | var Loader = {}; //namespace 9 | Loader.starttime = Date.now(); 10 | Loader.timer = {}; // contains timers for scripts 11 | Loader.scripts = []; // contains called script references 12 | Loader.version = '0.0.0'; 13 | Loader.loaded = 0; 14 | Loader.finish = function(){}; 15 | Loader.load = function(url, callback) { 16 | // handle object or path 17 | var classname = null; 18 | var properties = null; 19 | try { 20 | // make sure we only load once 21 | if (Loader.scripts.indexOf(url) == -1) { 22 | // note that we loaded already 23 | Loader.scripts.push(url); 24 | var script = document.createElement("script"); 25 | script.src = url+'?v='+Loader.version; 26 | script.type = "text/javascript"; 27 | script.charset = 'utf-8'; 28 | document.querySelector('head').appendChild(script); // add script tag to head element 29 | 30 | // was a callback requested 31 | if (callback) { 32 | // test for onreadystatechange to trigger callback 33 | script.onreadystatechange = function () { 34 | if (script.readyState == 'loaded' || script.readyState == 'complete') { 35 | callback(); 36 | } 37 | } 38 | // test for onload to trigger callback 39 | script.onload = function () { 40 | Loader.loaded += 1; 41 | callback(); 42 | if (Loader.loaded == Loader.scripts.length) { 43 | console.info('[Loader] All ('+Loader.loaded+') scripts are loaded.', (Date.now()-Loader.starttime+"ms")); 44 | Loader.finish(); 45 | } 46 | return; 47 | } 48 | // safari doesn't support either onload or readystate, create a timer 49 | // only way to do this in safari 50 | /*if ((Prototype.Browser.WebKit && navigator.userAgent.match(/Version\/[12]/)) || Prototype.Browser.Opera) { // sniff 51 | Loader.timer[url] = setInterval(function() { 52 | if (/loaded|complete/.test(document.readyState)) { 53 | clearInterval(Loader.timer[url]); 54 | callback(); // call the callback handler 55 | } 56 | }, 10); 57 | }*/ 58 | } else { 59 | script.onload = function () { 60 | Loader.loaded += 1; 61 | if (Loader.loaded == Loader.scripts.length) { 62 | console.info('[Loader] All ('+Loader.loaded+') scripts are loaded.', (Date.now()-Loader.starttime+"ms")); 63 | Loader.finish(); 64 | } 65 | } 66 | } 67 | } else { 68 | if (callback) { callback(); } 69 | } 70 | } catch (e) { 71 | alert('Loader: ' + e); 72 | } 73 | } -------------------------------------------------------------------------------- /script/sound.js: -------------------------------------------------------------------------------- 1 | // 2 | // sound.js 3 | // The JS for sound engine 4 | // Very basic one I made 5 | // 6 | // Last updated - 11/05/2015 7 | 8 | // playSound(filename, volume, loop?, channelnumber) - Play a sound 9 | // ShowAudioChannels() - Shows audio that different channels are playing. 10 | // loopSound() - Used by playSound to loop sounds using eventlisteners 11 | // stopSound(channelnumber) - Stop a sound on a specific channel or all of them. 12 | // stopAmbientSound() - Stops all the ambient sound; for gameovers. 13 | 14 | /** 15 | * @file The JS for sound engine 16 | * @author Sam Lynch 17 | * @version 1.0.0 18 | * @readonly 19 | * @copyright (c) 2015 Amduat Games 20 | */ 21 | 22 | debuglog("Initializing sound.js..."); 23 | 24 | /** @constant 25 | @type {float} 26 | @default 27 | @readonly 28 | */ 29 | var DEFAULT_VOLUME = 0.3; 30 | 31 | var ambiance1 = new SeamlessLoop(); 32 | var ambiance2 = new SeamlessLoop(); 33 | ambiance1.addUri("sounds/Buzz_Fan_Florescent2.wav", 9600, "ambiancetrack1"); 34 | ambiance2.addUri("sounds/ambience2.wav", 60000, "ambiancetrack2"); 35 | 36 | /** @namespace 37 | * @description The namespace for accessing the sound engine. */ 38 | var sound=new function(){ 39 | 40 | /** @function playSound 41 | * @description Plays the specified sound file from sounds[] 42 | * @param {string} src Sound filename 43 | * @param {float} [volume] Volume of the sound, defaults to DEFAULT_VOLUME if unspecified 44 | * @param {boolean} [loop] Loop the sound if true 45 | */ 46 | this.playSound=function(src, volume, loop) { 47 | if (DEBUG_MODE) return debuglog("Suppressing "+src+" due to debug mode"); 48 | if ((typeof loop) == "undefined" || loop == false) { 49 | loop = false; 50 | }; 51 | if ((typeof volume) == "undefined") { 52 | volume = DEFAULT_VOLUME; 53 | }; 54 | if ((typeof src) == "undefined") { 55 | return debuglog("playSound(src [string], volume [float], loop? [bool]) error - no sound specified"); 56 | }; 57 | for (x = 0; x < sounds.length; x++) { 58 | if (sounds[x].name == src) { 59 | sounds[x].file.removeEventListener("ended", sound.loopSound); 60 | if(sounds[x].file.paused==false){ 61 | sounds[x].file.pause(); 62 | sounds[x].file.currentTime = 0; 63 | }; 64 | sounds[x].file.volume = volume; 65 | sounds[x].file.loop = loop; 66 | if (loop == true) { 67 | sounds[x].file.addEventListener('ended', sound.loopSound, false); 68 | }; 69 | sounds[x].file.play(); 70 | return debuglog("Sound " + sounds[x].name + " now playing at " + (volume * 100) + "% volume."); 71 | }; 72 | }; 73 | return debuglog("Sound " + src + " not found, is it in sounds[]?"); 74 | }; 75 | 76 | /** @function loopSound 77 | * @description Called by eventlistener to replay the sound */ 78 | this.loopSound=function(){this.currentTime = 0;this.play();}; 79 | 80 | /** @function stopSound 81 | * @description Stops the specified sound 82 | * @param {string} src Sound filename */ 83 | this.stopSound=function(src){if((typeof src)=="undefined") {console.log("stopSound() error - no sound specified\nProceeding to stop all sound..."); for(x=0;x"; 46 | debugdiv.innerHTML += "Bonnie location: CAM-"+roomClosenessBunny[animatronicStates[1].currentRoomArray].name+"
"; 47 | debugdiv.innerHTML += "Freddy location: CAM-"+roomClosenessFreddy[animatronicStates[2].currentRoomArray].name+"
"; 48 | debugdiv.innerHTML += "Foxxy state: "+animatronicStates[3].state+"

"; 49 | debugdiv.innerHTML += "Chica timer: "+chicatimer+" out of "+chicadifficultyarray[chicadifficulty]+"
"; 50 | debugdiv.innerHTML += "Bonnie timer: "+bunnytimer+" out of "+bunnydifficultyarray[bunnydifficulty]+"
"; 51 | debugdiv.innerHTML += "Freddy timer: "+freddytimer+" out of "+freddydifficultyarray[freddydifficulty]+"
"; 52 | debugdiv.innerHTML += "Foxxy timer: "+foxxytimer+" out of "+foxydifficultyarray[foxydifficulty]+"
"; 53 | }; 54 | 55 | if (DEBUG_MODE==true){ 56 | document.getElementById("debugmode").innerHTML = "DEBUG MODE"; 57 | $(document).ready(function() { 58 | $(document).bind('keydown',function(e){ 59 | if(e.keyCode == 88) { 60 | playfreddygameoveranimation("freddyoffice"); 61 | }; 62 | }); 63 | }); 64 | $(window).on("error",function(msg,url,linenumber) { 65 | sound.playSound("error.wav",1.0); 66 | document.getElementById("debugmode").innerHTML+="
ERROR - SEE CONSOLE" 67 | return true; 68 | }); 69 | } else { 70 | $(window).on("error",function(msg,url,linenumber) { 71 | sound.playSound("error.wav",1.0); 72 | document.getElementById("debugmode").innerHTML+="ERROR - SEE CONSOLE - "+msg+"
" 73 | return true; 74 | }); 75 | }; 76 | 77 | /** @function debuglog 78 | * @description Shows a message in the console if DEBUG_MODE is enabled. 79 | * @param {string} string Message to show 80 | * @param {auto} [additional] Variable to pass onto console message 81 | * @param {auto} [additional2] Second variable to pass onto console message 82 | */ 83 | function debuglog(string,additional,additional2){ 84 | if(DEBUG_MODE==false) return; 85 | if((typeof string) == "undefined"){ 86 | return; 87 | }; 88 | if((typeof additional)=="undefined"){ 89 | string = cssString.concat(string); 90 | return console.log(string,debugCSS); 91 | } else if(((typeof additional2)=="undefined") && additional){ 92 | return console.log(string,additional); 93 | }; 94 | console.log(string,additional,additional); 95 | }; 96 | 97 | /** @function printSave 98 | * @description Prints the night the player is on into the console. 99 | */ 100 | function printSave(){ 101 | return console.log("Player is on night %s ",localStorage["fnaf-js-savegame.night"]); 102 | }; 103 | -------------------------------------------------------------------------------- /script/jquery.timer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jquery.timer.js 3 | * 4 | * Copyright (c) 2011 Jason Chavannes 5 | * 6 | * http://jchavannes.com/jquery-timer 7 | * 8 | * Permission is hereby granted, free of charge, to any person 9 | * obtaining a copy of this software and associated documentation 10 | * files (the "Software"), to deal in the Software without 11 | * restriction, including without limitation the rights to use, copy, 12 | * modify, merge, publish, distribute, sublicense, and/or sell copies 13 | * of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 23 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 24 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | */ 28 | 29 | ;(function($) { 30 | $.timer = function(func, time, autostart) { 31 | this.set = function(func, time, autostart) { 32 | this.init = true; 33 | if(typeof func == 'object') { 34 | var paramList = ['autostart', 'time']; 35 | for(var arg in paramList) {if(func[paramList[arg]] != undefined) {eval(paramList[arg] + " = func[paramList[arg]]");}}; 36 | func = func.action; 37 | } 38 | if(typeof func == 'function') {this.action = func;} 39 | if(!isNaN(time)) {this.intervalTime = time;} 40 | if(autostart && !this.active) { 41 | this.active = true; 42 | this.setTimer(); 43 | } 44 | return this; 45 | }; 46 | this.once = function(time) { 47 | var timer = this; 48 | if(isNaN(time)) {time = 0;} 49 | window.setTimeout(function() {timer.action();}, time); 50 | return this; 51 | }; 52 | this.play = function(reset) { 53 | if(!this.active) { 54 | if(reset) {this.setTimer();} 55 | else {this.setTimer(this.remaining);} 56 | this.active = true; 57 | } 58 | return this; 59 | }; 60 | this.pause = function() { 61 | if(this.active) { 62 | this.active = false; 63 | this.remaining -= new Date() - this.last; 64 | this.clearTimer(); 65 | } 66 | return this; 67 | }; 68 | this.stop = function() { 69 | this.active = false; 70 | this.remaining = this.intervalTime; 71 | this.clearTimer(); 72 | return this; 73 | }; 74 | this.toggle = function(reset) { 75 | if(this.active) {this.pause();} 76 | else if(reset) {this.play(true);} 77 | else {this.play();} 78 | return this; 79 | }; 80 | this.reset = function() { 81 | this.active = false; 82 | this.play(true); 83 | return this; 84 | }; 85 | this.clearTimer = function() { 86 | window.clearTimeout(this.timeoutObject); 87 | }; 88 | this.setTimer = function(time) { 89 | var timer = this; 90 | if(typeof this.action != 'function') {return;} 91 | if(isNaN(time)) {time = this.intervalTime;} 92 | this.remaining = time; 93 | this.last = new Date(); 94 | this.clearTimer(); 95 | this.timeoutObject = window.setTimeout(function() {timer.go();}, time); 96 | }; 97 | this.go = function() { 98 | if(this.active) { 99 | this.action(); 100 | this.setTimer(); 101 | } 102 | }; 103 | 104 | if(this.init) { 105 | return new $.timer(func, time, autostart); 106 | } else { 107 | this.set(func, time, autostart); 108 | return this; 109 | } 110 | }; 111 | })(jQuery); -------------------------------------------------------------------------------- /feed.css: -------------------------------------------------------------------------------- 1 | body { 2 | /* zoom:0.5;*/ 3 | width: 100%; 4 | height: 100%; 5 | background-color:black; 6 | margin-left:auto; 7 | margin-right:auto; 8 | overflow:hidden; 9 | /* image-rendering: pixelated; */ 10 | } 11 | ::-moz-selection{ 12 | background-color:Transparent; 13 | color:#000; 14 | } 15 | 16 | ::selection { 17 | background-color:Transparent; 18 | color:#000; 19 | } 20 | body::-moz-selection, 21 | body::selection { ... } 22 | #camerafeed { 23 | z-index:1; 24 | } 25 | 26 | #achievement1, #achievement2, #achievement3{ 27 | content:url(graphics/mainmenu/star.png); 28 | position:absolute; 29 | top:44%; 30 | width:3.7%; 31 | height:7.09%; 32 | image-rendering: pixelated; 33 | display: none; 34 | } 35 | 36 | #arrowleft{ 37 | height:4.81%; 38 | width:1.77%; 39 | position:absolute; 40 | content:url(graphics/mainmenu/customnight/arrowleft.png); 41 | } 42 | 43 | #arrowright{ 44 | height:4.81%; 45 | width:1.77%; 46 | position:absolute; 47 | content:url(graphics/mainmenu/customnight/arrowright.png); 48 | } 49 | 50 | #power { 51 | z-index:2; 52 | } 53 | 54 | #timekeeper { 55 | z-index:2; 56 | } 57 | 58 | #fan { 59 | top: 42.3%; 60 | } 61 | 62 | #record { 63 | display:block; 64 | } 65 | 66 | div.map { 67 | position:absolute; 68 | bottom: 0px; 69 | right: 150px; 70 | } 71 | 72 | div.main, img.main { 73 | position: absolute; 74 | width: 100%; 75 | height: 100%; 76 | top: 0; 77 | left: 0; 78 | } 79 | 80 | div.overlay { 81 | position: absolute; 82 | width: 98%; 83 | height: 100%; 84 | top: 0; 85 | left: 0; 86 | /* background-repeat: no-repeat;*/ 87 | } 88 | 89 | #static { 90 | /* background-image: url("graphics/camera/static_test3.jpg"); 91 | background: url('graphics/camera/static_test3.jpg') left center;*/ 92 | display:block; 93 | opacity:0.25; 94 | position:fixed; 95 | /* width: 125%; 96 | height: 125%; 97 | z-index:77; 98 | height:141px; 99 | margin-left:659px; 100 | top:73px; 101 | right: 265px; 102 | 103 | animation: play .8s steps(1280) infinite;*/ 104 | } 105 | 106 | #staticimg { 107 | display:block; 108 | width: 225%; 109 | height: 225%; 110 | } 111 | 112 | #map{ 113 | z-index:105; 114 | bottom:85px; 115 | right:2.5%; 116 | } 117 | 118 | #button-1a { 119 | position: absolute; 120 | width:45px; 121 | top:20px; 122 | left:110px; 123 | background-color:#107010; 124 | padding:6px; 125 | border: 3px solid white; 126 | } 127 | 128 | #button-1b{ 129 | position: absolute; 130 | width:45px; 131 | top:77px; 132 | left:85px; 133 | background-color:#101010; 134 | padding:6px; 135 | border: 3px solid white; 136 | } 137 | 138 | #button-1c{ 139 | position: absolute; 140 | width:45px; 141 | top:155px; 142 | left:55px; 143 | background-color:#101010; 144 | padding:6px; 145 | border: 3px solid white; 146 | } 147 | 148 | #button-2a{ 149 | position: absolute; 150 | width:41px; 151 | bottom:97px; 152 | left:106px; 153 | background-color:#101010; 154 | padding:6px; 155 | border: 3px solid white; 156 | } 157 | 158 | #button-2b{ 159 | position: absolute; 160 | width:41px; 161 | bottom:47px; 162 | left:106px; 163 | background-color:#101010; 164 | padding:6px; 165 | border: 3px solid white; 166 | } 167 | 168 | #button-5{ 169 | position: absolute; 170 | width:45px; 171 | top:94px; 172 | left:-27px; 173 | background-color:#101010; 174 | padding:6px; 175 | border: 3px solid white; 176 | } 177 | 178 | #button-7{ 179 | position: absolute; 180 | width:45px; 181 | top:104px; 182 | right:20px; 183 | background-color:#101010; 184 | padding:6px; 185 | border: 3px solid white; 186 | } 187 | 188 | #button-3{ 189 | position: absolute; 190 | width:45px; 191 | bottom:102px; 192 | left:16px; 193 | background-color:#101010; 194 | padding:6px; 195 | border: 3px solid white; 196 | } 197 | 198 | #button-4a{ 199 | position: absolute; 200 | width:41px; 201 | bottom:97px; 202 | left:214px; 203 | background-color:#101010; 204 | padding:6px; 205 | border: 3px solid white; 206 | } 207 | 208 | #button-4b{ 209 | position: absolute; 210 | width:41px; 211 | bottom:47px; 212 | left:214px; 213 | background-color:#101010; 214 | padding:6px; 215 | border: 3px solid white; 216 | } 217 | 218 | #button-6{ 219 | position: absolute; 220 | width:45px; 221 | bottom:121px; 222 | left:307px; 223 | background-color:#101010; 224 | padding:6px; 225 | border: 3px solid white; 226 | } 227 | 228 | #room { 229 | position: fixed; 230 | left:0; 231 | width: 98%; 232 | height: 100%; 233 | } 234 | 235 | .roomtest { 236 | -webkit-animation: play 7s linear infinite alternate; 237 | } 238 | 239 | @-webkit-keyframes play { 240 | from { -webkit-transform:translateX(-5%) } 241 | to { -webkit-transform:translateX(-20%) } 242 | } 243 | 244 | div.camera { 245 | position: absolute; 246 | bottom: 7px; 247 | left: 10px; 248 | font-family: Verdana, Arial, Helvetica, sans-serif; 249 | font-size: 7pt; 250 | color: #c0f0c0; 251 | text-shadow: #80c080 0 0 1px; 252 | width: 98%; 253 | height: 100%; 254 | } -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | *********************** 2 | ** FNAF-JS Changelog ** 3 | ** By Slynch ** 4 | *********************** 5 | 6 | Thirtieth Commit: 7 | - Started documentation process 8 | - Removed Greenworks code/binaries so people have to get it themselves 9 | 10 | Twenty-ninth Commit: 11 | - Fixed evals on most animations (courtesy of a tip from chrysls) 12 | - Fixed mistake on playpoweroutageanimation where it would always last 6~ seconds 13 | - Fixed misnamed soundPlay call in an animation 14 | - Fixed bug when "continuing" night 5 when you've beaten the game 15 | - Added error message for when not in debug mode 16 | - Made cssString a global variable so it isn't constantly remade every time debuglog is called 17 | - Tweaked difficulty slightly. May need further work 18 | - Adjusted main menu alignments 19 | - Removed pointless constant in save.js 20 | - Foxy's timer is now reduced by 1 whenever the player looks back to room 1C 21 | - Also moved from main thread to updatecurrentroom 22 | - Converted many things to WebP to lower filesize (30MB!!) 23 | - Added a graphics button on the main menu. Not sure whether to use it yet 24 | - Added randomised fading on main menu static 25 | - Need to implement this for camera static; could use same function? 26 | 27 | - Thirtieth commit will mark beta testing phase, in which all the kinks will be worked out. 28 | - After the bugs are fixed and the port is released, any additions will be quality-of-life ones or optimizations. 29 | 30 | Twenty-eighth Commit: 31 | - Finished custom night 32 | - Added main menu stars 33 | - Added error notifier in corner (for unnoticed errors) when in debug mode 34 | - Added check in main loop that if the difficulty of an AI is 0, don't update (for freddy on night 1/2 and custom nights) 35 | - Need to: 36 | - Add sine fading on static 37 | - Convert UI to WebP (and convert some back to PNG due to quality loss) 38 | - I want to finish this by 30th commit. 39 | 40 | Twenty-seventh Commit: 41 | - Added a script loader for HTML builds 42 | - Added sixth night and customise night (not yet implemented) 43 | - Fixed typo in debug display 44 | - Turned off JS error alert if running debug mode (console would be up anyway) 45 | - Added night 7 loading screen but can't find night 6? Will have to find that or make one. 46 | - Need to: 47 | - Add sine fading on static 48 | - Finish custom night implementation (should be easy enough) 49 | - Main menu stars on achievements 50 | - Note: using this video for reference https://www.youtube.com/watch?v=bnBS9Sxw1T8 since I don't actually play this game. 51 | 52 | Twenty-sixth Commit: 53 | - Re-enabled other AI 54 | - Improved debug display 55 | - Added Greenworks 56 | 57 | Twenty-fifth Commit: 58 | - Finished Fazbear 59 | - Added sounds for Chica in kitchen 60 | - Added random int from range function at bottom of main.js 61 | - Removed code that ran when 1!=1 62 | - Added a notice for when running in debug mode. 63 | - Tweaked debuginfo 64 | - Fixed gameover animation not lowering camera feed. 65 | - Added sounds for Fazbear moving around. 66 | 67 | Twenty-fourth Commit: 68 | - Added draft version of Freddy Fazbear! 69 | - I forgot the rest; check commits description 70 | 71 | Twenty-third Commit: 72 | - Fixed save.js not being loaded 73 | - Added animation.js for any animation code. 74 | - Added transitional animation. Only used on night start at the moment. 75 | - Commented console messages from SeamlessLoop to prevent clutter. 76 | - Again, probably more stuff I forgot. 77 | 78 | Twenty-second Commit: 79 | - Fixed endnight() function 80 | - Not completely; children cheering doesn't work. 81 | - Added day to loading screen 82 | - Fixed stopAmbientSound() not working/crashing the game on debug mode 83 | - Added debuglog() 84 | - Fixed gameover by power outage. 85 | - Probably some other stuff I forgot. 86 | 87 | Twenty-first Commit: 88 | - Added room names to map 89 | - Added sound for light switch not working 90 | - Added JS error alert catcher for testers to report errors without needing console up 91 | - Tweaked night 1 difficulty 92 | - Added WebP converter to /bin/ 93 | - Added SeamlessLoop.js for fixing the ambient track loops 94 | 95 | Twentieth Commit: 96 | - Added a changelog 97 | - Fixed "feedopen=true" bug, caused camerafeed to not open when foxxy appeared. 98 | - Added difficulty settings for nights 1-6 99 | - Updated sound engine: 100 | - Sounds are all preloaded for faster playback 101 | - Individual sounds can only be played one at a time (so no two of the same sound at the same time) 102 | - Hopefully this fixes sounds not playing back when game is run server-side. 103 | - Needs work on the functions; pauseSound() for example, to make it future-proof. 104 | - Added intro picture 105 | - Fixed highlighting bug. 106 | - Fixed new game not resetting to night 1. 107 | - Not an addition but a note; use %s, %i, %f inside console.log to show string, integer and float, respectively. 108 | - Example: flopper = "hello"; console.log("%s, my name is Sam",flopper); 109 | - Output is "hello, my name is Sam" in console. 110 | - Not sure if this is quicker than console.log(flopper + ", my name is Sam") though. 111 | - Some other additions I might have forgotten. -------------------------------------------------------------------------------- /script/SeamlessLoop.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file SeamlessLoop.js - Reproduces seamless loops on HTML5/Javascript 3 | * @author https://github.com/Hivenfour/SeamlessLoop 4 | * @version 2.0 5 | * @copyright (c) 2012 Main Software 6 | */ 7 | 8 | function SeamlessLoop() { 9 | this.is = { 10 | ff: Boolean(!(window.mozInnerScreenX == null) && /firefox/.test( navigator.userAgent.toLowerCase() )), 11 | ie: Boolean(document.all && !window.opera), 12 | opera: Boolean(window.opera), 13 | chrome: Boolean(window.chrome), 14 | safari: Boolean(!window.chrome && /safari/.test( navigator.userAgent.toLowerCase() ) && window.getComputedStyle && !window.globalStorage && !window.opera) 15 | }; 16 | /* console.debug("ff: " + this.is.ff); 17 | console.debug("ie: " + this.is.ie); 18 | console.debug("opera: " + this.is.opera); 19 | console.debug("chrome: " + this.is.chrome); 20 | console.debug("safari: " + this.is.safari); */ 21 | this._total = 0; 22 | this._load = 0; 23 | this.cb_loaded; 24 | this.cb_loaded_flag = new Boolean(); 25 | this.timeout; 26 | this.playDelay = -30; 27 | this.stopDelay = 30; 28 | if(this.is.chrome) this.playDelay = -25; 29 | if(this.is.chrome) this.stopDelay = 25; 30 | if(this.is.ff) this.playDelay = -25; 31 | if(this.is.ff) this.stopDelay = 85; 32 | if(this.is.opera) this.playDelay = 5; 33 | if(this.is.opera) this.stopDelay = 0; 34 | // console.debug(this.playDelay + ", " + this.stopDelay); 35 | this.next = 1; 36 | this.audios = new Array(); 37 | this.actual = new Array(); 38 | this.dropOld = new Boolean(); 39 | this.old; 40 | this._volume = 1; 41 | 42 | var t = this; 43 | this._eventCanplaythrough = function(audBool) { 44 | if(audBool == false) { 45 | audBool = true; 46 | t._load++; 47 | if(t._load == t._total) { 48 | t.loaded = true; 49 | if(t.cb_loaded_flag == true) { 50 | t.cb_loaded(); 51 | t.cb_loaded_flag = false; 52 | } 53 | } 54 | } 55 | }; 56 | 57 | this._eventPlaying = function(audMute) { 58 | setTimeout(function() { 59 | audMute.pause(); 60 | try { 61 | audMute.currentTime = 0; 62 | } catch (e){console.debug(e.message);}; 63 | }, t.stopDelay); 64 | 65 | if(t.dropOld == true) { 66 | setTimeout(function() { 67 | if(t.old.paused == false) { 68 | t.old.pause(); 69 | try { 70 | t.old.currentTime = 0; 71 | } catch (e){console.debug(e.message);}; 72 | } 73 | }, t.stopDelay); 74 | t.dropOld = false; 75 | } 76 | }; 77 | 78 | this._eventEnded = function(aud) { 79 | aud.volume = this._volume; 80 | }; 81 | 82 | this.doLoop = function() { 83 | var key = (this.next == 1 ? "_1" : "_2"); 84 | var antikey = (this.next == 1 ? "_2" : "_1"); 85 | 86 | var t = this; 87 | this.timeout = setTimeout(function() {t.doLoop();}, this.actual._length + this.playDelay); 88 | 89 | if(this.is.opera) this.actual[antikey].pause(); 90 | 91 | this.actual[key].play(); 92 | this.next *= -1; 93 | }; 94 | 95 | this.isLoaded = function() { 96 | return Boolean(this._load == this._total); 97 | }; 98 | } 99 | 100 | SeamlessLoop.prototype.start = function(id) { 101 | if(id != "") { 102 | this.actual = this.audios[id]; 103 | } 104 | this.doLoop(); 105 | }; 106 | 107 | SeamlessLoop.prototype.volume = function(vol) { 108 | if(typeof vol != "undefined") { 109 | this.actual._1.volume = vol; 110 | this.actual._2.volume = vol; 111 | this._volume = vol; 112 | } 113 | 114 | return vol; 115 | }; 116 | 117 | SeamlessLoop.prototype.stop = function() { 118 | clearTimeout(this.timeout); 119 | this.actual._1.currentTime = 0; 120 | this.actual._1.pause(); 121 | this.actual._2.currentTime = 0; 122 | this.actual._2.pause(); 123 | }; 124 | 125 | SeamlessLoop.prototype.callback = function(cb_loaded) { 126 | this.cb_loaded = cb_loaded; 127 | if(this.isLoaded() == true) cb_loaded(); 128 | else this.cb_loaded_flag = true; 129 | }; 130 | 131 | SeamlessLoop.prototype.update = function(id, sync) { 132 | //var key = (this.next == 1 ? "_1" : "_2"); 133 | var antikey = (this.next == 1 ? "_2" : "_1"); 134 | 135 | this.old = this.actual[antikey]; 136 | this.actual = this.audios[id]; 137 | if(sync == false) { 138 | if(this.old.paused == false) { 139 | this.dropOld = true; 140 | if(this.is.opera) this.old.pause(); 141 | } 142 | clearTimeout(this.timeout); 143 | this.doLoop(); 144 | } 145 | }; 146 | 147 | SeamlessLoop.prototype.addUri = function(uri, length, id) { 148 | this.audios[id] = new Array(); 149 | this.audios[id]._length = length; 150 | var t = this; 151 | this.audios[id]._1_isLoaded = new Boolean(); 152 | this.audios[id]._2_isLoaded = new Boolean(); 153 | this.audios[id]._1 = new Audio(uri); 154 | this.audios[id]._2 = new Audio(uri); 155 | this._total++; 156 | this.audios[id]._1.addEventListener("canplaythrough", function() {t._eventCanplaythrough(t.audios[id]._1_isLoaded);}); 157 | this.audios[id]._2.addEventListener("canplaythrough", function() {t._eventCanplaythrough(t.audios[id]._2_isLoaded);}); 158 | this.audios[id]._1.addEventListener("playing", function() {t._eventPlaying(t.audios[id]._2);}); 159 | this.audios[id]._2.addEventListener("playing", function() {t._eventPlaying(t.audios[id]._1);}); 160 | this.audios[id]._1.addEventListener("ended", function() {t._eventEnded(t.audios[id]._1);}); 161 | this.audios[id]._2.addEventListener("ended", function() {t._eventEnded(t.audios[id]._2);}); 162 | this.audios[id]._1.load(); 163 | this.audios[id]._2.load(); 164 | this.audios[id]._1.volume = this._volume; 165 | this.audios[id]._2.volume = this._volume; 166 | }; -------------------------------------------------------------------------------- /script/loading.js: -------------------------------------------------------------------------------- 1 | // 2 | // loading.js 3 | // The JS for loading the game (purely to reduce clutter) 4 | // Like seriously, I doubt this improves perf or anything. 5 | // 6 | // Last updated - 12/08/2015 7 | 8 | /** 9 | * @file Code for loading all files into variables 10 | * @author Sam Lynch 11 | * @version 1.0.0 12 | * @copyright (c) 2015 Amduat Games 13 | */ 14 | 15 | debuglog("Initializing loading.js..."); 16 | 17 | for(x=0;x<8;x++){ 18 | transitionimages[x] = new Image(); 19 | transitionimages[x].src = "graphics/transition/"+x+".webp"; 20 | }; 21 | 22 | /** @name sounds 23 | * @description The array of sound names and Audio() objects */ 24 | var sounds=[ 25 | {name: "chimes 2.wav",file: new Audio()}, // 0 26 | {name: "blip3.wav",file: new Audio()}, // 1 27 | {name: "CAMERA_VIDEO_LOA_60105303.wav",file: new Audio()}, // 2 28 | {name: "DOOR_POUNDING_ME_D0291401.wav",file: new Audio()}, // 3 29 | {name: "knock2.wav",file: new Audio()}, // 4 30 | {name: "pirate_song2.wav",file: new Audio()}, // 5 31 | {name: "powerdown.wav",file: new Audio()}, // 6 32 | {name: "put_down.wav",file: new Audio()}, // 7 33 | {name: "run.wav",file: new Audio()}, // 8 34 | {name: "SFXBible_12478.wav",file: new Audio()}, // 9 35 | {name: "static2.wav",file: new Audio()}, // 10 36 | {name: "windowscare.wav",file: new Audio()}, // 11 37 | {name: "XSCREAM.wav",file: new Audio()}, 38 | {name: "XSCREAM2.wav",file: new Audio()}, 39 | {name: "freddy/poweroutmusic.ogg",file: new Audio()}, 40 | {name: "error.wav",file: new Audio()}, 41 | {name: "kitchen1.wav",file: new Audio()}, 42 | {name: "kitchen2.wav",file: new Audio()}, 43 | {name: "kitchen3.wav",file: new Audio()}, 44 | {name: "kitchen4.wav",file: new Audio()}, 45 | {name: "Laugh_Giggle_Girl_1d.wav",file: new Audio()}, 46 | {name: "Laugh_Giggle_Girl_2d.wav",file: new Audio()}, 47 | {name: "Laugh_Giggle_Girl_8d.wav",file: new Audio()}, 48 | {name: "deep steps.wav",file: new Audio()} 49 | ]; 50 | 51 | for(x=0;x=1;x--){ 87 | foxydifficultyarray[x] = (baseFoxyTime += 2) 88 | }; 89 | for(x=20;x>=1;x--){ 90 | bunnydifficultyarray[x] = (baseBonnyTime += 2) //formerly 3 91 | }; 92 | for(x=20;x>=1;x--){ 93 | chicadifficultyarray[x] = (baseChicaTime += 2) //formerly 4 94 | }; 95 | for(x=20;x>=1;x--){ 96 | freddydifficultyarray[x] = (baseFreddyTime += 2) //formerly 4 97 | }; 98 | for(x=2;x<=20;x++){ 99 | bunnyChanceToMoveCloser[x] = (baseBunnyChanceToMoveCloser += 4.5) 100 | }; 101 | for(x=2;x<=20;x++){ 102 | chicaChanceToMoveCloser[x] = (baseChicaChanceToMoveCloser += 4.5) 103 | }; 104 | 105 | var mainThreadID; 106 | var play2aanimation=false; 107 | var storedselectedroom; 108 | 109 | var animatronicStates = [{name:"Chica",currentRoom:"1a",state:0,currentRoomArray:6}, 110 | {name:"Bonnie",currentRoom:"1a",state:0,currentRoomArray:6}, 111 | {name:"Freddy",currentRoom:"1a",state:0,currentRoomArray:6}, 112 | {name:"Foxxy",currentRoom:"1c",state:0,currentRoomArray:2} 113 | ]; 114 | 115 | var poweroutimg = []; 116 | var MAINBODY = $("#mainbody"); 117 | var mainmenu = $("#mainmenu"); 118 | var amduatlogo = $("#amduatlogo"); 119 | var mainmenufazbearanimdiv = $("#mainmenufazbearanim"); 120 | var roomdiv = $("#room"); 121 | var staticdiv = $("#static"); 122 | var staticimgdiv = document.getElementById("staticimg"); 123 | var mainmenustaticimgdiv = document.getElementById("mainmenustaticimg"); 124 | var recorddiv = $("#record"); 125 | var doorleftdiv = $("#doorleft"); 126 | var doorrightdiv = $("#doorright"); 127 | var doorbuttonsleftdiv = $("#doorbuttonsleft"); 128 | var doorbuttonsrightdiv = $("#doorbuttonsright"); 129 | var doorbuttonsleft_lightdiv = $("#doorbuttonsleft_light"); 130 | var doorbuttonsleft_doordiv = $("#doorbuttonsleft_door"); 131 | var doorbuttonsright_doordiv = $("#doorbuttonsright_door"); 132 | var doorbuttonsright_lightdiv = $("#doorbuttonsright_light"); 133 | var camerafeeddiv = $("#camerafeed"); 134 | var nightover5div = $("#nightover5"); 135 | var nightover6div = $("#nightover6"); 136 | //var officediv = $("#office"); 137 | var officemaindiv = $("#officemain"); 138 | 139 | var windowwidth = $( document ).width(); 140 | window.onresize = function(event) { 141 | windowwidth = $( document ).width(); 142 | }; 143 | 144 | var transitionimages = []; 145 | 146 | var fandiv = $("#fan"); 147 | var officecamerarightdiv = $("#officecameraright"); 148 | var officecameraleftdiv = $("#officecameraleft"); 149 | var numberonediv = $("#numberone"); 150 | var numbertwodiv = $("#numbertwo"); 151 | var numberthreediv = $("#numberthree"); 152 | var timehourdiv = $("#timehour"); 153 | var timehourextradiv = $("#timehourextra"); 154 | var powerusagediv = $("#powerusage"); 155 | var camerafeedanimationdiv = $("#camerafeedanimation"); 156 | var transitiondiv = document.getElementById("transistionanimation"); 157 | var officeX=0 158 | var officeXInterval; 159 | var officeXOtherInterval; 160 | var leftdooropen=false; // These two variables are actually "false = open" 161 | var rightdooropen=false; // and "true = closed/locked" 162 | var leftlighton=false; 163 | var rightlighton=false; 164 | var yArray = ["left","right"]; 165 | 166 | var camerafeedanimationimage = []; 167 | var doorleftanim = []; 168 | var doorrightanim = []; 169 | var powerusageimage = []; 170 | var powerusagenumbersimage = []; 171 | var timehourimage = []; 172 | var room2aimage = []; 173 | var room2afoxxyanim = []; 174 | var mainmenufazbear = []; 175 | var foxxyofficeanim = []; 176 | var foxxyofficeanimtimeout = []; 177 | var roomnameimages = []; 178 | 179 | var officelightstates = []; 180 | var officestates = []; 181 | var buttonleftstates = []; 182 | var buttonrightstates = []; 183 | 184 | var button1adiv = $("#button-1a"); 185 | var button1bdiv = $("#button-1b"); 186 | var button1cdiv = $("#button-1c"); 187 | var button2adiv = $("#button-2a"); 188 | var button2bdiv = $("#button-2b"); 189 | var button5div = $("#button-5"); 190 | var button7div = $("#button-7"); 191 | var button3div = $("#button-3"); 192 | var button4adiv = $("#button-4a"); 193 | var button4bdiv = $("#button-4b"); 194 | var button6div = $("#button-6"); 195 | var buttonopenclosecameradiv = $("#openclosecamera"); 196 | 197 | var currentRoom = "1a"; 198 | var currentRoomID = 0; 199 | var animatestatic = 0; 200 | var showrecord = false; 201 | var feedopen = false; 202 | var fananim =[]; 203 | var currentPower = 100; 204 | var currentPowerUsage = 0; 205 | var currenthour = 0; 206 | var hours = []; 207 | var timeCounter=0; 208 | var foxxyrunning = false; 209 | var foxxytimeout; 210 | var foxxytimer=0; 211 | var playedfoxxyrunninganimation=false; 212 | var foxxyrunninganimationtimeout = []; 213 | 214 | var roomImages = []; 215 | 216 | 217 | // roomstates: 0 = default, 1 = different, etc. 218 | var currRoomStates=[{name:"1a",roomstate:0}, 219 | {name:"1b",roomstate:0}, 220 | {name:"1c",roomstate:0}, 221 | {name:"2a",roomstate:0}, 222 | {name:"2b",roomstate:0}, 223 | {name:"5",roomstate:0,AIStates:[1,2]}, 224 | {name:"7",roomstate:0}, 225 | {name:"3",roomstate:0}, 226 | {name:"4a",roomstate:0}, 227 | {name:"4b",roomstate:0}, 228 | {name:"6",roomstate:0}, 229 | {name:"office",roomstate:0} 230 | ]; 231 | 232 | var rooms=[{name:"1a",movingcamera:true,leftadjustment:0}, 233 | {name:"1b",movingcamera:true,leftadjustment:12}, 234 | {name:"1c",movingcamera:true,leftadjustment:17}, 235 | {name:"2a",movingcamera:true,leftadjustment:22}, 236 | {name:"2b",movingcamera:true,leftadjustment:13}, 237 | {name:"5",movingcamera:true,leftadjustment:13}, 238 | {name:"7",movingcamera:true,leftadjustment:22}, 239 | {name:"3",movingcamera:false,leftadjustment:22}, 240 | {name:"4a",movingcamera:true,leftadjustment:22}, 241 | {name:"4b",movingcamera:true,leftadjustment:22}, 242 | {name:"6",movingcamera:false,leftadjustment:0} 243 | ]; 244 | 245 | // amountofimages is the amount of images, but the highest number will be 1 less than that number. 246 | // so image 4 in an array will be amountofimages-1 247 | var roomImagesIndex = [{name: "1a",amountofImages: 7}, 248 | {name: "1b",amountofImages: 6}, 249 | {name: "1c",amountofImages: 4}, 250 | {name: "2a",amountofImages: 3}, 251 | {name: "2b",amountofImages: 3}, 252 | {name: "5",amountofImages: 3}, 253 | {name: "7",amountofImages: 4}, 254 | {name: "3",amountofImages: 3}, 255 | {name: "4a",amountofImages: 4}, 256 | {name: "4b",amountofImages: 5}] 257 | 258 | /** @function setVariables 259 | * @description Resets variables to their default values for loading new levels 260 | */ 261 | setVariables = function(){ 262 | for(x=0;x=(0);x--){ 231 | //eval('setTimeout(function(){doorrightdiv.attr("src",doorrightanim['+x+'].src);},(20*(Math.abs('+x+'-13))));') 232 | setTimeout(function(number){doorrightdiv.attr("src",doorrightanim[number].src);},(20*(Math.abs(x-13))),x); 233 | } 234 | } 235 | } 236 | 237 | function playcamerafeedanimation(inReverse){ 238 | if(inReverse==0) { 239 | camerafeedanimationdiv.css("display","block"); 240 | for(x=0;x<(10);x++){ 241 | //eval('setTimeout(function(){camerafeedanimationdiv.attr("src",camerafeedanimationimage['+x+'].src);},(30*('+x+'+1)));') 242 | setTimeout(function(number){camerafeedanimationdiv.attr("src",camerafeedanimationimage[number].src);},(30*(x+1)),x); 243 | //eval('setTimeout(function(){camerafeedanimationdiv.css("display","none");},(330));') 244 | setTimeout(function(){camerafeedanimationdiv.css("display","none");},(330)); 245 | } 246 | } 247 | else if(inReverse==1) { 248 | camerafeedanimationdiv.css("display","block"); 249 | for(x=9;x>=(0);x--){ 250 | //eval('setTimeout(function(){camerafeedanimationdiv.attr("src",camerafeedanimationimage['+x+'].src);},(20*(Math.abs('+x+'-9))));') 251 | setTimeout(function(number){camerafeedanimationdiv.attr("src",camerafeedanimationimage[number].src);},(20*(Math.abs(x-9))),x); 252 | //eval('setTimeout(function(){camerafeedanimationdiv.css("display","none");},(200));') 253 | setTimeout(function(){camerafeedanimationdiv.css("display","none");},(200)); 254 | } 255 | }; 256 | } 257 | 258 | // lol this is only used for one bloody room... 259 | function playroomanimation(room,randomnumber){ 260 | switch(room) { 261 | case "2a": 262 | for(x=0;x<(9);x++){ 263 | if(randomnumber>0.5) { 264 | //eval('setTimeout(function(){roomdiv.attr("src",room2aimage['+(x & 1)+'].src);},(45*(Math.abs('+x+'+1))));'); 265 | setTimeout(function(number){roomdiv.attr("src",room2aimage[(number & 1)].src);},(45*(Math.abs(x+1))),x); 266 | } 267 | else { 268 | //eval('setTimeout(function(){roomdiv.attr("src",room2aimage['+(x & 1)+'].src);},(15*(Math.abs('+x+'+1))));'); 269 | setTimeout(function(number){roomdiv.attr("src",room2aimage[(number & 1)].src);},(15*(Math.abs(x+1))),x); 270 | } 271 | } 272 | break; 273 | default: 274 | alert("Invalid or no room name given!"); 275 | } 276 | }; 277 | 278 | function playdooranimationleft(inReverse){ 279 | if(inReverse==0) { 280 | for(x=0;x<(14);x++){ 281 | //eval('setTimeout(function(){doorleftdiv.attr("src",doorleftanim['+x+'].src);},(30*('+x+'+1)));') 282 | setTimeout(function(number){doorleftdiv.attr("src",doorleftanim[number].src);},(30*(x+1)),x); 283 | } 284 | } 285 | else if(inReverse==1) { 286 | for(x=13;x>=(0);x--){ 287 | //eval('setTimeout(function(){doorleftdiv.attr("src",doorleftanim['+x+'].src);},(20*(Math.abs('+x+'-13))));') 288 | setTimeout(function(number){doorleftdiv.attr("src",doorleftanim[number].src);},(20*(Math.abs('+x+'-13))),x); 289 | } 290 | } 291 | } -------------------------------------------------------------------------------- /script/ui.js: -------------------------------------------------------------------------------- 1 | // 2 | // ui.js 3 | // The JS for handling UI changes and functions 4 | // 5 | // Last updated - 10/04/2015 @ 01:53am 6 | 7 | debuglog("Initializing ui.js..."); 8 | 9 | function staticTick() { 10 | randomcheck++ 11 | if(randomcheck>8) randomcheck=1; 12 | staticimgdiv.src=staticanim[randomcheck].src; 13 | 14 | staticId = setTimeout('staticTick()', 30); 15 | } 16 | 17 | function updateselectedmenuitem(obj) { 18 | if(obj.id=="newbutton"){ 19 | document.getElementById("selectedarrows").style.top="57.5%" 20 | } else if(obj.id=="continuebutton") { 21 | document.getElementById("selectedarrows").style.top="65.5%" 22 | } else if(obj.id=="6thnight") { 23 | document.getElementById("selectedarrows").style.top="75.5%" 24 | } else if(obj.id=="customnight") { 25 | document.getElementById("selectedarrows").style.top="83.5%" 26 | }; 27 | } 28 | 29 | function OpenCloseFeed() { 30 | debuglog(feedopen); 31 | if(feedopen==false){ 32 | debuglog("Opening feed..."); 33 | setTimeout(function(){camerafeeddiv.toggle();officemaindiv.toggle();sound.playSound("CAMERA_VIDEO_LOA_60105303.wav");},360); 34 | } else { 35 | debuglog("Closing feed..."); 36 | camerafeeddiv.toggle(); 37 | officemaindiv.toggle(); 38 | sound.playSound("put_down.wav"); 39 | }; 40 | playcamerafeedanimation(feedopen); 41 | fandiv.toggle(); 42 | if(feedopen==false){ 43 | staticimgdiv.play(); 44 | feedopen=true; 45 | currentPowerUsage++; 46 | updatePowerUsage(); 47 | } else { 48 | staticimgdiv.pause(); 49 | feedopen=false; 50 | currentPowerUsage--; 51 | updatePowerUsage(); 52 | }; 53 | if(currentRoom==animatronicStates[1].currentRoom) { 54 | updateAIState(1,1,false); 55 | }; 56 | if(currentRoom==animatronicStates[0].currentRoom) { 57 | updateAIState(0,1,false); 58 | }; 59 | if(currentRoom==animatronicStates[2].currentRoom) { 60 | updateAIState(2,1,false); 61 | }; 62 | } 63 | 64 | function updateRoomStateStatic(duration){ 65 | if(duration=="") duration = 500; 66 | animationduration = 250; 67 | animatestatic=1; 68 | staticdiv.animate({ 69 | opacity: 2 70 | },0,function(){ 71 | animatestatic=2; 72 | setTimeout(function(){ 73 | staticdiv.animate({ 74 | opacity: 0.25 75 | },animationduration,function(){ 76 | animatestatic=0; 77 | }); 78 | }, duration); 79 | }); 80 | } 81 | 82 | function camerapositionTick() { 83 | //element.style.webkitTransform = "rotate(-2deg)"; 84 | if(rooms[currentRoomID].movingcamera!==false){ 85 | roomdiv.animate({ 86 | left: leftpos, 87 | },6000,function(){ 88 | if(leftornot==1) leftornot=0 89 | else leftornot=1; 90 | if(leftornot==0){leftpos = "-=300px"} 91 | else{leftpos = "+=300px"}; 92 | }); 93 | } 94 | } 95 | 96 | // ==============================================BUTTON EVENTS============================================== 97 | assertButtons = function(){ 98 | button1adiv.mouseenter(function(){ 99 | if(this.id!==("button-"+currentRoom)){ 100 | this.style.backgroundColor='#505050'; 101 | } 102 | else this.style.backgroundColor='#107010'; 103 | }); 104 | button1adiv.mouseleave(function(){ 105 | if(this.id!==("button-"+currentRoom)){ 106 | this.style.backgroundColor='#101010'; 107 | } 108 | }); 109 | button1adiv.click(function(){ 110 | if(currentRoom!=="1a" && animatestatic<1){ 111 | this.style.backgroundColor='#107010'; 112 | updatecurrentRoom("1a"); 113 | resetCameraButtons(currentRoom); 114 | } 115 | }); 116 | 117 | button1bdiv.mouseenter(function(){ 118 | if(this.id!==("button-"+currentRoom)){ 119 | this.style.backgroundColor='#505050'; 120 | } 121 | else this.style.backgroundColor='#107010'; 122 | }); 123 | button1bdiv.mouseleave(function(){ 124 | if(this.id!==("button-"+currentRoom)){ 125 | this.style.backgroundColor='#101010'; 126 | } 127 | }); 128 | button1bdiv.click(function(){ 129 | if(currentRoom!=="1b" && animatestatic<1){ 130 | this.style.backgroundColor='#107010'; 131 | updatecurrentRoom("1b"); 132 | resetCameraButtons(currentRoom); 133 | } 134 | }); 135 | 136 | button1cdiv.mouseenter(function(){ 137 | if(this.id!==("button-"+currentRoom)){ 138 | this.style.backgroundColor='#505050'; 139 | } 140 | else this.style.backgroundColor='#107010'; 141 | }); 142 | button1cdiv.mouseleave(function(){ 143 | if(this.id!==("button-"+currentRoom)){ 144 | this.style.backgroundColor='#101010'; 145 | } 146 | }); 147 | button1cdiv.click(function(){ 148 | if(currentRoom!=="1c" && animatestatic<1){ 149 | this.style.backgroundColor='#107010'; 150 | updatecurrentRoom("1c"); 151 | resetCameraButtons(currentRoom); 152 | } 153 | }); 154 | 155 | button2adiv.mouseenter(function(){ 156 | if(this.id!==("button-"+currentRoom)){ 157 | this.style.backgroundColor='#505050'; 158 | } 159 | else this.style.backgroundColor='#107010'; 160 | }); 161 | button2adiv.mouseleave(function(){ 162 | if(this.id!==("button-"+currentRoom)){ 163 | this.style.backgroundColor='#101010'; 164 | } 165 | }); 166 | button2adiv.click(function(){ 167 | if(currentRoom!=="2a" && animatestatic<1){ 168 | this.style.backgroundColor='#107010'; 169 | updatecurrentRoom("2a"); 170 | resetCameraButtons(currentRoom); 171 | } 172 | }); 173 | 174 | button2bdiv.mouseenter(function(){ 175 | if(this.id!==("button-"+currentRoom)){ 176 | this.style.backgroundColor='#505050'; 177 | } 178 | else this.style.backgroundColor='#107010'; 179 | }); 180 | button2bdiv.mouseleave(function(){ 181 | if(this.id!==("button-"+currentRoom)){ 182 | this.style.backgroundColor='#101010'; 183 | } 184 | }); 185 | button2bdiv.click(function(){ 186 | if(currentRoom!=="2b" && animatestatic<1){ 187 | this.style.backgroundColor='#107010'; 188 | updatecurrentRoom("2b"); 189 | resetCameraButtons(currentRoom); 190 | } 191 | }); 192 | 193 | button5div.mouseenter(function(){ 194 | if(this.id!==("button-"+currentRoom)){ 195 | this.style.backgroundColor='#505050'; 196 | } 197 | else this.style.backgroundColor='#107010'; 198 | }); 199 | button5div.mouseleave(function(){ 200 | if(this.id!==("button-"+currentRoom)){ 201 | this.style.backgroundColor='#101010'; 202 | } 203 | }); 204 | button5div.click(function(){ 205 | if(currentRoom!=="5" && animatestatic<1){ 206 | this.style.backgroundColor='#107010'; 207 | updatecurrentRoom("5"); 208 | resetCameraButtons(currentRoom); 209 | } 210 | }); 211 | 212 | button7div.mouseenter(function(){ 213 | if(this.id!==("button-"+currentRoom)){ 214 | this.style.backgroundColor='#505050'; 215 | } 216 | else this.style.backgroundColor='#107010'; 217 | }); 218 | button7div.mouseleave(function(){ 219 | if(this.id!==("button-"+currentRoom)){ 220 | this.style.backgroundColor='#101010'; 221 | } 222 | }); 223 | button7div.click(function(){ 224 | if(currentRoom!=="7" && animatestatic<1){ 225 | this.style.backgroundColor='#107010'; 226 | updatecurrentRoom("7"); 227 | resetCameraButtons(currentRoom); 228 | } 229 | }); 230 | 231 | button3div.mouseenter(function(){ 232 | if(this.id!==("button-"+currentRoom)){ 233 | this.style.backgroundColor='#505050'; 234 | } 235 | else this.style.backgroundColor='#107010'; 236 | }); 237 | button3div.mouseleave(function(){ 238 | if(this.id!==("button-"+currentRoom)){ 239 | this.style.backgroundColor='#101010'; 240 | } 241 | }); 242 | button3div.click(function(){ 243 | if(currentRoom!=="3" && animatestatic<1){ 244 | this.style.backgroundColor='#107010'; 245 | updatecurrentRoom("3"); 246 | resetCameraButtons(currentRoom); 247 | } 248 | }); 249 | 250 | button4adiv.mouseenter(function(){ 251 | if(this.id!==("button-"+currentRoom)){ 252 | this.style.backgroundColor='#505050'; 253 | } 254 | else this.style.backgroundColor='#107010'; 255 | }); 256 | button4adiv.mouseleave(function(){ 257 | if(this.id!==("button-"+currentRoom)){ 258 | this.style.backgroundColor='#101010'; 259 | } 260 | }); 261 | button4adiv.click(function(){ 262 | if(currentRoom!=="4a" && animatestatic<1){ 263 | this.style.backgroundColor='#107010'; 264 | updatecurrentRoom("4a"); 265 | resetCameraButtons(currentRoom); 266 | } 267 | }); 268 | 269 | button4bdiv.mouseenter(function(){ 270 | if(this.id!==("button-"+currentRoom)){ 271 | this.style.backgroundColor='#505050'; 272 | } 273 | else this.style.backgroundColor='#107010'; 274 | }); 275 | button4bdiv.mouseleave(function(){ 276 | if(this.id!==("button-"+currentRoom)){ 277 | this.style.backgroundColor='#101010'; 278 | } 279 | }); 280 | button4bdiv.click(function(){ 281 | if(currentRoom!=="4b" && animatestatic<1){ 282 | this.style.backgroundColor='#107010'; 283 | updatecurrentRoom("4b"); 284 | resetCameraButtons(currentRoom); 285 | } 286 | }); 287 | 288 | button6div.mouseenter(function(){ 289 | if(this.id!==("button-"+currentRoom)){ 290 | this.style.backgroundColor='#505050'; 291 | } 292 | else this.style.backgroundColor='#107010'; 293 | }); 294 | button6div.mouseleave(function(){ 295 | if(this.id!==("button-"+currentRoom)){ 296 | this.style.backgroundColor='#101010'; 297 | } 298 | }); 299 | button6div.click(function(){ 300 | if(currentRoom!=="6" && animatestatic<1){ 301 | this.style.backgroundColor='#107010'; 302 | updatecurrentRoom("6"); 303 | resetCameraButtons(currentRoom); 304 | } 305 | }); 306 | 307 | buttonopenclosecameradiv.click(function(){ 308 | // playcamerafeedanimation(feedopen); 309 | OpenCloseFeed(); 310 | }); 311 | officecamerarightdiv.mouseenter(function(){ 312 | officeXInterval = setInterval(function(){//380 313 | if(officeX>=(windowwidth/5)) {document.getElementById("officecameraright").style.display="none";return;}; 314 | document.getElementById("officecameraleft").style.display="block"; 315 | officeX=(officeX+10); 316 | document.getElementById("office").style.webkitTransform="translate(-"+officeX+"px)"; 317 | // console.log("Translated by +"+officeX); 318 | },10); 319 | }); 320 | officecamerarightdiv.mouseleave(function(){ 321 | clearInterval(officeXInterval); 322 | }); 323 | officecameraleftdiv.mouseenter(function(){ 324 | officeXOtherInterval = setInterval(function(){ 325 | if(officeX==0) {document.getElementById("officecameraleft").style.display="none";return;}; 326 | document.getElementById("officecameraright").style.display="block"; 327 | officeX=(officeX-10); 328 | document.getElementById("office").style.webkitTransform="translate(-"+officeX+"px)"; 329 | // console.log("Translated by -"+officeX); 330 | },10); 331 | }); 332 | officecameraleftdiv.mouseleave(function(){ 333 | clearInterval(officeXOtherInterval); 334 | }); 335 | 336 | doorbuttonsleft_lightdiv.click(function(){ 337 | if(leftlighton==false && rightlighton==false) { 338 | if(animatronicStates[1].currentRoom=="office"){ 339 | officemaindiv.css("background-image","url("+officelightstates[1][0].src+")"); 340 | sound.playSound("windowscare.wav"); 341 | } else { 342 | officemaindiv.css("background-image", "url('"+officelightstates[0][1].src+"')"); 343 | }; 344 | if(leftdooropen==false) { 345 | doorbuttonsleftdiv.css("background-image", "url('"+buttonleftstates[2].src+"')"); 346 | } else { 347 | doorbuttonsleftdiv.css("background-image", "url('"+buttonleftstates[4].src+"')"); 348 | }; 349 | leftlighton=true; 350 | currentPowerUsage++; 351 | updatePowerUsage(); 352 | } 353 | else if(rightlighton!==true) { 354 | officemaindiv.css("background-image", "url('"+officestates[0].src+"')"); 355 | if(leftdooropen==false) { 356 | doorbuttonsleftdiv.css("background-image", "url('"+buttonleftstates[1].src+"')"); 357 | } else { 358 | doorbuttonsleftdiv.css("background-image", "url('"+buttonleftstates[3].src+"')"); 359 | }; 360 | leftlighton=false; 361 | currentPowerUsage--; 362 | updatePowerUsage(); 363 | } else { 364 | sound.playSound("error.wav"); 365 | }; 366 | }); 367 | 368 | doorbuttonsleft_doordiv.click(function(){ 369 | if(leftdooropen==false) { 370 | playdooranimationleft(0); 371 | sound.playSound("SFXBible_12478.wav",0.2); 372 | leftdooropen=true; 373 | if(leftlighton) { 374 | doorbuttonsleftdiv.css("background-image", "url('"+buttonleftstates[4].src+"')"); 375 | } 376 | else { 377 | doorbuttonsleftdiv.css("background-image", "url('"+buttonleftstates[3].src+"')"); 378 | }; 379 | currentPowerUsage++; 380 | updatePowerUsage(); 381 | } 382 | else { 383 | playdooranimationleft(1); 384 | sound.playSound("SFXBible_12478.wav",0.2); 385 | leftdooropen=false; 386 | if(leftlighton) { 387 | doorbuttonsleftdiv.css("background-image", "url('"+buttonleftstates[2].src+"')"); 388 | } 389 | else { 390 | doorbuttonsleftdiv.css("background-image", "url('"+buttonleftstates[1].src+"')"); 391 | }; 392 | currentPowerUsage--; 393 | updatePowerUsage(); 394 | }; 395 | }); 396 | 397 | doorbuttonsright_doordiv.click(function(){ 398 | if(rightdooropen==false) { 399 | playdooranimationright(0); 400 | sound.playSound("SFXBible_12478.wav",0.2); 401 | rightdooropen=true; 402 | if(rightlighton) { 403 | doorbuttonsrightdiv.css("background-image", "url('"+buttonrightstates[4].src+"')"); 404 | } 405 | else { 406 | doorbuttonsrightdiv.css("background-image", "url('"+buttonrightstates[3].src+"')"); 407 | }; 408 | currentPowerUsage++; 409 | updatePowerUsage(); 410 | } 411 | else { 412 | playdooranimationright(1); 413 | sound.playSound("SFXBible_12478.wav",0.2); 414 | rightdooropen=false; 415 | if(rightlighton) { 416 | doorbuttonsrightdiv.css("background-image", "url('"+buttonrightstates[2].src+"')"); 417 | } 418 | else { 419 | doorbuttonsrightdiv.css("background-image", "url('"+buttonrightstates[1].src+"')"); 420 | }; 421 | currentPowerUsage--; 422 | updatePowerUsage(); 423 | }; 424 | }); 425 | 426 | doorbuttonsright_lightdiv.click(function(){ 427 | if(leftlighton==false && rightlighton==false) { 428 | if(animatronicStates[0].currentRoom=="office"){ 429 | officemaindiv.css("background-image","url("+officelightstates[2][0].src+")"); 430 | sound.playSound("windowscare.wav"); 431 | } else { 432 | officemaindiv.css("background-image", "url('"+officelightstates[0][0].src+"')"); 433 | }; 434 | if(rightdooropen==false) { 435 | doorbuttonsrightdiv.css("background-image", "url('"+buttonrightstates[2].src+"')"); 436 | } else { 437 | doorbuttonsrightdiv.css("background-image", "url('"+buttonrightstates[4].src+"')"); 438 | }; 439 | rightlighton=true; 440 | currentPowerUsage++; 441 | updatePowerUsage(); 442 | } 443 | else if(leftlighton!==true) { 444 | officemaindiv.css("background-image", "url('"+officestates[0].src+"')"); 445 | if(rightdooropen==false) { 446 | doorbuttonsrightdiv.css("background-image", "url('"+buttonrightstates[1].src+"')"); 447 | } else { 448 | doorbuttonsrightdiv.css("background-image", "url('"+buttonrightstates[3].src+"')"); 449 | }; 450 | rightlighton=false; 451 | currentPowerUsage--; 452 | updatePowerUsage(); 453 | } else { 454 | sound.playSound("error.wav"); 455 | }; 456 | }); 457 | }; 458 | 459 | function resetCameraButtons(current){ 460 | for(x=0;x=foxydifficultyarray[foxydifficulty]){ 252 | updateAIState(3,1); 253 | sound.playSound("pirate_song2.wav",0.01); 254 | } 255 | break; 256 | case 1: 257 | foxxytimer++; 258 | if(foxxytimer>=foxydifficultyarray[foxydifficulty]){ 259 | updateAIState(3,2); 260 | sound.playSound("pirate_song2.wav",0.01); 261 | }; 262 | break; 263 | case 2: 264 | foxxytimer++; 265 | if(foxxytimer>=foxydifficultyarray[foxydifficulty]){ 266 | updateAIState(3,3); 267 | sound.playSound("pirate_song2.wav",0.01); 268 | } 269 | break; 270 | case 3: 271 | foxxytimer++; 272 | if(foxxytimer>=6 && leftdooropen==false){ 273 | if(feedopen==true){ 274 | OpenCloseFeed(); 275 | }; 276 | playfoxxyofficeanimation(); 277 | } else if(foxxytimer<5 && leftdooropen==true){ 278 | updateAIState(3,4); 279 | }; 280 | break; 281 | case 4: 282 | foxxytimer++; 283 | if(foxxytimer<=9 && leftdooropen==true){ 284 | currentPower-=(0.775); 285 | } else if(foxxytimer<=9 && leftdooropen==false){ 286 | playfoxxyofficeanimation(); 287 | } else if(foxxytimer>=10 && leftdooropen==true){ 288 | updateAIState(3,0); 289 | }; 290 | break; 291 | default: 292 | } 293 | }; 294 | 295 | /** @function updateFreddyAI 296 | * @description Updates AI of Freddy 297 | */ 298 | function updateFreddyAI() { 299 | switch(animatronicStates[2].state) { 300 | case 0: // unseen 301 | freddytimer++; 302 | debuglog("freddytimer = "+freddytimer); 303 | if(animatronicStates[2].currentRoomArray==0) { 304 | debuglog("FREDDY HAS REACHED THE OFFICE"); 305 | }; 306 | if(freddytimer>=freddydifficultyarray[freddydifficulty]){ 307 | // updateRoomState(roomname,state,timeout); 308 | // animatronicStates[1].state=2; 309 | updateAIState(2,2); 310 | }; 311 | break; 312 | case 1: // seen 313 | if(currentRoom!=animatronicStates[2].currentRoom || feedopen == false) { 314 | //if(animatronicStates[2].currentRoomArray==0 && rightlighton==true) { 315 | updateAIState(2,0,false); 316 | //return; 317 | } else { 318 | updateAIState(2,1,false); 319 | // return; 320 | }; 321 | break; 322 | case 2: // moving 323 | debuglog("freddytimer = "+freddytimer); 324 | if(animatronicStates[2].currentRoomArray==1) { 325 | updateAIState(2,3); 326 | debuglog("FREDDY HAS REACHED THE OFFICE"); 327 | return; 328 | }; 329 | if(1==1){ 330 | animatronicStates[2].currentRoomArray-=1 331 | debuglog(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name); 332 | if((animatronicStates[2].currentRoomArray + 1)==6) { 333 | debuglog("FREDDY HAS LEFT THE STAGE"); 334 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray+1].name,5); 335 | } else { 336 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray+1].name,0); 337 | }; 338 | if(animatronicStates[2].currentRoomArray==5){ 339 | if(animatronicStates[0].currentRoomArray==5){ 340 | animatronicStates[2].currentRoomArray-=1; 341 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,5); 342 | } else { 343 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,5); 344 | }; 345 | } else if(animatronicStates[2].currentRoomArray==4){ 346 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,3); 347 | } else if(animatronicStates[2].currentRoomArray==1){ 348 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,4); 349 | } else { 350 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,3); 351 | }; 352 | if(animatronicStates[0].currentRoomArray==animatronicStates[2].currentRoomArray){ 353 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,1); 354 | animatronicStates[2].currentRoomArray-=1; 355 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,3); 356 | }; 357 | animatronicStates[2].currentRoom=roomClosenessFreddy[animatronicStates[2].currentRoomArray].name 358 | debuglog("closer!"); 359 | if(currentRoom!=animatronicStates[2].currentRoom || feedopen == false) { 360 | updateAIState(2,0); 361 | } else { 362 | updateAIState(2,1); 363 | }; 364 | if(animatronicStates[2].currentRoom=="4b"){ 365 | updateAIState(2,3); 366 | } else if(animatronicStates[2].currentRoom=="6"){ 367 | sound.playSound("kitchen"+(randomIntFromInterval(1,4))+".wav",0.6); 368 | }; 369 | if(Math.random()<0.84){ 370 | // play a sound 371 | whatsound = randomIntFromInterval(1,4); 372 | switch(whatsound){ 373 | case 1: 374 | sound.playSound("Laugh_Giggle_Girl_8d.wav",0.5); 375 | break; 376 | case 2: 377 | sound.playSound("Laugh_Giggle_Girl_2d.wav",0.5); 378 | break; 379 | case 3: 380 | sound.playSound("Laugh_Giggle_Girl_1d.wav",0.5); 381 | break; 382 | case 4: 383 | sound.playSound("deep steps.wav",0.5); 384 | break; 385 | }; 386 | }; 387 | }; 388 | break; 389 | case 3: // at door outside office 390 | freddytimer++; 391 | debuglog("freddytimer = "+freddytimer); 392 | if(freddytimer<=7 && rightdooropen==true){ 393 | //keep the door closed for 4 seconds lest you get fucked 394 | } else if(freddytimer>=7 && rightdooropen==false){ 395 | //door was not closed. Shame. 396 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,0); 397 | animatronicStates[2].currentRoomArray=0; 398 | updateAIState(2,4); 399 | } else if(freddytimer>=8 && rightdooropen==true){ 400 | //the door was shut for 8 seconds so he flees. 401 | if(animatronicStates[1].currentRoomArray!=5 && animatronicStates[0].currentRoomArray!=5){ 402 | updateAIState(2,0); 403 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,0); 404 | animatronicStates[2].currentRoomArray=5; 405 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,5); 406 | animatronicStates[2].currentRoom=roomClosenessFreddy[animatronicStates[2].currentRoomArray].name; 407 | debuglog("Returning Freddy to room 1b"); 408 | } else if(animatronicStates[0].currentRoomArray!=4){ 409 | updateAIState(2,0); 410 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,0); 411 | animatronicStates[2].currentRoomArray=4; 412 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,3); 413 | animatronicStates[2].currentRoom=roomClosenessFreddy[animatronicStates[2].currentRoomArray].name; 414 | debuglog("Returning Freddy to room 7"); 415 | } else { 416 | updateAIState(2,0); 417 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,0); 418 | animatronicStates[2].currentRoomArray=3; 419 | updateRoomState(roomClosenessFreddy[animatronicStates[2].currentRoomArray].name,2); 420 | animatronicStates[2].currentRoom=roomClosenessFreddy[animatronicStates[2].currentRoomArray].name; 421 | debuglog("Returning Freddy to room 6"); 422 | }; 423 | }; 424 | break; 425 | case 4: // inside office/dead 426 | if(freddytimer==0){ 427 | animatronicStates[2].currentRoomArray = 0; 428 | animatronicStates[2].currentRoom=roomClosenessFreddy[animatronicStates[2].currentRoomArray].name; 429 | }; 430 | freddytimer++; 431 | debuglog("freddytimer = "+freddytimer); 432 | if(freddytimer>=14){ 433 | //dead 434 | playfreddygameoveranimation("freddyoffice") 435 | }; 436 | break; 437 | default: 438 | } 439 | }; -------------------------------------------------------------------------------- /feed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Five Nights at Freddy's JS - v 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 32 | 35 | 53 | 91 | 133 | 134 | 135 | 136 | 144 | 149 | 150 |
151 | 152 |
153 | 154 | 155 | 156 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /script/main.js: -------------------------------------------------------------------------------- 1 | // 2 | // FNAF-JS 3 | // Five Night's at Freddy's - JavaScript 4 | // 5 | // Original game by Scott Cawthon 6 | // 7 | // Ported by Sam 'Slynch' Lynch 8 | // Tested by Lewis 'Earwig' M. 9 | // ^as well as just generally helping^ 10 | // 11 | // For legality's sake, it is necessary to say that you may not monetize this code 12 | // without my express permission. This also works the other way around; I cannot 13 | // monetize this port without the original developer's permission. 14 | // I also can't release it without authentication or DRM that checks if 15 | // the user owns the normal version, otherwise I'm basically releasing the 16 | // game for free. 17 | // 18 | // Planned methods of auth: 19 | // - Greenworks for executables 20 | // - Steam Web API login for HTML. 21 | // 22 | // Last updated - 12/08/2015 23 | 24 | /** 25 | * @file Primary JavaScript file housing main loop and main menu code 26 | * @author Sam Lynch 27 | * @version 1.0.0 28 | * @copyright (c) 2015 Amduat Games 29 | */ 30 | 31 | debuglog("Initializing main.js..."); 32 | 33 | if(BUILD_TARGET == "NW.JS"){ 34 | NWGUI = require('nw.gui'); 35 | debuglog("Initializing Greenworks..."); 36 | greenworks = require('./greenworks'); 37 | if(greenworks.initAPI()){ 38 | debuglog('Steam API has been initalized.'); 39 | } else { 40 | alert('Error on initializing Steam API.'); 41 | gui.App.quit(); 42 | }; 43 | } else { 44 | debuglog('Skipping Steam auth...'); 45 | }; 46 | 47 | document.getElementById("title").innerHTML += VERSION; 48 | 49 | assertButtons(); 50 | var cachedbody = document.getElementById("alldahtml").innerHTML; 51 | 52 | function mainThread() { 53 | if(currentPower>0) { 54 | updatePowerPercent(); 55 | updatePowerUsage(); 56 | } 57 | updateTime(); 58 | //if(currentRoom=="1c" && feedopen == true && animatronicStates[3].state<3) { 59 | // if(foxxytimer>0)foxxytimer--; 60 | //}; 61 | if(bunnydifficulty!=0) updateBunnyAI(); 62 | if(chicadifficulty!=0) updateChicaAI(); 63 | if(foxydifficulty!=0) updateFoxxyAI(); 64 | if(freddydifficulty!=0) updateFreddyAI(); 65 | if(DEBUG_MODE==true) debugInfo(); 66 | if(currentRoom=="2a" && animatronicStates[3].state!==3 && play2aanimation==false && animatronicStates[1].currentRoom!="2a") { 67 | play2aanimation=true; 68 | setTimeout(function(){ 69 | play2aanimation=false; 70 | },445); 71 | playroomanimation("2a",Math.random()); 72 | }; 73 | }; 74 | 75 | function loadgame2() { 76 | loadgame(); 77 | }; 78 | 79 | function newgame() { 80 | night = 1; 81 | foxydifficulty = 8; 82 | bunnydifficulty = 9; 83 | chicadifficulty = 6; 84 | freddydifficulty = 0; 85 | sound.stopSound(); 86 | localStorage["fnaf-js-savegame.night"]="1"; 87 | document.getElementById("newgamebg").style.display="block"; 88 | document.getElementById("newgamebg").style.opacity="0"; 89 | $("#newgamebg").animate({ 90 | opacity: "1" 91 | },1000,function(){ 92 | eval('setTimeout(function(){loadroomImages();loadEverythingElse();},5000)'); 93 | }); 94 | }; 95 | 96 | function loadgame(nightmare) { 97 | if(typeof(nightmare)=="undefined" || nightmare == false){ 98 | night = localStorage["fnaf-js-savegame.night"]; 99 | if(night == "6" || night == "7") night = "5"; 100 | switch(night){ 101 | case "1": 102 | foxydifficulty = 8; 103 | bunnydifficulty = 9; 104 | chicadifficulty = 6; 105 | freddydifficulty = 0; 106 | break; 107 | case "2": 108 | foxydifficulty = 10; 109 | bunnydifficulty = 12; 110 | chicadifficulty = 9; 111 | freddydifficulty = 0; 112 | break; 113 | case "3": 114 | foxydifficulty = 12; 115 | bunnydifficulty = 15; 116 | chicadifficulty = 12; 117 | freddydifficulty = 10; 118 | break; 119 | case "4": 120 | foxydifficulty = 14; 121 | bunnydifficulty = 18; 122 | chicadifficulty = 15; 123 | freddydifficulty = 13; 124 | break; 125 | case "5": 126 | foxydifficulty = 16; 127 | bunnydifficulty = 19; 128 | chicadifficulty = 17; 129 | freddydifficulty = 16; 130 | break; 131 | case "6": 132 | foxydifficulty = 20; 133 | bunnydifficulty = 20; 134 | chicadifficulty = 19; 135 | freddydifficulty = 18; 136 | break; 137 | case "7": 138 | foxydifficulty = 16; 139 | bunnydifficulty = 19; 140 | chicadifficulty = 17; 141 | freddydifficulty = 16; 142 | break; 143 | }; 144 | } else { 145 | alert("nightmare mode!"); 146 | night = 6; 147 | foxydifficulty = 17; 148 | bunnydifficulty = 19; 149 | chicadifficulty = 17; 150 | freddydifficulty = 15; 151 | }; 152 | sound.stopSound(); 153 | loadroomImages(); 154 | loadEverythingElse(); 155 | if(DEBUG_MODE==true) debugdiv.style.display="block"; 156 | }; 157 | 158 | hours[0] = 12; 159 | for(x=1;x<7;x++){ 160 | hours[x] = x; 161 | }; 162 | 163 | function updateAIPosition(AIID,AIstate,newroom,roomstate,oldroomstate){ 164 | if(!AIID){ 165 | debuglog("updateAIPosition(AI ID, AI new state, AI new room, new room state, old room state"); 166 | return; 167 | }; 168 | if(DEBUG_MODE) debuglog("updateRoomState("+animatronicStates[AIID].currentRoom+","+oldroomstate+")"); 169 | updateRoomState(animatronicStates[AIID].currentRoom,oldroomstate,1); //old room 170 | updateAIState(AIID,AIstate,newroom); 171 | updateRoomState(newroom,roomstate); //new room 172 | } 173 | 174 | /** @function searchForState 175 | * @description Searches for the current state of a room 176 | * @param {string} room Name of the room 177 | * @returns {Number} roomstate Current state of specified room 178 | */ 179 | function searchForState(room){ 180 | for (var i=0; i < currRoomStates.length; i++) { 181 | if (currRoomStates[i].name === room) { 182 | return currRoomStates[i].roomstate; 183 | }; 184 | }; 185 | }; 186 | 187 | /** @function searchForRoomID 188 | * @description Searches for the ID of a room using the name 189 | * @param {string} room Name of the room 190 | * @returns {string} roomid ID of specified room 191 | */ 192 | function searchForRoomID(roomname){ 193 | for (var i=0; i < currRoomStates.length; i++) { 194 | if (rooms[i].name === roomname) { 195 | return i; 196 | }; 197 | }; 198 | }; 199 | 200 | /** @function searchForRoomID 201 | * @description Searches for the ID of a room using the name. Param 4 and 5 are deprecated. 202 | * @param {int} AIID ID of AI 203 | * @param {int} state What state to set the AI to 204 | * @param {boolean} updatetimer Reset the timer to 0 or not 205 | * @param {string} [newroom] Name of the room to set AI to 206 | * @param {int} [roomID] ID of the room to set AI to 207 | */ 208 | function updateAIState(AIID,state,updatetimer,newroom,roomID){ 209 | if((typeof AIID)=="undefined"){ 210 | debuglog("updateAIState:\nAIID - ID of the AI to update\nstate - What state to set it to\nnewroom - What room to change to\nroomID - I don't fucking know, the ID of the room but I don't know what it is used for."); 211 | return; 212 | }; 213 | if(state=="") state = 0;//parseInt(state); 214 | if((typeof updatetimer)=="undefined") updatetimer = true; 215 | if(newroom=="") debuglog("No new room specified, expect errors if unintended"); 216 | 217 | switch(AIID) { 218 | case 0:// chica 219 | animatronicStates[0].state=state; 220 | if(updatetimer==true) chicatimer=0; 221 | break; 222 | case 1: //Bunny 223 | animatronicStates[AIID].state=state; 224 | if(updatetimer==true) bunnytimer=0; 225 | break; 226 | case 2: //Freddy 227 | animatronicStates[AIID].state=state; 228 | if(updatetimer==true) freddytimer=0; 229 | break; 230 | case 3: //Foxy 231 | switch(state) { 232 | case 0: // hiding 233 | updateRoomState("1c",0,1); 234 | break; 235 | case 1: // peeking round curtain 236 | updateRoomState("1c",1,1); 237 | break; 238 | case 2: // visible 239 | updateRoomState("1c",2,1); 240 | break; 241 | case 3: // OSHIT IT'S MISSING; IT'S ON ITS WAY 242 | updateRoomState("1c",3,1); 243 | foxxyrunning = true; 244 | break; 245 | case 4: // damn bro you ded 246 | break; 247 | case 5: // "Curses, foiled again! [bangs door in anger]" 248 | break; 249 | } 250 | animatronicStates[AIID].state=state; 251 | foxxytimer=0; 252 | break; 253 | default: 254 | alert("updateAIState() error - Invalid or no room name given!"); 255 | } 256 | 257 | debuglog("AI "+animatronicStates[AIID].name+" state updated to "+state); 258 | return; 259 | }; 260 | 261 | var updateRoomState = function(roomname,state){ 262 | if(state=="") state = 0//parseInt(state); 263 | if((typeof roomname) != "string") return debuglog("Room name not a string!"); 264 | 265 | switch(roomname) { 266 | case "1a": 267 | currRoomStates[0].roomstate=state; 268 | if(currentRoom == roomname) { 269 | updateRoomStateStatic(2500); 270 | updatecurrentRoom("1a"); 271 | }; 272 | break; 273 | case "1b": 274 | currRoomStates[1].roomstate=state; 275 | if(currentRoom == roomname) { 276 | updateRoomStateStatic(2500); 277 | updatecurrentRoom("1b"); 278 | }; 279 | break; 280 | case "1c": 281 | currRoomStates[2].roomstate=state; 282 | if(currentRoom == roomname) { 283 | updateRoomStateStatic(2500); 284 | updatecurrentRoom("1c"); 285 | }; 286 | 287 | break; 288 | case "2a": 289 | currRoomStates[3].roomstate=state; 290 | if(currentRoom == roomname) { 291 | updateRoomStateStatic(2500); 292 | updatecurrentRoom("2a"); 293 | }; 294 | break; 295 | case "2b": 296 | currRoomStates[4].roomstate=state; 297 | if(currentRoom == roomname) { 298 | updateRoomStateStatic(2500); 299 | updatecurrentRoom("2b"); 300 | }; 301 | break; 302 | case "5": 303 | currRoomStates[5].roomstate=state; 304 | if(currentRoom == roomname) { 305 | updateRoomStateStatic(2500); 306 | updatecurrentRoom("5"); 307 | }; 308 | break; 309 | case "3": 310 | currRoomStates[7].roomstate=state; 311 | if(currentRoom == roomname) { 312 | updateRoomStateStatic(2500); 313 | updatecurrentRoom("3"); 314 | }; 315 | break; 316 | case "7": 317 | currRoomStates[6].roomstate=state; 318 | if(currentRoom == roomname) { 319 | updateRoomStateStatic(2500); 320 | updatecurrentRoom("7"); 321 | }; 322 | break; 323 | case "4a": 324 | currRoomStates[8].roomstate=state; 325 | if(currentRoom == roomname) { 326 | updateRoomStateStatic(2500); 327 | updatecurrentRoom("4a"); 328 | }; 329 | break; 330 | case "4b": 331 | currRoomStates[9].roomstate=state; 332 | if(currentRoom == roomname) { 333 | updateRoomStateStatic(2500); 334 | updatecurrentRoom("4b"); 335 | }; 336 | break; 337 | case "6": 338 | currRoomStates[10].roomstate=state; 339 | if(currentRoom == roomname) { 340 | updateRoomStateStatic(2500); 341 | updatecurrentRoom("6"); 342 | }; 343 | break; 344 | case "office": 345 | currRoomStates[7].roomstate=state; 346 | break; 347 | default: 348 | debuglog("Invalid or no room name given!"); 349 | return; 350 | } 351 | 352 | debuglog("Camera "+roomname+" updated to state "+state); 353 | return ; 354 | }; 355 | 356 | var leftornot = 0 357 | var leftpos="-=300px" 358 | var staticanim=[]; 359 | var randomcheck=1 360 | 361 | function updatecurrentRoom(roomparameter) { 362 | if(roomparameter=="") return debuglog("updatecurrentRoom() error - No parameter given"); 363 | 364 | // COMMENCE HACKY FIX FOR ROOM ANIMATION LEAKING TO NEXT ROOM, WILL NEED TO REUSE LATER 365 | if(play2aanimation==true){ 366 | setTimeout(function(){ 367 | eval("button"+roomparameter+"div.click();"); 368 | },450); 369 | return; 370 | }; 371 | // END 372 | 373 | sound.playSound("blip3.wav",0.5); 374 | currentRoom=roomparameter; 375 | currentroomstatetoset = 0 376 | currentroomstatetoset = searchForState(roomparameter); 377 | currentroomstatetoset2 = searchForRoomID(roomparameter); 378 | document.getElementById("roomname").src=roomnameimages[currentroomstatetoset2].src 379 | if(currentroomstatetoset== -1) return debuglog("updatecurrentRoom() error - Invalid parameter given"); 380 | currentRoomID=searchForRoomID(roomparameter) 381 | if(roomparameter!="6"){ 382 | updateRoomStateStatic(175); 383 | roomdiv.attr("src",roomImages[currentRoomID][currRoomStates[currentroomstatetoset2].roomstate].src); //"graphics/rooms/"+currentRoom+"/"+currRoomStates[currentroomstatetoset2].roomstate+".png"); 384 | document.getElementById("cameradisabled").style.display = "none"; 385 | } else { 386 | document.getElementById("static").style.opacity = "2"; 387 | document.getElementById("cameradisabled").style.display = "block"; 388 | }; 389 | roomdiv.css("left","0"); 390 | if(rooms[currentRoomID].leftadjustment!==0){ 391 | // roomdiv.css("left","-"+rooms[currentRoomID].leftadjustment+"%"); 392 | }; 393 | if(rooms[currentRoomID].movingcamera==false){ 394 | roomdiv.removeClass("roomtest"); 395 | } 396 | else { 397 | roomdiv.addClass("roomtest"); 398 | }; 399 | if(currentRoom!=="2a") { 400 | for(x=0;x<31;x++){ 401 | clearTimeout(foxxyrunninganimationtimeout[x]); 402 | }; 403 | } 404 | else if(foxxyrunning==true && currentRoom=="2a"){ 405 | setTimeout(playFoxxyRunningAnimation,600); 406 | }; 407 | 408 | if(currentRoom=="1c" && animatronicStates[3].state<3) { 409 | if(foxxytimer>1) foxxytimer-=2; 410 | if(foxxytimer<0) foxxytimer=0; 411 | }; 412 | 413 | if(currentRoom==animatronicStates[1].currentRoom && feedopen == true) { 414 | updateAIState(1,1,false); 415 | }; 416 | if(currentRoom==animatronicStates[2].currentRoom && feedopen == true) { 417 | updateAIState(2,1,false); 418 | }; 419 | if(currentRoom==animatronicStates[0].currentRoom && feedopen == true) { 420 | if(animatronicStates[0].state==2){ 421 | return; 422 | } else { 423 | updateAIState(0,1,false); 424 | }; 425 | }; 426 | } 427 | 428 | function updatePowerPercent() { 429 | switch(currentPowerUsage) { 430 | case 0: 431 | currentPower-=(0.141); 432 | break; 433 | case 1: 434 | currentPower-=(0.235); 435 | break; 436 | case 2: 437 | currentPower-=(0.341); 438 | break; 439 | case 3: 440 | currentPower-=(0.447); 441 | break; 442 | case 4: 443 | currentPower-=(0.553); 444 | break; 445 | default: 446 | }; 447 | var digit1 = currentPower.toString()[0]; 448 | var digit2 = currentPower.toString()[1]; 449 | var digit3 = currentPower.toString()[2]; 450 | digit1 = parseInt(digit1); 451 | digit2 = parseInt(digit2); 452 | digit3 = parseInt(digit3); 453 | if (currentPower<=0){ 454 | numberonediv.attr("src","graphics/rooms/office/cameraposition.webp"); 455 | numbertwodiv.attr("src","graphics/rooms/office/cameraposition.webp"); 456 | } else if(currentPower<10) { 457 | numberonediv.attr("src",powerusagenumbersimage[digit1].src); 458 | numbertwodiv.attr("src","graphics/rooms/office/cameraposition.webp"); 459 | } else if (currentPower<100) { 460 | numberonediv.attr("src",powerusagenumbersimage[digit1].src); 461 | numbertwodiv.attr("src",powerusagenumbersimage[digit2].src); 462 | numberthreediv.attr("src","graphics/rooms/office/cameraposition.webp"); 463 | }; 464 | }; 465 | 466 | function updatePowerUsage() { 467 | powerusagediv.attr("src","graphics/camera/power"+(currentPowerUsage+1)+".png"); 468 | if(currentPower<=0) gameoverPowerFailure(); 469 | } 470 | 471 | function updateTime() { 472 | timeCounter++; 473 | if(timeCounter==85) { 474 | timeCounter=0; 475 | currenthour++; 476 | } 477 | if(currenthour>0 && currenthour<6){ 478 | timehourextradiv.attr("src",timehourimage[currenthour].src); 479 | document.getElementById("timehour").style.display="none" 480 | } 481 | else if(currenthour==6){ 482 | endnight(); 483 | }; 484 | }; 485 | 486 | function endnight() { 487 | clearInterval(mainThreadID); 488 | timer.stop(); 489 | document.getElementById("mainmenu").style.display="none"; 490 | document.getElementById("timekeeper").style.display="none"; 491 | document.getElementById("openclosecamera").style.display="none"; 492 | document.getElementById("power").style.display="none"; 493 | document.getElementById("body").style.display="none"; 494 | document.getElementById("nightover").style.display="block"; 495 | document.getElementById("nightoveram").style.top="80px"; 496 | document.getElementById("nightover5").style.top="80px"; 497 | document.getElementById("nightover6").style.top="20px"; 498 | 499 | // Update savegame------------------------------------------------- 500 | parsednight = parseInt(localStorage["fnaf-js-savegame.night"]); // To int so I can add 1 501 | if(parsednight!=7){ 502 | parsednight+=1; // Add 1 503 | 504 | if(parsednight==6 && localStorage["fnaf-js-savegame.stars"]=="0"){ 505 | localStorage["fnaf-js-savegame.stars"]="1"; 506 | } else if(parsednight==7 && parseInt(localStorage["fnaf-js-savegame.stars"])<2){ 507 | localStorage["fnaf-js-savegame.stars"]="2"; 508 | }; 509 | if(difficulty20202020==true && parseInt(localStorage["fnaf-js-savegame.stars"])!=3){ 510 | localStorage["fnaf-js-savegame.stars"]="3"; 511 | }; 512 | 513 | parsednight = parsednight.toString(); // Back to a string (not actually needed but meh) 514 | localStorage["fnaf-js-savegame.night"]=parsednight; // Set savegame 515 | debuglog("Night won! Set night in saved game to: "+localStorage["fnaf-js-savegame.night"]); 516 | }; 517 | // Update savegame------------------------------------------------- 518 | 519 | sound.playSound("chimes 2.wav"); 520 | sound.stopAmbientSound(); 521 | 522 | setTimeout(function(){ 523 | nightover5div.animate({top: "140px"}, 6000, "linear",function() { 524 | // Animation complete. 525 | }); 526 | nightover6div.animate({top: "80px"}, 6000, "linear",sound.playSound("CROWD_SMALL_CHIL_EC049202.wav")); 527 | },1500); 528 | setTimeout(function(){ 529 | document.getElementById("nightover").style.display="none"; 530 | document.getElementById("gameoverstaticimg").play(); 531 | document.getElementById("mainmenustaticimg").style.display="block"; 532 | mainmenu(); 533 | },10000); 534 | }; 535 | 536 | function gameoverstatic(timeout){ 537 | if(typeof(timeout)=="undefined") timeout=900; 538 | setTimeout(function(){ 539 | sound.stopSound(); 540 | sound.stopAmbientSound(); 541 | document.getElementById("gameoverstaticimg").style.display="block"; 542 | document.getElementById("gameoverstaticimg").play(); 543 | gameover(); 544 | },timeout); 545 | }; 546 | 547 | function updatedifficulty(animatronic,negativepositive){ 548 | switch(animatronic) { 549 | case "foxxy": 550 | if(negativepositive && foxydifficulty!=20){foxydifficulty++;} else if(negativepositive==false && foxydifficulty!=0){foxydifficulty--;}; 551 | tempvar = ""+foxydifficulty; 552 | if(tempvar.length==2){ 553 | tempvar1 = tempvar.substr(0,1); 554 | tempvar2 = tempvar.substr(1,2); 555 | document.getElementById("foxxydifficulty0").src="graphics/mainmenu/customnight/text/"+tempvar1+".png"; 556 | document.getElementById("foxxydifficulty1").src="graphics/mainmenu/customnight/text/"+tempvar2+".png"; 557 | document.getElementById("foxxydifficulty0").style.display="block"; 558 | } else { 559 | document.getElementById("foxxydifficulty0").style.display="none"; 560 | document.getElementById("foxxydifficulty1").src="graphics/mainmenu/customnight/text/"+tempvar+".png"; 561 | }; 562 | break; 563 | case "bunny": 564 | if(negativepositive && bunnydifficulty!=20){bunnydifficulty++;} else if(negativepositive==false && bunnydifficulty!=0){bunnydifficulty--;}; 565 | tempvar = ""+bunnydifficulty; 566 | if(tempvar.length==2){ 567 | tempvar1 = tempvar.substr(0,1); 568 | tempvar2 = tempvar.substr(1,2); 569 | document.getElementById("bunnydifficulty0").src="graphics/mainmenu/customnight/text/"+tempvar1+".png"; 570 | document.getElementById("bunnydifficulty1").src="graphics/mainmenu/customnight/text/"+tempvar2+".png"; 571 | document.getElementById("bunnydifficulty0").style.display="block"; 572 | } else { 573 | document.getElementById("bunnydifficulty0").style.display="none"; 574 | document.getElementById("bunnydifficulty1").src="graphics/mainmenu/customnight/text/"+tempvar+".png"; 575 | }; 576 | break; 577 | case "freddy": 578 | if(negativepositive && freddydifficulty!=20){freddydifficulty++;} else if(negativepositive==false && freddydifficulty!=0){freddydifficulty--;}; 579 | tempvar = ""+freddydifficulty; 580 | if(tempvar.length==2){ 581 | tempvar1 = tempvar.substr(0,1); 582 | tempvar2 = tempvar.substr(1,2); 583 | document.getElementById("freddydifficulty0").src="graphics/mainmenu/customnight/text/"+tempvar1+".png"; 584 | document.getElementById("freddydifficulty1").src="graphics/mainmenu/customnight/text/"+tempvar2+".png"; 585 | document.getElementById("freddydifficulty0").style.display="block"; 586 | } else { 587 | document.getElementById("freddydifficulty0").style.display="none"; 588 | document.getElementById("freddydifficulty1").src="graphics/mainmenu/customnight/text/"+tempvar+".png"; 589 | }; 590 | break; 591 | case "chica": 592 | if(negativepositive && chicadifficulty!=20){chicadifficulty++;} else if(negativepositive==false && chicadifficulty!=0){chicadifficulty--;}; 593 | tempvar = ""+chicadifficulty; 594 | if(tempvar.length==2){ 595 | tempvar1 = tempvar.substr(0,1); 596 | tempvar2 = tempvar.substr(1,2); 597 | document.getElementById("chicadifficulty0").src="graphics/mainmenu/customnight/text/"+tempvar1+".png"; 598 | document.getElementById("chicadifficulty1").src="graphics/mainmenu/customnight/text/"+tempvar2+".png"; 599 | document.getElementById("chicadifficulty0").style.display="block"; 600 | } else { 601 | document.getElementById("chicadifficulty0").style.display="none"; 602 | document.getElementById("chicadifficulty1").src="graphics/mainmenu/customnight/text/"+tempvar+".png"; 603 | }; 604 | break; 605 | default: 606 | }; 607 | }; 608 | 609 | function customizenight(){ 610 | document.getElementById("gameoverstaticimg").pause(); 611 | document.getElementById("mainmenustaticimg").style.display="none"; 612 | document.getElementById("mainmenu").style.display="none"; 613 | document.getElementById("night7interface").style.display="block" 614 | foxydifficulty=20; 615 | chicadifficulty=20; 616 | bunnydifficulty=20; 617 | freddydifficulty=20; 618 | }; 619 | 620 | function mainmenu(){ 621 | if(DEBUG_MODE){ 622 | localStorage["fnaf-js-savegame.night"]="7"; 623 | localStorage["fnaf-js-savegame.stars"]="3"; 624 | }; 625 | document.getElementById("amduatlogo").style.display="none"; 626 | document.getElementById("mainmenu").style.display="block"; 627 | tempvar = parseInt(localStorage["fnaf-js-savegame.stars"]); 628 | for(x=1;x<=tempvar;x++){ 629 | document.getElementById("achievement"+x).style.display="block"; 630 | }; 631 | if(localStorage["fnaf-js-savegame.night"]!="1") { 632 | document.getElementById("continuebutton").style.display="block"; 633 | document.getElementById("continuebuttonnight").style.display="block"; 634 | document.getElementById("continuebuttonnightnumber").style.display="block"; 635 | if(parseInt(localStorage["fnaf-js-savegame.night"])<5) { 636 | document.getElementById("continuebuttonnightnumber").src="graphics/mainmenu/littletext/"+localStorage["fnaf-js-savegame.night"]+".png"; 637 | } else { 638 | document.getElementById("continuebuttonnightnumber").src="graphics/mainmenu/littletext/5.png"; 639 | document.getElementById("6thnight").style.display="block"; 640 | if(localStorage["fnaf-js-savegame.night"]=="7") document.getElementById("customnight").style.display="block"; 641 | }; 642 | }; 643 | sound.playSound("static2.wav",0.3,true); 644 | clearInterval(mainmenuanimInterval1); 645 | sineStatic1(); 646 | mainmenuanimInterval1 = setInterval(function(){ 647 | rand=Math.random(); 648 | if(rand>0.8) { 649 | for(x=0;x<(6);x++){ 650 | //eval('setTimeout(function(){mainmenufazbearanimdiv.attr("src",mainmenufazbear['+(x & 3)+'].src);},(65*(Math.abs('+x+'+1))));'); 651 | setTimeout(function(number){mainmenufazbearanimdiv.attr("src",mainmenufazbear[(number & 3)].src);},(65*( Math.abs(x+1))),x); 652 | }; 653 | } 654 | else if(rand<0.8 && rand>0.6) { 655 | for(x=0;x<(7);x++){ 656 | //eval('setTimeout(function(){mainmenufazbearanimdiv.attr("src",mainmenufazbear['+(x & 2)+'].src);},(45*(Math.abs('+x+'+1))));'); 657 | setTimeout(function(number){mainmenufazbearanimdiv.attr("src",mainmenufazbear[(number & 2)].src);},(45*(Math.abs(x+1)))); 658 | }; 659 | } else if(rand<0.6 && rand>0.4) { 660 | for(x=0;x<(7);x++){ 661 | //eval('setTimeout(function(){mainmenufazbearanimdiv.attr("src",mainmenufazbear['+(x & 1)+'].src);},(25*(Math.abs('+x+'+1))));'); 662 | setTimeout(function(number){mainmenufazbearanimdiv.attr("src",mainmenufazbear[(number & 1)].src);},(25*(Math.abs(x+1)))); 663 | }; 664 | } else { 665 | mainmenufazbearanimdiv.attr("src",mainmenufazbear[0].src) 666 | }; 667 | },1000); 668 | }; 669 | 670 | function sineStatic1(){ 671 | temprandom = Math.random(); 672 | sineanimationtest = $('#mainmenustaticimg').animate({ 673 | opacity: 0.6 674 | },80*(temprandom*100),sineStatic2); 675 | }; 676 | 677 | function sineStatic2(){ 678 | temprandom = Math.random(); 679 | sineanimationtest = $('#mainmenustaticimg').animate({ 680 | opacity: 0.3 681 | },80*(temprandom*100),sineStatic1); 682 | }; 683 | 684 | function gameoverPowerFailure(){ 685 | clearInterval(mainThreadID); 686 | sound.playSound("powerdown.wav"); 687 | sound.stopAmbientSound(); 688 | if(feedopen==true) { 689 | OpenCloseFeed(); 690 | }; 691 | if(rightdooropen==true) { 692 | playdooranimationright(1); 693 | }; 694 | if(leftdooropen==true) { 695 | playdooranimationleft(1); 696 | }; 697 | timer.stop(); 698 | document.getElementById("fan").style.display="none"; 699 | document.getElementById("timekeeper").style.display="none"; 700 | document.getElementById("power").style.display="none"; 701 | document.getElementById("doorbuttonsleft").style.display="none"; 702 | document.getElementById("doorbuttonsright").style.display="none"; 703 | document.getElementById("openclosecamera").style.display="none"; 704 | document.getElementById("officemain").style.backgroundImage="url("+poweroutimg[0].src+")"; 705 | original = 'setTimeout(function(){document.getElementById("officemain").style.backgroundImage="url("+poweroutimg[1].src+")"},(450*5))' 706 | part1 = 'setTimeout(function(){document.getElementById("officemain").style.backgroundImage="url("+poweroutimg['; 707 | part2 = '].src+")"},(450*'; 708 | part3 = '))'; 709 | duration = ((Math.random()*100)*0.66); 710 | delay = (duration*0.2); 711 | console.log(duration); 712 | setTimeout(function(){ 713 | sound.playSound("freddy/poweroutmusic.ogg"); 714 | for(x=1;xa?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=hb(),z=hb(),A=hb(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},eb=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fb){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function gb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+rb(o[l]);w=ab.test(a)&&pb(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function hb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ib(a){return a[u]=!0,a}function jb(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function kb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function lb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function nb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function ob(a){return ib(function(b){return b=+b,ib(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pb(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=gb.support={},f=gb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=gb.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",eb,!1):e.attachEvent&&e.attachEvent("onunload",eb)),p=!f(g),c.attributes=jb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=jb(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=jb(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(jb(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),jb(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&jb(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return lb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?lb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},gb.matches=function(a,b){return gb(a,null,null,b)},gb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return gb(b,n,null,[a]).length>0},gb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},gb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},gb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},gb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=gb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=gb.selectors={cacheLength:50,createPseudo:ib,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||gb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&gb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=gb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||gb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ib(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ib(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ib(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ib(function(a){return function(b){return gb(a,b).length>0}}),contains:ib(function(a){return a=a.replace(cb,db),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ib(function(a){return W.test(a||"")||gb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:ob(function(){return[0]}),last:ob(function(a,b){return[b-1]}),eq:ob(function(a,b,c){return[0>c?c+b:c]}),even:ob(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:ob(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:ob(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:ob(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function tb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ub(a,b,c){for(var d=0,e=b.length;e>d;d++)gb(a,b[d],c);return c}function vb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wb(a,b,c,d,e,f){return d&&!d[u]&&(d=wb(d)),e&&!e[u]&&(e=wb(e,f)),ib(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ub(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:vb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=vb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=vb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sb(function(a){return a===b},h,!0),l=sb(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sb(tb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wb(i>1&&tb(m),i>1&&rb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xb(a.slice(i,e)),f>e&&xb(a=a.slice(e)),f>e&&rb(a))}m.push(c)}return tb(m)}function yb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=vb(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&gb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ib(f):f}return h=gb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,yb(e,d)),f.selector=a}return f},i=gb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&pb(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&rb(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&pb(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=jb(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),jb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||kb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&jb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||kb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),jb(function(a){return null==a.getAttribute("disabled")})||kb(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),gb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c) 3 | },removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("