jQuery(document).ready(function(){jQuery('a[href=#totop]').click(function(){jQuery('html, body').animate({scrollTop:0},600);return false;});jQuery('#featured-products').jcarousel();jQuery("a.group").fancybox({'zoomSpeedIn':300,'zoomSpeedOut':300,'overlayShow':true});jQuery("#slider").easySlider({auto:true,continuous:true,numeric:true});});;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;function setLocation(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{window.location.href=url;}}
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){}
productAddToCartForm.submit=function(url){if(this.validator&&this.validator.validate()){ajaxcartsend('?awacp=1','form',this,'');}
return false;}
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();ajaxcartsend(url+'/awacp/1','url','');}
else{if(setFocus){window.opener.focus();}
window.opener.location.href=url;}}
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){showConfirmDialog();}
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){showConfirmDialog();}
__onACPRender();updateCartView(resp);}}});}}
function __onACPRender(){if(AW_ACP.onRender&&AW_ACP.onRender.length){$A(AW_ACP.onRender).each(function(h){h(AW_ACP)})}}
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;}}
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(){var pW=260;var pH=50;p=$$('.ajaxcartpro_progress')[0];p.style.width=pW+'px';p.style.height=pH+'px';if(Prototype.Browser.IE&&!navigator.appVersion.match("8")){p.style.position='absolute';window.ACPTop=200;}
if(aw_ajaxcartpro_proganim=='center'){if(!(Prototype.Browser.IE&&!navigator.appVersion.match("8"))){p.style.top=(screen.height/2)-(pH)+'px';}else{window.ACPTop=200;}}
if(aw_ajaxcartpro_proganim=='top'){if(!(Prototype.Browser.IE&&!navigator.appVersion.match("8"))){p.style.top='0px';}else{window.ACPTop=0;}}
if(aw_ajaxcartpro_proganim=='bottom'){p.style.bottom='0px';}
if(aw_ajaxcartpro_proganim!='none'){p.style.display='block';}}
function showConfirmDialog(){var pW=260;var pH=104;p=$$('.ajaxcartpro_confirm')[0];p.style.width=pW+'px';p.style.height=pH+'px';if(Prototype.Browser.IE&&!navigator.appVersion.match("8")){p.style.position='absolute';}else{p.style.position='fixed';if(aw_ajaxcartpro_proganim=='center'){p.style.top=(screen.height/2)-(pH)+'px';}
if(aw_ajaxcartpro_proganim=='top'){p.style.top='0px';}
if(aw_ajaxcartpro_proganim=='bottom'){p.style.bottom='0px';}
if(aw_ajaxcartpro_proganim=='none'){p.style.top=(screen.height/2)-(pH)+'px';}}
p.style.display='block';}
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)";}}}
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;};window.intPrevious=setInterval(function(){if(typeof AW_ACP!='undefined'&&document.body){if(typeof aw_cartDivClass=='undefined'){aw_cartDivClass=AW_ACP.theme=='blank'?'.block-cart':'.mini-cart';if(!$$(aw_cartDivClass).length||!$$(aw_cartDivClass)[0].tagName){aw_cartDivClass='.block-cart'}}
if(typeof aw_topLinkCartClass=='undefined'){aw_topLinkCartClass='.top-link-cart';}
if(typeof aw_addToCartButtonClass=='undefined'){aw_addToCartButtonClass='.form-button';}
if(typeof aw_bigCartClass=='undefined'){aw_bigCartClass=AW_ACP.theme=='modern'?'.layout-1column':'.col-main';}
if(window.location.toString().search('/product_compare/')!=-1){win=window.opener;}
else{win=window;}
clearInterval(intPrevious)}},500);function ajaxcartprodelete(url){showProgressAnimation();url=getCommonUrl(url)
new Ajax.Request(url,{onSuccess:function(resp){try{if(typeof(resp.responseText)=='string')eval('resp = '+resp.responseText);}catch(e){return;}
hideProgressAnimation();__onACPRender()
updateCartView(resp,'');}});}
function updateCartView(resp){if(AW_ACP.isCartPage)return updateBigCartView(resp);var __cartObj=$$(aw_cartDivClass)[0];if(!__cartObj)return false;if(typeof(__cartObj.length)=='number')__cartObj=__cartObj[0];var oldHeight=__cartObj.offsetHeight;var tmpDiv=win.document.createElement('div');tmpDiv.innerHTML=resp.cart;var tmpParent=__cartObj.parentNode;tmpParent.replaceChild(tmpDiv.firstChild,__cartObj);var __cartObj=$$(aw_cartDivClass)[0];var newHeight=__cartObj.offsetHeight;if(aw_ajaxcartpro_cartanim=='opacity'){$(__cartObj).hide();new Effect.Appear(__cartObj);}
if(aw_ajaxcartpro_cartanim=='grow'){$(__cartObj).hide();new Effect.BlindDown(__cartObj);}
if(aw_ajaxcartpro_cartanim=='blink'){new Effect.Pulsate(__cartObj);}
updateDeleteLinks();updateTopLinks(resp);};AwOnSale=Class.create();AwOnSale.prototype={initialize:function(){this.helements=new Array();this.velements=new Array();document.observe("dom:loaded",onPageLoad);},setVertPos:function(element,position){var eH=element.offsetHeight;var pH=element.parentNode.offsetHeight;var eT=0;if(eH!=pH){switch(position){case'top':eT=0;break;case'middle':eT=(pH-eH)/2;break;case'middle':eT=pH-eH;break;default:eT=0;}}else if(eH==pH){eT=0;}
element.style.top=eT+'px';},setHorPos:function(element,position){var eW=element.offsetWidth;var pW=element.parentNode.offsetWidth;var eL=0;if(eW!=pW){switch(position){case'left':eL=0;break;case'center':eL=(pW-eW)/2;break;case'right':eL=pW-eW;break;default:eL=0;}}else if(eW==pW){eL=0;}
element.style.left=eL+'px';},registerVertPosition:function(element,position){element.vposition=position;this.velements.push(element);},registerHorPosition:function(element,position){element.hposition=position;this.helements.push(element);}}
var onPageLoad=function(){if(onsale.helements.length>0){for(var i=0;i<onsale.helements.length;i++){onsale.setHorPos(onsale.helements[i],onsale.helements[i].hposition);}}
if(onsale.velements.length>0){for(var j=0;j<onsale.velements.length;j++){onsale.setVertPos(onsale.velements[j],onsale.velements[j].vposition);}}}
if(typeof onsale=='undefined'){var onsale=new AwOnSale();};var Autocomplete=function(el,options){this.el=$(el);this.elico=$(el+'ajaxico');this.id=this.el.identify();this.el.setAttribute('autocomplete','off');this.suggestions=[];this.image=[];this.description=[];this.data=[];this.badQueries=[];this.selectedIndex=-1;this.currentValue=this.el.value;this.intervalId=0;this.cachedResponse=[];this.instanceId=null;this.onChangeInterval=null;this.ignoreValueChange=false;this.serviceUrl=options.serviceUrl;this.options={autoSubmit:false,minChars:1,store:1,enableimage:0,enableloader:0,maxHeight:300,deferRequestBy:0,width:0,searchtext:'',container:null};if(options){Object.extend(this.options,options);}
if(Autocomplete.isDomLoaded){this.initialize();}else{Event.observe(document,'dom:loaded',this.initialize.bind(this),false);}};Autocomplete.instances=[];Autocomplete.isDomLoaded=false;Autocomplete.getInstance=function(id){var instances=Autocomplete.instances;var i=instances.length;while(i--){if(instances[i].id===id){return instances[i];}}};Autocomplete.highlight=function(value,re){return value.replace(re,function(match){return'<strong>'+match+'<\/strong>'});};Autocomplete.prototype={killerFn:null,initialize:function(){var me=this;this.killerFn=function(e){if(!$(Event.element(e)).up('.autocomplete')){me.killSuggestions();me.disableKillerFn();}}.bindAsEventListener(this);if(!this.options.width){this.options.width=this.el.getWidth();}
var div=new Element('div',{style:'position:absolute;'});div.update('<div class="autocomplete-w1"><div class="autocomplete-w2"><div class="autocomplete" id="Autocomplete_'+this.id+'" style="display:none; width:'+this.options.width+'px;"></div></div></div>');this.options.container=$(this.options.container);if(this.options.container){this.options.container.appendChild(div);this.fixPosition=function(){};}else{document.body.appendChild(div);}
this.mainContainerId=div.identify();this.container=$('Autocomplete_'+this.id);this.fixPosition();Event.observe(this.el,window.opera?'keypress':'keydown',this.onKeyPress.bind(this));Event.observe(this.el,'keyup',this.onKeyUp.bind(this));Event.observe(this.el,'blur',this.enableKillerFn.bind(this));Event.observe(this.el,'focus',this.fixPosition.bind(this));Event.observe(this.el,'click',this.fixText.bind(this));Event.observe(this.el,'blur',this.fixText.bind(this));this.container.setStyle({maxHeight:this.options.maxHeight+'px'});this.instanceId=Autocomplete.instances.push(this)-1;},fixPosition:function(){var offset=this.el.cumulativeOffset();$(this.mainContainerId).setStyle({top:(offset.top+this.el.getHeight())+'px',left:offset.left+'px'});},fixText:function(){if(this.el.value==this.options.searchtext){this.el.value='';}else if(this.el.value.length==0){this.el.value=this.options.searchtext;}else{return;};},enableKillerFn:function(){Event.observe(document.body,'click',this.killerFn);},disableKillerFn:function(){Event.stopObserving(document.body,'click',this.killerFn);},killSuggestions:function(){this.stopKillSuggestions();this.intervalId=window.setInterval(function(){this.hide();this.stopKillSuggestions();}.bind(this),300);},stopKillSuggestions:function(){window.clearInterval(this.intervalId);},onKeyPress:function(e){if(!this.enabled){return;}
switch(e.keyCode){case Event.KEY_ESC:this.el.value=this.currentValue;this.hide();break;case Event.KEY_TAB:case Event.KEY_RETURN:if(this.selectedIndex===-1){this.hide();return;}
this.select(this.selectedIndex);if(e.keyCode===Event.KEY_TAB){return;}
break;case Event.KEY_UP:this.moveUp();break;case Event.KEY_DOWN:this.moveDown();break;default:return;}
Event.stop(e);},onKeyUp:function(e){switch(e.keyCode){case Event.KEY_UP:case Event.KEY_DOWN:return;}
clearInterval(this.onChangeInterval);if(this.currentValue!==this.el.value){if(this.options.deferRequestBy>0){this.onChangeInterval=setInterval((function(){this.onValueChange();}).bind(this),this.options.deferRequestBy);}else{this.onValueChange();}}},onValueChange:function(){clearInterval(this.onChangeInterval);this.currentValue=this.el.value;this.selectedIndex=-1;if(this.ignoreValueChange){this.ignoreValueChange=false;return;}
if(this.currentValue===''||this.currentValue.length<this.options.minChars){this.hide();}else{this.getSuggestions();}},getSuggestions:function(){var cr=this.cachedResponse[this.currentValue];if(cr&&Object.isArray(cr.suggestions)){this.suggestions=cr.suggestions;this.image=cr.image;this.description=cr.description;this.data=cr.data;this.suggest();}else if(!this.isBadQuery(this.currentValue)){this.showloader();new Ajax.Request(this.serviceUrl,{parameters:{query:this.currentValue,store:this.options.store,enableimage:this.options.enableimage,enabledescription:this.options.enabledescription,descriptionchars:this.options.descriptionchars},onComplete:this.processResponse.bind(this),method:'get'});}},isBadQuery:function(q){var i=this.badQueries.length;while(i--){if(q.indexOf(this.badQueries[i])===0){return true;}}
return false;},hide:function(){this.enabled=false;this.selectedIndex=-1;this.container.hide();},suggest:function(){this.hideloader();if(this.suggestions.length===0){this.hide();return;}
var content=[];var re=new RegExp('\\b'+this.currentValue.match(/\w+/g).join('|\\b'),'gi');this.suggestions.each(function(value,i){var image=this.image[i];var description=this.description[i];content.push((this.selectedIndex===i?'<div class="selected ajaxsearchtitle"':'<div class="ajaxsearchtitle"'),' title="',value,'" onclick="Autocomplete.instances[',this.instanceId,'].select(',i,');" onmouseover="Autocomplete.instances[',this.instanceId,'].activate(',i,');">',image,'<p>',Autocomplete.highlight(value,re),'',description,'</p></div>');}.bind(this));this.enabled=true;this.container.update(content.join('')).show();},processResponse:function(xhr){var response;try{response=xhr.responseText.evalJSON();if(!Object.isArray(response.data)){response.data=[];}}catch(err){return;}
this.suggestions=response.suggestions;this.image=response.image;this.description=response.description;this.data=response.data;this.cachedResponse[response.query]=response;if(response.suggestions.length===0){this.badQueries.push(response.query);}
if(response.query===this.currentValue){this.suggest();}},activate:function(index){var divs=this.container.childNodes;var activeItem;if(this.selectedIndex!==-1&&divs.length>this.selectedIndex){divs[this.selectedIndex].className='';}
this.selectedIndex=index;if(this.selectedIndex!==-1&&divs.length>this.selectedIndex){activeItem=divs[this.selectedIndex]
activeItem.className='selected';}
return activeItem;},deactivate:function(div,index){div.className='';if(this.selectedIndex===index){this.selectedIndex=-1;}},select:function(i){var selectedValue=this.suggestions[i];if(selectedValue){this.el.value=selectedValue;if(this.options.autoSubmit&&this.el.form){this.el.form.submit();}
this.ignoreValueChange=true;this.hide();this.onSelect(i);}},moveUp:function(){if(this.selectedIndex===-1){return;}
if(this.selectedIndex===0){this.container.childNodes[0].className='';this.selectedIndex=-1;this.el.value=this.currentValue;return;}
this.adjustScroll(this.selectedIndex-1);},moveDown:function(){if(this.selectedIndex===(this.suggestions.length-1)){return;}
this.adjustScroll(this.selectedIndex+1);},showloader:function(){if(this.options.enableloader==1){this.elico.setStyle({display:'block'});}},hideloader:function(){if(this.options.enableloader==1){this.elico.setStyle({display:'none'});}},adjustScroll:function(i){var container=this.container;var activeItem=this.activate(i);var offsetTop=activeItem.offsetTop;var upperBound=container.scrollTop;var lowerBound=upperBound+this.options.maxHeight-25;if(offsetTop<upperBound){container.scrollTop=offsetTop;}else if(offsetTop>lowerBound){container.scrollTop=offsetTop-this.options.maxHeight+25;}
this.el.value=this.suggestions[i];},onSelect:function(i){(this.options.onSelect||Prototype.emptyFunction)(this.suggestions[i],this.data[i]);}};function onAutocompleteSubmit(value,data){setLocation(data)}
Event.observe(document,'dom:loaded',function(){Autocomplete.isDomLoaded=true;},false);
