
Prototype.Browser.IE6=Prototype.Browser.IE&&parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5))==6;Prototype.Browser.IE7=Prototype.Browser.IE&&parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5))==7;Prototype.Browser.IE8=Prototype.Browser.IE&&!Prototype.Browser.IE6&&!Prototype.Browser.IE7;window.ACPTop=200;if(!Prototype.Browser.IE6){setLocation=function(url){if(window.location.href.match('https://')&&!url.match('https://')){url=url.replace('http://','https://')}
if(AW_ACP.isCartPage&&((url.search('/add')!=-1)||(url.search('/remove')!=-1))){ajaxcartsend(url+'awacp/1/is_checkout/1','url','','');}else if(url.search('checkout/cart/add')!=-1){ajaxcartsend(url+'awacp/1','url','','');}else if(url.search('wishlist/index/cart')!=-1){ajaxcartsendwishlist(url+'awwishl/1/awacp/1','url','','');}else if(url.search('options=cart')!=-1){ajaxcartsendconfigurable(url);}
else
{window.location.href=url;}}}
function addSubmitEvent()
{productAddToCartForm.submit=function(url){if(this.validator&&this.validator.validate()){ajaxcartsend('?awacp=1','form',this,'');}
return false;}
productAddToCartForm.form.onsubmit=function(){productAddToCartForm.submit();return false;};}
if(!Prototype.Browser.IE6){var cnt1=20;__intId=setInterval(function(){cnt1--;if(typeof productAddToCartForm!='undefined'){try{$$('#product_addtocart_form '+aw_addToCartButtonClass).each(function(el){el.setAttribute('type','button')})}catch(err){}
addSubmitEvent();clearInterval(__intId);}
if(!cnt1)clearInterval(__intId);},500);var cnt2=20;__intId2=setInterval(function(){cnt2--;if(typeof aw_cartDivClass!='undefined'&&$$(aw_cartDivClass).length||((typeof AW_ACP!=='undefined')&&AW_ACP.isCartPage)){updateDeleteLinks();clearInterval(__intId2);}
if(!cnt2)clearInterval(__intId);},500);}
function setPLocation(url,setFocus){if(url.search('checkout/cart/add')!=-1){window.opener.focus();if(url[url.length-1]=='/')delim='';else delim='/';if(window.opener.location.pathname.search('checkout/cart')==-1)
window.opener.ajaxcartsend(url+delim+'awacp/1','url','');else
window.opener.ajaxcartsend(url+delim+'awacp/1/is_checkout/1','url','');}
else{if(setFocus){window.opener.focus();}
window.opener.location.href=url;}}
function ajaxcartsendwishlist(url,type,obj){url=getCommonUrl(url);showProgressAnimation();new Ajax.Request(url,{onSuccess:function(resp){try{if(typeof(resp.responseText)=='string')eval('resp = '+resp.responseText);}catch(e){win.location.href=url;hideProgressAnimation();return;}
hideProgressAnimation();if(resp.r!='success'){if(resp.redirect)
win.location.href=resp.redirect;else
win.location.href=url;}
else{if(AW_ACP.useConfirmation){showConfirmDialog(resp.product_name,(typeof resp.product_content=='undefined')?false:resp.product_content);}
__onACPRender();updateCartView(resp);updateTopLinks(resp);updateWishlist(resp);updateWishlistTopLinks(resp);updateAddLinks();}}});}
function ajaxcartsend(url,type,obj){url=getCommonUrl(url)
showProgressAnimation();if(type=='form'){$('product_addtocart_form').action+=url;$('product_addtocart_form').request({onComplete:function(resp){if(typeof(resp.responseText)=='string'){try{eval('resp = '+resp.responseText);}catch(e){return obj.form.submit();}}
hideProgressAnimation();if(resp.r!='success'){obj.form.submit();}
else{__onACPRender();if(AW_ACP.useConfirmation&&(url.search('is_checkout/1')!=1)){showConfirmDialog(resp.product_name,(typeof resp.product_content=='undefined')?false:resp.product_content);}
updateCartView(resp);}}})}
if(type=='url'){new Ajax.Request(url,{onSuccess:function(resp){try{if(typeof(resp.responseText)=='string')eval('resp = '+resp.responseText);}catch(e){win.location.href=url;hideProgressAnimation();return;}
hideProgressAnimation();if(resp.r!='success'){win.location.href=url;}
else{if(AW_ACP.useConfirmation&&(url.search('is_checkout/1')==-1)){showConfirmDialog(resp.product_name,(typeof resp.product_content=='undefined')?false:resp.product_content);}
__onACPRender();updateCartView(resp);}}});}}
function __onACPRender(){if(AW_ACP.onRender&&AW_ACP.onRender.length){$A(AW_ACP.onRender).each(function(h){h(AW_ACP)})}}
function addEffectACP(obj,effect)
{if(effect=='opacity'){$(obj).hide();new Effect.Appear(obj);}
if(effect=='grow'){$(obj).hide();new Effect.BlindDown(obj);}
if(effect=='blink'){new Effect.Pulsate(obj);}}
function updateDeleteLinks(){var tmpLinks=document.links;for(i=0;i<tmpLinks.length;i++){if(tmpLinks[i].href.search('checkout/cart/delete')!=-1){url=tmpLinks[i].href.replace(/\/uenc\/.+,/g,"");var del=url.match(/delete\/id\/\d+\//g);var id=del[0].match(/\d+/g);if(window.location.protocol=='https:'){aw_base_url=aw_base_url.replace("http:","https:");}
if(!AW_ACP.isCartPage){tmpLinks[i].href='javascript:ajaxcartprodelete("'+aw_base_url+'ajaxcartpro/cart/remove/id/'+id+'")';}else{tmpLinks[i].href='javascript:ajaxcartprodelete("'+aw_base_url+'ajaxcartpro/cart/remove/id/'+id+'/is_checkout/1")';}}}}
function updateTopLinks(resp){if($$(aw_topLinkCartClass).length){$$(aw_topLinkCartClass)[0].title=$$(aw_topLinkCartClass)[0].innerHTML=resp.links;}}
function updateWishlistTopLinks(resp){if($$(aw_topWishlistLinkCartClass).length){$$(aw_topWishlistLinkCartClass)[0].innerHTML=resp.wishlist_links;}}
window.updateBigCartView=function(resp){$$(aw_bigCartClass)[0].innerHTML=resp.cart
if($('shopping-cart-table')){decorateTable('shopping-cart-table')}
updateDeleteLinks();updateTopLinks(resp);updateAddLinks();var scripts=resp.cart.match(/<script[^>]*>([^<]+)<\/script>/gim);if(scripts)
{for(var i=0;i<scripts.length;i++){var code=scripts[i].match(/<script[^>]*>([^<]+)<\/script>/im)[1].replace(/var\s+/g,'');try{eval(code)}catch(e){}}}}
function showProgressAnimation(){alignBlock($$('.ajaxcartpro_progress')[0],260,50,'progress');}
var beginCounter;Event.observe(window,'load',function()
{if(typeof $$('#ACPcountdown')[0]!='undefined')
beginCounter=parseInt($$('#ACPcountdown')[0].innerHTML);});function showConfirmDialog(product_name,product_content){if(product_name)$('acp_product_name').innerHTML=product_name;if(product_content)
$('acp-tm-product-content').innerHTML=product_content;block=$$('.ajaxcartpro_confirm')[0];alignBlock(block,330,209,'confirmation');block.style.display='block';if(typeof($$('.ajaxcartpro_confirm .focus')[0])!='undefined')$$('.ajaxcartpro_confirm .focus')[0].focus();var ACPcountdown=$$('#ACPcountdown')[0];if(typeof ACPcountdown!='undefined')
{ACPcountdown.innerHTML=beginCounter;if(typeof __intId3!='undefined')clearInterval(__intId3);__intId3=setInterval(function(){if(parseInt(ACPcountdown.innerHTML)){ACPcountdown.innerHTML=parseInt(ACPcountdown.innerHTML)-1;}
else
{clearInterval(__intId3);block.style.display="none";ACPcountdown.innerHTML=beginCounter;}},1000);}}
function hideProgressAnimation(){$$('.ajaxcartpro_progress')[0].style.display='none';}
if(!Prototype.Browser.IE6){window.onload=function(){updateAddLinks()
$('aw_acp_continue').onclick=function(e){e=e||event;if(e.preventDefault)
e.preventDefault()
$$('.ajaxcartpro_confirm')[0].style.display='none';return false;}
$('aw_acp_checkout').onclick=function(e){$$('.ajaxcartpro_confirm')[0].style.display='none';return true;}
if((typeof aw_cartDivClass!='undefined')&&($$(aw_cartDivClass).length||((typeof AW_ACP!=='undefined')&&AW_ACP.isCartPage))){updateDeleteLinks();}}}
function updateAddLinks(){var ats=document.links;for(i=ats.length-1;i>=0;i--){if(ats[i].href.search('checkout/cart/add')!=-1){ats[i].onclick=function(link){return function(){setLocation(link)}}(ats[i].href);ats[i].href="javascript:void(0)";}
if(ats[i].href.search('wishlist/index/cart')!=-1){ats[i].onclick=function(link){return function(){setLocation(link)}}(ats[i].href);ats[i].href="javascript:void(0)";}}}
function getCommonUrl(url){if(window.location.href.match('www.')&&url.match('http://')&&!url.match('www.')){url=url.replace('http://','http://www.');}else if(!window.location.href.match('www.')&&url.match('http://')&&url.match('www.')){url=url.replace('www.','');}
return url;}
var productAddToCartForm;function ajaxcartsendconfigurable(url)
{showProgressAnimation();urlToSend=url+'&ajaxcartpro=1';new Ajax.Request(urlToSend,{onSuccess:function(resp){if(resp.responseText=='false')
{window.location=url;}
else
{tmpDiv=win.document.createElement('div');var scripts=resp.responseText.extractScripts();tmpDiv.innerHTML=resp.responseText.stripScripts();win.document.body.appendChild(tmpDiv);showOptionsDialog();hideProgressAnimation();productAddToCartForm=new VarienForm('product_addtocart_form');decorateGeneric($$('#product-options-wrapper dl'),['last']);addSubmitEvent();if(typeof($$('#acp_configurable_block .focus')[0])!='undefined')$$('#acp_configurable_block .focus')[0].focus();for(i=0;i<scripts.length;i++)
{eval(scripts[i].replace(/var/g,''));}}}});}
function showOptionsDialog()
{alignBlock($('acp_product_options'),400,$('acp_product_options').offsetHeight,'custom_options');}
function alignBlock(block,width,height,blockType)
{if(blockType=='confirmation'&&!AW_ACP.useConfirmation)
return false;if(blockType=='progress'&&!AW_ACP.useProgress)
return false;block.style.display='block';block.style.width=width+'px';block.style.height=height+'px';if(Prototype.Browser.IE&&!navigator.appVersion.match("8")){block.style.position='absolute';window.ACPTop=200;}
if(aw_ajaxcartpro_proganim=='center'){if(!(Prototype.Browser.IE&&!navigator.appVersion.match("8"))){block.style.top=(document.viewport.getHeight()/2-height/2)+'px';}else{window.ACPTop=200;}}
if(aw_ajaxcartpro_proganim=='top'){if(!(Prototype.Browser.IE&&!navigator.appVersion.match("8"))){block.style.top='0px';}else{window.ACPTop=0;}}
if(aw_ajaxcartpro_proganim=='bottom'){block.style.bottom='0px';}}
