$(document).ready(function(){

var softtimer = 500;
function ladeanzeige(zustand){
	var preloader = '<span id="lade" style="position:absolute; left:550px;; top:180px; z-index:10; display: none;"><img src="img/preloader.gif" width="40" height="90" /></span>';
	if(zustand){
		$('body').append(preloader);
		$('#lade').fadeIn(100);
		}else{
		$('#lade').delay(softtimer).fadeOut(softtimer, function(){$('#lade').remove();});
		}
}

// AJAX FUNKTION

	ladeanzeige(true);
	
	$('a').live('click', function(){
		var href = $(this).attr('href');
		if( href=='shop/' ){
			return true;
			}else{
			var inhalt1;
			var inhalt2;
			ladeanzeige(true);
			$('#content2').fadeOut(softtimer);
			$('#content1').fadeOut(softtimer, function(){
				$.ajax({
					url: href,
					cache: false,
					dataType: "html",
					success: function(daten){
					inhalt1 = $(daten).find('#holder').html();
					inhalt2 = $(daten).find('#holder2').html();
					},
					complete: function(){
					$('#content1').css({ 'display' : 'none' }).empty().html(inhalt1).delay(softtimer).fadeIn(softtimer);
					$('#content2').css({ 'display' : 'none' }).empty().html(inhalt2).delay(softtimer).fadeIn(softtimer);
					if( href=='index.html' ){ slideshow(); };
					ladeanzeige(false);
					}
				});
			});
			return false;
		};
	});

// AJAX FUNKTION ENDE


// DELAYHANDLER	
	$.fn.delay = function( time, name ) {
	
		return this.queue( ( name || "fx" ), function() {
			var self = this;
			setTimeout(function() { $.dequeue(self); } , time );
		} );
	
	};
// DELAYHANDLER	ENDE


// SLIDESHOW AUF DER STARTSEITE
var frameNum = 2;
var zustand = true;
function slideshow(){
	if(frameNum <= 6 && zustand){
		$('#animation').delay(1600).fadeOut(1000, function () {
				$('#animation').empty().html('<img src="img/frame0' + frameNum + '.jpg" width="188" height="220" alt="" />').fadeIn(1000, function(){frameNum++});
				if(frameNum==6) frameNum=1;
				if(zustand) slideshow();
		});
	};
};
// SLIDESHOW ENDE

// NEWSBUTTON MOUSE OVER UND BROWSERWEICHE
	if ( !$.browser.msie ){
		$('.newsbtn a').live('mouseenter', function(){
			$('#newsswap').fadeIn(300);
		});
		$('.newsbtn a').live('mouseleave', function(){
			$('#newsswap').fadeOut(300);
		});
	} else {
		$('.newsbtn a').live('mouseenter', function(){
			$('#newsswap').css({ 'display' : 'block' });
		});
		$('.newsbtn a').live('mouseleave', function(){
			$('#newsswap').css({ 'display' : 'none' });
		});
	};
// NEWSBUTTON MOUSE OVER UND BROWSERWEICHE ENDE


// MAPBUTTON MOUSE OVER UND BROWSERWEICHE
	if ( !$.browser.msie ){
		$('#mapbtn a').live('mouseenter', function(){
			$('#mapswap').fadeIn(300);
		});
		$('#mapbtn a').live('mouseleave', function(){
			$('#mapswap').fadeOut(300);
		});
	} else {
		$('#mapbtn a').live('mouseenter', function(){
			$('#mapswap').css({ 'display' : 'block' });
		});
		$('#mapbtn a').live('mouseleave', function(){
			$('#mapswap').css({ 'display' : 'none' });
		});
	};
// MAPBUTTON MOUSE OVER UND BROWSERWEICHE ENDE


// SHOPBUTTON MOUSE OVER UND BROWSERWEICHE
	if ( !$.browser.msie ){
		$('#shopbtn a').bind('mouseenter', function(){
			$('#shopswap').fadeIn(300);
		});
		$('#shopbtn a').bind('mouseleave', function(){
			$('#shopswap').fadeOut(300);
		});
		}else{
			if ( parseInt($.browser.version) > 6 ){
				$('#shopbtn a').bind('mouseenter', function(){
					$('#shopswap').fadeIn(300);
				});
				$('#shopbtn a').bind('mouseleave', function(){
					$('#shopswap').fadeOut(300);
				});
			}
	};
// SHOPBUTTON MOUSE OVER UND BROWSERWEICHE ENDE


// SEITE EINBLENDEN UND BILDER NACHLADEN
	ladeanzeige(false);
	$('#fader').delay(700).fadeIn(1000, function(){
		function preload(s){
			if (document.images){
				i = new Image ();
				i.src = s;
			}
		}
// ROLLOVERBILDER
		preload('img/news-red.gif');
		preload('img/preloader.gif');
		preload('img/mapslinkhov.jpg');
		preload('img/content1-news.jpg');
		preload('img/content2-news.gif');
// SLIDESHOWBILDER
		preload('img/frame01.jpg');
		preload('img/frame02.jpg');
		preload('img/frame03.jpg');
		preload('img/frame04.jpg');
		preload('img/frame05.jpg');
		preload('img/frame06.jpg');
// CONTENTBILDER
		preload('img/content1-agb.jpg');
		preload('img/content1-bestellung.jpg');
		preload('img/content1-dankeschoen.jpg');
		preload('img/content1-geburtstage.jpg');
		preload('img/content1-geschenkeservice.jpg');
		preload('img/content1-hochzeit.jpg');
		preload('img/content1-impressum.jpg');
		preload('img/content1-jubilaeen.jpg');
		preload('img/content1-kontakt.jpg');
		preload('img/content1-links.jpg');
		preload('img/content1-pokale.jpg');
		preload('img/content1-schauwerkstatt.jpg');
		preload('img/content1-vereinsfeste.jpg');
	
		preload('img/content2-agb.gif');
		preload('img/content2-bestellung.gif');
		preload('img/content2-dankeschoen.gif');
		preload('img/content2-geburtstage.gif');
		preload('img/content2-geschenkeservice.gif');
		preload('img/content2-hochzeit.gif');
		preload('img/content2-impressum.gif');
		preload('img/content2-jubilaeen.gif');
		preload('img/content2-kontakt.gif');
		preload('img/content2-links.gif');
		preload('img/content2-pokale.gif');
		preload('img/content2-schauwerkstatt.gif');
		preload('img/content2-vereinsfeste.gif');
	});
// SEITE EINBLENDEN UND BILDER NACHLADEN ENDE


// SLIDESHOW STARTEN
	slideshow();
// SLIDESHOW STARTEN ENDE

});






