jQuery(document).ready(function(){
  
	/*
			Primary Navigation
	*/
	
	jQuery('#nav ul.sf-menu').superfish({ 
		animation:					{ opacity: 'show', height: 'show' },
		autoArrows:					false,
		delay:							200,
		dropShadows:				false,
		speed:							'fast'
	});
	jQuery('#slider-nav').append('<ul></ul>');
	
	
	/*
			Slideshow
	*/
	
	jQuery('#slideshow').cycle({
		before:							function(cur, nxt){
		
			// Switch Logo Variant
			if (jQuery(nxt).hasClass('bright')) {
				jQuery('#logo').css({ backgroundPosition: 'left bottom' });
			} else {
				jQuery('#logo').css({ backgroundPosition: 'left top' });
			}
			
			// Animate Slides
			switch(jQuery(nxt).attr('id')) {
				case 'nothing': /* have fun */ ; break;
			}
			
		},
		fx:									'fade',
		pause:							true,
		random:							true,
		speed:							1000,
		timeout:						8000
	});
	
	
	/*
			Slider
	*/
	
	jQuery('#slider').cycle({
		fx:										'fade',
		timeout:							0,
		pager:								'#slider-nav ul',
		pagerAnchorBuilder:		function(idx, slide) {
			var originalSource = jQuery(slide).find(".image img").eq(0).attr("src");
			if (originalSource) { var newSource = originalSource.replace(/.jpg/g, "") + '-78x65.jpg';
			return '<li><a href="#"></a><img src="' + newSource + '" width="78" height="65" /></li>'; }
			else { jQuery(slide).find(".image a").text('Kein Bild'); return '<li><a href="#">Kein Bild</a></li>'; } 
		}
	});
	
	
	/* Image Class for Content Links */
	jQuery('#content a img').each(function(){ jQuery(this).parent().addClass('image-wrap'); });
	
	/* Tabs */
	jQuery(".tabs").tabs();	
	
	/* Input Focus */
	jQuery('input, textarea').focus(function(){
		jQuery(this).css({
			'border':				'1px solid #B0100A',
			'boxShadow':		'0 0 2px rgba(176,16,10, 0.5)',
			'color':				'#333'
		});
	});
	
	/* Input Blur */
	jQuery('input, textarea').blur(function(){
		jQuery(this).css({
			'border':				'1px solid #CCC',
			'boxShadow':		'none',
			'color':				'#333'
		});
	});
	
	/* Scroll Top */
	jQuery('a.scroll-top').click(function(){ jQuery('html,body').animate({ scrollTop: '0' }, 500); return false; });
	
	
	/*
			Search
	*/
	
	jQuery('.s').each(function(){
	
		if(jQuery(this).val() === '' || jQuery(this).val() === 'Website durchsuchen...') {
			
			jQuery(this).val('Website durchsuchen...');
			
			jQuery(this).blur(function(){
				jQuery(this).val('Website durchsuchen...');
			});
		
			jQuery(this).focus(function(){
				jQuery(this).val('');
			});
		}
	
	});
	
	
	/*
			Shadowbox
	*/
	
	Shadowbox.init({});
	
	/* Content Images */
	jQuery('#content a img').each(function(){
		if (!jQuery('#content .gallery').hasClass('big') && !jQuery(this).hasClass('transparent')) {
			jQuery('#content a').has('img').addClass('shadowbox');
		}
	});
	if (jQuery('#content a.shadowbox').length == 1) {
		Shadowbox.setup('a.shadowbox');
	}
	else {
		Shadowbox.setup('a.shadowbox', {
			gallery:					'Bildergalerie'
		});
	}
	
	/* Content Images */
	
	/* Reservix */
	jQuery('a[href*="www.reservix.de"]').click(function(){
		var href = jQuery(this).attr('href');
		Shadowbox.open({
			content:    '<iframe src="' + href + '" width="100%" height="100%" name="Reservix"></iframe>',
			player:     'html',
			height:     600,
			width:      1024
		});
		return false;
	});
	
	/* Google Maps */
	jQuery('a[href*="maps.google.com"]').click(function(){
		var href = jQuery(this).attr('href');
		Shadowbox.open({
			content:    '<iframe width="100%" height="100%" name="Google Maps" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Austra%C3%9Fe+87+Herborn+Hessen+34745+Deutschland&amp;ie=UTF8&amp;hq=&amp;hnear=Austra%C3%9Fe+87,+Herborn+35745+Herborn,+Lahn-Dill-Kreis,+Hessen,+Germany&amp;t=m&amp;vpsrc=0&amp;ll=50.668994,8.307037&amp;spn=0.03264,0.087805&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe>',
			player:     'html',
			height:     600,
			width:      1024
		});
		return false;
	});

});
