//Only need one document ready function, throw it in here. 
$(document).ready(function() {
	
	//Scroll for Find a Member
	 var msie6 = $.browser == 'msie' && $.browser.version < 7;
	  
	 if ($('#map').length != 0) {
	  if (!msie6 ) {
	    var top = $('#map').offset().top - parseFloat($('#map').css('margin-top').replace(/auto/, 0));
	    $(window).scroll(function (event) {
	      // what the y position of the scroll is
	      var y = $(this).scrollTop();
	      
	      // whether that's below the form
	      if (y >= top) {
	        // if so, ad the fixed class
	        $('#map').addClass('fixed');
	      } else {
	        // otherwise remove it
	        $('#map').removeClass('fixed');
	      }
	    });
	  }  
 	}
	 
	$("#vertMenu").accordion({
		active: false, 
		autoHeight: false,
		collapsible: true
	});

	//////////////////
	// SELECTED TAB //
	//////////////////
	$(function() {
		var tab = window.location.pathname;
		tab = tab.replace('.html', '');
		switch(tab)
		{
			case '/home':
			case '/':
				tab = "home";
				break;
			case '/find-cdpe-results':
				tab = "find_cdpe";
				break;
			case '/what-is-a-cdpe':
				tab = "what_is_cdpe";
				break;
			case '/become-a-cdpe-now':
				tab = "become_cdpe";
				break;
			case '/forum/':
				tab = "forum";
				break;
			case '/press-releases':
				tab = "press_releases";
				break;
			case '/blog/':
				tab = "blog";
				break;
			case '/contact-us':
				tab = "contact_us";
				break;
			case '/schedule-now':
				tab = "schedule_now";
				break;
			case '/resources':
				tab = "resources";
				break;
		}

		tab = document.getElementById(tab);
		
		if(tab)
		{
			tab.setAttribute('class', 'active')
		}
	});
	//////////////////////
	// END SELECTED TAB //
	//////////////////////
	
	//tabs on resources 
	// $("#resource_tabs").tabs({ cookie: { expires: 30 } });
	
	
	$('#hide-me').css('display','none');
	$('a.close_toggle').click(function() {   
		$("#find_icon").toggleClass("member_on").next().slideToggle("slow");
		return false;	  
	});
}); //End Document Ready



