$(function(){
	if( window.location.pathname.match(/^(\/events)?(\/)?$/i) ) {
		
		$('.section.events .listing.full a').bigTarget({
			clickZone : '.item'
		});
		
		// SET VARS
		var $eventsListing = $('.section.events .listing.full');
		var $events = $eventsListing.find('.item');
		var eventsWidth = $events.eq(0).outerWidth(true) * $events.length;
		var eventsHeight = $events.eq(0).outerHeight();
		
		var windowWidth = $(window).width();
		
		// SET CSS
		$eventsListing.children('ul').css({
			width		: eventsWidth + $events.length
		});
		
		if(!navigator.userAgent.match(/iPhone/i) && !navigator.userAgent.match(/iPod/i) && !navigator.userAgent.match(/iPad/i)) {
			$eventsListing.css({
				marginLeft	: -(parseInt($('#page').css('margin-left')) + parseInt($('#main').css('margin-left'))),
				width		: $(window).width(),
				overflow	: 'hidden'
			});

			// CREATE SCROLLBAR FUNC
			$('body').append('<div id="slider" />');
			$('#slider').slider({
				animate			: true,
				slide			: function(event, ui) {
					$eventsListing.children('ul').stop().animate({
						marginLeft		: -(eventsWidth - windowWidth) * (ui.value/100)
					});
				}
			});

			$(window).resize(function() {
				windowWidth = $(window).width();

				$eventsListing.css({
					width		: $(window).width()
				});
			});
		}
	}
});



