// Preload and display / stretch visuals
function imgpreload(a,b){b instanceof Function&&(b={all:b}),typeof a=="string"&&(a=[a]);var c=[],d=a.length,e=0;for(e;e<d;e++){var f=new Image;f.onload=function(){c.push(this),b.each instanceof Function&&b.each.call(this),c.length>=d&&b.all instanceof Function&&b.all.call(c)},f.src=a[e]}}(function(a){a.doVisuals=function(b){function j(b,c,d){clearTimeout(f);var e=b.length,f=setTimeout(function(){a.backstretch("/images/visuals/"+b[c]+".jpg",g),j(b,(c+1).mod(e),settings.rotateDelay)},d)}settings={loresVisual:"",hiresVisual:"",imageCenter:"",rotatingVisuals:[],fadeSpeed:1500,rotateDelay:5e3,niceFadeAfter:350},a.extend(settings,b);var c=!1,d=!1,e=null,f=!1,g={center:settings.imageCenter,speed:settings.fadeSpeed},h={center:settings.imageCenter,speed:0},i=setTimeout(function(){f=!0},settings.niceFadeAfter);a.imgpreload(settings.hiresVisual,function(){d=!0,clearTimeout(i),c?a.backstretch(settings.hiresVisual,g):a.backstretch(settings.hiresVisual,h),settings.rotatingVisuals.length&&j(settings.rotatingVisuals,0,settings.rotateDelay+(c&&f?settings.fadeSpeed:0))}),d||a.backstretch(settings.loresVisual,h,function(){c=!0})}})(jQuery),Number.prototype.mod=function(a){return(this%a+a)%a},function(a){a.backstretch=function(b,c,d){function n(){c&&typeof c=="object"&&(a.extend(e,c),e.centeredX===!0?e.centeredX=.5:e.centeredX===!1&&(e.centeredX=0),e.centeredY===!0?e.centeredY=.5:e.centeredY===!1&&(e.centeredY=0),e.center!=undefined&&e.center.constructor==Array&&(e.center[0]!=undefined&&(e.centeredX=e.center[0]),e.center[1]!=undefined&&(e.centeredY=e.center[1])))}function o(){if(b){var c;f.length==0?f=a("<div />").attr("id","backstretch").css({left:0,top:0,position:"fixed",overflow:"hidden",zIndex:-999999,margin:0,padding:0,height:"100%",width:"100%"}):f.find("img").addClass("deleteable"),c=a("<img />").css({position:"absolute",display:"none",margin:0,padding:0,border:"none",zIndex:-999999}).bind("load",function(b){var c=a(this),g,i;c.css({width:"auto",height:"auto"}),g=this.width||a(b.target).width(),i=this.height||a(b.target).height(),h=g/i,p(function(){c.fadeIn(e.speed,function(){f.find(".deleteable").remove(),typeof d=="function"&&d()})})}).appendTo(f),a("body #backstretch").length==0&&a("body").append(f),f.data("settings",e),c.attr("src",b),a(window).resize(p)}}function p(b){try{m={left:0,top:0},j=g.width(),k=j/h,k>=g.height()?e.centeredY>0&&(l=(k-g.height())*e.centeredY,a.extend(m,{top:"-"+l+"px"})):(k=g.height(),j=k*h,e.centeredX>0&&(l=(j-g.width())*e.centeredX,a.extend(m,{left:"-"+l+"px"}))),a("#backstretch, #backstretch img:not(.deleteable)").width(j).height(k).filter("img").css(m)}catch(c){}typeof b=="function"&&b()}var e={centeredX:.5,centeredY:.5,speed:0},f=a("#backstretch"),g="onorientationchange"in window?a(document):a(window),h,i,j,k,l,m;return n(),a(document).ready(o),this}}(jQuery),typeof jQuery!="undefined"&&function(a){a.imgpreload=imgpreload,a.fn.imgpreload=function(b){b=a.extend({},a.fn.imgpreload.defaults,b instanceof Function?{all:b}:b),this.each(function(){var c=this;imgpreload(a(this).attr("src"),function(){b.each instanceof Function&&b.each.call(c)})});var c=[];this.each(function(){c.push(a(this).attr("src"))});var d=this;return imgpreload(c,function(){b.all instanceof Function&&b.all.call(d)}),this},a.fn.imgpreload.defaults={each:null,all:null}}(jQuery),$(document).ready(function(){if($("body").hasClass("home"))var a=[.5,.3],b=["beveiliging/beveiliging","mobiliteit/junior-directiechauffeur","receptie/homepage"];else var a=visualFocus?visualFocus:"",b=[];$.browser.msie&&$.browser.version.substr(0,1)<7?$("body").css({background:"url("+hiresVisual+") left top no-repeat"}):$.doVisuals({loresVisual:loresVisual,hiresVisual:hiresVisual,imageCenter:a,rotatingVisuals:b})})
