/* OnloadScheduler.js - schedules functions to run when a document has loaded
 * ImagePreloader.js  - schedules images to be preloaded
 * SmoothMovement.js  - facilitates the smooth movement of display components
 *
 * The author of this program, Safalra (Stephen Morley), irrevocably releases
 * all rights to this program, with the intention of it becoming part of the
 * public domain. Because this program is released into the public domain, it
 * comes with no warranty either expressed or implied, to the extent permitted
 * by law.
 *
 * For more public domain JavaScript code by the same author, visit:
 * http://safalra.com/web-design/javascript/
 */

var OnloadScheduler=new function(){this.allTasksExecuted=false;var _1=false;var _2=new Array();var _3=new Array();this.executeAllTasks=function(){if(!OnloadScheduler.allTasksExecuted){OnloadScheduler.allTasksExecuted=true;for(var i=_2.length-1;i>0;i--){_5(_2[i]);}for(var i=0;i<_3.length;i++){_5(_3[i]);}}};function _5(_6){if(_6){for(var i=0;i<_6.length;i++){_6[i]();}}};function _8(){if(!_1){_1=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);OnloadScheduler.executeAllTasks();},false);}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState=="complete"){document.detachEvent("onreadystatechange",arguments.callee);OnloadScheduler.executeAllTasks();}});if(document.documentElement.doScroll&&window==window.top){(function(){if(!OnloadScheduler.allTasksExecuted){try{document.documentElement.doScroll("left");OnloadScheduler.executeAllTasks();}catch(error){setTimeout(arguments.callee,0);}}})();}window.onload=function(){OnloadScheduler.executeAllTasks();};}}}};this.schedule=function(_9,_a){_8();if(_9 instanceof Function){if(!_a){_a=0;}if(_a<0){if(_2[-_a]){_2[-_a].push(_9);}else{_2[-_a]=[_9];}}else{if(_3[_a]){_3[_a].push(_9);}else{_3[_a]=[_9];}}}else{this.schedule(function(){eval(_9);},_a);}};};

var ImagePreloader=new function(){var _1=[];this.schedule=function(_2,_3,_4,_5){OnloadScheduler.schedule(createPreloadClosure(_2,_4,_5),_3);};function createPreloadClosure(_6,_7,_8){return function(){var _9=new Image();if(_7 instanceof Function){_9.onload=_7();}if(_8 instanceof Function){_9.onerror=_8();}_9.src=_6;_1.push(_9);};}}();

function SmoothMovement(_1,_2,_3){_1=Math.round(_1);_2=Math.round(_2);_3=(_3?Math.round(_3):0);this.updatePosition=function(){_1+=_3;if(_3<0){if(_1-_3*(_3-1)/2<_2){_3++;}else{if(_1-(_3-1)*(_3-2)/2>=_2){_3--;}}}else{if(_1+_3*(_3+1)/2>_2){_3--;}else{if(_1+(_3+1)*(_3+2)/2<=_2){_3++;}}}return _1;};this.changeTarget=function(_4){_2=Math.round(_4);};this.getPosition=function(){return _1;};this.getVelocity=function(){return _3;};this.hasStopped=function(){return (_1==_2&&_3==0);};}

/*

webedit-lightbox.js

A function for creating a lightbox.

(C) 2009 Spoton Corporation - http://www.spoton.net/
Created by Stephen Morley - http://safalra.com/

*/

function webeditLightbox(_1,_2,_3){var _4=0;var _5=0;if(window.innerWidth){_4=window.innerWidth;_5=window.innerHeight;}else{if(document.documentElement&&document.documentElement.clientWidth){_4=document.documentElement.clientWidth;_5=document.documentElement.clientHeight;}else{if(document.body&&document.body.clientWidth){_4=document.body.clientWidth;_5=document.body.clientHeight;}}}if(_4&&_5){var _6=_4-48;var _7=_5-76;if(_6>_2&&_7>_3){_6=_2;_7=_3;}else{if(_6*_3>_2*_7){_6=Math.round(_7*_2/_3);}else{_7=Math.round(_6*_3/_2);}}var _8=document.createElement("div");_8.id="webeditCoreLightbox";_8.onclick=function(){document.body.removeChild(document.getElementById("webeditCoreLightbox"));};_8.innerHTML="<div style=\"top:"+Math.floor((_5-_7)/2-26)+"px;left:"+Math.floor((_4-_6)/2-12)+"px;\">"+"<img src=\""+_1.replace(/%%width%%/g,_6).replace(/%%height%%/g,_7)+"\" width=\""+_6+"\" height=\""+_7+"\">"+(window.XMLHttpRequest?"<br><span>Click to close this box</span>":"")+"</div>";if(!window.XMLHttpRequest){_8.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+rootPath+"_webedit/images/semitransparent-black-block.png\",sizingMethod=\"scale\")";_8.style.width=document.documentElement.scrollWidth;_8.style.height=document.documentElement.scrollHeight;_8.firstChild.style.top=document.documentElement.scrollTop+12;}document.body.appendChild(_8);}};
