// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// jQuery preload images
jQuery.preloadImages = function() {
	for(var i=0; i<arguments.length; i++) {
		$("<img>").attr("src", arguments[i]);
	}
}

$(document).ready(function(){

	// settings dropdown
	$("a.settings_dropdown").mouseover(function(){
		$(this).siblings("div.settings_region_lang").slideDown();
	});
	
	// nav hover dropdowns
	$('div#nav_about').mouseover(function(){ $('#nav_about_dropdown').show(); });
	$('div#nav_about').mouseout(function(){ $('#nav_about_dropdown').hide(); });
	$('div#nav_participants').mouseover(function(){ $('#nav_participants_dropdown').show(); });
	$('div#nav_participants').mouseout(function(){ $('#nav_participants_dropdown').hide(); });
	$('div#nav_fundraising').mouseover(function(){ $('#nav_fundraising_dropdown').show(); });
	$('div#nav_fundraising').mouseout(function(){ $('#nav_fundraising_dropdown').hide(); });
	$('div#nav_volunteer').mouseover(function(){ $('#nav_volunteer_dropdown').show(); });
	$('div#nav_volunteer').mouseout(function(){ $('#nav_volunteer_dropdown').hide(); });
	$('div#nav_sponsors').mouseover(function(){ $('#nav_sponsors_dropdown').show(); });
	$('div#nav_sponsors').mouseout(function(){ $('#nav_sponsors_dropdown').hide(); });
	$('div#nav_connected').mouseover(function(){ $('#nav_connected_dropdown').show(); });
	$('div#nav_connected').mouseout(function(){ $('#nav_connected_dropdown').hide(); });
	$('div#nav_sponsors').mouseover(function(){ $('#nav_sponsors_dropdown_ca').show(); });
	$('div#nav_sponsors').mouseout(function(){ $('#nav_sponsors_dropdown_ca').hide(); });
	$('div#nav_connected').mouseover(function(){ $('#nav_connected_dropdown_ca').show(); });
	$('div#nav_connected').mouseout(function(){ $('#nav_connected_dropdown_ca').hide(); });
	$('#nav_about_dropdown').hover(
		function(){ $(this).show(); },
		function(){ $(this).hide(); }
	);
	$('#nav_participants_dropdown').hover(
		function(){ $(this).show(); },
		function(){ $(this).hide(); }
	);
	$('#nav_fundraising_dropdown').hover(
		function(){ $(this).show(); },
		function(){ $(this).hide(); }
	);
	$('#nav_volunteer_dropdown').hover(
		function(){ $(this).show(); },
		function(){ $(this).hide(); }
	);
	$('#nav_sponsors_dropdown').hover(
		function(){ $(this).show(); },
		function(){ $(this).hide(); }
	);
	$('#nav_connected_dropdown').hover(
		function(){ $(this).show(); },
		function(){ $(this).hide(); }
	);
	$('#nav_sponsors_dropdown_ca').hover(
		function(){ $(this).show(); },
		function(){ $(this).hide(); }
	);
	$('#nav_connected_dropdown_ca').hover(
		function(){ $(this).show(); },
		function(){ $(this).hide(); }
	);
	
	// support answer toggle
	$(".question").click(function(){
		// jQuery(this).siblings(".answer").toggle();
		$(".answer").hide();
		$(this).siblings(".answer").show();
		return false;
	});
	
	// support contact dropdown
	$("select#support_contact").change( function() {
		if (url = $(this).val()) {
			window.location = url;
		}
	});

});

