OLSON.namespace("OLSON.cardstack.expander");if(typeof(OLSON.cardstack.stack)=="undefined"){console.warn("OLSON.cardstack.expander requires OLSON.cardstack.stack");}$(document).ready(function(){$("."+OLSON.cardstack.stack.CLASSES.STACK+" ."+OLSON.cardstack.expander.CLASSES.EXPAND_BUTTON).click(OLSON.cardstack.expander.expandStack);
});OLSON.cardstack.expander={stackToExpand:null,expandedStackContainer:null,stackOffset:null,startPositionLeft:0,startPositionLeft:0,runningLeftIncrement:0,runningTopIncrement:0,viewportHeight:0,runningPosition:{top:OLSON.cardstack.expander.startPositionTop,left:OLSON.cardstack.expander.startPositionLeft},EXPANDED_CARDS_PER_ROW:5,TOP_OFFSET:80,OVERLAY_OPACITY:0.5,CLASSES:{EXPAND_BUTTON:"btn-expand",CLOSE_BUTTON:"btn-close",PAGE:"page"},IDS:{EXPANDED_CONTAINER:"stack-expanded-container",EXPANDED_OVERLAY:"stack-expanded-overlay",EXPANDED_WRAPPER:"stack-expanded-wrapper"},expandStack:function(a){a.preventDefault();
$(a.target).trigger("OLSON.cardstack.expander.expandStack");OLSON.cardstack.expander.prepareDom(a);var b=OLSON.cardstack.expander.stackToExpand.children();if(b.length>1){OLSON.cardstack.expander.showStack();OLSON.cardstack.expander.showCards();}},prepareDom:function(a){OLSON.cardstack.expander.createElements();
OLSON.cardstack.expander.findElements(a);},createElements:function(){var a=$("#"+OLSON.cardstack.expander.IDS.EXPANDED_CONTAINER);if(!a.get(0)){var a=document.createElement("div");a.id=OLSON.cardstack.expander.IDS.EXPANDED_CONTAINER;$(a).html('<div id="'+OLSON.cardstack.expander.IDS.EXPANDED_OVERLAY+'"></div>'+'<div id="'+OLSON.cardstack.expander.IDS.EXPANDED_WRAPPER+'"></div>');
$(a).appendTo(document.body);$("#"+OLSON.cardstack.expander.IDS.EXPANDED_OVERLAY).css("opacity",OLSON.cardstack.expander.OVERLAY_OPACITY).click(OLSON.cardstack.expander.closeOverlay);if($.browser.msie){$("#"+OLSON.cardstack.expander.IDS.EXPANDED_OVERLAY).css("height",$(document.body).height());}}},findElements:function(a){OLSON.cardstack.expander.stackToExpand=OLSON.cardstack.stack._getStack(a);
OLSON.cardstack.expander.expandedStackContainer=$("#"+OLSON.cardstack.expander.IDS.EXPANDED_CONTAINER);},showStack:function(){OLSON.cardstack.expander.createExpandableStack();OLSON.cardstack.expander.findStackOffset();OLSON.cardstack.expander.postionExpandableStack();OLSON.cardstack.expander.revealExpandableStack();
},createExpandableStack:function(){$overlayStack=OLSON.cardstack.expander.stackToExpand.clone().appendTo("#"+OLSON.cardstack.expander.IDS.EXPANDED_WRAPPER);$overlayStack.find(OLSON.cardstack.stack.TAGS.CARD+"."+OLSON.cardstack.stack.CLASSES.CARD+"."+OLSON.cardstack.stack.CLASSES.INACTIVE).removeClass(OLSON.cardstack.stack.CLASSES.INACTIVE);
$overlayStack.find("."+OLSON.cardstack.expander.CLASSES.CLOSE_BUTTON).click(OLSON.cardstack.expander.closeOverlay);},findStackOffset:function(){OLSON.cardstack.expander.stackOffset=OLSON.cardstack.expander.stackToExpand.offset();},postionExpandableStack:function(){$overlayStack.css({"left":OLSON.cardstack.expander.stackOffset.left,"top":OLSON.cardstack.expander.stackOffset.top-$(window).scrollTop()});
},revealExpandableStack:function(){$(OLSON.cardstack.expander.expandedStackContainer).fadeIn("normal",function(){try{this.style.removeAttribute("filter");}catch(a){}});},showCards:function(){OLSON.cardstack.expander.findValuesForCardAnimation();OLSON.cardstack.expander.animateStackExpansion();OLSON.cardstack.expander.enableScrollingOnOverflow();
},findValuesForCardAnimation:function(){OLSON.cardstack.expander.startPositionTop=OLSON.cardstack.expander.TOP_OFFSET-(OLSON.cardstack.expander.stackOffset.top-$(window).scrollTop());OLSON.cardstack.expander.startPositionLeft=$("."+OLSON.cardstack.expander.CLASSES.PAGE).offset().left-OLSON.cardstack.expander.stackOffset.left;
if($.browser.msie&&$.browser.version<7){OLSON.cardstack.expander.startPositionTop+=$(window).scrollTop();}OLSON.cardstack.expander.runningPosition={top:OLSON.cardstack.expander.startPositionTop,left:OLSON.cardstack.expander.startPositionLeft};OLSON.cardstack.expander.runningLeftIncrement=$("."+OLSON.cardstack.expander.CLASSES.PAGE).width()/OLSON.cardstack.expander.EXPANDED_CARDS_PER_ROW;
OLSON.cardstack.expander.runningTopIncrement=$overlayStack.find("."+OLSON.cardstack.stack.CLASSES.CARD).height();OLSON.cardstack.expander.viewportHeight=$(window).height();},animateStackExpansion:function(){$overlayStack.find("."+OLSON.cardstack.stack.CLASSES.CARD).each(OLSON.cardstack.expander.animateCard);
},animateCard:function(a,b){var d=OLSON.cardstack.expander.runningPosition.left;var c=OLSON.cardstack.expander.runningPosition.top;setTimeout(function(){$(b).animate({left:d,top:c});},50*a+500);OLSON.cardstack.expander.incrementValuesForCardAnimation(a,b);},incrementValuesForCardAnimation:function(a,b){if(!((a+1)%OLSON.cardstack.expander.EXPANDED_CARDS_PER_ROW)){OLSON.cardstack.expander.runningPosition.top+=OLSON.cardstack.expander.runningTopIncrement;
OLSON.cardstack.expander.runningPosition.left=OLSON.cardstack.expander.startPositionLeft;}else{OLSON.cardstack.expander.runningPosition.left+=OLSON.cardstack.expander.runningLeftIncrement;}},enableScrollingOnOverflow:function(){var a=OLSON.cardstack.expander.stackToExpand.children();if(OLSON.cardstack.expander.stackToExpand.context.clientHeight*Math.ceil(a.length/OLSON.cardstack.expander.EXPANDED_CARDS_PER_ROW)+OLSON.cardstack.expander.TOP_OFFSET>OLSON.cardstack.expander.viewportHeight&&$(OLSON.cardstack.expander.expandedStackContainer).css("position")!=="absolute"){$(OLSON.cardstack.expander.expandedStackContainer).css({position:"absolute",width:$(window).width(),height:$(document.body).height()});
$("#"+OLSON.cardstack.expander.IDS.EXPANDED_WRAPPER).css("top",$(window).scrollTop());}},closeOverlay:function(a){try{a.preventDefault();}catch(b){}$("#"+OLSON.cardstack.expander.IDS.EXPANDED_CONTAINER).fadeOut("fast",function(){$("#"+OLSON.cardstack.expander.IDS.EXPANDED_WRAPPER).removeAttr("style").empty();
$("#"+OLSON.cardstack.expander.IDS.EXPANDED_CONTAINER).removeAttr("style");});}};