var storage = new Array( 'werk85', 'schnittreif', 'kaffeebummler', 'gaestehaus-am-deich', 'pa-bremen', 'maritime-woche', 'fats', 'bootsausbildung', 'daily-marmelade' );var pages = new Array();var currentPage = '';function updateSizes() {	var vpw = $(window).width();	var vph = $(window).height();		$('#slider').css( 'width', vpw * pages.length ).css( 'height', vph );	$('.page').each( function() {		$(this).css( 'width', vpw ).css( 'height', vph );	});}function syncWithHash() {	var tag = window.location.hash.slice(1);		if( pages.indexOf( tag ) > -1 ) {		gotoPage( tag );	}}function extendPageList( tag ) {	pages.push( tag );		$('#pagelist').append('<li><a href="#' + tag + '">' + tag + '</a></li>');		color = $('#' + tag + ' h1:first').css( 'color' );		$('#pagelist li:last a').css('background-color', color).data('color', color );}function loadPage( showPageOnLoad ) {	if( !storage.length ) { // all pages loaded		syncWithHash();		return;	}		var tag = storage.shift();	var vfile = tag + '.html';		$.ajax({		url: vfile,		statusCode: {			404: function() {				alert('Leider wurde die angeforderte Seite nicht gefunden.');			}		},		success: function( data ){			$('#slider').append( '<div class="page" id="' + tag + '">' + data + '</div>' );						extendPageList( tag ); // has to be called before updateSizes()						updateSizes();						$('.page:last img:last').load( function() {				if( showPageOnLoad ) {					gotoPage( tag );				}				loadPage();			});		}	});}function gotoPage( tag ) {	var offset = pages.indexOf( tag );		if( offset > -1 ) {		currentPage = tag;				$('#pagelist li a').each( function() {			if( $(this).attr('href').slice(1) == currentPage ) {				$(this).css('background-color', '#FFFFFF');			} else {				$(this).css('background-color', $(this).data('color') );			}		});				$("#peephole").animate( {scrollLeft: $(window).width() * offset }, 'slow', function() {			window.location.hash = '#' + currentPage;		});	}}function gotoNext() {	gotoPage( pages[ pages.indexOf( currentPage ) + 1 ]  );}function gotoPrev() {	gotoPage( pages[ pages.indexOf( currentPage ) - 1 ] );}$(function() {	updateSizes();		if( $.browser.msie ) {			$(window).load( function() {			if( storage.indexOf( window.location.hash.slice(1) ) < 1 ) {				$('#prev div').fadeOut(1500);			}			loadPage( !window.location.hash );		});			$('#prev div').mouseenter( function() {			if( pages.indexOf( currentPage ) > 0 ) {				$(this).css('cursor', 'pointer');			} else {				$(this).cursor( 'cursor', 'pointer' );			}		}).click( function() {			gotoPrev();						$('#next div').fadeIn();						if( pages.indexOf( currentPage ) <= 0 ) {				$(this).css('cursor', 'auto');				$(this).fadeOut();			}		});			$('#next div').mouseenter( function() {			if( pages.indexOf( currentPage ) < pages.length - 1 ) {				$(this).css('cursor', 'pointer');			}		}).click( function() {			gotoNext();						$('#prev div').fadeIn();				if( pages.indexOf( currentPage ) >= pages.length - 1 ) {				$(this).css('cursor', 'auto');				$(this).fadeOut();			}		});			} else { // not msie		$(window).load( function() {			$('#prev div, #next div').delay(2000).fadeOut(1500);			loadPage( !window.location.hash );		});		$('#prev').mouseenter( function() {			if( pages.indexOf( currentPage ) > 0 ) {				$(this).css('cursor', 'pointer');				$(this).find('div').fadeIn();			} else {				$(this).cursor( 'cursor', 'pointer' );			}		}).click( function() {			gotoPrev();			if( pages.indexOf( currentPage ) <= 0 ) {				$(this).css('cursor', 'auto');				$(this).find('div').fadeOut();			}		});		$('#next').mouseenter( function() {			if( pages.indexOf( currentPage ) < pages.length - 1 ) {				$(this).css('cursor', 'pointer');				$(this).find('div').fadeIn();			}		}).click( function() {			gotoNext();			if( pages.indexOf( currentPage ) >= pages.length - 1 ) {				$(this).css('cursor', 'auto');				$(this).find('div').fadeOut();			}		});		$('#prev, #next').mouseleave( function() {			$(this).find('div').fadeOut();		});			}		$('#pagelist li a').live( 'click', function( e ) {		e.preventDefault();				gotoPage( $(this).attr('href').slice(1) );				return(false);	});		$('#logo img').click( function(e) {		e.preventDefault();				gotoPage( 'werk85' );	});	});$(window).resize( function() {	updateSizes();});
