(function(c){var a,b;c.fn.panohead=function(d){a=c.extend({},c.fn.panohead.defaults,d);a.time=a.timeInit;loadNewImage();return this};change=function(){var e;e=c(document).scrollTop()||c(window).scrollTop();if(e<a.topHeight){clearTimeout(b);c("#head1").fadeTo("slow",0,function(){c("#head1").css("background-image","url("+a.baseUrl+a.index+a.fileExt+")");c("#head1").fadeTo("slow",1,function(){a.time=(a.time>=a.timeMax)?a.timeMax:(a.time+a.timeAdd);loadNewImage()})})}else{clearTimeout(b);b=setTimeout(function d(){change()},a.timeMax)}};getNewIndex=function(){var d=a.Index;while(d===a.Index){d=randomBetween(0,a.maxImg)}return d};loadNewImage=function(){var e="",d;a.index=getNewIndex();e=a.baseUrl+a.index+a.fileExt;d=new Image();c(d).attr("src",e).load(function(){c("#head2").css("background-image","url("+e+")");b=setTimeout(function f(){change()},a.time)})};random=function(d){return Math.floor(d*(Math.random()%1))};randomBetween=function(e,d){return(e+random(d-e+1))};c.fn.panohead.defaults={index:1,maxImg:92,baseUrl:"res/head_",fileExt:".jpg",topHeight:250,timeInit:4000,time:2000,timeAdd:100,timeMax:20000}})(jQuery);
