$(function() {

	var flip = 0;
	
	  // fix for IE z-index issue
	  if ( $.browser.msie ) {
	  	$("#header-container").css("z-index", 5000);
	  	$("#footer-container").css("z-index", 1);
	  }
	  

	$(".find-store, .close-button").click(function() {
		if ( flip % 2 == 0 ) {
			$(".arrow").attr("src", "/images/find-store/find_store_arrow_up.png");
		}
		else {
			$(".arrow").attr("src", "/images/find-store/find_store_arrow_down.png");
		}
		$("#find-store-content").slideToggle("fast", function() {
			// animation complete
			flip++;
		});
		return false;
	});
	
	var $stickyHeight = 120;
	var $padding = 0;
	var $topOffset = 120;
	var $footerHeight = 83;
	var obj = $("#find-a-store");
	
	function scrollSticky(){
	    if($(window).height() >= $stickyHeight) {
	        var aOffset = $(obj).offset();
			
			if($(window).scrollTop() + $padding > $topOffset) {
	            $(obj).attr('style', 'position:fixed; top:'+$padding+'px; margin-left:-132px');
	
	        }else{
	            $(obj).attr('style', 'position:relative; margin-left: -132px;');
	        }
	    }
	}
	
	$(window).scroll(function(){
	    scrollSticky()
	});

	
});
