/* Author: mfairbairn
*/
jQuery(document).ready(function() {
	
	jQuery.fn.exists = function(){return jQuery(this).length>0;}
	
	
	
	
	/* ------------------------------------------- */
	/* Contact Form */
	/* ------------------------------------------- */
	if(jQuery(".wpcf7").exists()){
		
		/* ----------------------- */
		/* How did you hear about us */
		/* ---------------------- */
		jQuery(".wpcf7 .Other").css({display: "none"});
		jQuery(".other_dropper").change(function() {
			
			$curr_select = jQuery(".other_dropper option:selected").text();
			//$curr_select = $raw_select.substr(0,5);
			//alert($curr_select);
		
			if($curr_select == "Other"){
				jQuery(".wpcf7 .Other").css({display: "block"});
			} else {
				jQuery("input.other").val("How did you find us?");
				jQuery(".wpcf7 .Other").css({display: "none"});
			}
			
		});
		
		
		/* ----------------------- */
		/* Tour Date */
		/* ---------------------- */
		
		
		
		jQuery(".select_date_").css({display: "none"});
		jQuery("p.long_dates_").css({display: "none"});
		
		
		jQuery(".iten_drop").change(function() {
			$curr_t_select = jQuery(".iten_drop option:selected").text();
			//alert($curr_t_select);
			
			if($curr_t_select == "Fiordland Explorer - 8 Day Tour"){
				reset_t_selects();
				change_select_display(".wpcf7 #m_drop", "none");
				change_select_display(".wpcf7 #f_drop", "block");
				change_select_display(".wpcf7 p.long_dates_", "none");
				jQuery(".wpcf7 .select_date_").css({display: "block"});
			} else if ($curr_t_select == "Mountain, Island and Ocean Life - 11 Day Tour"){
				reset_t_selects();
				change_select_display(".wpcf7 #m_drop", "block");
				change_select_display(".wpcf7 #f_drop", "none");
				change_select_display(".wpcf7 p.long_dates_", "none");
				jQuery(".wpcf7 .select_date_").css({display: "block"});
			} else if ($curr_t_select == "Long White Cloud, North and South - 19 Day Tour"){
				reset_t_selects();
				change_select_display(".wpcf7 #m_drop", "none");
				change_select_display(".wpcf7 #f_drop", "none");
				change_select_display(".wpcf7 p.long_dates_", "block");
				jQuery(".wpcf7 .select_date_").css({display: "block"});
			} else {
				reset_t_selects();
				jQuery(".wpcf7 .select_date_").css({display: "none"});
				
			}
			
		});
		
		
		
		function reset_t_selects(){
			jQuery(".wpcf7 #f_drop").val(1);
			jQuery(".wpcf7 #m_drop").val(1);
		}
		function change_select_display(target_select, display_mode){
			jQuery(target_select).css({display: display_mode});
		}
		
		
	};
	
	
	
	
	
	
});
