// $Id: popup.js 285 2008-07-29 09:10:05Z jelner $

window.addEvent('domready',function() {
	var el1 = $$('.stp_context_navigation_movie')[0];
	if($chk(el1)) {
		el1.addEvent('click',function(e) {
			var el2 = $(new Event(e).preventDefault().stopPropagation().target);
			while(el2.get('tag') != 'a') el2 = el2.getParent();
			el2.blur();
			var close = 'Schließen';
			if(location.href.match(/L=1/)) close = 'Close';
			$$('body')[0].adopt(
				new Element('div',{
					'id': 'stp_context_navigation_shadow',
					'styles': {'opacity': 0.2},
					'events': {
						'click': function(e) { new Event(e).stopPropagation(); }
					}
				}),
				new Element('div',{
					'id': 'stp_context_navigation_layer',
					'events': {
						'click': function(e) { new Event(e).stopPropagation(); }
					}
				}).adopt(
					new Element('div',{'class': 'close'}).adopt(
						new Element('a',{
							'title': close,
							'href': '#',
							'events': {
								'click': function(e) {
									new Event(e).preventDefault().target.blur();
									var el3 = $('stp_context_navigation_shadow');
									if($chk(el3)) el3.destroy();
									el3 = $('stp_context_navigation_layer');
									if($chk(el3)) el3.destroy();
								}
							}
						}).set('text','X')
					),
					new Element('iframe',{
						'src': el2.href,
						'width': 400,
						'height': 265,
						'frameborder': 0,
						'scrolling': 'no'
					})
				)
			);
			var bWindow = window;
			if(Browser.Engine.trident) bWindow = $$('html')[0];
			bWindow.addEvent('click',function(e) {
				var el2 = $('stp_context_navigation_shadow');
				if($chk(el2)) el2.destroy();
				el2 = $('stp_context_navigation_layer');
				if($chk(el2)) el2.destroy();
			});
		});
	};
});
