/*

shared-javascript.js

Shared JavaScript functions.

Except where stated otherwise:

(C) 2010 Spoton.net Limited - http://spoton.net/
Created by Stephen Morley - http://stephenmorley.org/

*/

// prevent framing
if (window.top!=window.self&&(window.location.href.indexOf('itseeze.co.uk')!=-1||window.location.href.indexOf('spotonnet.co.uk')!=-1)){window.top.location.replace('http://spotonnet.co.uk/frames/?url='+encodeURIComponent(window.location.href));}

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=\""+WebEdit.ROOT_PATH+"_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);}};

WebEdit.DropDown =
    {
      'show' : function(_1){WebEdit.DropDown.hide();var _2=document.createElement("div");_2.id="webeditDropDownCover";_2.style.width=document.documentElement.scrollWidth+"px";_2.style.height=document.documentElement.scrollHeight+"px";_2.onmouseover=WebEdit.DropDown.hide;document.body.appendChild(_2);var _3=_1.getElementsByTagName("ul");if(_3.length>0){_3[0].style.display="block";}},
      'hide' : function(){var _4=document.getElementById("webeditDropDownCover");if(_4){document.body.removeChild(_4);var _5=document.getElementsByTagName("ul");for(var _6=0;_6<_5.length;_6++){if(_5[_6].parentNode.className=="webeditDropdownChildren"){_5[_6].style.display="none";}}}}
    }

/*

OnloadScheduler.js

Schedules functions to run when a document has loaded.

ImagePreloader.js

Schedules images to be preloaded.

SmoothMovement.js

Facilitates smooth movement effects.

Created by Stephen Morley - http://stephenmorley.org/ - and released under the
terms of the CC0 1.0 Universal legal code:

http://creativecommons.org/publicdomain/zero/1.0/legalcode

*/

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--){_4(_2[i]);}for(var i=0;i<_3.length;i++){_4(_3[i]);}}};function _4(_5){if(_5){for(var i=0;i<_5.length;i++){try{_5[i]();}catch(e){}}}};function _6(){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(_7,_8){_6();if(_7 instanceof Function){if(!_8){_8=0;}if(_8<0){if(_2[-_8]){_2[-_8].push(_7);}else{_2[-_8]=[_7];}}else{if(_3[_8]){_3[_8].push(_7);}else{_3[_8]=[_7];}}}else{this.schedule(function(){eval(_7);},_8);}};};

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){
this.position=_1;
this.target=_2;
this.velocity=0;
this.animationInterval=null;
};
SmoothMovement.prototype.update=function(){
if(this.velocity<0){
if(this.target>this.position-this.velocity*(this.velocity-1)/2){
this.velocity++;
}else{
if(this.target<=this.position-(this.velocity-1)*(this.velocity-2)/2){
this.velocity--;
}
}
}else{
if(this.target<this.position+this.velocity*(this.velocity+1)/2){
this.velocity--;
}else{
if(this.target>=this.position+(this.velocity+1)*(this.velocity+2)/2){
this.velocity++;
}
}
}
this.position+=this.velocity;
return this.position;
};
SmoothMovement.prototype.hasStopped=function(){
return (this.position==this.target&&this.velocity==0);
};
SmoothMovement.prototype.animate=function(_3,_4,_5){
if(this.animationInterval){
window.clearInterval(this.animationInterval);
}
this.animationInterval=window.setInterval(this.createAnimationClosure(_4,_5),_3);
};
SmoothMovement.prototype.createAnimationClosure=function(_6,_7){
var _8=this;
return function(){
_8.update();
_6(_8.position,_8);
if(_8.hasStopped()){
window.clearInterval(_8.animationInterval);
_8.animationInterval=null;
if(_7){
_7(_8);
}
}
};
};

