﻿var IEPNGFix=window.IEPNGFix||{};IEPNGFix.tileBG=function(g,q,n){var F=this.data[g.uniqueID],b=Math.max(g.clientWidth,g.scrollWidth),h=Math.max(g.clientHeight,g.scrollHeight),j=g.currentStyle.backgroundPositionX,i=g.currentStyle.backgroundPositionY,o=g.currentStyle.backgroundRepeat;if(!F.tiles){F.tiles={elm:g,src:"",cache:[],img:new Image(),old:{}}}var B=F.tiles,u=B.img.width,c=B.img.height;if(q){if(!n&&q!=B.src){B.img.onload=function(){this.onload=null;IEPNGFix.tileBG(g,q,1)};return B.img.src=q}}else{if(B.src){n=1}u=c=0}B.src=q;if(!n&&b==B.old.w&&h==B.old.h&&j==B.old.x&&i==B.old.y&&o==B.old.r){return}var e={top:"0%",left:"0%",center:"50%",bottom:"100%",right:"100%"},l,k,a;l=e[j]||j;k=e[i]||i;if(a=l.match(/(\d+)%/)){l=Math.round((b-u)*(parseInt(a[1])/100))}if(a=k.match(/(\d+)%/)){k=Math.round((h-c)*(parseInt(a[1])/100))}l=parseInt(l);k=parseInt(k);var D={repeat:1,"repeat-x":1}[o],A={repeat:1,"repeat-y":1}[o];if(D){l%=u;if(l>0){l-=u}}if(A){k%=c;if(k>0){k-=c}}this.hook.enabled=0;if(!({relative:1,absolute:1}[g.currentStyle.position])){g.style.position="relative"}var f=0,m,z=D?b:l+0.1,r,v=A?h:k+0.1,w,p,C;if(u&&c){for(m=l;m<z;m+=u){for(r=k;r<v;r+=c){C=0;if(!B.cache[f]){B.cache[f]=document.createElement("div");C=1}var t=Math.max(0,m+u>b?b-m:u),E=Math.max(0,r+c>h?h-r:c);w=B.cache[f];p=w.style;p.behavior="none";p.left=(m-parseInt(g.currentStyle.paddingLeft))+"px";p.top=r+"px";p.width=t+"px";p.height=E+"px";p.clip="rect("+(r<0?0-r:0)+"px,"+t+"px,"+E+"px,"+(m<0?0-m:0)+"px)";p.display="block";if(C){p.position="absolute";p.zIndex=-999;if(g.firstChild){g.insertBefore(w,g.firstChild)}else{g.appendChild(w)}}this.fix(w,q,0);f++}}}while(f<B.cache.length){this.fix(B.cache[f],"",0);B.cache[f++].style.display="none"}this.hook.enabled=1;B.old={w:b,h:h,x:j,y:i,r:o}};IEPNGFix.update=function(){for(var b in IEPNGFix.data){var a=IEPNGFix.data[b].tiles;if(a&&a.elm&&a.src){IEPNGFix.tileBG(a.elm,a.src)}}};IEPNGFix.update.timer=0;if(window.attachEvent&&!window.opera){window.attachEvent("onresize",function(){clearTimeout(IEPNGFix.update.timer);IEPNGFix.update.timer=setTimeout(IEPNGFix.update,100)})};