$(document).ready(function() {
    $('#chooseYourPark p.toggle').click(function() {
	/*if the element following this one has the class 'hidden' and the class 'showMe'*/
	if($(this).next('.hidden').hasClass('showMe')) {
	    /*remove the class 'showMe' from all elements with the class 'hidden'*/
	    $('.hidden').removeClass('showMe').hide();
	    $('#headerRight').removeClass("headerRight").hide;
	    $('#ticketsLink').removeClass("ticketsLink").hide;
	    $('#seasonPassesLink').removeClass("seasonPassesLink").hide;
	    return false; 
	}
	/*if the element following this one has the class 'hidden' and does not have the class 'showMe'*/
	else {
	    /*remove the class 'showMe' from all elements with the class 'hidden'*/
	    $('.hidden').removeClass('showMe').hide();
	    $('#headerRight').removeClass("headerRight").hide;
	    $('#ticketsLink').removeClass("ticketsLink").hide;
	    $('#seasonPassesLink').removeClass("seasonPassesLink").hide;
	    /*add the class 'showMe' to the element following this one with the class 'hidden'*/
	    $(this).next('.hidden').addClass('showMe').show();
	    return false;
	}
    });
	    
    $('#tickets p.toggle').click(function() {
	$('#headerRight').toggleClass("headerRight");
	$('#ticketsLink').toggleClass("ticketsLink");
	
	/*if the element following this one has the class 'hidden' and the class 'showMe'*/
	if($(this).next('.hidden').hasClass('showMe')) {
	    /*remove the class 'showMe' from all elements with the class 'hidden'*/
	    $('.hidden').removeClass('showMe').hide();
	    $('#headerRight').removeClass("headerRight").hide;
	    $('#ticketsLink').removeClass("ticketsLink").hide;
	    return false;       
	}
	/*if the element following this one has the class 'hidden' and does not have the class 'showMe'*/
	else {
	    /*remove the class 'showMe' from all elements with the class 'hidden'*/
	    $('.hidden').removeClass('showMe').hide();
	    $('#headerRight').removeClass("headerRight").hide;
	    $('#ticketsLink').removeClass("ticketsLink").hide;
	    $('#seasonPassesLink').removeClass("seasonPassesLink").hide;
	    /*add the class 'showMe' to the element following this one with the class 'hidden'*/
	    $(this).next('.hidden').addClass('showMe').show();
	    $('#headerRight').toggleClass("headerRight");
	    $('#ticketsLink').toggleClass("ticketsLink");
	    return false;
	}
    });
    
    $('#seasonPasses p.toggle').click(function() {
        $('#headerRight').toggleClass("headerRight");
        $('#seasonPassesLink').toggleClass("seasonPassesLink");
        /*if the element following this one has the class 'hidden' and the class 'showMe'*/
        if($(this).next('.hidden').hasClass('showMe')) {
            /*remove the class 'showMe' from all elements with the class 'hidden'*/
            $('.hidden').removeClass('showMe').hide();
            $('#headerRight').removeClass("headerRight").hide;
            $('#seasonPassesLink').removeClass("seasonPassesLink").hide;
            return false;        
        }
        /*if the element following this one has the class 'hidden' and does not have the class 'showMe'*/
        else {
            /*remove the class 'showMe' from all elements with the class 'hidden'*/
            $('.hidden').removeClass('showMe').hide();
            $('#headerRight').removeClass("headerRight").hide;
            $('#seasonPassesLink').removeClass("seasonPassesLink").hide;
            $('#ticketsLink').removeClass("ticketsLink").hide;
            /*add the class 'showMe' to the element following this one with the class 'hidden'*/
            $(this).next('.hidden').addClass('showMe').show();
            $('#headerRight').toggleClass("headerRight");
            $('#seasonPassesLink').toggleClass("seasonPassesLink");
            return false; 
        }
    });

    $('body').click(function(event) {
        if ($.inArray(event.target, $('#chooseYourPark p.toggle, #seasonPasses p.toggle, #tickets p.toggle, #viewMap, #promoWrap, .menu ul')) < 0 &&
            !$(event.target).parents('#chooseYourPark p.toggle, #seasonPasses p.toggle, #tickets p.toggle, #viewMap, #promoWrap, .menu ul').length) {
        //if (!$(event.target).closest('#chooseYourPark p.toggle, #seasonPasses p.toggle, #tickets p.toggle, #viewMap, #promoWrap, .menu ul').length) {
          $('.hidden').removeClass('showMe').hide();
          $('#headerRight').removeClass("headerRight").hide;
          $('#seasonPassesLink').removeClass("seasonPassesLink").hide;
          $('#ticketsLink').removeClass("ticketsLink").hide;
      };
    }); 
   
});
