$(document).ready(function(){

	// Fix iphone/ipad fixed toolbar
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
	{
	     $("#riverwalk_bar_wrapper").hide();
	     $("#plan_trip_wrapper").hide();
	};
	

	// Swap Values Input Fields
	$(function() {
	    swapValues = [];
	    $(".swap_value").each(function(i){
	        swapValues[i] = $(this).val();
	        $(this).focus(function(){
	            if ($(this).val() == swapValues[i]) {$(this).val("");}
	        }).blur(function(){
	            if ($.trim($(this).val()) == "") {$(this).val(swapValues[i]);}
	        });
	    });
	});
	
	// Plan Your Trip Slider				
	$(".plan_your_trip_button").click(function(){
		
		if($('#plan_trip_wrapper').hasClass('active')){
			$('#plan_trip_wrapper').removeClass('active');
			$('#plan_trip_wrapper').animate({bottom: '-560px'}, 1200, 'easeInBack',function(){$('#plan_trip_wrapper').hide(1);}); 
		} else {
			$('#plan_trip_wrapper').show(1,function(){
				$('#plan_trip_wrapper').addClass('active');
				$('#plan_trip_wrapper').animate({bottom: '-20px'}, 1200, 'easeOutBack'); 
			});
		}
		return false;
	});

	// Load Calendar 
	$('#sc_calendar').load('http://www.thesanantonioriverwalk.com/events/mini_calendar');

	//Home Banner Slider
	$('#home_banner_navigation a').click(function(){
		$('#home_banner_navigation a.active').removeClass('active');
		var clickedSlider = $(this).attr('href');
		var currentSlider;
		if($('#home_banner_sliders').children('.home_banner_slider').hasClass('active')){	
			currentSlider = '#'+$('#home_banner_sliders').children('.active').attr('id');
		};
		if(currentSlider){
			if(currentSlider == clickedSlider){
				$('#home_banner_color_overlay').hide();
				$(clickedSlider).removeClass('active').animate({right: '-600px'}, 500, 'easeOutQuad');
			} else {
				$('#home_banner_sliders').children('div.active').removeClass('active').animate({right: '-600px'}, 500, 'easeOutQuad');
				$(this).addClass('active');
				$(clickedSlider).addClass('active').delay(500).animate({right: '0'}, 1000, 'easeOutQuad');
			}
		} else {
			$(this).addClass('active');
			$('#home_banner_color_overlay').show();
			$(clickedSlider).addClass('active').animate({right: '0'}, 1000, 'easeOutQuad');
		}
		return false;
	});
		
	// Sponsors
	$("#sponsors_logos_slider").jCarouselLite({
        btnNext: "#sponsor_nav_right",
        btnPrev: "#sponsor_nav_left",
		auto: 1000,
		speed: 1000,
		visible: 5,
		scroll: 1
    });

	// Choice a trip
	$('.choice_button').toggle(function(){
			$(this).addClass('choice_chosen');
			$(this).next('.hiddenField').html('<input type="hidden" name="'+$(this).attr('rel')+'" value="On" />');
			return false;
		}, function(){
			$(this).removeClass('choice_chosen');
			$(this).next('.hiddenField').html('');
			
			return false;
		});
	
	//Colorbox
	$(".colorbox_photo").colorbox({
		maxWidth: "95%", 
		maxHeight: "95%", 
		photoScaling: "true", 
		opacity: .75});
	$(".colorbox").colorbox({
		opacity: .75
	});
	$(".colorbox_iframe").colorbox({width:"940px", height:"750px", iframe:true});
	
	// Member Controller
	$('#controller_top ul li a').click(function(){
		$('#controller_top ul li a.active').removeClass('active');
		$(this).addClass('active');
		$('#controller_lists').children('div:visible').hide();
		$($(this).attr('href')).show();
		return false;
	});
	
	// Events Share Bar
	$('.event_share_bar a.event_drop').click(function(){					
		if($('.detail_sections').children('div:visible').length > 0){
			if($(this).attr('href') == '#'+$('.detail_sections').children('div:visible').attr('id')){
				$($('.detail_sections').children('div:visible')).slideUp(500,'easeOutQuad');
				return false;
			}
			$($('.detail_sections').children('div:visible')).slideUp(500,'easeOutQuad');
			$($(this).attr('href')).delay(500).slideDown(500,'easeOutQuad');
		} else {$($(this).attr('href')).slideDown(500,'easeOutQuad');}
		return false;
	});
	
	
});
