$.validator.setDefaults({
	submitHandler: function() { 
		var inhalt = $("#email").html();
		var email_to = $("input#email_to").val();
		var email_from = $("input#email_from").val();
		var url = $("input#email_url").val();
		var text = $("input#email_url_text").val();
		var daten = 'email_to='+ email_to + '&email_from=' + email_from + '&email_url=' + url + '&email_url_text=' + text;
		$.ajax({
      		type: "POST",
      		url: "send_email.php",
     	 	data: daten,
      		success: function() {
        		$('#email').html("<div id='message'></div>"+inhalt);
        		$('#message').html("<b>Email wurde erfolgreich versandt!</b>")
        		.hide()
        		.fadeIn(500)
//$('#email').delay(2000).html(inhalt);
//        		setTimeout('alert("asdfdsf")',3000);
       			setTimeout("$('#email').slideUp(500);",3000);

 			}
		});
	}
});
$(document).ready(
	function() {
    		$("#email_form").validate({
			rules: {
				email_to: {
					required: true,
					email: true
				},
				email_from: {
					required: true,
					email: true
				}
			},
			messages: {
				email_to: {
					required: "Bitte geben Sie die Email Adresse des Empf&auml;ngers",
					email: "Bitte geben Sie eine g&uuml;ltige Email Adresse ein"
				},
				email_from: {
					required: "Bitte geben Sie Ihre Email Adresse ein",
					email: "Bitte geben Sie eine g&uuml;ltige Email Adresse ein"
				}
			}
		});
		$('.icon').mouseover(function() {
        	$(this).addClass('over');
    	});
    	$('.icon').mouseout(function() {
        	$(this).removeClass('over');
    	});
    	$('#email').hide();
		$('.icon.email').click(function() {
			if ($('#email').is(":hidden")) {
				$('#email').slideDown(500);
			} else {
				$('#email').slideUp(500);
			}
		});
		$(".link1").css({'text-decoration':'none','cursor':'auto'});
		$(".link2").css({'text-decoration':'underline','cursor':'pointer'});
		$(".link3").css({'text-decoration':'underline','cursor':'pointer'});
		$(".link4").css({'text-decoration':'underline','cursor':'pointer'});
		$(".link5").css({'text-decoration':'underline','cursor':'pointer'});
		$('.team_info[number="999"]').fadeIn();
		$('.team_info[number="999"]').addClass("show");
		adapt_bgimages();
		$(window).resize(function() {
  			adapt_bgimages();
 			}
 		);
 		$("a #legendeclick").click(function() {
			showhidelegend();
			}
		);
		$('.team_member[number]').click(function() {
			var number=$(this).attr('number');
			$('.team_info.show').css({'display': 'none'});
			$('.team_info[number="'+number+'"]').fadeIn();
			$('.team_info[number="'+number+'"]').addClass("show");
			
		});
		$('img[data-hover]').hover(function() {
        	$(this).attr('tmp', $(this).attr('src'))
        		.attr('src', $(this).attr('data-hover'))
        		.attr('data-hover', $(this).attr('tmp'))
        		.removeAttr('tmp');
    	});
		$(".link1").click(function(){
				$("#tab1").fadeIn();
				$(".link1").css({'text-decoration':'none','cursor':'auto'});
				$("#tab2").css({'display': 'none'});
				$(".link2").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab5").css("display", "none");
				$(".link5").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab3").css("display", "none");
				$(".link3").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab4").css("display", "none");
				$(".link4").css({'text-decoration':'underline','cursor':'pointer'});
		});
		$(".link2").click(function(){
				$("#tab2").fadeIn();
				$(".link2").css({'text-decoration':'none','cursor':'auto'});
				$("#tab1").css({'display': 'none'});
				$(".link1").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab5").css("display", "none");
				$(".link5").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab3").css("display", "none");
				$(".link3").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab4").css("display", "none");
				$(".link4").css({'text-decoration':'underline','cursor':'pointer'});
				setTimeout('$("#galleria").galleria({autoplay:15000});',500);				
		});
		$(".link3").click(function(){
				$("#tab3").fadeIn();
				$(".link3").css({'text-decoration':'none','cursor':'auto'});
				$("#tab2").css({'display': 'none'});
				$(".link2").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab5").css("display", "none");
				$(".link5").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab1").css("display", "none");
				$(".link1").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab4").css("display", "none");
				$(".link4").css({'text-decoration':'underline','cursor':'pointer'});
		});
		$(".link4").click(function(){
				$("#tab4").fadeIn();
				$(".link4").css({'text-decoration':'none','cursor':'auto'});
				$("#tab2").css({'display': 'none'});
				$(".link2").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab5").css("display", "none");
				$(".link5").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab3").css("display", "none");
				$(".link3").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab1").css("display", "none");
				$(".link1").css({'text-decoration':'underline','cursor':'pointer'});
		});
		$(".link5").click(function(){
				$("#tab5").fadeIn();
				$(".link5").css({'text-decoration':'none','cursor':'auto'});
				$("#tab2").css({'display': 'none'});
				$(".link2").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab1").css("display", "none");
				$(".link1").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab3").css("display", "none");
				$(".link3").css({'text-decoration':'underline','cursor':'pointer'});
				$("#tab4").css("display", "none");
				$(".link4").css({'text-decoration':'underline','cursor':'pointer'});
		});
		$(".tab:first").fadeIn().addClass('show');
		$(".tabs1 li:first").addClass('show').css({'text-decoration':'none','cursor':'auto'});
		$(".tabs1 li").click(function(){
			var num=$(this).attr('nummer');
			var oldlink=$('li.show');
			var oldtab=$('.tab.show');
			$(this).css({'text-decoration':'none','cursor':'auto'});
			$(this).addClass('show');
			oldlink.css({'text-decoration':'underline','cursor':'pointer'});
			oldlink.removeClass('show');
			oldtab.fadeOut();
			oldtab.removeClass('show');
			$('.tab[nummer='+num+']').fadeIn();
			$('.tab[nummer='+num+']').addClass('show');
		});
		$('#galleria_editorial').galleria({autoplay:15000});
	}
);
$(document).ready(function(){
});
function adapt_bgimages() {
	var contentbreite=732;
  	var fensterbreite=$(window).width();
  	var logoposition=((fensterbreite-contentbreite)/2)-110;
  	$("#floating_background img").width(fensterbreite);
  	$("#floating_background img").height($(window).height());
  	$("#logo_links").css('left',logoposition);
  	if ($.cookie('legende')=='ja') {
  		if ($('#legende.noshow').length<1) {
	  		$('#legende').addClass('noshow');
	  		$('#legendelink').hide();
  		}
  	}
	if ($('#legende.noshow').length>0) {
		pos=fensterbreite-15;
		clickposx=pos-5;
		clickposy=270;
	} else {
		pos=fensterbreite-217;
		clickposx=pos+120;
		clickposy=425;
	}
  	$("#legende").css('left',pos);
  	$("#legendeclick").css('left',clickposx);
  	$("#legendeclick").css('top',clickposy);
}
function showhidelegend() {
	if ($('#legende.noshow').length>0) {
		pos=$(window).width()-217;
		clickposx=pos+120;
		clickposy=425;		
		$.cookie('legende',null);
		$('#legendelink').show();
		$('#legende').removeClass('noshow');
		$('#legende').animate({left:+pos+'px'},500,function(){
//			animation complete
			});
	} else {
		pos=$(window).width()-15;
		clickposx=pos-5;
		clickposy=270;
		$.cookie('legende','ja');
		$('#legendelink').hide();
		$('#legende').addClass('noshow');
		$('#legende').animate({left:+pos+'px'},500,function(){
//			animation complete
			});
	}
  	$("#legendeclick").css('left',clickposx);
  	$("#legendeclick").css('top',clickposy);
}
