var content ="";
var id_typ = 0;
var id_utyp = 0;
var id_uutyp = 0;
var id = 0;

var sliderIsOpened = true;
var initSliderWhenOpened = false;

function checkMandatories(formular){
		var fehler=false;
		$(formular).find(".mandatory").each(function(i){
			if($(this).attr("type")=="checkbox"){

				if($(this).attr("checked")== false && $(this).attr("disabled")==false){
					fehler=true;
					try {
						$(this).next().animate( { backgroundColor:"white", color:"#006bb3" }, { queue:true, duration:250 } );
						$(this).next().animate( { backgroundColor:"#5a0000", color:"white" }, { queue:true, duration:250 } );
						$(this).next().animate( { backgroundColor:"white", color:"#006bb3" }, { queue:true, duration:250 } );
						$(this).next().animate( { backgroundColor:"#5a0000", color:"white" }, { queue:true, duration:300 } );
					} catch(e){}
					show_hinweis("Bitte überprüfen Sie die Pflichtfelder.");
				} else {
					try {	
						$(this).next().animate( { backgroundColor:"transparent", color:"black" }, { queue:true, duration:250 } );
					} catch(e){}
				}
			} else {
				if($(this).val()=="" && $(this).attr("disabled")==false){
					
					fehler=true;
					try {
						$(this).animate( { backgroundColor:"white", color:"black" }, { queue:true, duration:250 } );
						$(this).animate( { backgroundColor:"#5a0000", color:"#006bb3" }, { queue:true, duration:250 } );
						$(this).animate( { backgroundColor:"white", color:"#006bb3" }, { queue:true, duration:250 } );
						$(this).animate( { backgroundColor:"#5a0000", color:"white" }, { queue:true, duration:300 } );
					} catch(e){}
				} else {
					try {
						$(this).animate( { backgroundColor:"white", color:"black" }, { queue:true, duration:500 } );
					} catch(e){}
				}
			}
		});
		return fehler;
}



function init(){

		content = $('#content').val();
		id_typ = $('#id_typ').val();
		id_utyp = $('#id_utyp').val();
		id_uutyp = $('#id_uutyp').val();
		id = $('#id').val();
	
		
		$(".fancy").fancybox();
		
		$('.rollover').hoverswap({});
		
		
		if($(".teaser").height() < 50){
			sliderIsOpened = false;
		} 		
		
		
//  kontaktformular________________________________________________

	$("#kontaktformular").submit(function(){
		var fehler=checkMandatories(this);
		
		if(!fehler){
		 
		 var inhalte = $(this).find("input, textarea").serialize();
		 
		 $.ajax({
		   type: "POST",
		   url: "lib/js_functions.php",
		   async: false,
		   data: "function=sendMessage&"+inhalte,
		   success: function(data_str){
		   	 var data = eval(data_str);
		   	 if(data.hinweis != "")show_hinweis(data.hinweis);
		   	 if(data.fehler != "")show_hinweis(data.fehler);
		   	 else $("#kontaktformular").find("input, textarea").val("");
		   }
		 });


		} else {
			show_hinweis("Bitte überprüfen Sie die Pflichtfelder.");
		}
			return false;
		
		//
		
	});
//  kontaktformular ende___________________________________________

	if($("#hinweis_text").text() != "")show_hinweis($("#hinweis_text").html());
		
}

function initFlash()
{

}

$(document).ready(function(){
	
  init();
  initFlash();
  	
  $(".teaser_line").jCarouselLite({
				    btnNext: ".teaser_btn_next",
				    btnPrev: ".teaser_btn_prev",
				    auto:8000,
				  	speed:750});
				  	
  $(".kunden_item").cycle({
			 timeout:5000,
			 cleartypeNoBg:true,
			 fx:'fade'
  });				  	

});
  	

function hinweis_aus() {
  //document.getElementById("hinweis").style.visibility = "hidden";
	$("#hinweis").animate({"top":-$("#hinweis").height()},300, "easeInBack");

}

function show_hinweis(hinweis, decode){
	if(decode)hinweis = $.url.decode(hinweis);
	$("#hinweis_text").html(hinweis);
	document.getElementById("hinweis").style.visibility = "visible";
	//$("#hinweis").css("z-index",100);
	var posY =  ($(window).height() / 2) - ($("#hinweis_text").height() / 2);
	$("#hinweis").css("top",-$("#hinweis").height());
	//$("#hinweis").css("z-index",100);
	$("#hinweis").animate({"top":posY},800, "easeOutBounce");
}



