jQuery(function(){});
window.onload = function(){

$('#header_text_block').removeClass('hidden');

if (getCookie('options') == 1) 
	{
			$('.optionen2').hide();
			$('.optionen3').hide();
			$('.optionen4').show();
	}
else {
			$('.optionen2').show();
			$('.optionen3').show();
			$('.optionen4').hide();
}

if (document.getElementById('header_menu_1')){


		$(".projekt").click( function () {
			$('li.googlemap').hide();
		});
		
		$(".anfahrt").click( function () {
			$('li.ul_5li').hide();
			$('li.googlemap').animate({opacity: "show"});
		});
		
		$(".wohnobjekte").click( function () {
			$('li.googlemap').hide();
			$('li.home_pictures').animate({opacity: "show"});
		});
		
		$(".optionen3 a").click( function () {	
			$('.optionen2').hide();
			$('.optionen3').hide();
			$('.optionen4').show();
			setCookie('options',1,555);
		});

		$(".optionen4 a").click( function () {	
			$('.optionen2').show();
			$('.optionen3').show();
			$('.optionen4').hide();
			setCookie('options',0,555);
			
		});
		
		
		$("input[name='check_all']").click( function(){
			        if($(this).is(":checked"))
			        {	
			            $(this).parents("form#filterform")
					   .find("input:checkbox.citycheckbox")
					   .attr("checked","unchecked");
			        }
			        else
			        {	
				$(this).parents("form#filterform")
					   .find("input:checkbox.citycheckbox")
					   .removeAttr("checked");
			        }
		});
		
		$("#header_menu_1 li").hover( function () {
						if ($(this).find('ul').length) {
						$(this).addClass('act');
						}
								}, function() {
									$(this).removeClass('act');
								});
	}

	$('img.big_img').removeAttr("height");
	$('img.big_img').removeAttr("width");

	$("#header_maps .ul_7 li a").click( function () {
	$(this.parentNode.parentNode).find('li').removeClass('active');	
	$(this.parentNode).addClass('active');	
    var zzz=$(this.parentNode.parentNode.parentNode).find(".ul_6");
	if ($(this).html()=='1'){
		zzz.animate({marginTop: "0"}, 300);
	}
	else if ($(this).html()=='2'){
		zzz.animate({marginTop: "-252px"}, 300);
		}
	else if ($(this).html()=='3'){
	zzz.animate({marginTop: "-504px"}, 300);
	}
	});	
	
	$("#header_maps #district_thums li a").mousedown( function () {
		$(this.parentNode.parentNode.parentNode.parentNode.parentNode).find('.big_img').attr('src',$(this).attr('name'));
		$(this.parentNode.parentNode.parentNode.parentNode.parentNode).find('.big_foto_bg a:first').attr('href',$(this).attr('href'));
		
		$(this.parentNode.parentNode.parentNode.parentNode.parentNode).find('.big_foto_bg .resize a:first').attr('href',$(this).attr('href'));
		$(this.parentNode.parentNode.parentNode.parentNode.parentNode).find('.big_foto_bg .text').html($(this).attr('rel'));
		
		});											  
	$("#district_thums li a").click( function () {
				return false;
			});	
			
	$("#header_maps .home_thums li a").mousedown( function () {
		$(this.parentNode.parentNode.parentNode.parentNode.parentNode).find('.big_img').attr('src',$(this).attr('name'));
		$(this.parentNode.parentNode.parentNode.parentNode.parentNode).find('.big_foto_bg a:first').attr('href',$(this).attr('href'));
		
		$(this.parentNode.parentNode.parentNode.parentNode.parentNode).find('.big_foto_bg .resize a:first').attr('href',$(this).attr('href'));
		$(this.parentNode.parentNode.parentNode.parentNode.parentNode).find('.big_foto_bg .text').html($(this).attr('rel'));
		
		});											  
	$(".home_thums li a").click( function () {
				return false;
			});	

	
	
	if (document.getElementById('header_menu_2')){
		$("#header_menu_2 .mmm").hover( function () {
						if ($(this).find('ul:first').css("display")=="none"){
						$(this).find('ul:first').animate({height: "show" }, 100);
						}
								}, function() {
									$(this).find('ul:first').animate({height: "hide"}, 100);
								});
		}
			$("#header_slider .prev").mouseover( function () {
			$('#header_slider .slider ul').addClass('move');
			slider_next();
		});	
			$("#header_slider .prev").mouseout( function () {
			$('#header_slider .slider ul').removeClass('move');
			
		});	
			$("#header_slider .next").mouseover( function () {
			$('#header_slider .slider ul').addClass('move');
			slider_prev();
		});	
			$("#header_slider .next").mouseout( function () {
			$('#header_slider .slider ul').removeClass('move');
			
		});	
		
			$(".ul_6div  .prev1").mouseover( function () {
			$('#district_thums').addClass('move');
			slider_next1();
		});	
			$(".ul_6div .prev1").mouseout( function () {
			$('#district_thums').removeClass('move');
			
		});	
			$(".ul_6div .next1").mouseover( function () {
			$('#district_thums').addClass('move');
			slider_prev1();
		});	
			$(".ul_6div .next1").mouseout( function () {
			$('#district_thums').removeClass('move');
			
		});	
		
		
		$(".next2").mouseover( function () {
			$(this).prev().find('.home_thums').addClass('move');
			slider_next5();
		});	
		
		$(".next2").mouseout( function () {
			$(this).prev().find('.home_thums').removeClass('move');
			
		});	
		
		$(".prev2").mouseover( function () {
		$(this).next().find('.home_thums').addClass('move_prev');
		slider_prev5();
		});

		$(".prev2").mouseout( function () {
			$(".prev2").next().find('.home_thums').removeClass('move_prev');
			
		});
		
		
		$(".select").click( function () {
			 if ($('.select .list').css('display')=='none'){
			setTimeout(function(){$('.select .list').animate({height: "show"}, 100);},50);
			 }
			 else { }
			});	
		$(".select .list li a").click( function () {
            $('.select .txt').text($(this).html());
			$('.select input:first-child').attr("value", $(this).html());
		  });	
		$("html").click( function () {
				if ($('.select .list').css('display')=='block'){
				$('.select .list').animate({height: 'hide'}, 100);	
				}
				else {}
			});	
		
	$("#header_maps .ul_4 li a").click( function () {	
		$(this.parentNode.parentNode).find('li').removeClass('active');
	 	$(this.parentNode).addClass('active');
		$(this.parentNode.parentNode.parentNode).find('li.ul_5li').animate({opacity:"hide"});
		$(this.parentNode.parentNode.parentNode).find('li.ul_5li').eq($(this).attr("rel")).animate({opacity:"show"});
		});
	
	$("#header_maps .ul_1 li a").click( function () {	
	
	$(this.parentNode.parentNode).find('li').removeClass('active');
	$(this.parentNode).addClass('active');
	var ggg=$(this).attr("rel")-0-2;
	$(this.parentNode.parentNode.parentNode).find('.ul_3 li.ul_3_li').animate({opacity: "hide"});
	$(this.parentNode.parentNode.parentNode).find('.ul_3 li.ul_3_li').eq(ggg).animate({opacity: "show"});
	if(ggg==3)
		{
			$('.ul_8').show();
			$('.main_ul_5li').hide();
			$(this.parentNode.parentNode.parentNode).find('.ul_5 li.ul_5li').eq(ggg).animate({opacity: "show"});
		}
	else
		{
			$('.ul_8').hide();
			$('.main_ul_5li').show();
		}
	});
	
	}
								  
	
	function slider_prev(){
		 if ($('#header_slider .slider ul').attr('class')=='move'){
		left=$('#header_slider .slider ul').css("left");
		left=left.replace(/px/, "")-0;
		var n = $("#header_slider .slider ul li").length;
		n=-(n*155)+(4*155);
		
		if (n==0) {}
		else if (n>=left){}
		else {
		left=left -20 +'px'
		$('#header_slider .slider ul').css({"left": left});
		 setTimeout('slider_prev()',30);
		 }
		 }
		 else {}
	}
function slider_next(){
		 if ($('#header_slider .slider ul').attr('class')=='move'){
		 if ($('#header_slider .slider ul').css('left')>='1px'){
		 }
		 else {
		left=$('#header_slider .slider ul').css("left");
		left=left.replace(/px/, "")-0+20;
		left=left+'px'
		$('#header_slider .slider ul').css({"left": left});
		 setTimeout('slider_next()',30);
		 }
	}
}

function slider_prev1(){
		 if ($('#district_thums').attr('class')=='move'){
		left=$('#district_thums').css("left");
		left=left.replace(/px/, "")-0;
		var n = $("#district_thums li").length;
		n=-(n*98)+(5*98);
		
		if (n==0) {}
		else if (n>=left){}
		else {
		left=left -20 +'px'
		$('#district_thums').css({"left": left});
		 setTimeout('slider_prev1()',30);
		 }
		 }
		 else {}
	}
function slider_next1(){
		 if ($('#district_thums').attr('class')=='move'){
		 if ($('#district_thums').css('left')>='1px'){
		 }
		 else {
		left=$('#district_thums').css("left");
		left=left.replace(/px/, "")-0+20;
		left=left+'px'
		$('#district_thums').css({"left": left});
		 setTimeout('slider_next1()',30);
		 }
	}
}

function slider_prev2(){
alert('aaa');
}
	
function slider_next2(test){
$(test).css('left')='6666px';
}


function show_header_text() {
   $('#header_text_block').removeClass('hidden');
} 

function head_map_3(n){
	$('#header_maps .ul_8 li').removeClass('active');
	$('#header_maps .ul_8 li').eq(n).addClass('active');

	$('#header_maps .main_ul_li').animate({opacity: "hide"});
	$('#header_maps .main_ul_li').eq(n).animate({opacity: "show"});
	
	$('#center_block .center_block_tab').css({'display': "none"});
	$('#center_block .center_block_tab').eq(n).css({'display': "block"});
	
	$('#header_maps .ul_1 li').removeClass('active');
	$('#header_maps .ul_1 li.wohnobjekte').addClass('active');
	
	$('#header_maps .ul_3_li_last').animate({opacity: "show"});
	$('#header_maps .ul_3_li_first').animate({opacity: "show"});

}

		function slider_next5() {
				left=$('.move').css("left");
				left=left.replace(/px/, "")-0;
				var elemente = $('.move').find('li').length;
				w=98;
				n=-((elemente*w))+5*w;
				if (n==0) {}
				else if (n>=left){
					}
				else {
					left= left -20 +'px';
					$('.move').css({"left": left});
					setTimeout('slider_next5()',30);
				}
		}
		function slider_prev5() {
		if ($(".move_prev").css('left')=='1px'){
						}
						else {
							left=$(".move_prev").css("left");
							left=left.replace(/px/, "")-0+20;
							left=left+'px';
								$(".move_prev").css({"left": left});
								setTimeout('slider_prev5()',30);
							 }
		}
		
	function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}
	
	function getCookie(c_name){
	if (document.cookie.length>0){
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1){
	    c_start=c_start + c_name.length+1;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    }
	  }
	return "";
	}
