// JavaScript Document

$(document).ready(function() {
	
		
	$('#messages').innerfade({
		animationtype: 'fade',
		speed: 1000,
		timeout: 4000,
		type: 'random',
		containerheight: '1em'
	});		
	
	(function($){
	 $.fn.extend({

	 	customStyle : function(options) {
		  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
		  return this.each(function() {

				var currentSelected = $(this).find(':selected');
				$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
				var selectBoxSpan = $(this).next();
				var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
				var selectBoxSpanInner = selectBoxSpan.find(':first-child');
				selectBoxSpan.css({display:'inline-block'});
				selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
				var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			

		  });
		  }
		}
	 });
	})(jQuery);

  $(function(){
    $('select.styled').customStyle();
	  $('select').change(function(){
	    $('span.customStyleSelectBox').remove();
	    $('select.styled').customStyle();
	  });
	});
	
	
	$('.toggle_container').hide();
	$('.trigger').bind('click', function(){
		$('.toggle_container').slideToggle('slow');
	});
	
	/*-- Corners --*/	

	$(function(){ 
	
		settings = {
			tl: { radius: 3 },
			tr: { radius: 3 },
			bl: { radius: 3 },
			br: { radius: 3 },
			autoPad: true,
			validTags: ["div"]
		}
		
		settingsbottom = {
			tl: { radius: 0 },
			tr: { radius: 0 },
			bl: { radius: 3 },
			br: { radius: 3 },
			autoPad: true,
			validTags: ["div"]
		}

		$('.logo-testimonial').corner(settings);
		$('#frame-copyright').corner(settingsbottom);
	
	});
	
	/*--Carousel--*/
	
	$('#partner').jcarousel({
    	wrap: 'circular',
		buttonNextHTML: '<div class="next-arrow"></div>',
		buttonPrevHTML: '<div class="previous-arrow"></div>'
    });
	
		$('#impressionen').jcarousel({
	    	wrap: 'circular',
			buttonNextHTML: '<div class="next-arrow"></div>',
			buttonPrevHTML: '<div class="previous-arrow"></div>'
	    });
	
	/*-- Text Replacement --*/
	
	Cufon.replace('h1,h2,h3,#phone');
	
	/*--Lightbox--*/
	
	$("a.lightbox").fancybox({
		'titlePosition' : 'over'
	});
	
	/*--Smooth Scrolling--*/
	
	$(function(){
		$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
			&& location.hostname == this.hostname) {
				var $target = $(this.hash);
				$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					$('html,body').animate({scrollTop: targetOffset}, 1000);
					return false;
				}
			}
		});
	});   
	
	/*--Form Validation--*/
	
	$('#contact-form').ajaxForm(function(data) {
		if (data==0){
			$('.reservierung-error').hide();
			$('.reservierung-success').fadeIn("slow");
			$('#contact-form').hide();
		}
		else if (data==2){
			$('.reservierung-success').hide(); 
			$('.reservierung-error').fadeIn("slow");
			$('.reservierung-error').empty();
			$('.reservierung-error').append('Bitte tragen Sie Ihren Vornamen ein!');
		}
		else if (data==3){
			$('.reservierung-success').hide(); 
			$('.reservierung-error').fadeIn("slow");
			$('.reservierung-error').empty();
			$('.reservierung-error').append('Bitte tragen Sie Ihren Nachnamen ein!');
		}
		else if (data==4){
			$('.reservierung-success').hide(); 
			$('.reservierung-error').fadeIn("slow");
			$('.reservierung-error').empty();
			$('.reservierung-error').append('Bitte tragen Sie Ihre Telefonnummer ein!');
		}
		else if (data==5){
			$('.reservierung-success').hide(); 
			$('.reservierung-error').fadeIn("slow");
			$('.reservierung-error').empty();
			$('.reservierung-error').append('Bitte tragen Sie eine gültige E-Mail Adresse ein!');
		}
	});

});



