
// Hooks
onloadHooks.push(function(){
	tx_igpopuplayer_pi1_onload();
});


function popup_ausschalten(){
	if($('overlay1_p') && $('overlay2_p')){
		$('overlay1_p').destroy();
		$('overlay2_p').destroy();
	}
}


// Load-Funktionen
function tx_igpopuplayer_pi1_onload(){
	
	window.addEvents({
		'resize' : function(){
			positionOverlays_p();
		}
		
	});
	
	if(!$('overlay1_p') && !$('overlay2_p') && !$('overlay1') && !$('overlay2')){
		var overlay1_p = new Element('div', {
			'id'					:	'overlay1_p',
			'styles'			:	{
				'position'		: 'absolute',
				'top'					:	'0px',
				'left'				:	'0px',
				'width'				: '100%',
				'height'			: '100%',
				'opacity'			:	'0.7',
				'background'	: '#000000'
			}
		});
		
		var myLink;
		if(anzeige.layerAktPageLink.length){
			myLink = anzeige.layerAktPageLink;
		}else{
			myLink = 'javascript:void(0)';
		}
		
		
		var overlay2_p = new Element('div', {
			'id'					:	'overlay2_p',
			'styles'			:	{
				'position'		: 'absolute',
				'top'					:	'0px',
				'left'				:	'0px',
				'width'				: anzeige.layerImage_w,
				'height'			: anzeige.layerImage_h
			},
			'html'				:	'<div class="lightbox_outer_wrap_p"><div class="lightbox_top_p" id="lightbox_top_p"></div><div class="lightbox_center_p" id="lightbox_center_inner_content">&nbsp;</div><div class="lightbox_bottom_p">&nbsp;</div></div>'
		});
		
		
		var closelink = new Element('a',{
			'href'		: myLink,
			'html'		: 'SCHLIESSEN',
			'class'		:	'close_button',
			'events'	: {
				'click' 	: 	function(){
					popup_ausschalten();
				}
			}
		});
		
		//<a class="close_button" href="'+myLink+'" onclick="popup_ausschalten(); return false;">SCHLIESSEN</a>
		
		
		
		overlay1_p.inject(document.body, 'bottom');
		overlay2_p.inject(document.body, 'bottom');
		
		closelink.inject($('lightbox_center_inner_content'), 'top');
		
		var anzeige_wrap = $('lightbox_center_inner_content');
		
		myPic = new Image();
		myPic.src = anzeige.layerImage;
		$(myPic).setProperty('id', 'popup_image');		
		
		if(anzeige.layerLink != "") {
			var link_to = new Element('a', {
		    href: anzeige.layerLink
			});
				
			// Bild in Link
			link_to.inject($(anzeige_wrap));
			myPic.inject($(link_to));	
		}else {
			// Bild in Layer
			myPic.inject($(anzeige_wrap));			
		}
		
		var FadeEffekt = new Fx.Tween(myPic, {
		'duration': 2000
		});
		
    positionOverlays_p();
		FadeEffekt.start('opacity', 0, 1);
		
	}
}


function positionOverlays_p(){
	if($('overlay1_p') && $('overlay2_p')){
		if (window.innerHeight){
			theHeight=window.innerHeight;
		}else if (document.documentElement && document.documentElement.clientHeight){
			theHeight=document.documentElement.clientHeight;
		}else if (document.body){
			theHeight=document.body.clientHeight;
		} 
		
		theScrollHeight = window.getScrollHeight();
				
		if (window.innerWidth){
			theWidth=window.innerWidth;
		}else if (document.documentElement && document.documentElement.clientWidth){
			theWidth=document.documentElement.clientWidth;
		}else if (document.body){
			theWidth=document.body.clientWidth;
		}
		
		
		if (window.pageYOffset){
			theHeightOffset=window.pageYOffset;
		}else if (document.documentElement && document.documentElement.scrollTop){
			theHeightOffset=document.documentElement.scrollTop;
		}else if (document.body.scrollTop){
			theHeightOffset=document.body.scrollTop;
		}else{
			theHeightOffset=0;
		}
		
		if(!iexplore){
			if(theScrollHeight > theHeight){
				theWidth = theWidth - 17;
			}
		}
		
		$('overlay1_p').setStyle('width',(theWidth-1));
		$('overlay1_p').setStyle('height',(theScrollHeight-1));
		
		if(theWidth > anzeige.layerImage_w){
			ovleft = Math.floor((theWidth-anzeige.layerImage_w)/2);
		}else{
			ovleft = 0;
		}
		$('overlay2_p').setStyle('left',ovleft);
		
		ovHeight = $('overlay2_p').getChildren()[0].getChildren()[1].getStyle('height').toInt() + 30;
		
		if(theScrollHeight > ovHeight){
			var reltop = Math.floor((theHeight-ovHeight)/2);
			ovtop = reltop + theHeightOffset;
		}else{
			ovtop = 0;
		}
		
		//if(ovtop < 50){
			ovtop = 50;
		//}
		
		
		$('overlay2_p').setStyle('top',(ovtop));
		
		theScrollHeight = window.getScrollHeight();
		
		$('overlay1_p').setStyle('width',(theWidth-1));
		$('overlay1_p').setStyle('height',(theScrollHeight-1));
	}
}


/*
// Globale Variablen
var ie6		 = 0;

// Hooks
onloadHooks.push(function(){
	tx_igpopuplayer_pi1_checkBrowser();
	tx_igpopuplayer_pi1_onload();
});

// Load-Funktionen
function tx_igpopuplayer_pi1_onload(){
	
	if((typeof(setNewLayer) != 'undefined')) {
		// Lightbox Layer
		var popuplayer  = new Element('div', {id: 'popuplayer'});
		
		// Anzeige
		var anzeige_wrap = new Element('div', {id: 'popup_inner_wrap'});
		$(anzeige_wrap).setStyles({
	    width: anzeige.layerImage_w,
	    height: anzeige.layerImage_h
		});
		
		popuplayer.inject($(document.body));
		anzeige_wrap.inject($(popuplayer));
		CenterScreenDiv(anzeige_wrap);
		
		var myLink;
		if(anzeige.layerAktPageLink.length) myLink = anzeige.layerAktPageLink;
		else myLink = 'javascript:void(0)';
		// Close Button
		var close_button = new Element('a', {
	    href: myLink,
	    'class': 'close_button',
	    html: 'SCHLIESSEN',
	    events: {
	        click: function(){
	            $(popuplayer).destroy();
	        }
	    }
		});
		
		if(ie6 == 1) $(close_button).setStyle('color', '#000000');
		
		// Bild Preload und Show
		myPic = new Image();
		myPic.src = anzeige.layerImage;
		$(myPic).setProperty('id', 'popup_image');		
		
		if(anzeige.layerLink != "") {
			var link_to = new Element('a', {
		    href: anzeige.layerLink
			});
				
			// Bild in Link
			link_to.inject($(anzeige_wrap));
			myPic.inject($(link_to));	
		}else {
			// Bild in Layer
			myPic.inject($(anzeige_wrap));			
		}
		
		var FadeEffekt = new Fx.Tween(myPic, {
		'duration': 2000
		});
		FadeEffekt.addEvent('complete', function(){
      close_button.inject($(anzeige_wrap));
    });		
		FadeEffekt.start('opacity', 0, 1);
		
		
		
		
	
	}
	
}


function CenterScreenDiv(div) {
  div.style.left='50%';
  div.style.marginLeft = "-" + parseInt(div.offsetWidth / 2) + "px";
}


function tx_igpopuplayer_pi1_checkBrowser(){
	var browser = navigator.userAgent.toLowerCase();
  var ganzzahl = parseInt(navigator.appVersion);
  var genauezahl = parseFloat(navigator.appVersion);
  var explorer = ((browser.indexOf("msie") != -1) && (browser.indexOf("opera") == -1));
	var explorer6 = (explorer && (ganzzahl == 4) && (browser.indexOf("msie 6.0") !=-1));
	
	if(explorer6){
		ie6 = 1;
	}
}

*/
