$(document).ready(function(){
	
		if ($(".chronikimages").length) {
			
			$(".chronikimages").each(function(intIndex) {
				// freiraum HÃ¶he Text Liste  - HÃ¶he Bilder- Liste
				var space = $(this).next().height() - $(this).height();
				if (space > 0 && $(this).children().length > 1) {
					// freiraum / anzahl der Bilder(Listenelemente) + 18px(default margin) -> margin fÃ¼r jedes Listenelement
					var $mBottom = (space / $(this).children().length) + 18;
					
					$(this).children().css('margin-bottom', Math.min(80,$mBottom));
				}
				});
		}
		
		if (location.hash !== '') {
			ankerName = location.hash.substring(1,location.hash.length);
			if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 6) {
				$('a[name='+ankerName+']').parent().parent().scrollTo();			
			}
			else {
				$('a[name='+ankerName+']').scrollTo();
			}

			//window.scrollBy(0, -150); // Hier ebenfalls.
		}

		$('#Scrollbereich a').bind("click", handle_internal_link);


     });

	function getHash(url) {
			return url.match(/#[A-Za-z\d_]+$/);
	}

	function handle_internal_link (e) {

		var hashposition, link_uri, ankerName;
		
		if (typeof(this.hash) == "undefined" || this.hash.length == 0 || this.hash == "#") {
			return true;
		}
		// wir haben eine anker
		link_url = this.href;
		
		if (link_url != null) {
			hashposition = link_url.indexOf("#");
			if (hashposition > -1) {
				link_url = link_url.substring(0,hashposition);
			}

			if (link_url == location.href) {
				// wir haben einen lokalen anker
				ankerName = this.hash.substring(1,this.hash.length);

				$('a[name='+ankerName+']').scrollTo();			


				return false;


			}
		

		}

	
	}


	
	jQuery.fn.extend({
	  scrollTo : function() {
	    return this.each(function() {
	      var targetOffset = $(this).offset().top - 200;
			

	  		if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 6) {
				$('#Scrollbereich').animate({scrollTop: targetOffset}, 400);
	  		}

			else {
				$('html,body').animate({scrollTop: targetOffset}, 400);
			}
			
			

	    });
	  }
	});



var oldPlayer = '';


function play(sFile, sPlayer) {

		if (oldPlayer != '') {
			if (document.getElementById(oldPlayer)) {
				document.getElementById(oldPlayer).style.display = 'none';
			}
		}

		if (document.getElementById(sPlayer)) {
			document.getElementById(sPlayer).style.display = '';
		}

		var params = {};

		params.allowscriptaccess = "always";
		params.allowfullscreen = "true";
		params.wmode = "opaque";

		var flashvars = {};
		flashvars.file = "http://" + document.domain + "/flashfiles/0/"+sFile;
		flashvars.autostart = "true";

		swfobject.embedSWF('fileadmin/mediaplayer/player.swf', sPlayer ,'250','20','9','fileadmin/mediaplayer/player.swf', flashvars, params);


		oldPlayer = sPlayer;
	}
