// JavaScript Document



/**Gästebuch */

function absenden() {
	$('.gb_loader').fadeIn();
	
	$.ajax({
	   type: "POST",
	   url: "kultur/scripts/schreibeinsgaestebuch.php",
	   data: "name="+$('#name').val()+
	         "&url="+$('#url').val()+
			 "&email="+$('#email').val()+
			 "&text="+$('#text').val(),
	   
	  success: function(msg){
			text = "";
		
		
			if(msg == 0) {
				text = "Upps! Es wurde kein Eintrag vorgenommen."
			}
			if(msg == 1) {
				text = "Vielen Dank für Ihren Eintrag.";
			}
			
			$('#result_text').text(text);
			$('#formular').fadeOut(function() {
				$('#formular').text("");
				$('#result').fadeIn();
			});
			
			
		 
	   }
	 });
}



function bauergbtohexum(rgb) {
	 rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
	 function hex(x) {
	 	 return ("0" + parseInt(x).toString(16)).slice(-2);
	 }
	 return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}


function galleryfade() {
	$('#diashow div:first').fadeOut("slow",
		function() {
			$(this).remove().appendTo('#diashow');
			$('#diashow div:first').fadeIn("slow");
		}
	);
} 


$(document).ready(function() {
	
	
		i = 1;
		$('.mainmenu li a').each(function () {
			if(i % 2 == 0) {
				if( $(this).parent().parent().get(0).className != "submenu") { 
					$(this).addClass('m_alternative');
				}
			}
			i++;	
		});
				
		y = 1;
		
		if( $('.submenu').length > 0) {
			if( $('.submenu').prev().get(0).className == "m_alternative") {
				$('.submenu li a').addClass('sub_alt');
				//$('.submenu li a').css('background-color','#94a263');
			}
		}
		
	setInterval("galleryfade()", 4000);
});


$(function() {
	$('.map_overlay').mouseleave(function() {
			$('.map_overlay').fadeOut('slow');
	});	
	
	$('#m1').click(function(){
		switch_layer(1);
		return false;
	});
	$('#m2').click(function(){
		switch_layer(2);
		return false;
	});
	$('#m3').click(function(){
		switch_layer(3);
		return false;
	});
	
	
	$('.presse a').click(function(){
		$('.presseub').css('list-style-type','none');
		$('.pressesub').slideUp();
		$(this).next('.pressesub').slideDown();
		return false;
	});	
	
	$('.pressesub a').click(function() {
		window.location.href = $(this).attr('href');
	});
	
	
	
	
	
	
	
});


function open_anfahrt(id) {
	
	
	$('#'+id+'').fadeIn('slow');
}

function close_anfahrt(id) {
	$('#'+id+'').fadeOut('slow');
}

function male_hoehe_neu() {
 
            $(".second_textarea_long").css("margin-top",$(".content_container_2").height()-234+"px");
            
            //$("#second_menu_long").css("margin-top",10+$('.content_container_2').height()+$(".second_textarea_long").height()-175+"px");
}

function switch_layer(el) {
	$('.text_el').css('display','none');
		$('#e'+el).fadeIn();
	
				
	
	
}

function openmap() {
	
	$('.map_overlay').fadeIn('slow');

}
