$(function() {
	$('.actionContainer').css('display', 'none');
	
	$('.branchInfo').click(function() {
        $('.branchInfo').removeClass('active').addClass('fade');
        $(this).addClass('active');
        
        $('.actionContainer').slideDown();
        
        document.branch.selected = $(this).attr('data-branch');
        $('a.branch-infoLink').attr('rel', document.branch.selected);
        
		$('img.arrow').css('display', 'block').clearQueue().animate({
			left: $(this).attr('data-arrow-pos')+'px'
		});
	});
	
	$('.actionContainer a.attach').click(function(e) {
        e.preventDefault();
        var href = $(this).attr('href');
        
        if(document.branch.selected) {
            href += '?branch='+document.branch.selected;
        }
        
        window.location.href = href;
	});
});

document.branch = {
    selected: null
}
