function resizePanels() {	
	width = $(window).width();
	$("#sections ul li").css("width", width + "px");
	// TODO: the navigation should also resize, but the next lines don't do it:
	// $("#navigation").css("width", width + "px");
	// $("#screen .prev").css("right", "20px");
	// $("#screen .next").css("right", "78px");
}

$(document).ready(function () {
	resizePanels();
	$(window).resize(resizePanels);
	
	$('#screen').serialScroll({
		target:'#sections',
		items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'p.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'p.next',// Selector to the 'next' button (absolute too)
		axis:'xy',// The default is 'y' scroll on both ways
		navigation:'#navigation li a', 
		duration:240,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		queue:false,// We scroll on both axes, scroll both at the same time.
		start: 0, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		cycle:true,// Cycle endlessly ( constant velocity, true is the default )
		
		onBefore:function( e, elem, $pane, $items, pos ){
			/**
			 * 'this' is the triggered element 
			 * e is the event object
			 * elem is the element we'll be scrolling to
			 * $pane is the element being scrolled
			 * $items is the items collection at this moment
			 * pos is the position of elem in the collection
			 * if it returns false, the event will be ignored
			 */
			 //those arguments with a $ are jqueryfied, elem isn't.
			e.preventDefault();
			if( this.blur ) this.blur();
			$.scrollTo(0, 0, { axis: "y" });
		},
		onAfter:function( elem ){
			//'this' is the element being scrolled ($pane) not jqueryfied
		}
	});
		

		$(".relly").bind("click", function () {
			$("#sections").trigger("goto", $("#" + this.id));
		});
	});
