$(document).ready(function() {

	var url = window.location.href.split('/');
	
	if((url[3] == 'wissen' || url[3] == 'verfahren') && url[4] != undefined){

		$('html, body').scrollTop($('#wissen').offset().top - 100);
	}


	$('#jsbox li a').click(switch_boxcontent);
	
	
	if($('.mapview').length > 0){
		var map1, map2 = null;
		show_address('map1', 'Alten Holstenstrasse 16, 21031 Hamburg');
		show_address('map2', 'Eppendorfer Baum 8, 20249 Hamburg');


	}

	
	
	if($('.vb').length > 0){
		
		$f(".player","/lib/flow/flowplayer-3.2.7.swf").each(function(){
			this.ipad();
		});
		
	}
	

	
	function switch_boxcontent(event){
		event.preventDefault();
		this.blur();
		
		if(!$(this).hasClass('active') && $('.c:animated').length == 0){
			

			$('#jsbox li a').removeClass('active');
			var url = $(this).attr('href').split('/');
			$(this).addClass('active');


			if($('#'+url[2]).height() != $('.c:visible').height()+20){
				$('.c:visible').fadeOut('fast', function(){
					$('.c').addClass('hide');
				});
			
				$('#jsbox .content').animate({height:($('#'+url[2]).height())+'px'},700, function(){
					$('#'+url[2]).fadeIn('normal', function(){
						$('#'+url[2]).removeClass('hide')
					});
				});
				
			}
			else{
				$('.c:visible').fadeOut('fast', function(){
					$('.c').addClass('hide');
					
					$('#'+url[2]).fadeIn('normal', function(){
						$('#'+url[2]).removeClass('hide')
					});
				});

			}
		}
	}


	/**
	* Zeigt eine übergebene Adresse in Google Maps an
	*
	*
	*/
	function show_address(container, address) {

		var map;
		var geocoder	    = new google.maps.Geocoder();
		var latlng	    	= new google.maps.LatLng(0,0);

		var myOptions = {
		    zoom:							15,
		    center:							latlng,
		    mapTypeId:						google.maps.MapTypeId.ROADMAP,
		    navigationControlOptions:		{style: google.maps.NavigationControlStyle.SMALL},
		    mapTypeControl:					false,
		    navigationControl:				true,
		    scaleControl:					true
		};
		
		

		map = new google.maps.Map(document.getElementById(container), myOptions);


		if (geocoder) {
		    geocoder.geocode( { 'address': address}, function(results, status) {
		    if (status == google.maps.GeocoderStatus.OK) {
			map.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
			    map: map,
			    position: results[0].geometry.location
			});
		    } else {
				alert("Geocode was not successful for the following reason: " + status);
		    }
		    });
		}
	}

});
