$(document).ready(function(){
	
	$('#banner').flash({
		src: banner_src,
		width: 820,
		height: 340,
		wmode: 'transparent',
		flashvars: { dyn_ueberschrift: banner_params }
	});

	popup.init();


});


var popup = {

	active: null,
	init: function(){

		$('a.popup').click(function(){
			var image_url = $(this).attr('href');

			popup.build( image_url );
			return false;

		});

		

	},

	build: function( image_url ){

			

		var image = new Image();
		image.src = image_url;

		image.onload = function(){
			if(!$('#popupimage').length){
				$('<div id="popupimage"><div id="popupimage_close"><a href="javascript:popup.close();">Bild schließen<'+'/'+'a><'+'/'+'div><div id="popupimagesrc"></div><'+'/'+'div>').appendTo('body');
			}else{
				$('#popupimagesrc').empty();
			}
			
			$(this).appendTo('#popupimagesrc');
			popup.center($('#popupimage'), this.width, this.height,$('body'));
			
		}

	},

	center: function(el, width, height, referenz){
		
		newWidth = (referenz.width()/2)-(width/2)
		newHeight= ((referenz.height()/2)-(height/2))+referenz.scrollTop()
		el.css({'left' : newWidth, 'top' : newHeight}, 400);


	},

	close: function(){

		$('#popupimage').remove();

	}

}

