// on dom ready
$(function() {

	$('#shareThis').show();
	$('a#share').addClass('active');

	$('li#categories').hover(
      function () {
        $(this).children('ul').show();
        $(this).addClass('active');
        if ($(this).parent('ul').hasClass('hover')) {
        	$('#project_brogo_banner').hide();
        };
      }, 
      function () {
        $(this).children('ul').hide();
        $(this).removeClass('active');
        if ($(this).parent('ul').hasClass('hover')) {
        	$('#project_brogo_banner').show();
        };
      }
    );
    
    $('#cards').hide();
    
    $('li#categories ul li a , #brogo_image #map a').click( 
    	function () {
    	
    		//$.scrollTo(40, 100);
    		
    		//ajax stuff to load articles based upon cats go here
    		
    		$('li#categories').parent('ul').removeClass('hover');
    		$('#project_brogo_banner').show();
    		$('#brogo_image #map a').hide();
    		
    		//hide the menu
			$('li#categories ul').hide();
    		
    		var link = $(this).attr('href');
    		
    		$('#cards').empty();
    		
    		//$('h1#brogo_title').animate({ top: '45px' }, 1500);
    		
    		$('li#categories ul li a').removeClass('active');
    		$(this).addClass('active');
    		
    		$.blockUI({  
            message: $('<h1 style="margin:0;"><img src="/investigations/broken_government/assets/layout/img/brogo_loading1.gif"/><br/>Loading</h1>'),
            overlayCSS:  {  
        		backgroundColor:'transparent',  
        		opacity:        '0'  
    		},
            css: {   
                background: 'white',
                fontSize: '21px',
                fontFamily: 'Georgia, serif',
                textTransform: 'uppercase',
                letterSpacing: '4px',
                lineHeight: '21px',
                color: '#C91C1C',
                borderColor: '#333',
                borderWidth: '7px',
                padding: '30px 0'
            } });
    		
    		$.ajax({
   				type: "GET",
  				url: link,
   				success: function(html){
     				$("#cards").append(html);
     				$.getScript("/investigations/broken_government/assets/layout/js/jquery.slideshow-ui.js");
     				$.getScript("/investigations/broken_government/assets/layout/js/jquery.slideshow.js");
     				$().ajaxStop($.unblockUI);
   				}
 			});
 			
    		return false;
    	}
    );

});