if(typeof LITHIUM=='undefined'){var LITHIUM={};};

var IEPNGFix=window.IEPNGFix||{};IEPNGFix.tileBG=function(elm,pngSrc,ready){if(!elm.currentStyle){return;}
var data=this.data[elm.uniqueID],elmW=Math.max(elm.clientWidth,elm.scrollWidth),elmH=Math.max(elm.clientHeight,elm.scrollHeight),bgX=elm.currentStyle.backgroundPositionX,bgY=elm.currentStyle.backgroundPositionY,bgR=elm.currentStyle.backgroundRepeat;if(!data.tiles){data.tiles={elm:elm,src:'',cache:[],img:new Image(),old:{}};}
var tiles=data.tiles,pngW=tiles.img.width,pngH=tiles.img.height;if(pngSrc){if(!ready&&pngSrc!=tiles.src){tiles.img.onload=function(){this.onload=null;IEPNGFix.tileBG(elm,pngSrc,1);};return tiles.img.src=pngSrc;}}else{if(tiles.src)ready=1;pngW=pngH=0;}
tiles.src=pngSrc;if(!ready&&elmW==tiles.old.w&&elmH==tiles.old.h&&bgX==tiles.old.x&&bgY==tiles.old.y&&bgR==tiles.old.r){return;}
var pos={top:'0%',left:'0%',center:'50%',bottom:'100%',right:'100%'},x,y,pc;x=pos[bgX]||bgX;y=pos[bgY]||bgY;if(pc=x.match(/(\d+)%/)){x=Math.round((elmW-pngW)*(parseInt(pc[1])/100));}
if(pc=y.match(/(\d+)%/)){y=Math.round((elmH-pngH)*(parseInt(pc[1])/100));}
x=parseInt(x);y=parseInt(y);var repeatX={'repeat':1,'repeat-x':1}[bgR],repeatY={'repeat':1,'repeat-y':1}[bgR];if(repeatX){return;}
if(repeatY){return;}
this.hook.enabled=0;if(!({relative:1,absolute:1}[elm.currentStyle.position])){elm.style.position='relative';}
var count=0,xPos,maxX=repeatX?elmW:x+0.1,yPos,maxY=repeatY?elmH:y+0.1,d,s,isNew;if(pngW&&pngH){for(xPos=x;xPos<maxX;xPos+=pngW){for(yPos=y;yPos<maxY;yPos+=pngH){isNew=0;if(!tiles.cache[count]){tiles.cache[count]=document.createElement('div');isNew=1;}
var clipR=(xPos+pngW>elmW?elmW-xPos:pngW),clipB=(yPos+pngH>elmH?elmH-yPos:pngH);d=tiles.cache[count];s=d.style;s.behavior='none';s.left=xPos+'px';s.top=yPos+'px';s.width=clipR+'px';s.height=clipB+'px';s.clip='rect('+
(yPos<0?0-yPos:0)+'px,'+
clipR+'px,'+
clipB+'px,'+
(xPos<0?0-xPos:0)+'px)';s.display='block';if(isNew){s.position='absolute';s.zIndex=-999;if(elm.firstChild){elm.insertBefore(d,elm.firstChild);}else{elm.appendChild(d);}}
this.fix(d,pngSrc,0);count++;}}}
while(count<tiles.cache.length){this.fix(tiles.cache[count],'',0);tiles.cache[count++].style.display='none';}
this.hook.enabled=1;tiles.old={w:elmW,h:elmH,x:bgX,y:bgY,r:bgR};};IEPNGFix.update=function(){for(var i in IEPNGFix.data){var t=IEPNGFix.data[i].tiles;if(t&&t.elm&&t.src){IEPNGFix.tileBG(t.elm,t.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);});}

LITHIUM.Loader=function(){var functionCache=[];var loaded=false;return{"onLoad":function(func){functionCache.push(func);},getOnLoadFunctions:function(){return functionCache;},setLoaded:function(){loaded=true;},isLoaded:function(){return loaded;}}}();

if(typeof LITHIUM.Components=='undefined'){LITHIUM.Components={};};LITHIUM.Components.render=function(componentId,parameters,optionsParam){var runner=function(){var url=LITHIUM.Components.renderUrl(componentId);var options={method:"GET"}
Object.extend(options,optionsParam||{});options.parameters=$H(parameters).update(options.parameters);new Ajax.CachedRequest(url,options);}
if(LITHIUM.Loader.isLoaded()==true){runner();}else{runner();}}
LITHIUM.Components.renderUrl=function(componentId,parameters){var url=new Template(LITHIUM.Components.RENDER_URL).evaluate({"component-id":componentId});if(!Object.isUndefined(parameters)){url+="?"+$H(parameters).toQueryString();}
return url;}
LITHIUM.Components.renderInPlace=function(componentId,parametersParam,optionsParam){if(LITHIUM.Loader.isLoaded()==false){var parameters=parametersParam||{};var options=optionsParam||{};var placeHolderId=new Date().getTime().toString();document.write("<div id='"+placeHolderId+"'></div>");options.onSuccess=function(transport){$(placeHolderId).replace(transport.responseJSON.content);}
this.render(componentId,parameters,options);}else{throw new Error("LITHIUM.Components.renderInPlace can only be used during page loading.")}}
LITHIUM.Components.renderTemplateInPlace=function(template,options){LITHIUM.Components.renderInPlace("common.widget.template-content",{value:template},options);}
LITHIUM.Components.renderTemplate=function(template,options){return this.render("common.widget.template-content",{value:template,asMarkup:true},options);}
