$(document).ready(function() {
	
	//initial state: collapse all
	$('.group ul').hide()

	// show the current menus
	$('.current ul').show()
	
	//click on group title
	$('.group_title').click(function() {
		$('.group ul').hide();
		//console.log(window.scrollTop);
		$('.group_title_active').removeClass('group_title_active');
		$(this).addClass('group_title_active');
		$(this).parent().find('ul').show()
		//window.scroll(0,0);
	})

	// setup the drop down functionality on our "which publisher" buttons
	$('.lnkAllPublishers').click(
		function(){
			// close any open boxes
			$('.extraDropdownActive').not($(this).next('.extraDropdown')).removeClass('extraDropdownActive');
			
			// now toggle it
			$(this).next('.extraDropdown').toggleClass('lnkAllPublishersActive');

			if ($(this).next('.extraDropdown ').is(".lnkAllPublishersActive")) {
				$(this).next('.extraDropdown').css( {
												   'left':$(this).position().left+1,
												   'top':$(this).position().top+18
												   }
												   );
			} else {
				$(this).next('.extraDropdown').css( {
												   'left':-999,
												   'top':-999
												   }
												   );
			}
			return false;
		}
	);

	// make sure a click outside will hide the dropdown
	$('body').click(
		function() {
			$('.lnkAllPublishersActive').removeClass('lnkAllPublishersActive').css({'top':-999,'left':-999});
		}
	)

})