// $Header: $
/***************************************************************************
* Automatic Image Popup
* Copyright 2002 by David Schontzler | www.stilleye.com
* Free to use under GNU General Public License as long as this message
*  remains intact.
* Description:  Automate your image popup windows (centered and sized)
* URI: http://www.stilleye.com/scripts/iPop
***************************************************************************
* Version: 1.0
***************************************************************************/
function iPop(img,w,h,ttl)
{
	var iPopURL = '/ipop.html' // set as location of ipop.html
	var url = iPopURL + '?' + img + (ttl ? '&'+escape(ttl) : '')
	var l = (screen.width-w)/2
	var t = (screen.height-h)/2
	var attribs = 'width='+w+',height='+h+',left='+l+',top='+t
	try { iPop.close(); } catch (e) { ; } 
	open(url,'iPop',attribs)
	return false;
}

/****************************************************
*	Creates and centers a popup window
*		by LWD-hk 20030722
****************************************************/
function rsPopUp(url,w,h,ttl)
{
	var l = (screen.width-w)/2
	var t = (screen.height-h)/2
	var attribs = 'scrollbars=yes,resizable=yes,width='+w+',height='+h+',left='+l+',top='+t
	try { rspopup.close(); } catch (e) { ; } 
	open(url,'rspopup',attribs)
	return false;
}

/****************************************************
*	DOM image rollover:
*		by Chris Poole
*		http://chrispoole.com
*
*		Keep this notice intact to use it :-)
****************************************************/

function domRollover() {
if (!document.getElementById) return;
	var imgTemp=new Array();
	var imgarr=document.getElementsByTagName('img');
	for (var i=0;i<imgarr.length;i++){
	if (imgarr[i].getAttribute('hsrc')){
			imgTemp[i]=new Image();
			imgTemp[i].src=imgarr[i].getAttribute('hsrc');
			imgarr[i].setAttribute('xsrc', imgarr[i].getAttribute('src'));
			imgarr[i].onmouseover=function(){
				this.setAttribute('src',this.getAttribute('hsrc'))
			}
			imgarr[i].onmouseout=function(){
				this.setAttribute('src',this.getAttribute('xsrc'))
			}
		}
	}
}
domRollover();

/****************************************************
*	Show/Hide DIV Layer by ID:
*		by LWD-hk 20030312
****************************************************/
function divVisibility(id,vis)
{var dddd;
 if(document.all)
  {dddd=document.all[id].style;
   dddd.visibility = vis ? "visible" : "hidden";
  }
 if(document.layers)
  {dddd=document.layers[id];
   dddd.visibility = vis ? "show" : "hide";
  }
}


/****************************************************
*	Show/Hide DIV by ID + description:
*		by LWD-hk 20090223
****************************************************/


function toggleShowHide(id) {
	var o=document.getElementById(id);
	var d=document.getElementById(id+'_description');
	if(d.style.display=='none') {
		d.style.display='block';
		o.className='close';
	}
	else {
		d.style.display='none';
		o.className='open';
	}
}



/****************************************************
*	Accordion DIV + description:
*		by md 20100406
****************************************************/

function toggleAccordion(elem) {
	/* Configuration */
	var toggleAtOnce = true; // Toggle Open DIV and to open DIV at once?
	
	// All sibling elements (DIV's)
	//var sibling_elements = elem.previousSiblings();
	//sibling_elements.concat(elem.nextSiblings());
	var sibling_elements = $(elem.id).up(0).childElements();
		
	for(var i=0; i<sibling_elements.length; i++) {
		var sibling_element = sibling_elements[i];
		if(!sibling_element.inspect().indexOf('div') || sibling_element.id.indexOf('tab')===false) {
			continue;
		}
		
		if(sibling_element.hasClassName('close')) {
			// "Close" all DIV elements
			sibling_element.removeClassName('close'); // close = geöffnet
			sibling_element.addClassName('open'); // open = geschlossen
		}
		if(sibling_element.id.indexOf('_description')>0) {
			// "Close" all DIV description elements
			if(sibling_element.id!=(elem.id+'_description')) {
				Effect.BlindUp(sibling_element.id, { duration: 0.5 });
			}
		}
		
	}
	// "Open" current accordion
	if (!toggleAtOnce) {
		var params =
		{
			duration: 0.5,
			queue: 'end',
			afterFinish: function() {
				$(elem.id).removeClassName('open');
				$(elem.id).addClassName('close');
			}
		}
	} else {
		var params =
		{
			duration: 0.5,
			afterFinish: function() {
				$(elem.id).removeClassName('open');
				$(elem.id).addClassName('close');
			}
		}
	}
	
	new Effect.BlindDown(elem.id+'_description', params);
	
	// Switch teaser image
	try {
		if(arguments[1]==undefined) {
			var imgContainer = $('accordionImgContainer');
		} else {
			var imgContainer = $('accordionImgContainer_'+arguments[1]);
		}
		var image = $(elem.id + '_image').select('img').first();
		if (imgContainer && image) {
			var image_link = $(elem.id + '_image').select('a').first();
			if (image_link) {
				// Copy image incl. link to imgContainer:
				imgContainer.update($(elem.id + '_image').innerHTML);
			}
			else {
				imgContainer.update($(elem.id + '_image').select('img').first().innerHTML);
			}
		}
		else {
			// empty
			imgContainer.update('');
		}
	} catch(e) {
		if(arguments[1]==undefined) {
			$('accordionImgContainer').update('');
		} else {
			$('accordionImgContainer_'+arguments[1]).update('');
		}
	}
	return false;
}


/****************************************************
*	ImageGallery for rooms with cross-over effect:
*		by md 20100408
****************************************************/

function imageGallery_showImage(container_id, image_index) {
	var elemToHide = null;
	var elemToShow = null;
	var thumbToActivate = 0;
	var stdOptions = {
		useFading: true,
		fadeDuration: 0.7
	}
	var options = stdOptions;
	if(arguments[2]) {
		for(o in arguments[2]) {
			options[o] = arguments[2][o];
		}
	}
	
	// Fade out all visible images expect the current to shown image index 
	var iterator = 1;
	$$('#'+container_id+' div').each(function(img_div) {
		if(image_index!=iterator && img_div.visible()) {
			elemToHide = img_div;
		} else if(image_index==iterator) {
			elemToShow = img_div;
			thumbToActivate = iterator;
		}
		iterator++;
	});
	
	if(options.useFading) {
		new Effect.Fade(elemToHide, {
			duration: options.fadeDuration,
			from: 1,
			to: 0,
			afterFinish: function() {
				new Effect.Appear(elemToShow, { duration: options.fadeDuration, from:0, to: 1 } );
			}
		});
	} else {
		elemToHide.hide();
		elemToShow.show();
	}
	
	// Active Thumbs
	var iterator = 1;
	$$('.thumblina').each(function(thisthumblina) {
		// Loop every thumblina:
		if(image_index!=iterator) {
			thisthumblina.removeClassName('thumblina_active');
		} else if(image_index==iterator) {
			thisthumblina.addClassName('thumblina_active');
		}
		iterator++;
	});
	
	
	
}

/****************************************************
*	Get Body background color:
*		by LWD-hk 20030722
****************************************************/
function prodHighl(o) { o.style.backgroundColor = document.body.style.backgroundColor; }
function prodNormal(o) { o.style.backgroundColor = 'white'; }


/****************************************************
*	Add Site to Favorits:
*		by LWD-sb 20051019
****************************************************/
function addBookmark(title) {

	var url = document.location.href;
	var foo = url.split('?');
	url = foo[0];
	
	if (window.sidebar)
		window.sidebar.addPanel(title, url,""); 
	else if( document.all )
		window.external.AddFavorite( url, title);
	return;
}

/****************************************************
*	Change Languages
*		by HK LWD
****************************************************/
 function showLang(value) {
	var o = document.getElementById('langnote');
	oldTXT = o.innerHTML;
	o.innerHTML = value;
}
function restoreLang() {
	var o = document.getElementById('langnote');
	if(!oldTXT) oldTXT = o.innerHTML;
	o.innerHTML = oldTXT;
}
function openFlashLayer(src,cid,lang,w,h) {
	var s=navigator.userAgent.toLowerCase();
	var browserInfo={
		IsIE		: /*@cc_on!@*/false,
		IsIE7		: /*@cc_on!@*/false && ( parseInt( s.match( /msie (\d+)/ )[1], 10 ) >= 7 )
	};
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
    var arrayPageSize = getPageSize();
    $('flashoverlay').style.height = arrayPageSize[1] + "px";
	new Effect.Appear('flashoverlay', { duration: 0.0, from: 0.0, to: 0.6 });
    var xyscroll = ( browserInfo.IsIE && !browserInfo.IsIE7 )?document.viewport.getScrollOffsets():[0,0];
	var innerH=document.viewport.getHeight(),innerW=document.viewport.getWidth();
	var pars='action=flashpopup&clientid=' + cid + '&lang=' + lang + '&' + Math.random(9999);
    var m = new Ajax.Updater('flashpopup', '/ajaxhelper.cfm', {
        method: 'get',
        parameters: pars,
        onComplete: function(){
    		var l=Math.round(xyscroll[0]+(innerW-w)/2),t=Math.round(xyscroll[1]+(innerH-h)/2);
    		h+=25;
			$('flashpopup').setStyle({ top: t + "px", left: l + "px", width: w + "px", height: h + "px",cursor : 'pointer'});
			$('flashpopup').style.position=( browserInfo.IsIE && !browserInfo.IsIE7 ) ? 'absolute' : 'fixed';
			preventDocScroll();
			var flashvars = {clientID:cid,lang:lang},params = {bgcolor: '#FFFFFF'},attributes = {};
			swfobject.embedSWF(src, 'flashpopupcontent', w, h, "9.0.124","/media/expressInstall.swf", flashvars, params, attributes);
			$('flashpopup').show();
			myFlashDrag = new Draggable('flashpopup',{});
        }
    });
}
function hideLayer(id,oid) {
	Effect.BlindUp(id, {duration: 0.3});
    $(oid).hide();
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
	allowDocScroll();
}
function getPageSize() {
    var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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
		if(document.documentElement.clientWidth)
			windowWidth = document.documentElement.clientWidth; 
		else
			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
	pageHeight=(yScroll < windowHeight)?windowHeight:yScroll;
	// for small pages with total width less then width of the viewport
	pageWidth=(xScroll < windowWidth)?xScroll:windowWidth;
	return [pageWidth,pageHeight];
}
function preventDocScroll()
{ 
    if (document.all)
    {               
        document.body.scroll = "no";
    }
    else
    {
        var oTop = document.body.scrollTop;
        document.body.style.overflow = "hidden";
        document.body.scrollTop = oTop;
    }
}
function allowDocScroll()
{
    document.body.scroll = "";
    document.body.style.overflow = "";
}


/****************************************************
*	Sonnenhof: Homepage Collage Toogler
*		by md 20100407
****************************************************/
function sonnenhof_homepageCollageToggle(elem_name) {
	if($('offers').visible() && elem_name!='offers') {
		$('offers').blindUp({ queue: 'end' });
	}
	if($('events').visible() && elem_name!='events') {
		$('events').blindUp({ queue: 'end' });
	}
	if($('packages').visible() && elem_name!='packages') {
		$('packages').blindUp({ queue: 'end' });
	}
	if($('booking').visible() && elem_name!='booking') {
		$('booking').blindUp({ queue: 'end' });
	}
	if($(elem_name).visible()==false) {
		$(elem_name).blindDown();
	}
	return false;
}

/****************************************************
*	Google Routing Widget functions
*		by hk/md 20100408
****************************************************/
function showRouting(id,lang,key, layerOptions) {
	var s=navigator.userAgent.toLowerCase();
	var browserInfo={
		IsIE		: /*@cc_on!@*/false,
		IsIE7		: /*@cc_on!@*/false && ( parseInt( s.match( /msie (\d+)/ )[1], 10 ) >= 7 )
	};
	var w=layerOptions.layerWidth||970,h=layerOptions.layerHeight||600;
	var key=key||'ABQIAAAAaJuQh4msgKAwAUzkMW7hehTBz7b9MY2V0F5XyBasjiqSIXSqhxSWczCrSZjzkg089OKPrBPMatK7Rw';
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
    var arrayPageSize = getPageSize();
	
	var overlayDiv = $('overlay');
	if(!overlayDiv) {
		overlayDiv = document.createElement('div');
		overlayDiv.id = 'overlay';
		overlayDiv.style.display= 'none';
		overlayDiv.style.zIndex = '100';
		overlayDiv.appendChild(document.createTextNode("&nbsp;"));
		document.body.appendChild(overlayDiv);
		$('overlay').hide().observe('click', function() {
			hideMap();
			new Effect.Fade(this, { duration: 0.5 });
		});
	}
	var popup = $('popup') || $$('div#gmaprouting').first();
	if(!popup) {
		popup = document.createElement('div');
		popup.id = 'gmaprouting';
		popup.style.display = 'none';
		popup.style.zIndex  = '200';
		popup.style.height = (h+15)+'px';
		popup.appendChild(document.createTextNode("&nbsp;"));
		document.body.appendChild(popup);
	}
	
    overlayDiv.style.height = arrayPageSize[1] + "px";
	new Effect.Appear('overlay', { duration: 0.0, from: 0.0, to: 0.6 });
    var xyscroll = ( browserInfo.IsIE && !browserInfo.IsIE7 )?document.viewport.getScrollOffsets():[0,0];
	var innerH=document.viewport.getHeight(),innerW=document.viewport.getWidth();
	var pars='clientid=' + id + '&lang=' + lang;
	
    var m = new Ajax.Updater(popup, '/routing.cfm', {
        method: 'get',
        parameters: pars,
        onComplete: function() {
    		var l=Math.round(xyscroll[0]+(innerW-w)/2),t=Math.round(xyscroll[1]+(innerH-h)/2);
			$('gmaprouting').setStyle({ top: t + "px", left: l + "px", width: w + "px", height: h + "px", cursor : 'pointer'});
			$('gmaprouting').style.position=( browserInfo.IsIE && !browserInfo.IsIE7 ) ? 'absolute' : 'fixed';
			preventDocScroll();
			Effect.Appear('gmaprouting',{duration:.5});
        }
    });
}
function hideMap() {
    Effect.BlindUp('gmaprouting', {
        duration: 0.3
    });
    $('overlay').hide();
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
	allowDocScroll();
}