$(document).ready(function() {
	$('.js_hide').hide();
	$('.js_hide + div').hide();
	
	//re-open the search fields if they have search data in them
	$('.js_hide + div :checked').each(function(index) {
		if($(this).val() != '') {
			
			$(this).parents('.expandable').show();
			$(this).parents('.expandable').prev().show();
			$(this).parents('.expandable').prev().prev().hide();
			
		}
		
	});
	
	$('.js_show').click(function(e) {
		e.preventDefault();

		$(this).hide();
		$(this).next('.js_hide').show();
		$(this).next('.js_hide').next().slideDown();
	});
	
	$('.js_hide').click(function(e) {
		e.preventDefault();
		
		$(this).hide();
		$(this).prev('.js_show').show();
		$(this).next().slideUp();
	});
	
	if($('.stay_length select').val() != -1 ) {
		$('.stay_other').hide();		
	}
	
	$('.stay_length select').change(function(e) {
		if($(this).val() == -1) {
			$('.stay_other').show();
		} else {
			$('.stay_other').hide();
		}	
	});
	
	$('.url_select').change(function(e) {
		window.location = $(this).val();
	});
	
	
});
