function kickstrapReady(){if(appCheck){this.loadedLoop=[];for(var e=0;appArray.length>e||function(){this.loadedLoop.every(Boolean)&&ks.fire()}();e++){var t=appArray[e].countRequired,s=appArray[e].countDependent;appArray[e].loaded=t[0]==t[1]&&s[0]==s[1]?!0:!1,this.loadedLoop.push(appArray[e].loaded)}}}function consoleLog(e,t,s){var r="KS: ";if(ks.opts.console&&window.console)if(s)console.log([e,s]);else switch(t){case"warn":console.warn(r+e);break;case"error":console.error(r+e);break;default:console.log(r+e)}}function setDir(e,t){"root"==t&&(ks.opts.rootDir=ks.opts.rootDir||e),"universal"==t&&(ks.opts.universals=ks.opts.universals||e)}function clearCache(){var e="w"==(localStorage.setItem="w");e?(localStorage.clear(),consoleLog("Cache has been cleared. Reloading..."),location.reload(!0)):consoleLog("This browser does not support localStorage.","error")}function formatString(e,t){return e+="",t?(e+="",e=e.replace(/\\'/g,"'"),e=e.replace(/\\"/g,'"'),e=e.replace(/\\0/g,"\0"),e=e.replace(/\\\\/g,"\\"),e=e.substring(1,e.length-1)):e=e.replace(/['"]/g,""),e=e.replace(/br-/gi,";")}function getInternetExplorerVersion(){var e=-1;if("Microsoft Internet Explorer"==navigator.appName){var t=navigator.userAgent,s=RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");null!=s.exec(t)&&(e=parseFloat(RegExp.$1))}return e}function themeFunction(e){$.ajax({type:"GET",url:ks.opts.rootDir+"Kickstrap/themes/"+e+"/functions.js",dataType:"script",context:self})}function setupKickstrap(){if(("normal"==$("#appList").css("content")||void 0==$("#appList").css("content"))&&(contentHack.selector="ie8",void 0==$("#appList").css("ie8")||""==$("#appList").css("ie8"))){var e="";contentHack.parse=!0;for(var t=0;document.styleSheets.length>t;t++)if(null!=document.styleSheets[t].rules)for(var s=0;document.styleSheets[t].rules.length>s;s++){var r=document.styleSheets[t].rules[s].selectorText;"#appList"==r?ks.apps=ks.apps.concat(formatString(document.styleSheets[t].rules[s].style.content,!0).splitCSV()):("script#rootDir"==r||"script#console"==r||"script#caching"==r)&&(e+=formatString(document.styleSheets[t].rules[s].style.content,!0))}document.write(e)}document.write('<script id="ffBug"></script><script id="rootDir" type="text/javascript">appendMagic(\'#rootDir\');</script><script id="themeFunctions">appendMagic(\'#themeFunctions\');</script><script id="console" type="text/javascript">appendMagic(\'#console\');</script><script id="caching" type="text/javascript">appendMagic(\'#caching\');ffSlashBugCheck();</script>')}function appendMagic(e){appendees=appendees.concat(e)}function ffSlashBugCheck(){var e=$("script#ffBug").css("content");"success"!=e&&setTimeout(function(){initKickstrap()},500)}function initKickstrap(){if(!contentHack.parse)for(var e=0;appendees.length>e;e++){var t=formatString($(appendees[e]).css(contentHack.selector),!0);("ndefine"==t||"on"==t)&&(t="<script></script>"),$("body").append(t)}if(universalsSet||"none"!=ks.opts.universals||(universalsSet=!0),universalsSet){contentHack.parse||(ks.apps=ks.apps.concat(formatString($("#appList").css(contentHack.selector)).splitCSV())),8!=ver&&7!=ver&&(ks.apps=ks.apps.filter(function(e,t){return ks.apps.indexOf(e)==t}));for(var e=0;ks.apps.length>e;e++)theapp=ks.apps[e],theapp.isIgnored()&&(ks.apps.remove(e),e--);0==ks.apps.length&&ks.fire();for(var e=0;ks.apps.length>e;e++)theapp=ks.apps[e],window[ks.apps[e]]=new app(theapp)}else universal=new app("universal")}function cssIfy(e){var t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("type","text/css"),t.setAttribute("href",e),document.getElementsByTagName("body")[0].appendChild(t)}function app(e){function t(t){var s=t[0].splitCSV();for(i=0;s.length>i;i++)s[i].isIgnored()&&s.splice(s.indexOf(s[i]),1);var n;if(n="object"==typeof window[e]?window[e]:this,n.resourcesRequired=s,t[1]){var o=t[1].splitCSV();for(i=0;o.length>i;i++)o[i].isIgnored()&&o.splice(o.indexOf(o[i]),1);n.resourcesDependent=o}appArray.push(n),universalsSet||r(),appArray.length==ks.apps.length&&r()}function s(){universalsSet=!0,appArray=[],initKickstrap()}function r(){universalsSet&&ks.apps.length>0&&(appCheck=!0);for(var e=0;appArray.length>e||function(){universalsSet||0!=appArray[0].countRequired[1]||s()}();e++){appArray[e].countRequired[0]=0,consoleLog("KS: "+appArray[e].name,null,appArray[e]);for(var t=0;appArray[e].resourcesRequired.length>t;t++){var r=appArray[e].resourcesRequired[t],n=configPath+appArray[e].name+"/"+r;r.isPublic()&&(n=r),r.isIgnored()||(r.isJS()?$.ajax({type:"GET",url:n,dataType:"script",context:this,beforeSend:function(t){t.thisIs=appArray[e],t.thisIs.countRequired[1]++},success:function(e,t,s){var r=s.thisIs;if(r.countRequired[0]++,r.countRequired[0]==r.countRequired[1]){universalsSet||(universalsSet=!0,appArray=[],initKickstrap(),universal.countDependent=[0,0]),r.countDependent[0]=0,kickstrapReady(r.name);for(var n=0;r.resourcesDependent.length>n;n++){var o=configPath+r.name+"/"+r.resourcesDependent[n];r.resourcesDependent[n].isPublic()&&(o=r.resourcesDependent[n]),o.isJS()?$.ajax({type:"GET",url:o,dataType:"script",context:this,beforeSend:function(e){e.thisIs=r,e.thisIs.countDependent[1]++},success:function(e,t,s){var r=s.thisIs;r.countDependent[0]++,kickstrapReady(r.name)}}):(r.countDependent[0]++,r.countDependent[1]++,cssIfy(o))}}}}):(appArray[e].countRequired[0]++,appArray[e].countRequired[1]++,cssIfy(n)))}}}this.resourcesRequired=[],this.resourcesDependent=[],this.countRequired=[999,0],this.countDependent=[999,0],this.name=e,this.loaded=!1,configPath=ks.opts.rootDir+"Kickstrap/apps/",this.configPath=configPath+e+"/config.ks",("http:"==e.substring(0,5)||"https:"==e.substring(0,6))&&(this.configPath=e),universalsSet||"local"==ks.opts.universals||void 0==ks.opts.universals||(this.configPath=ks.opts.universals+"/universal/config.ks"),$.ajax({type:"GET",url:this.configPath,dataType:"html",context:self,success:function(e){this.resources=e.split(/\r\n|\n/),t(this.resources)},error:function(t,s,r){consoleLog('Could not load the app "'+e+'" ['+t.status+" ("+r+")]","error"),diagnosticMsgs.push("Verify your rootDir variable in kickstrap.less or in JavaScript has been set correctly."),diagnosticMsgs.push("Is the name of the app spelled correctly? Should match the name of the folder."),diagnosticMsgs.push("Do the above 404 errors reflect the right paths to files?.")}})}var contentHack={selector:"content",parse:!1},appendees=[],self=this,configPath,appArray=[],universalsSet=!1,readyFired=!1,appCheck=!1,thisVersion="1.3.0",diagnosticMsgs=[],rootDir,appList,kickstrap={};if(!ks)var ks={};ks.opts||(ks.opts={}),ks.apps||(ks.apps=[]);var empty=[];ks.apps=empty.concat(ks.apps),ks.opts.console&&"boolean"==typeof ks.opts.console||(ks.opts.console=!1),ks.hello="KS: Hi! ("+thisVersion+")",ks.edit=function(){document.body.contentEditable="true",document.designMode="on","function"==typeof window.$.pnotify?$.pnotify({title:"Prototyping Mode",text:"You can now edit anything in this page. (But it won't be saved!)",type:"success",styling:"bootstrap"}):consoleLog("You can now edit anything in this page. (But it won't be saved!")},ks.readyFxs=[],ks.ready=function(e){this.readyFxs.push(e)},kickstrap.ready=function(e){ks.readyFxs.push(e),consoleLog("Warning, kickstrap.ready is deprecated. Use ks.ready instead","warn")},ks.testParams={readyCount:0},ks.fire=function(){if(!readyFired){readyFired=!0,ks.testParams.readyCount++,consoleLog("Executing ks.ready() functions");for(var e=0;ks.readyFxs.length>e;e++)ks.readyFxs[e]();rootDir=ks.opts.rootDir,appList=ks.apps}},String.prototype.isIgnored=function(){return"//"==this.substr(0,2)||""==this},String.prototype.isPublic=function(){return"http:"==this.substr(0,5)||"https:"==this.substr(0,6)},String.prototype.isJS=function(){return".js"==this.substr(this.length-3,this.length)},String.prototype.splitCSV=function(e){for(var t,s=this.split(e=e||","),r=s.length-1;r>=0;r--)s[r]=s[r].replace(/ /g,""),'"'==s[r].replace(/"\s+$/,'"').charAt(s[r].length-1)?(t=s[r].replace(/^\s+"/,'"')).length>1&&'"'==t.charAt(0)?s[r]=s[r].replace(/^\s*"|"\s*$/g,"").replace(/""/g,'"'):r?s.splice(r-1,2,[s[r-1],s[r]].join(e)):s=s.shift().split(e).concat(s):s[r].replace(/""/g,'"');return s},Array.prototype.remove=function(e,t){var s=this.slice((t||e)+1||this.length);return this.length=0>e?this.length+e:e,this.push.apply(this,s)},"object"!=typeof console&&(console={},console.log=function(){}),"every"in Array.prototype||(Array.prototype.every=function(e,t){for(var s=0,r=this.length;r>s;s++)if(s in this&&!e.call(t,this[s],s,this))return!1;return!0}),"indexOf"in Array.prototype||(Array.prototype.indexOf=function(e,t){void 0===t&&(t=0),0>t&&(t+=this.length),0>t&&(t=0);for(var s=this.length;s>t;t++)if(t in this&&this[t]===e)return t;return-1}),"filter"in Array.prototype||(Array.prototype.filter=function(e,t){for(var s,r=[],n=0,o=this.length;o>n;n++)n in this&&e.call(t,s=this[n],n,this)&&r.push(s);return r});var ver=getInternetExplorerVersion();ver>-1&&(contentHack.selector=9>ver?"ie8":"content"),setTimeout(function(){if(!readyFired){if("undefined"==ks.opts.rootDir&&diagnosticMsgs.push('Your rootDir is "undefined" Often this is caused by the main stylesheet not loading.'),consoleLog("I noticed your page still hasn't loaded."),diagnosticMsgs=diagnosticMsgs.filter(function(e,t){return diagnosticMsgs.indexOf(e)==t}),diagnosticMsgs.length>0){consoleLog("-Diagnostics--------");for(var e=0;diagnosticMsgs.length>e;e++)consoleLog(diagnosticMsgs[e],"info");consoleLog("--------------------")}ks.opts.readyOverride?ks.fire():consoleLog("If you want ks.ready() to fire anyway, set ks.opts.readyOverride to true.")}},5e3),setupKickstrap();