(function(){
02.
var db=document.body;
03.
var img=document.getElementById('holder').getElementsByTagName('img')[0];
04.
 
05.
var dbsize={}; //needed to store body size
06.
var imgsrc=img.src; //needed to store images src
07.
var keyStop=function(e){
08.
var e=window.event||e||{};
09.
var tag=e.target.tagName.toLowerCase();
10.
if(tag!='textarea'&&!(tag=='input'&&(e.target.type=='text'||e.target.type=='password'))){ //are the user not writing?
11.
if(e.keyCode==32||e.keyCode==39||e.keyCode==40){ //Did he press any of the "scrolling-keys"? (down, right, and space key)
12.
if(e.preventDefault)e.preventDefault();
13.
else e.returnValue=false;
14.
}
15.
}
16.
}
17.
 
18.
if(this.addEventListener)window.addEventListener('keydown',keyStop,false);
19.
else window.attachEvent('onkeydown',keyStop);
20.
 
21.
setInterval(function(){
22.
window.scrollTo(0,0);
23.
if(img.complete){ //check if image has loaded
24.
if(db.clientWidth!=dbsize.w||db.clientHeight!=dbsize.h||img.src!=imgsrc){ //check if size or img size has changed
25.
imgsrc=img.src; //store current src
26.
dbsize.w=db.clientWidth; //store current body width
27.
dbsize.h=db.clientHeight; //store current body height
28.
 
29.
var newwidth=Math.round(dbsize.h*(img.offsetWidth/img.offsetHeight)); //calculate new width based on height
30.
 
31.
img.style.width=(dbsize.w>newwidth?dbsize.w:newwidth)+'px'; //use the largest value of body-width and newwidht
32.
//and this is the real trick: if there's no specified height, the height is automaticly calculated relative to the with
33.
}
34.
}
35.
},300);
36.
})();
