$(document).ready(function() {
	$("a.tooltip").tooltip({
		bodyHandler: function() {
			return $($(this).attr("href")).html();
		},
		showURL: false
	});

	$('input#locator_search_box, input#locator_search_box_door').filter(function(index) {
			return $(this).val() == "";
		}).val('Enter location').focus(function() {
			if ($(this).val() == 'Enter location') $(this).val('');
		}).blur(function() {
			if ($(this).val() == '') $(this).val('Enter location');
		});

	$('input#searchValue').filter(function(index) {
			return $(this).val() == "";
		}).val('Search').focus(function() {
			if ($(this).val() == 'Search') $(this).val('');
		}).blur(function() {
			if ($(this).val() == '') $(this).val('Search');
		});

	$("#nav-collapsed > li").hover(
		function() { 
			$(this).css('overflow','visible');
			
			switch ($(this).attr('id')) {
				case 'nav_staysafesecure':
					$('#apply_form select').css('visibility', 'hidden');
					break;
				case 'nav_insurance':
				case 'nav_savings':
				case 'nav_advicetools':
					$('#brochures_cat_select').css('visibility', 'hidden');
					break;
			}
		},
		function() {
			$(this).css('overflow','hidden');

			switch ($(this).attr('id')) {
				case 'nav_staysafesecure':
					$('#apply_form select').css('visibility', 'visible');
					break;
				case 'nav_insurance':
				case 'nav_savings':
				case 'nav_advicetools':
					$('#brochures_cat_select').css('visibility', 'visible');
					break;
			}
		}
	);
}).unload(function() { /* fix for firefox' back button events handling when loading a page from cache */ });
