if(!window.Mage)var Mage={};Mage.Cookies={};Mage.Cookies.set=function(name,value){var argv=arguments;var argc=arguments.length;var expires=(argc>2)?argv[2]:null;var path=(argc>3)?argv[3]:'/';var domain=(argc>4)?argv[4]:null;var secure=(argc>5)?argv[5]:false;document.cookie=name+"="+escape(value)+
((expires==null)?"":("; expires="+expires.toGMTString()))+
((path==null)?"":("; path="+path))+
((domain==null)?"":("; domain="+domain))+
((secure==true)?"; secure":"");};Mage.Cookies.get=function(name){var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;var j=0;while(i<clen){j=i+alen;if(document.cookie.substring(i,j)==arg)
return Mage.Cookies.getCookieVal(j);i=document.cookie.indexOf(" ",i)+1;if(i==0)
break;}
return null;};Mage.Cookies.clear=function(name){if(Mage.Cookies.get(name)){document.cookie=name+"="+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}};Mage.Cookies.getCookieVal=function(offset){var endstr=document.cookie.indexOf(";",offset);if(endstr==-1){endstr=document.cookie.length;}
return unescape(document.cookie.substring(offset,endstr));};;var aitpagecache_Loader=Class.create({isDataLoaded:false,data:null,config:{blockClass:'aitoc-aitpagecache-loadable-block',loadingEffectClass:'aitoc-aitpagecache-loading-effect',disabledCacheBlocks:[],noCacheFlag:'noMagentoBoosterCache'},initialize:function(config){Object.extend(this.config,config);document.observe('dom:loaded',this.onDomLoaded.bind(this));},onDomLoaded:function(){this.process();},process:function(){if(!$$('.'+this.config.blockClass).size()){return;}
this.config.disabledCacheBlocks.each(function(blockId){this.addLoadingEffect(this.getPageCacheBlockId(blockId))},this);new Ajax.Request(this.getNoCacheUrl(this.config.url,this.config.noCacheFlag),{method:'GET',onSuccess:function(transport){var cntr=new Element('div');Element.extend(cntr);cntr.update(transport.responseText);this.config.disabledCacheBlocks.each(function(blockId){var block=$(this.getPageCacheBlockId(blockId));if(block)
{block.replace(cntr.down('#'+block.id).innerHTML);this.removeLoadingEffect(block.id);}},this);}.bind(this),onComplete:function(transport){this.config.disabledCacheBlocks.each(function(blockId){this.removeLoadingEffect(this.getPageCacheBlockId(blockId));},this);}});},addLoadingEffect:function(id)
{var cntr=$(id);if(!cntr)
{return;}
var loadingEffect=new Element('div',{'class':this.config.loadingEffectClass,'id':this.getLoadingEffectBlockId(id)}).setStyle({'width':cntr.getWidth()+'px','height':cntr.getHeight()+'px','left':this.getLeftPos(cntr)+'px','top':this.getTopPos(cntr)+'px'});$$('body').first().appendChild(loadingEffect);},removeLoadingEffect:function(id)
{var loadingEffect=$(this.getLoadingEffectBlockId(id));if(!loadingEffect)
{return;}
loadingEffect.remove();},getLoadingEffectBlockId:function(id)
{return this.config.loadingEffectClass+'-'+id;},getPageCacheBlockId:function(id)
{return this.config.blockClass+'-'+id;},getLeftPos:function(element)
{var valueL=0;try
{do
{valueL+=element.offsetLeft||0;element=element.offsetParent;}while(element);}
catch(ex){}
return valueL;},getTopPos:function(element)
{var valueT=0;try
{do
{valueT+=element.offsetTop||0;element=element.offsetParent;}while(element);}
catch(ex){}
return valueT;},getNoCacheUrl:function(url,flag)
{var sign='?';if((url.indexOf('?')>-1)&&(url.indexOf('&')>-1))
{sign='&';}
return url+sign+flag;}});
