/*--------------------------------------------------------------------------*
 * 
 * Mouse Over Shopping Cart Summary (Thalia)
 * 
 * Version 1.3.2
 * 
 * Copyright (C) 2009-2011 Brand Labs LLC
 * 
 *--------------------------------------------------------------------------*/
var Thalia={LOADED:false,load:function(){try{if(Thalia.LOADED){return;}
Thalia.LOADED=true;if(location.pathname.toLowerCase()!='/shoppingcart.asp'){if(ThaliaCartSummaryPreviewSettings.ENABLED){ThaliaCartSummaryPreview.load();}}}
catch(err){}}};Event.observe(window,'load',Thalia.load);var ThaliaCartSummaryPreviewSettings={ENABLED:false,HIDE_SELECT_BOXES:true,HOVER_ELEMENT_ID:'view_cart_text_left',CART_SUMMARY_DIV_OFFSET_TOP:-35,CART_SUMMARY_DIV_OFFSET_LEFT:0,NO_PHOTO_URL:'/v/vspfiles/templates/90/images/NoPhoto.gif',CART_TOTAL_TEXT_CONTAINER_ID:'view_cart_text_right',CONFIRMATION_DIV_ID:'alley_confirmation',CONFIRMATION_POSITION_CONTAINER_ID:'content_area',CONFIRMATION_DIV_OFFSET_TOP:30,CONFIRMATION_DIV_OFFSET_LEFT:-25,TEMPLATE_CONFIRMATION_TOP:'<div id="alley_confirmation_close">[x]</div><div class="alley_top">Total items in cart <span id="alley_qty">#{total_cart_items}</span></div>',TEMPLATE_CONFIRMATION_ROW:'<div class="alley_row">'+'<div class="photo"><a href="/ProductDetails.asp?ProductCode=#{product_code}" title="#{photo_title}"><img src="#{photo_url}" alt="#{photo_alt}" title="#{photo_title}" /></a></div>'+'<div class="info">'+'<div class="name"><a href="/ProductDetails.asp?ProductCode=#{product_code}" title="#{photo_title}">#{product_name}</a></div>'+'<div class="qty">Qty #{product_qty}</div>'+'<div class="clearfloat">&nbsp;</div>'+'</div>'+'<div class="clearfloat">&nbsp;</div>'+'</div>',TEMPLATE_CONFIRMATION_BOTTOM:'<div class="alley_bottom">'+'<div class="checkout"><a href="https://'+window.location.host+'/one-page-checkout.asp" title="Proceed to Checkout"><img id="alley_confirmation_checkout" src="/v/thalia/images/proceed_to_checkout.gif" alt="Proceed to Checkout" title="Proceed to Checkout" /></a></div>'+'<div class="separator"><img src="/v/thalia/images/or.gif" alt="Or" title="Or" /></div>'+'<div class="continue"><img id="alley_confirmation_continue" src="/v/thalia/images/continue_shopping.gif" alt="Continue" title="Continue" /></div>'+'</div>',TEMPLATE_CART_TOTAL_TEXT:'#{product_qty} Items: <span><a title="Shopping Cart" href="/ShoppingCart.asp"> $#{cart_total_cost}</a></span>'};var ThaliaCartSummaryPreview={body:null,load:function(){var aa=null;try{ThaliaCartSummaryPreview.body=$$('body').first();aa=$(ThaliaCartSummaryPreviewSettings.HOVER_ELEMENT_ID);if(aa==null||ThaliaCartSummaryPreview.body==null){return;}
new ThaliaCartSummaryPreviewInitiator(aa);}
catch(err){}}};var ThaliaCartSummaryPreviewInitiator=Class.create({initialize:function(ba){if(ba==null){return;}
this.triggerElement=ba;this.mouseMoveEventListener=null;this.cartContentsDiv=null;this.summaryLoading=null;this.ieAppVersion=0.0;if(Prototype.Browser.IE){var ca=navigator.userAgent;var da=null;da=ca.match(/MSIE (\d+\.\d+);/);if(da!=null&&da.length>=2){this.ieAppVersion=new Number(da[1]);}}
Event.observe(ba,'mouseover',this.mouseOver.bindAsEventListener(this));},showCartContentsSummary:function(){var ea=this;var fa=null;var ga=null;var ha=null;var ia=null;var ja=null;try{new Ajax.Request('/v/princeton/get-shopping-cart.json.asp',{method:'get',evalJS:false,evalJSON:true,sanitizeJSON:true,encoding:'windows-1252',onSuccess:function(ka){try{var la=$A(ka.responseJSON);var ma=0;la.each(function(na){na=new Hash(na);ma+=parseInt(na.get('quantity'));});fa=$(ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_ID);if(fa!=null){fa.remove();}
ia=ea.triggerElement.cumulativeOffset();if(ia==null){return;}
ea.cartContentsDiv=new Element('div',{id:ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_ID});ea.cartContentsDiv.setStyle({position:'absolute',top:(ia.top+ThaliaCartSummaryPreviewSettings.CART_SUMMARY_DIV_OFFSET_TOP)+'px',left:(ia.left+ThaliaCartSummaryPreviewSettings.CART_SUMMARY_DIV_OFFSET_LEFT)+'px'});ga=new Element('div');ga.addClassName('alley_content');ea.cartContentsDiv.insert(ga);ga.insert({bottom:new Template(ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_TOP).evaluate({total_cart_items:ma})});ha=new Element('div',{id:'alley_rows'});ga.insert({bottom:ha});la.each(function(oa){oa=new Hash(oa);var pa=ThaliaCartSummaryPreviewSettings.NO_PHOTO_URL;var qa=$A(oa.get('photos')).first();if(undefined!=qa){pa='/v/vspfiles/photos/'+escape($H(qa).get('fileName'));}
ha.insert({bottom:new Template(ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_ROW).evaluate({photo_url:pa,photo_alt:oa.get('productName').stripTags(),photo_title:oa.get('productName').stripTags(),product_code_querystring_parameter:escape(oa.get('productCode')),product_code:escape(oa.get('productCode')),product_name:oa.get('productName'),product_qty:oa.get('quantity'),product_price:parseFloat(oa.get('productPrice')).toFixed(2)})});});ga.insert({bottom:ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_BOTTOM});ThaliaCartSummaryPreview.body.insert(ea.cartContentsDiv);ea.toggleIEElements(false);Event.observe($('alley_confirmation_continue'),'click',ea.closeCartContentsSummary.bind(ea));Event.observe($('alley_confirmation_close'),'click',ea.closeCartContentsSummary.bind(ea));if(ea.mouseMoveEventListener!=null){Event.stopObserving(ThaliaCartSummaryPreview.body,'mousemove',ea.mouseMoveEventListener);}
ea.mouseMoveEventListener=null;ea.mouseMoveEventListener=ea.mouseMove.bindAsEventListener(ea);Event.observe(ThaliaCartSummaryPreview.body,'mousemove',ea.mouseMoveEventListener);ea.summaryLoading=null;}
catch(e){}}});}
catch(e){}},closeCartContentsSummary:function(){if(this.cartContentsDiv==null){return;}
if(this.mouseMoveEventListener!=null){Event.stopObserving(ThaliaCartSummaryPreview.body,'mousemove',this.mouseMoveEventListener);}
this.mouseMoveEventListener=null;this.cartContentsDiv.hide();this.toggleIEElements(true);},toggleIEElements:function(ra){try{if(!Prototype.Browser.IE){return;}
if(!(this.ieAppVersion<7.0)){return;}
if(!ThaliaCartSummaryPreviewSettings.HIDE_SELECT_BOXES){return;}$$('select').invoke(ra?'show':'hide');}
catch(e){}},mouseMove:function(sa){var x=Event.pointerX(sa);var y=Event.pointerY(sa);if(this.cartContentsDiv==null||this.triggerElement==null){return;}
else if(this.boundsCheck(x,y,this.triggerElement,this.triggerElement.cumulativeOffset())||this.boundsCheck(x,y,this.cartContentsDiv,this.cartContentsDiv.cumulativeOffset())){return;}
this.mouseOut(sa);},mouseOver:function(ta){Event.stopObserving(this.triggerElement,'mouseover',this.mouseOver.bindAsEventListener(this));if(this.mouseMoveEventListener!=null){Event.stopObserving(ThaliaCartSummaryPreview.body,'mousemove',this.mouseMoveEventListener);}
this.mouseMoveEventListener=null;if(this.cartContentsDiv!=null){var ua=null;ua=this.triggerElement.cumulativeOffset();if(ua==null){return;}
this.cartContentsDiv.setStyle({position:'absolute',top:(ua.top+ThaliaCartSummaryPreviewSettings.CART_SUMMARY_DIV_OFFSET_TOP)+'px',left:(ua.left+ThaliaCartSummaryPreviewSettings.CART_SUMMARY_DIV_OFFSET_LEFT)+'px'});this.cartContentsDiv.show();this.toggleIEElements(false);}
else{if(this.summaryLoading!=null){return;}
this.summaryLoading=true;this.showCartContentsSummary();}
this.mouseMoveEventListener=this.mouseMove.bindAsEventListener(this);Event.observe(ThaliaCartSummaryPreview.body,'mousemove',this.mouseMoveEventListener);},mouseOut:function(va){this.closeCartContentsSummary();if(this.mouseMoveEventListener!=null){Event.stopObserving(ThaliaCartSummaryPreview.body,'mousemove',this.mouseMoveEventListener);}
this.mouseMoveEventListener=null;},boundsCheck:function(x,y,wa,xa){var ya=xa;var za={};var Aa=true;var Ba=true;var Ca=true;var Da=true;if(wa==null){return false;}
if(arguments[3]){za=arguments[3];}
Aa=za['excludeLeftEdge']?(x>ya.left):(x>=ya.left);Ba=za['excludeRightEdge']?(x<(ya.left+wa.getWidth())):(x<=(ya.left+wa.getWidth()));Ca=za['excludeTopEdge']?(y>ya.top):(y>=ya.top);Da=za['excludeBottomEdge']?(y<(ya.top+wa.getHeight())):(y<=(ya.top+wa.getHeight()));if(Aa&&Ba){if(Ca&&Da){return true;}}
return false;}});AlleySoftAddToCart.addMethods({displayConfirmation:function(){var Ea=this;var Fa=null;var Ga=null;var Ha=null;var Ia=null;var Ja=null;var Ka=null;var La=null;this.hideCartSummary();this.toggleIEElements(true);try{new Ajax.Request('/v/princeton/get-shopping-cart.json.asp',{parameters:{'Reset-Cache':'true'},method:'get',evalJS:false,evalJSON:true,sanitizeJSON:true,encoding:'windows-1252',onSuccess:function(Ma){try{var Na=$A(Ma.responseJSON);var Oa=0;var Pa=parseFloat('0.00');Na.each(function(Qa){Qa=new Hash(Qa);Oa+=parseInt(Qa.get('quantity'));Pa+=(parseFloat(Qa.get('productPrice'))*parseInt(Qa.get('quantity')));});Ja=$(ThaliaCartSummaryPreviewSettings.CONFIRMATION_POSITION_CONTAINER_ID);if(Ja==null){return;}
Ka=Ja.cumulativeOffset();if(Ka==null){return;}
Fa=$(ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_ID);Ha=$('alley_rows');Ia=$('alley_qty');if(Fa!=null){if(Ha!=null){Ha.update('');}
if(Ia!=null){Ia.update(Oa);}}
else{Fa=new Element('div',{id:ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_ID,style:'display:none;'});Ga=new Element('div');Ga.addClassName('alley_content');Fa.insert(Ga);Ga.insert({bottom:new Template(ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_TOP).evaluate({total_cart_items:Oa})});Ha=new Element('div',{id:'alley_rows'});Ga.insert({bottom:Ha});Ga.insert({bottom:ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_BOTTOM});$$('body').first().insert(Fa);$('alley_confirmation_continue').observe('click',function(Ra){this.hide();this.remove();Ea.toggleIEElements(true);}.bind(Fa));$('alley_confirmation_close').observe('click',function(Sa){this.hide();this.remove();Ea.toggleIEElements(true);}.bind(Fa));}
Na.each(function(Ta){Ta=new Hash(Ta);var Ua=ThaliaCartSummaryPreviewSettings.NO_PHOTO_URL;var Va=$A(Ta.get('photos')).first();if(undefined!=Va){Ua='/v/vspfiles/photos/'+escape($H(Va).get('fileName'));}
Ha.insert({bottom:new Template(ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_ROW).evaluate({photo_url:Ua,photo_alt:Ta.get('productName').stripTags(),photo_title:Ta.get('productName').stripTags(),product_code_querystring_parameter:escape(Ta.get('productCode')),product_code:escape(Ta.get('productCode')),product_name:Ta.get('productName'),product_qty:Ta.get('quantity'),product_price:parseFloat(Ta.get('productPrice')).toFixed(2)})});});Fa.setStyle({position:'absolute',top:(Ka.top+ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_OFFSET_TOP)+'px',left:(Ka.left+ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_OFFSET_LEFT)+'px'});Fa.show();Ea.toggleIEElements(false);La=$(ThaliaCartSummaryPreviewSettings.CART_TOTAL_TEXT_CONTAINER_ID);if(La!=null){La.update(new Template(ThaliaCartSummaryPreviewSettings.TEMPLATE_CART_TOTAL_TEXT).evaluate({product_qty:Oa,cart_total_cost:Pa.toFixed(2)}));}$$('body').first().scrollTo();}
catch(e){}}});}
catch(e){}},closeConfirmation:function(){var Wa=null;try{Wa=$(ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_ID);if(Wa==null){return;}
Wa.hide();Wa.remove();this.toggleIEElements(true);}
catch(e){}},toggleIEElements:function(Xa){try{if(!Prototype.Browser.IE){return;}
var Ya=navigator.userAgent;var Za=null;var $a=null;Za=Ya.match(/MSIE (\d+\.\d+);/);if(Za!=null&&Za.length>=2){$a=new Number(Za[1]);}
if(!($a<7.0)){return;}
if(!ThaliaCartSummaryPreviewSettings.HIDE_SELECT_BOXES){return;}$$('select').invoke(Xa?'show':'hide');}
catch(e){}}});
