/*--------------------------------------------------------------------------*
 * 
 * Mouse Over Shopping Cart Summary (Thalia)
 * 
 * Version 1.2.7
 * 
 * Copyright (C) 2010 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="/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,encoding:'iso-8859-1',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();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();Event.observe(this.triggerElement,'mouseover',this.mouseOver.bind(this));},toggleIEElements:function(){if(!Prototype.Browser.IE){return;}
if(!(this.ieAppVersion<7.0)){return;}
if(!ThaliaCartSummaryPreviewSettings.HIDE_SELECT_BOXES){return;}
try{$$('select').invoke('toggle');$$('object').invoke('toggle');$$('embed').invoke('toggle');}
catch(e){}},mouseMove:function(ra){var x=Event.pointerX(ra);var y=Event.pointerY(ra);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(ra);},mouseOver:function(sa){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 ta=null;ta=this.triggerElement.cumulativeOffset();if(ta==null){return;}
this.cartContentsDiv.setStyle({position:'absolute',top:(ta.top+ThaliaCartSummaryPreviewSettings.CART_SUMMARY_DIV_OFFSET_TOP)+'px',left:(ta.left+ThaliaCartSummaryPreviewSettings.CART_SUMMARY_DIV_OFFSET_LEFT)+'px'});this.cartContentsDiv.show();}
else{if(this.summaryLoading!=null){return;}
this.summaryLoading=true;this.showCartContentsSummary();}
this.toggleIEElements();this.mouseMoveEventListener=this.mouseMove.bindAsEventListener(this);Event.observe(ThaliaCartSummaryPreview.body,'mousemove',this.mouseMoveEventListener);},mouseOut:function(ua){this.closeCartContentsSummary();if(this.mouseMoveEventListener!=null){Event.stopObserving(ThaliaCartSummaryPreview.body,'mousemove',this.mouseMoveEventListener);}
this.mouseMoveEventListener=null;},boundsCheck:function(x,y,va,wa){var xa=wa;var ya={};var za=true;var Aa=true;var Ba=true;var Ca=true;if(va==null){return false;}
if(arguments[3]){ya=arguments[3];}
za=ya['excludeLeftEdge']?(x>xa.left):(x>=xa.left);Aa=ya['excludeRightEdge']?(x<(xa.left+va.getWidth())):(x<=(xa.left+va.getWidth()));Ba=ya['excludeTopEdge']?(y>xa.top):(y>=xa.top);Ca=ya['excludeBottomEdge']?(y<(xa.top+va.getHeight())):(y<=(xa.top+va.getHeight()));if(za&&Aa){if(Ba&&Ca){return true;}}
return false;}});AlleySoftAddToCart.addMethods({displayConfirmation:function(){var Da=null;var Ea=null;var Fa=null;var Ga=null;var Ha=null;var Ia=null;var Ja=null;this.hideCartSummary();if(ThaliaCartSummaryPreviewSettings.HIDE_SELECT_BOXES==true){$$('select').invoke('show');}
try{new Ajax.Request('/v/princeton/get-shopping-cart.json.asp',{parameters:{'Reset-Cache':'true'},method:'get',evalJS:false,evalJSON:true,encoding:'iso-8859-1',onSuccess:function(Ka){try{var La=$A(Ka.responseJSON);var Ma=0;var Na=parseFloat('0.00');La.each(function(Oa){Oa=new Hash(Oa);Ma+=parseInt(Oa.get('quantity'));Na+=(parseFloat(Oa.get('productPrice'))*parseInt(Oa.get('quantity')));});Ha=$(ThaliaCartSummaryPreviewSettings.CONFIRMATION_POSITION_CONTAINER_ID);if(Ha==null){return;}
Ia=Ha.cumulativeOffset();if(Ia==null){return;}
Da=$(ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_ID);Fa=$('alley_rows');Ga=$('alley_qty');if(Da!=null){if(Fa!=null){Fa.update('');}
if(Ga!=null){Ga.update(Ma);}}
else{Da=new Element('div',{id:ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_ID,style:'display:none;'});Ea=new Element('div');Ea.addClassName('alley_content');Da.insert(Ea);Ea.insert({bottom:new Template(ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_TOP).evaluate({total_cart_items:Ma})});Fa=new Element('div',{id:'alley_rows'});Ea.insert({bottom:Fa});Ea.insert({bottom:ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_BOTTOM});$$('body').first().insert(Da);$('alley_confirmation_continue').observe('click',function(Pa){this.hide();this.remove();$$('select').invoke('show');}.bind(Da));$('alley_confirmation_close').observe('click',function(Qa){this.hide();this.remove();$$('select').invoke('show');}.bind(Da));}
La.each(function(Ra){Ra=new Hash(Ra);var Sa=ThaliaCartSummaryPreviewSettings.NO_PHOTO_URL;var Ta=$A(Ra.get('photos')).first();if(undefined!=Ta){Sa='/v/vspfiles/photos/'+escape($H(Ta).get('fileName'));}
Fa.insert({bottom:new Template(ThaliaCartSummaryPreviewSettings.TEMPLATE_CONFIRMATION_ROW).evaluate({photo_url:Sa,photo_alt:Ra.get('productName').stripTags(),photo_title:Ra.get('productName').stripTags(),product_code_querystring_parameter:escape(Ra.get('productCode')),product_code:escape(Ra.get('productCode')),product_name:Ra.get('productName'),product_qty:Ra.get('quantity'),product_price:parseFloat(Ra.get('productPrice')).toFixed(2)})});});Da.setStyle({position:'absolute',top:(Ia.top+ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_OFFSET_TOP)+'px',left:(Ia.left+ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_OFFSET_LEFT)+'px'});Da.show();if(ThaliaCartSummaryPreviewSettings.HIDE_SELECT_BOXES==true){$$('select').invoke('hide');}
Ja=$(ThaliaCartSummaryPreviewSettings.CART_TOTAL_TEXT_CONTAINER_ID);if(Ja!=null){Ja.update(new Template(ThaliaCartSummaryPreviewSettings.TEMPLATE_CART_TOTAL_TEXT).evaluate({product_qty:Ma,cart_total_cost:Na.toFixed(2)}));}$$('body').first().scrollTo();}
catch(e){}}});}
catch(e){}},closeConfirmation:function(){var Ua=null;try{Ua=$(ThaliaCartSummaryPreviewSettings.CONFIRMATION_DIV_ID);if(Ua==null){return;}
Ua.hide();Ua.remove();$$('select').invoke('show');}
catch(e){}}});
