jQuery.fn.simpleImageRollover = function(preload) {
    
    if (preload) {
        this.each(function() {
            var i = new Image;
            i.src = this.src;
        });
    }
    
    this.hover(
        function() { this.src = this.src.replace(/\.(\w+)$/, '_h.$1'); },
        function() { this.src = this.src.replace(/_h\.(\w+)$/, '.$1'); }
    );

}

$(function() {
	
	var width = 884;
	var positions = { home: 0, interior: 1, menu: 2, 'private hire': 4, contact: 6 };
	var min = $('#container li').length * -width;
	
	$('#nav a').click(function() {
		page = $(this).html().toLowerCase();
		$('#container ul').animate({left: Math.max(positions[page] * -width, min + $(window).width())});
		return false;
	});
	
	$('.scrollable').scroller();

	$('.rollover').simpleImageRollover();
	
});