/*--------------------------------------------------------------------------*
 * 
 * RapidCart (Walnut)
 * 
 * Version 1.0.11
 * 
 * Copyright (C) 2009-2010 Brand Labs LLC
 * 
 *--------------------------------------------------------------------------*/
var Walnut={LOADED:false,STARTED:false,CURRENT_WINDOW:null,load:function(){if(!Walnut.Settings.ENABLED){return;}
if(Walnut.isCategoryPage()&&!Walnut.LOADED){Walnut.LOADED=true;Walnut.addPrerequisites();Event.observe(window,'load',Walnut.start);}},isCategoryPage:function(){return Cumberland.Volusion.Environment.isCategoryPage(window.location.pathname);},addPrerequisites:function(){if(typeof Scriptaculous=='undefined'){document.write('\<scr'+'ipt type="text/javascript" src="'+Walnut.Settings.SCRIPTACULOUS_URL+'">\<\/scr'+'ipt>');}
if(typeof Essex=='undefined'){document.write('\<scr'+'ipt type="text/javascript" src="'+Walnut.Settings.ESSEX_URL+'">\<\/scr'+'ipt>');}
document.write('<link href="'+Walnut.Settings.CSS_URL+'" rel="stylesheet" type="text/css"/>');document.write('\<scr'+'ipt type="text/javascript" src="'+Walnut.Settings.SMARTMATCH_URL+'">\<\/scr'+'ipt>');},start:function(){try{if(Walnut.STARTED){return;}
Walnut.STARTED=true;if(typeof AlleyProductSoftAddToCart!='undefined'){Walnut.AlleyProductSoftAddToCart=Class.create(AlleyProductSoftAddToCart,{initialize:function($super,ba,ca){$super(ba);this.walnutWindow=ca;},displayConfirmation:function($super){if(this.walnutWindow!=null){this.walnutWindow.destroy();}
$super();}});}
Walnut.Essex=Class.create(Essex,{initialize:function($super,fa){$super(fa);this.ieAppVersion=null;if(Prototype.Browser.IE){var ga=navigator.userAgent;var ha=null;ha=ga.match(/MSIE (\d+\.\d+);/);if(ha!=null&&ha.length>=2){this.ieAppVersion=new Number(ha[1]);}}},activate:function(){try{this.toggleIEElements();}
catch(e){}
this.positionContentElement();this.overlayElement.show();Effect.Appear(this.contentElement,{queue:'end',duration:Walnut.Settings.WINDOW_APPEAR_DURATION});},deactivate:function(){if(this.contentElement==null||this.overlayElement==null){this.destroy();return;}
try{this.toggleIEElements();}
catch(e){}
Effect.Fade(this.contentElement,{queue:'end',duration:Walnut.Settings.WINDOW_FADE_DURATION,afterFinish:this.destroy.bind(this)});this.overlayElement.hide();},toggleIEElements:function(){if(!Prototype.Browser.IE){return;}
if(!(this.ieAppVersion<7.0)){return;}
try{$$('select, object, embed').invoke('toggle');}
catch(e){}},destroy:function(){if(this.contentElement!=null){this.contentElement.remove();this.contentElement=null;}
if(this.overlayElement!=null){this.overlayElement.remove();this.overlayElement=null;}}});new Element('img',{src:Walnut.Settings.PREVIEW_BUTTON_URL});new Element('img',{src:Walnut.Settings.LOADING_IMAGE_URL});new Element('img',{src:Walnut.Settings.OVERLAY_IMAGE_URL});new Element('img',{src:Walnut.Settings.OVERLAY_PRESET_IMAGE_URL});Walnut.addDisplayForElements();}
catch(e){}},addDisplayForElements:function(){var ia=null;ia=$$(Walnut.Settings.ELEMENTS_SELECTOR);ia=ia.reject(function(ja){var ka=null;var la=null;var ma=null;ka=ja.up();if(Object.isUndefined(ka)){return true;}
la=ka.readAttribute('href');if(la==null){return true;}
if(Cumberland.Volusion.Environment.getProductCodeFromURL(la)==null){return true;}
if(la.toLowerCase().indexOf('shoppingcart.asp')!=-1){return true;}
ma=ja.readAttribute('src');if(ma==null){return true;}
if(ma.indexOf(Walnut.Settings.MORE_INFO_FILE_NAME)!=-1){return true;}
return false;});ia.each(function(na){var oa=null;oa=Cumberland.Volusion.Environment.getProductCodeFromURL(na.up().readAttribute('href'));new Walnut.WindowInitiator(oa,na);});},WindowInitiator:Class.create({initialize:function(pa,qa){if(pa==null||qa==null){return;}
this.body=$$('body').first();this.imageElement=qa;this.productCode=pa;this.mouseMoveEventListener=null;this.clickEventListener=null;this.overlayElement=null;Event.observe(qa,'mouseover',this.mouseOver.bindAsEventListener(this));},mouseOver:function(ra){var sa=null;try{if(this.overlayElement!=null){return;}
sa=this.createOverlay();this.overlayElement=sa.main;this.buttonElement=sa.button;this.clickEventListener=this.click.bindAsEventListener(this);Event.observe(this.overlayElement,'click',this.clickEventListener);this.body.insert(this.overlayElement);this.positionOverlay();this.showOverlay();this.mouseMoveEventListener=this.mouseMove.bindAsEventListener(this);Event.observe(this.body,'mousemove',this.mouseMoveEventListener);}
catch(e){}},positionOverlay:function(){var ta=null;var ua=0;var va=0;if(this.overlayElement==null||this.imageElement==null){return;}
ta=this.imageElement.cumulativeOffset();ua=ta.left+(this.imageElement.getWidth()/2.0)-(Walnut.Settings.PREVIEW_BUTTON_WIDTH/2.0);va=ta.top+this.imageElement.getHeight()-Walnut.Settings.PREVIEW_BUTTON_HEIGHT-Walnut.Settings.PREVIEW_BUTTON_BOTTOM_OFFSET;this.overlayElement.setStyle({top:va+'px',left:ua+'px'});},showOverlay:function(){if(this.overlayElement==null){return;}
this.overlayElement.show();},hideOverlayAndRemove:function(wa){if(wa==null){return;}
wa.hide();wa.remove();},createOverlay:function(){var xa=null;var ya=null;xa=new Element('div');xa.addClassName('walnut_category_quick_preview_overlay');xa.setStyle({display:'none',width:Walnut.Settings.PREVIEW_BUTTON_WIDTH+'px',height:Walnut.Settings.PREVIEW_BUTTON_HEIGHT+'px'});ya=new Element('img',{src:Walnut.Settings.PREVIEW_BUTTON_URL,alt:'Preview',title:'Preview'});ya.setStyle({width:Walnut.Settings.PREVIEW_BUTTON_WIDTH+'px',height:Walnut.Settings.PREVIEW_BUTTON_HEIGHT+'px'});ya.addClassName('walnut_category_quick_preview_overlay_btn');ya.addClassName(Walnut.Settings.PNG_FIX_CLASS);xa.insert(ya);return{main:xa,button:ya};},mouseMove:function(za){var x=Event.pointerX(za);var y=Event.pointerY(za);try{if(this.overlayElement==null){return;}
if(this.boundsCheck(x,y,this.imageElement,this.imageElement.cumulativeOffset())){return;}
if(this.mouseMoveEventListener!=null){Event.stopObserving(this.body,'mousemove',this.mouseMoveEventListener);}
this.mouseMoveEventListener=null;this.mouseOut();}
catch(e){}},mouseOut:function(){var Aa=this.overlayElement;this.overlayElement=null;try{if(Aa!=null){this.hideOverlayAndRemove(Aa);}}
catch(e){}},boundsCheck:function(x,y,Ba,Ca){var Da=Ca;var Ea={};var Fa=true;var Ga=true;var Ha=true;var Ia=true;if(Ba==null){return false;}
if(arguments[3]){Ea=arguments[3];}
Fa=Ea['excludeLeftEdge']?(x>Da.left):(x>=Da.left);Ga=Ea['excludeRightEdge']?(x<(Da.left+Ba.getWidth())):(x<=(Da.left+Ba.getWidth()));Ha=Ea['excludeTopEdge']?(y>Da.top):(y>=Da.top);Ia=Ea['excludeBottomEdge']?(y<(Da.top+Ba.getHeight())):(y<=(Da.top+Ba.getHeight()));if(Fa&&Ga){if(Ha&&Ia){return true;}}
return false;},click:function(Ja){try{if(this.clickEventListener!=null&&this.overlayElement!=null){Event.stopObserving(this.overlayElement,'click',this.clickEventListener);}
this.clickEventListener=null;new Walnut.Window(this.productCode);this.mouseOut();}
catch(e){}}}),Window:Class.create({initialize:function(Ka){this.productCode=Ka;this.essexObject=null;this.photoClickEventListeners=new Array();this.largePhotoElement=null;if(Walnut.CURRENT_WINDOW!=null){Walnut.CURRENT_WINDOW.destroy();}
Walnut.CURRENT_WINDOW=this;this.essexObject=new Walnut.Essex({Overlay:{id:'walnut_overlay',opacity:Walnut.Settings.OVERLAY_OPACITY,image:Walnut.Settings.OVERLAY_IMAGE_URL,presetImage:Walnut.Settings.OVERLAY_PRESET_IMAGE_URL},Content:{id:'walnut_content'}});new Ajax.Updater(this.essexObject.getContentElement(),Walnut.Settings.WINDOW_URL,{parameters:{'productcode':this.productCode},method:'get',encoding:'windows-1252',evalScripts:true,evalJSON:false,sanitizeJSON:false,onCreate:this.dataCallStarted.bind(this),onComplete:this.dataCallEnded.bind(this)});},dataCallStarted:function(){var La=null;try{if(this.essexObject==null){return;}
La=new Element('div');La.addClassName('walnut_loading');La.addClassName(Walnut.Settings.PNG_FIX_CLASS);La.insert(new Element('img',{src:Walnut.Settings.LOADING_IMAGE_URL,alt:'Loading',title:'Loading'}));this.essexObject.getContentElement().insert(La);this.essexObject.activate();}
catch(e){}},dataCallEnded:function(){try{if(this.essexObject==null){return;}
this.essexObject.positionContentElement();this.setupEvents();}
catch(e){}},setupEvents:function(){var Ma=$$(Walnut.Settings.SMALL_PHOTOS_SELECTOR);$$(Walnut.Settings.CLOSE_BUTTON_SELECTOR).each(function(Na){Event.observe(Na,'click',this.destroy.bind(this));this.photoClickEventListeners.push(Na);},this);this.largePhotoElement=$$(Walnut.Settings.LARGE_PHOTO_SELECTOR).first();if(Object.isUndefined(this.largePhotoElement)){return;}
if(Ma.size()<1){var Oa=null;Oa=new Element('img',{});Event.observe(Oa,'load',this.photoLoaded.bind(this,this.largePhotoElement.readAttribute('src'),Oa));Oa.writeAttribute('src',this.largePhotoElement.readAttribute('src'));Oa=null;}
else{Ma.each(function(Pa,Qa){var Ra=null;var Sa=Pa.up();if(Object.isUndefined(Sa)){return;}
Ra=this.photoClick.bindAsEventListener(this,Sa,Pa);this.photoClickEventListeners.push(Sa);Event.observe(Sa,'click',Ra);if(Qa==0){this.photoClick(null,Sa,Pa);}},this);}$$(Walnut.Settings.OPTION_PHOTOS_SELECTOR).each(function(Ta){var Ua=null;var Va=Ta.up();if(Object.isUndefined(Va)){return;}
Ua=this.photoClick.bindAsEventListener(this,Va,Ta);this.photoClickEventListeners.push(Va);Event.observe(Va,'click',Ua);},this);if(Walnut.AlleyProductSoftAddToCart!=null){var Wa=null;var Xa=null;Wa=AlleySettings.FORM_SELECTOR;AlleySettings.FORM_SELECTOR=Walnut.Settings.FORM_SELECTOR;Xa=$$(Walnut.Settings.FORM_SELECTOR).first();if(!Object.isUndefined(Xa)){new Walnut.AlleyProductSoftAddToCart(Xa,this);}
AlleySettings.FORM_SELECTOR=Wa;}},photoClick:function(Ya,Za,$a){var ab=null;var bb=null;try{if(Ya!=null){Event.stop(Ya);}
bb=Za.readAttribute('rel');if(bb==null){this.photoLoaded(bb,null);return;}
ab=new Element('img',{});Event.observe(ab,'load',this.photoLoaded.bind(this,bb,ab));ab.writeAttribute('src',bb);}
catch(e){}},photoLoaded:function(cb,db){var eb=this;try{if(db!=null){var fb=null;Event.stopObserving(db);fb=db.height;if(fb!=null&&fb>0){new Effect.Morph(this.largePhotoElement.up().up(),{style:'height: '+fb+'px;',duration:Walnut.Settings.PHOTO_MORPH_DURATION,afterFinish:function(){eb.largePhotoElement.writeAttribute('src',cb);if(!eb.largePhotoElement.visible()){eb.largePhotoElement.show();}
eb.largePhotoElement.setStyle({width:db.width+'px',height:db.height+'px'});}});return;}}
this.largePhotoElement.writeAttribute('src',cb);if(!this.largePhotoElement.visible()){this.largePhotoElement.show();}}
catch(e){}},destroy:function(){if(this.essexObject==null){return;}
this.essexObject.deactivate();this.essexObject=null;this.photoClickEventListeners.each(function(gb){Event.stopObserving(gb);});this.photoClickEventListeners.clear();}}),Essex:null,AlleyProductSoftAddToCart:null,Settings:{ENABLED:false,WINDOW_URL:'/v/walnut/',CSS_URL:'/v/walnut/css/walnut.css',SCRIPTACULOUS_URL:'/v/walnut/js/scriptaculous.js?load=effects',ESSEX_URL:'/v/walnut/js/essex.js',SMARTMATCH_URL:'/v/walnut/js/smartmatch.js',PREVIEW_BUTTON_URL:'/v/walnut/images/preview.png',PREVIEW_BUTTON_WIDTH:0,PREVIEW_BUTTON_HEIGHT:0,PREVIEW_BUTTON_BOTTOM_OFFSET:0,OVERLAY_OPACITY:0.7,OVERLAY_IMAGE_URL:'/v/walnut/images/black.png',OVERLAY_PRESET_IMAGE_URL:'/v/walnut/images/black-70.png',LOADING_IMAGE_URL:'/v/walnut/images/loading.gif',PNG_FIX_CLASS:'alphafix',CLOSE_BUTTON_SELECTOR:'.walnut_close img',LARGE_PHOTO_SELECTOR:'.walnut_large_photo a img',SMALL_PHOTOS_SELECTOR:'.walnut_small_photo a img',OPTION_PHOTOS_SELECTOR:'.walnut_opt_photo a img',FORM_SELECTOR:'.walnut_container form[name="walnut_form"]',ELEMENTS_SELECTOR:'#content_area form#MainForm a img',PHOTO_MORPH_DURATION:0.7,WINDOW_APPEAR_DURATION:0.4,WINDOW_FADE_DURATION:0.4,MORE_INFO_FILE_NAME:'Bullet_MoreInfo.gif'}};var separator='+#+';window.change_option=function(hb,ib,jb){if(document.walnut_form.elements[hb]&&document.walnut_form.elements[hb].options&&document.walnut_form.elements[hb].options.length>0){for(loop=0;loop<document.walnut_form.elements[hb].options.length;loop++){if(document.walnut_form.elements[hb].options[loop].value==ib){document.walnut_form.elements[hb].selectedIndex=loop;if(jb){TCN_reload(document.walnut_form.elements[hb]);}}}}
else if(document.walnut_form.elements[hb]&&document.walnut_form.elements[hb].length>1){for(loop=0;loop<document.walnut_form.elements[hb].length;loop++){if(document.walnut_form.elements[hb][loop].value==ib){document.walnut_form.elements[hb][loop].checked=true;if(jb){TCN_reload(document.walnut_form.elements[hb]);}}}}}
