(function($){

	Site = {
		gallery: function(x) {
			var length = x.length;
			var i = 0;
			var timer = 5000;
			
			var toggle = function() {
				x.hide();
				x.filter(':eq('+i+')').fadeIn();
				i = (i == length - 1) ? 0 : i + 1;
				
				setTimeout(toggle, timer);
			};
			
			toggle();
		},

		fileLinks: function() {
			var $link = $(this);
			var ext = $link.attr('href').split('?')[0].split('.');
			ext = ext[ext.length-1];
			$link.addClass(ext);
		},

		init: function() {
			// hasJS
			$(document.body).addClass('hasJS');

			// Gallery
			Site.gallery($('#home-flash').children());
			
			// Disable inactive nav links
			$('#nav li.inactive a').click(function(){ return false; });

			// File Links
			$('a').filter('[href*=.pdf], [href*=.zip], [href*=.rar], [href*=.gz]').each(Site.fileLinks).end();
		}
	};

	$(document).ready(Site.init);

})(jQuery);