var TripRegistration = {
	_idPrefix: "paymentMethod_",
	update: function() {
		var radios = $(".paymentMethodFieldArea input");
		radios.each(function() {
			if( this.checked ) {
				$( "#" + TripRegistration._idPrefix + this.value ).show();
			} else {
				$( "#" + TripRegistration._idPrefix + this.value ).hide();
			}
		});
	},
	changePaymentMethod: function() {
		this.update();
	}
};


$(function() {
	TripRegistration.update();
	
	$("body").addClass("jsEnabled");
	
	//Gallery Setup
	$("#galleryInner").scrollable({
		items: '#photoItems',
		size: 3,
		vertical: true,
		speed: 1000,
		clickable: false,
		next: '.nextPhoto',
		prev: '.previousPhoto',
		activeClass: "active"
	});
	
	var firstPhoto = $(".individualPhoto").eq(0);
	firstPhoto.show().addClass("current");
	
	$("#photoItems div").click(function(){
		var selectedPhoto = $("#photoItems div").index(this);
		var largePhoto = $(".individualPhoto").eq(selectedPhoto);
		
		$(".current").removeClass("current").hide();
		largePhoto.fadeIn("slow").addClass("current");
	});
	
	
	//Current Destinations Ajax Request
	var destinationSelector = $("#destinationSelector"); 
	var optionsArray = [];
	
	destinationSelector.children("select").change(function(){
		destinationSelector.children("select").each(function(i){
			optionsArray[i] = $(this).val();
		});
		
		$("#currentDestinations").load(
				"current-destinations.html #currentDestinationsInner", 
				{
					selectedYearMonth: optionsArray[0], 
					locationId: optionsArray[1], 
					activityId: optionsArray[2]  
				}
		);
	});
	
	$(".pageList:last").addClass("last-child");
	
	// Adding hover in IE for non-anchor elements
	$(".hoverEnabled").hover(
		function() {
			$(this).addClass("hover");
		},
		function(){
			$(this).removeClass("hover");
		}
	);
	
	//Add zebra-striping to tables
	$("table tr:odd").addClass("odd");
	
	//Automatically selects focused field text and adds class for styling
	$('input[type="text"]').focus(function(){
		$(this).select().addClass("focused");
	});
	$('input[type="text"]').blur(function(){
		$(this).removeClass("focused");
	});
	
}); 

