<public:component lightWeight="true">
<public:attach event="onpropertychange" onevent="handlePropertychange()" />
<public:attach event="ondetach" onevent="restore()" />
<public:attach event="onresize" for="window" onevent="handleResize()" />
<script type="text/javascript">
function init(){var e=doc.createElement("div"),t=doc.createElement("img"),n;e.style.position="absolute";e.style.zIndex=-1;e.style.top=0;e.style.right=0;e.style.left=0;e.style.bottom=0;e.style.overflow="hidden";t.alt="";t.style.position="absolute";t.style.width=t.style.width="auto";e.appendChild(t);element.insertBefore(e,element.firstChild);pos=[element.currentStyle.backgroundPositionX,element.currentStyle.backgroundPositionY];element.bgsExpando=n={wrapper:e,img:t};if(element.currentStyle.zIndex=="auto"){element.style.zIndex=0}if(element.currentStyle.position=="static"){element.style.position="relative"}if(refreshDisplay(element,n)){refreshDimensions(element,n);refreshBackgroundImage(element,n,function(){updateBackground(element,n)})}}function refreshDisplay(e,t){var n=e.currentStyle.display;if(n!=t.display){t.display=n;t.somethingChanged=true}return n!="none"}function refreshDimensions(e,t){var n=e.offsetWidth-(parseFloat(e.currentStyle.borderLeftWidth)||0)-(parseFloat(e.currentStyle.borderRightWidth)||0),r=e.offsetHeight-(parseFloat(e.currentStyle.borderTopWidth)||0)-(parseFloat(e.currentStyle.borderBottomWidth)||0);if(n!=t.innerWidth||r!=t.innerHeight){t.innerWidth=n;t.innerHeight=r;t.somethingChanged=true}}function refreshBackgroundImage(e,t,n){var r=t.img,i=(rsrc.exec(e.currentStyle.backgroundImage)||[])[1];if(i&&i!=t.backgroundSrc){t.backgroundSrc=i;t.somethingChanged=true;r.onload=function(){var e=r.width,i=r.height;if(e==1&&i==1){return}t.imgWidth=e;t.imgHeight=i;t.constrain=false;n();r.style.visibility="visible";r.onload=null};r.style.visibility="hidden";r.src=t.backgroundSrc;if(r.readyState||r.complete){r.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";r.src=t.backgroundSrc}t.ignoreNextPropertyChange=true;e.style.backgroundImage="none"}else{n()}}function updateBackground(e,t){if(!t.somethingChanged){return}var n=t.img,r=t.innerWidth/t.innerHeight,i=t.imgWidth/t.imgHeight,s=t.constrain,o,u,a,f,l,c,h;f=[e.currentStyle.backgroundPositionX,e.currentStyle.backgroundPositionY];l=e.currentStyle["background-size"];c=positions[f[0]];if(typeof c=="undefined")c=parseFloat(f[0])/100;h=positions[f[1]];if(typeof h=="undefined")h=parseFloat(f[1])/100;if(l=="contain"){if(i>r){t.constrain=o="width";u=Math.floor((t.innerHeight-t.innerWidth/i)*h);n.style.top=u+"px";if(o!=s){n.style.width="100%";n.style.height="auto";n.style.left=0}}else{t.constrain=o="height";u=Math.floor((t.innerWidth-t.innerHeight*i)*c);n.style.left=u+"px";if(o!=s){n.style.width="auto";n.style.height="100%";n.style.top=0}}}else if(l=="cover"){if(i>r){t.constrain=o="height";u=Math.floor((t.innerHeight*i-t.innerWidth)*c);n.style.left=-u+"px";if(o!=s){n.style.width="auto";n.style.height="100%";n.style.top=0}}else{t.constrain=o="width";u=Math.floor((t.innerWidth/i-t.innerHeight)*h);n.style.top=-u+"px";if(o!=s){n.style.width="100%";n.style.height="auto";n.style.left=0}}}else{a=l.split(" ");if(a.length==1)a[1]="auto";n.style.width=a[0];n.style.height=a[1];u=Math.floor((t.innerHeight*i-t.innerWidth)*c);n.style.left=-u+"px";u=Math.floor((t.innerWidth/i-t.innerHeight)*h);n.style.top=-u+"px"}t.somethingChanged=false}function handlePropertychange(){var e=element.bgsExpando;if(e.ignoreNextPropertyChange){e.ignoreNextPropertyChange=false;return}if(refreshDisplay(element,e)){refreshDimensions(element,e);refreshBackgroundImage(element,e,function(){updateBackground(element,e)})}}function handleResize(){var e=element.bgsExpando;if(e.display!="none"){refreshDimensions(element,e);updateBackground(element,e)}}function restore(){var e=element.bgsExpando;try{element.style.backgroundImage="url('"+e.backgroundSrc+"')";element.removeChild(e.wrapper);element.bgsExpando=null}catch(t){}}var rsrc=/url\(["']?(.*?)["']?\)/,positions={top:0,left:0,bottom:1,right:1,center:.5},doc=element.document;init();
</script>
</public:component>