$(document).ready(function () {		
	$('._accordion').accordion({ 
		header: 'h2',
		defaultContent: '.first-child',
		selectedClass: 'sectionOn',
		allowMultiple: false,
		allowClose: true,
		fixedHeight: false
	});
	$('.carousel').carousel({
		loop: false,
		slideTransition: true
	});	
    
    var goBackground;
    $('a.smallGoButton').click(function() {	
        
        if (document.getElementById("jumpMenu").value == "1")
        {
            location.href="http://www.vail.com/plan-your-trip/plan-your-trip.aspx";
        }
        else if (document.getElementById("jumpMenu").value == "2")
        {
            location.href="http://www.beavercreek.com/plan-your-trip/plan-your-winter-trip.aspx";
        }
        else if (document.getElementById("jumpMenu").value == "3")
        {
            location.href="http://www.breckenridge.com/plan-a-trip/plan-a-trip-to-breckenridge.aspx";
        }
        else if (document.getElementById("jumpMenu").value == "4")
        {
            location.href="http://www.keystoneresort.com/plan-a-vacation/plan-a-vacation.aspx";
        }
        else if (document.getElementById("jumpMenu").value == "21") 
        {
			location.href="http://www.skiheavenly.com/plan-your-trip/book-a-vacation.aspx";
        }
        else
        {
            location.href="https://onestore.snow.com/index.asp?siteid=" + document.getElementById("jumpMenu").value; 
        }
        
//        if ($('.plan_ajax_error').length) { 
//            $('.plan_ajax_error').text(''); 
//        }
//        var linkButton = $(this);		
//        var selectedResort = $('select#jumpMenu').val();
//        if(selectedResort != null && selectedResort != "" && !$(this).hasClass('plan_ajax_loading')){
//            goBackground = $(this).css('background-image');
//            $(this)
//                .css({ 'background-image':'url(/vailresorts/sites/snow/assets/img/global/ajax-loader.gif)' })
//                .addClass('plan_ajax_loading');

//            $.ajax({
//                type: "GET",
//                url: "/vailresorts/sites/snow/layouts/VacationPlanner.aspx",
//                data: "resort=" + selectedResort,
//                async: true,
//                error: function (request, textStatus, errorThrown) { 
//                    $('.smallGoButton').removeClass('plan_ajax_loading');
//                    VAIL.errors.push({ request:request, textStatus:textStatus, errorThrown:errorThrown });
//                    var message = "We are unable to complete your request."
//                    if ($('.plan_ajax_error').length) {
//                        $('.plan_ajax_error').text(message);
//                    } else {
//                        $('.smallGoButton').css({ 'background-image':goBackground }).after('<p class="plan_ajax_error" style="clear:both; color:red;">' + message + '</p>');
//                    }
//                },
//                success: function(msg) {
//                    $('.accordion').append(msg);
//                    $('.accordion').find('div.bottom').not($('#vacationPlanner>div.bottom')).hide();		
//                    $('._accordion').wrap('<div style="overflow:hidden;margin:0;padding:0;width:100%;"></div>')
//                        .parent()
//                        .animate({ 'height':0 }, 250, 'swing', function () {
//    	                    $('._accordion').hide();
//    	                    $(this).replaceWith($('._accordion'));					
//    	                    $('div.first-child').find('.content').wrap('<div style="overflow:hidden;margin:0;padding:0;width:100%;"></div>')
//    		                    .parent()
//    		                    .animate({ 'height':0 }, 250, 'swing', function () {
//    			                    $('div.first-child').find('.content').hide();
//    			                    $(this).replaceWith($('div.first-child').find('.content'));
//    			                    plannerDisplay();
//    			                    $('a.smallGoButton')
//                                        .css({ 'background-image':goBackground })
//                                        .removeClass('plan_ajax_loading');
//    		                    });						
//                        });
//                    
//                }
//            });
//        };		
//        return false;			
	});
	function adjColumnHeight(){
		var columnHeight = 0;
		$('div.column').each(function(){
			if(!$(this).children().hasClass("accordion") && columnHeight <= $(this).height()){
				columnHeight = $(this).height();
			}			
		});		
		$('div.column').each(function(){		
			if (!$(this).children().hasClass("accordion") && columnHeight >= $(this).height()){
				$(this).css('height',columnHeight+'px');
			}
			if ($(this).children().hasClass("accordion")){				
				$(this).css('background-image','none');
				$(this).find('div.promoBoxBottom').css('display','none');
			}
		});
	};	
	if (_homePage && _homePage == true) {
		adjColumnHeight();	
	}
	$('div.pagination').find('a').bind("click", function(e){
      	if (_homePage && _homePage == true) {
      		adjColumnHeight();	
      	}
    });
});
function plannerDisplay(){
	$('div#vacationPlanner').wrap('<div style="position:relative;overflow:hidden;height:0;margin:0 0 0 0;padding:0 0 0 0;"></div>').show();	
	$('.vacationList').listColumns({ 
		numberOfColumns: 2		
	});		
	$('div#vacationPlanner').parent()
		.animate({ 'height':$('div#vacationPlanner').height()}, 500, 'swing', function () {			
			$(this).replaceWith($('div#vacationPlanner'));	
	});			
	$('a.closePlanner').click(function() {		
		$('div#vacationPlanner').wrap('<div style="position:relative;overflow:hidden;margin:0;padding:0;width:100%;"></div>')
		.parent()
		.animate({ 'height':0 }, 500, 'swing', function () {
			$('div#vacationPlanner').hide();
			$(this).replaceWith($('div#vacationPlanner'));	
			$('div#vacationPlanner').remove();
			
			$('div.first-child').find('.content').wrap('<div style="position:relative;overflow:hidden;height:0;margin:0;padding:0;"></div>')
				.show()
				.parent()
				.animate({ 'height':$('div.first-child').find('.content').outerHeight() }, 500, 'swing', function () {
					$(this).replaceWith($('div.first-child').find('.content'));
					$('._accordion').wrap('<div style="position:relative;overflow:hidden;height:0;margin:0;padding:0;"></div>')
						.show()
						.parent()
						.animate({ 'height':$('._accordion').outerHeight() }, 500, 'swing', function () {
							$(this).replaceWith($('._accordion'));
							$('.accordion').find('div.bottom').not($('#vacationPlanner>div.bottom')).show();
						});
				});		
		});		
		return false;			
	});	
};