$(document).ready(function () {
	var pos = 0;
	var total = $('#slide').children('img').size()-1;
	
	$('#next a').click(function() {
		
		pos = slideshowpos(pos, total, 'next');
		$('#slide').dequeue().animate({ marginLeft: pos*(-462)}, 300);
		return false;
	});
	
	$('#prev a').click(function() {
		pos = slideshowpos(pos, total, 'prev');
		$('#slide').dequeue().animate({ marginLeft: pos*(-462)}, 300);
		return false;
	});
	
	$('#menu a').click(function() {
		return false;
	});
});

function slideshowpos(pos, total, direction) { //used when the last picture in slidehow is reached and user presses next. Or when user presses 'prev' on the first picture in slideshow
	if(direction == 'next') {
		if(pos<total) pos++;
		else pos=0;
	}
	else {
		if(pos>0) pos--;
		else pos = total;
	}
	return pos;
}

