jQuery(document).ready(function() {

		
	
	/*
	if(jQuery.cookie('topbar-toggle-visibility')){
		if(jQuery.cookie('topbar-toggle-visibility') == 'topbar-opened'){
			if(jQuery('#commentbox').length){
				jQuery('#commentbox, #commentbox-header').css({top: '100px'});
				jQuery('.widget-topbar').hide();
			}			
			jQuery("#topbar-toggle-visibility").removeClass('topbar-opened');			
			jQuery("#topbar-toggle-visibility").addClass('topbar-closed');		
			
		}
		else{
			if(jQuery('#commentbox').length){
				jQuery('#commentbox, #commentbox-header').css({top: '+200px'});
				jQuery('.widget-topbar').show();
				
			}			
			jQuery("#topbar-toggle-visibility").removeClass('topbar-closed');			
			jQuery("#topbar-toggle-visibility").addClass('topbar-opened');		
			
		}
	}

	*/


	
	jQuery('#menu-secondary-rule-issue').attr('href', jQuery(jQuery('.issue-of-day-header-label a').get(0)).attr('href'));
		
	if(jQuery.cookie('dynamic-topbar') == 'topbar-opened') {
		topbar_open();
		
	}
	else{
		topbar_close();
		
	}



	function topbar_open(){
		jQuery('#dynamic-topbar').animate({height: '100px'});
		jQuery("#dynamic-topbar").removeClass('topbar-closed');			
		jQuery("#dynamic-topbar").addClass('topbar-opened');		
		jQuery.cookie('dynamic-topbar', 'topbar-opened', { expires: 30 } );				

		jQuery("#topbar-toggle-visibility div").removeClass('topbar-closed');		
		jQuery("#topbar-toggle-visibility div").addClass('topbar-opened');		



		jQuery('.widget-topbar').show();
		if(jQuery('#commentbox').length){
			jQuery('#dynamic-topbar').css({height: '100px'});
			jQuery('#commentbox').position_main_elements();
		}	
			
	}

	function topbar_close(){
	
		jQuery('#dynamic-topbar').animate({height: '2px'});
		jQuery("#dynamic-topbar").removeClass('topbar-opened');
		jQuery("#dynamic-topbar").addClass('topbar-closed');
		jQuery.cookie('dynamic-topbar', 'topbar-closed', {  expires: 30 } );				

		jQuery("#topbar-toggle-visibility div").removeClass('topbar-opened');		
		jQuery("#topbar-toggle-visibility div").addClass('topbar-closed');		

		jQuery('.widget-topbar').hide();
		if(jQuery('#commentbox').length){
			jQuery('#dynamic-topbar').css({height: '2px'});			
			jQuery('#commentbox').position_main_elements();
		}	


	}
	
	jQuery("#topbar-toggle-visibility").click(function(e){
		
		if(jQuery("#dynamic-topbar").hasClass('topbar-closed')){

			topbar_open();


		
		}
		else if(jQuery("#dynamic-topbar").hasClass('topbar-opened')){
		
			topbar_close();


		}
	});	
	
	
	
	
});



