var AbbeyCoal = AbbeyCoal || {};

AbbeyCoal.Homepage = {
  init: function () {
    //$('#header li a').click(this.changePanelNavigation);
    $('.categories a').click(this.changePanelCategories);
  },
  changePanelNavigation: function (e) {
    e.preventDefault();
    var classLink = $(this).parent().attr('class');
    $('.container').hide();
    $('.container[data-slug='+ classLink +']').show();
  },
  changePanelCategories: function (e) {
    e.preventDefault();
    var category_id = $(this).attr('data-category-id');
    
    // Only within the current container
    $('div[id^=category]', $(this).parents('.container')).hide();
    $('#category_'+ category_id, $(this).parents('.container')).show();
  },
  gallery: function () {
    
  }
}

$(document).ready(function () {
	AbbeyCoal.Homepage.init();
	
		// Media Pages Fancyboxes
		$('a.fancybox').fancybox();
		
		// Homepage Slider
		$('.homeslideshow').nivoSlider({
			effect: 'fade'
		});
		
		// Advertisement Transitions
		$('#advertisement').nivoSlider({
			effect: 'fade',
			controlNav: false,
			directionNav: false,
			animSpeed: 1,
			pauseTime: 3000
		})
		// Lookbook Slider
		$('#lookbooklisting').nivoSlider({
			effect: 'fold',
			controlNav: false,
			pauseTime:3200
		});
		
		// Videos
		$(function() {    
			$("a.videopop").click(function() {
				$.fancybox({
					'autoscale' : false,
					'transitionIn' : 'none',
					'transitionOut': 'none',
					'padding' : 0,
					'title'  : this.title,
					'width'  : 500,
					'height' : 313,
					'type'    : 'swf',
					'href'    : this.href,
					'swf'   : { 'wmode':'transparent', 'allowfullscreen':'true' }
				});

				return false;
			});
		});
});
