//
// Hotelvergleich einblenden
//
showHotelvergleichbox = function (response, toggle) {
	if(empty(response)) return;
	if(toggle == true || empty(response) || toggle == 'fehlermeldung') toggleBlendEbene();
	
	arrayPageSize = getPageSize();
	arrayPageScroll = getPageScroll();
	
	if(toggle == 'fehlermeldung' || response.typ == 'fehlermeldung'){
		lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 2);
		lightboxLeft = (arrayPageSize[0] / 2)-100;
	}
	else {
		// lightbox zentrieren
		lightboxTop = 50;
		lightboxLeft = 50;
	}
	 
	
	if (!$('lightboxField')) {
		lightboxField = document.createElement('div');
		lightboxField.id = 'lightboxField';
		lightboxField.style.position = 'absolute';
		document.body.appendChild(lightboxField);
	}
	lightboxField.style.display = "none";
	lightboxField.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	lightboxField.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
	
	if(response.width - (-200) < 1600)
		ueberBlenderWidth = 1600;
	else
		ueberBlenderWidth = response.width - (-200)
	
	$('ueberBlender').style.width = ueberBlenderWidth + 'px'; 
	$('lightboxField').innerHTML = response.code;
	lightboxField.style.zIndex = 5001;
	
	if(toggle == 'fehlermeldung' || response.typ == 'fehlermeldung'){
		lightboxField.style.width = response.width + 'px';
	}
	else {
		if($('hv_mitteoben'))
			$('hv_mitteoben').style.width = response.width - 139 + 'px';
		if($('hv_untenmitte'))
			$('hv_untenmitte').style.width = response.width - 16 + 'px';
		lightboxField.style.width = response.width+'px';
	}
	
	lightboxField.style.display = "block";
	
}

//
// Lightbox einblenden
//
showLightbox = function (response, toggle) {
	if(empty(response)) return;
	
	if (toggle == true){
		toggleBlendEbene();
	}
	
	arrayPageSize = getPageSize();
	arrayPageScroll = getPageScroll();
	
	// lightbox zentrieren
	lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - response.hoehe) / 2);
	lightboxLeft = ((arrayPageSize[0] - 120 - response.breite) / 2);
	
	if (!$('lightboxField')) {
		lightboxField = document.createElement('div');
		lightboxField.id = 'lightboxField';
		document.body.appendChild(lightboxField);
	}
	$('lightboxField').style.display = 'none';
	if (response.html != '')
		$('lightboxField').innerHTML = response.html;
	with ($('lightboxField').style) {
		position = 'absolute';
		top = (lightboxTop < 0) ? '0px' : lightboxTop + 'px';
		left = (lightboxLeft < 0) ? '0px' : lightboxLeft + 'px';
		zIndex = 5001;
		display = 'block';
	}
	
	if(response.typ == 'video') {
		eval(response.js);
		UFO.create(FO, 'flvplayer');
	}
	else if(response.typ == 'newsletterLandingPage')
		new hc.scrollbalken_horizontal("angeboteAuswahlContent", "angeboteAuswahlLeft", "angeboteAuswahlRight");
	
}


//
// Hintergrundebene, die alles verdeckt, einblenden/ausblenden
//
toggleBlendEbene = function() {
	
	if ($('ueberBlender')) {
		document.body.removeChild($('ueberBlender'));
		sels = $T('select')
		for (i= 0;i < sels.length; i++) sels[i].style.display = '';
		objects = $T('object')
		for (i= 0;i < objects.length; i++) objects[i].style.display = '';
		//document.body.scroll = "";
		return;
	}
	//document.body.scroll = "no";
	var divl = document.createElement('div');
	divl.id = 'ueberBlender';
	with (divl.style) {
		position = 'absolute';
		top = '0px'; left = '0px';
		height = document.body.offsetHeight + 'px';
		width = 1600 + 'px';
		//width = document.body.offsetWidth + 'px';
		backgroundColor = '#DCE9FF';
		//backgroundColor = '#222';
		opacity = '0.8';
		zIndex = 5000;
	}
	sels = $T('select')
	for (i= 0;i < sels.length; i++) sels[i].style.display = 'none';
	objects = $T('object')
	for (i= 0;i < objects.length; i++) objects[i].style.display = 'none';
	divl.style.filter = 'alpha(opacity="50")';
	document.body.appendChild(divl);
}


//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}


//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
