<!--

var objContainer = null;
var mouseX, mouseY;
var loading = null;

var numFormBeChanged = 0;

/* Jeden Mausklick aufzeichnen */
document.onmousemove	= updateTooltipPosition;

function setChanged(boolChanged)
{
	numFormBeChanged = boolChanged;	
}

function checkForChanges(strMsg)
{
	if(numFormBeChanged==0)
		return true;
	else if(numFormBeChanged==1 && !confirm(strMsg))
		return false;
	else
		return true;
}

function updateTooltipPosition(e) 
{
	var scrollX=0, scrollY=0;
	
	if(document.body && (document.body.scrollLeft || document.body.scrollTop) )
	{
		scrollX = document.body.scrollLeft;
		scrollY = document.body.scrollTop;	
	}
		
	if( document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop) )
	{
		scrollX = document.documentElement.scrollLeft;
		scrollY = document.documentElement.scrollTop;	
	}
	
	if(!document.all)
	{
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
	
	if(window.event && document.all)
	{
		mouseX = window.event.clientX + scrollX;
		mouseY = window.event.clientY + scrollY;
	}
	
	if(loading)
	{
		loading.style.top		= mouseY + 'px';
		loading.style.left		= mouseX + 'px';
	}
}

function absLeft(el)
{
    return (el.offsetParent) ? el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;
}

function absTop(el)
{
     return (!document.body.all && el.offsetParent) ? el.offsetTop + absTop(el.offsetParent) : el.offsetTop;
}

function showLoading()
{
	if (!loading)
	{
		loading = document.createElement('div');
		loading.id = 'i_show_loading';
		loading.className = 'show_loading';
		loading.innerHTML = '<img src="gfx/ajaxload.gif" border="0" vspace="0" hspace="0" alt="Bitte warten ... in Bearbeitung" />';
		
		document.getElementsByTagName('body').item(0).appendChild(loading);
	}
	
	loading.style.top		= mouseY + 'px';
	loading.style.left		= mouseX + 'px';
	loading.style.display	= 'block';
	
	return false;
}

function hideLoading()
{
	if(loading)
		loading.style.display	= 'none';
		
	if(objContainer)
	{
		numWidth	= objContainer.offsetWidth;
		numHeight	= objContainer.offsetHeight;
		
		numClientWidth	= document.body.clientWidth;
		numClientHeight	= document.body.clientHeight;
		
		if(numWidth && (absLeft(objContainer)+numWidth) > numClientWidth)
		{
			numX = absLeft(objContainer) - numWidth - 2;
			objContainer.style.left		= numX + 'px';
		}
		
		if(numHeight && (absTop(objContainer)+numHeight) > numClientHeight)
		{
			numY = absTop(objContainer);
			
			numY -= absTop(objContainer) + numHeight - numClientHeight - 2;
			objContainer.style.top		= numY + 'px';
		}
			
	}
}

function loadOverlayContainer(objCaller, strContainerId)
{
	objContainer	= document.getElementById(strContainerId);
	
	if(objContainer)
	{
		objContainer.style.top		= mouseY + 'px';
		objContainer.style.left		= mouseX + 'px';
		objContainer.style.display	= 'block';
	}
}

function unloadOverlayContainer(strContainerId)
{
	var objContainer	= document.getElementById(strContainerId);
	
	if(objContainer)
	{
		objContainer.style.display	= 'none';
		objContainer.innerHTML	= '';
	}
}

function setDepartureDate(strArrivalDate, strDepartureFieldId)
{
	if(strArrivalDate)
	{
		strSeperator	= ".";
		strArrivalDate	= strArrivalDate.toString();
		arArrivalDate	= strArrivalDate.split(strSeperator);
		
		if(arArrivalDate.length != 3)
		{
			strSeperator	= "/";
			arArrivalDate	= strArrivalDate.split(strSeperator);
		}
		
		if(arArrivalDate.length != 3)
		{
			strSeperator	= "-";
			arArrivalDate	= strArrivalDate.split(strSeperator);
		}
		
		if(arArrivalDate.length == 3)
		{
			// führende Nullen weg
			
			var objNow	= new Date();
			
			var numYearLength	= parseInt(arArrivalDate[2].length, 10);
			
			var numDepDay		= parseInt(arArrivalDate[0], 10);
 			var numDepMonth		= Math.ceil(parseInt(arArrivalDate[1], 10) - 1);
 			var numDepYear		= numYearLength==2 ? (objNow.getFullYear().toString().substr(0, 2) + arArrivalDate[2]) : arArrivalDate[2];
 			
 			var numOneDay	= Math.ceil(24*60*60*1000);
 			
 			var objDepartureDate	= new Date();
 			
 			objDepartureDate.setDate(numDepDay);
 			objDepartureDate.setMonth(numDepMonth);
 			objDepartureDate.setFullYear(numDepYear);
 			
 			objDepartureDate.setTime( Math.ceil(objDepartureDate.getTime() + parseInt(numOneDay,10)) );
 			
 			numDay		= objDepartureDate.getDate();
 			numMonth	= Math.ceil(objDepartureDate.getMonth()+1);
 			numYear		= objDepartureDate.getFullYear();
 			
 			strDay		= numDay.toString().length==1		? '0' + numDay.toString()		: numDay.toString();
 			strMonth	= numMonth.toString().length==1	? '0' + numMonth.toString()	: numMonth.toString();
 			strYear		= numYearLength==2				? numYear.toString().substr(2,4) : numYear.toString(); 
 			
 			strDepartureDate = strDay + strSeperator + strMonth + strSeperator + strYear;
 			
 			document.getElementById(strDepartureFieldId).value = strDepartureDate;
		}
	}	
}

function setToDate(strFromDate, strToFieldId, numDays)
{
	if(strFromDate)
	{
		strSeperator	= ".";
		strArrivalDate	= strFromDate.toString();
		arArrivalDate	= strFromDate.split(strSeperator);
		
		if(arArrivalDate.length != 3)
		{
			strSeperator	= "/";
			arArrivalDate	= strArrivalDate.split(strSeperator);
		}
		
		if(arArrivalDate.length != 3)
		{
			strSeperator	= "-";
			arArrivalDate	= strArrivalDate.split(strSeperator);
		}
		
		if(arArrivalDate.length == 3)
		{
			// führende Nullen weg
			
			var objNow	= new Date();
			
			var numYearLength	= parseInt(arArrivalDate[2].length, 10);
			
			var numDepDay		= parseInt(arArrivalDate[0], 10);
 			var numDepMonth		= Math.ceil(parseInt(arArrivalDate[1], 10) - 1);
 			var numDepYear		= numYearLength==2 ? (objNow.getFullYear().toString().substr(0, 2) + arArrivalDate[2]) : arArrivalDate[2];
 			
 			var numDays	= Math.ceil(24*60*60*1000) * numDays;
 			
 			var objDepartureDate	= new Date();
 			
 			objDepartureDate.setDate(numDepDay);
 			objDepartureDate.setMonth(numDepMonth);
 			objDepartureDate.setFullYear(numDepYear);
 			
 			objDepartureDate.setTime( Math.ceil(objDepartureDate.getTime() + parseInt(numDays,10)) );
 			
 			numDay		= objDepartureDate.getDate();
 			numMonth	= Math.ceil(objDepartureDate.getMonth()+1);
 			numYear		= objDepartureDate.getFullYear();
 			
 			strDay		= numDay.toString().length==1		? '0' + numDay.toString()		: numDay.toString();
 			strMonth	= numMonth.toString().length==1	? '0' + numMonth.toString()	: numMonth.toString();
 			strYear		= numYearLength==2				? numYear.toString().substr(2,4) : numYear.toString(); 
 			
 			strDepartureDate = strDay + strSeperator + strMonth + strSeperator + strYear;
 			
 			document.getElementById(strToFieldId).value = strDepartureDate;
		}
	}	
}

function copyDepartureDate(strArrivalDate, strDepartureFieldId)
{
	if(strArrivalDate)
	{
		strSeperator	= ".";
		strArrivalDate	= strArrivalDate.toString();
		arArrivalDate	= strArrivalDate.split(strSeperator);
		
		if(arArrivalDate.length != 3)
		{
			strSeperator	= "/";
			arArrivalDate	= strArrivalDate.split(strSeperator);
		}
		
		if(arArrivalDate.length != 3)
		{
			strSeperator	= "-";
			arArrivalDate	= strArrivalDate.split(strSeperator);
		}
		
		if(arArrivalDate.length == 3)
		{
			var objNow	= new Date();
			
			var numYearLength	= parseInt(arArrivalDate[2].length, 10);
			
			var numDepDay		= parseInt(arArrivalDate[0], 10);
 			var numDepMonth		= Math.ceil(parseInt(arArrivalDate[1], 10) - 1);
 			var numDepYear		= numYearLength==2 ? (objNow.getFullYear().toString().substr(0, 2) + arArrivalDate[2]) : arArrivalDate[2];
 			
 			var objDepartureDate	= new Date();
 			
 			objDepartureDate.setDate(numDepDay);
 			objDepartureDate.setMonth(numDepMonth);
 			objDepartureDate.setFullYear(numDepYear);
 			
 			numDay		= objDepartureDate.getDate();
 			numMonth	= Math.ceil(objDepartureDate.getMonth()+1);
 			numYear		= objDepartureDate.getFullYear();
 			
 			strDay		= numDay.toString().length==1		? '0' + numDay.toString()		: numDay.toString();
 			strMonth	= numMonth.toString().length==1	? '0' + numMonth.toString()	: numMonth.toString();
 			strYear		= numYearLength==2				? numYear.toString().substr(2,4) : numYear.toString(); 
 			
 			strDepartureDate = strDay + strSeperator + strMonth + strSeperator + strYear;
 			
 			document.getElementById(strDepartureFieldId).value = strDepartureDate;
		}
	}	
}

function setCalculatedGuestCount(strSglRoomId, strDblRoomId, strAdultId)
{
	var objSglRoomField	= document.getElementById(strSglRoomId);
	var objDblRoomField	= document.getElementById(strDblRoomId);
	var objAdultField	= document.getElementById(strAdultId);

	if(objSglRoomField && objDblRoomField && objAdultField)
	{
		try
		{
			numSgl		= objSglRoomField.value ? parseInt(objSglRoomField.value) : 0;
			numDbl		= objDblRoomField.value ? parseInt(objDblRoomField.value) : 0;
			
			numAdults = 2*numDbl + numSgl;
			
			if(numAdults)
				objAdultField.value = numAdults;
		}
		catch(e)
		{
			
		}
		
	}
}

function disableField(strObjId, boolDisable)
{
	var objField = document.getElementById(strObjId);
	
	if(objField)
	{
		boolDisable ? objField.setAttribute('disabled', 'disabled') : objField.removeAttribute('disabled'); 
	}
}

/* Funktionen zum Buchungsformular */
var numBookingPriceSummary = 0.00;
var strDecSeperator		= ',';
var strThouSeperator	= '.';

function booking_resetAgioValueField(strReset, strPriceAreaId)
{
	objPriceArea1	= document.getElementById(strPriceAreaId);
	
	// alten Wert abziehen
	if(objPriceArea1)
	{
		numBookingPriceSummary = parseFloat(numBookingPriceSummary) - parseFloat(objPriceArea1.value);
	}
		
	if(objPriceArea1)
		objPriceArea1.value = strReset;
}

function booking_calcAndSetAgioValue(numPrice, strAmountFieldId, strNightsFieldId, strPriceAreaId)
{
	objPriceArea2	= document.getElementById(strPriceAreaId);
	
	numPrice	= numPrice / 100;
	numAmount	= getSelectedValue( document.getElementById(strAmountFieldId) );
	numNights	= getSelectedValue( document.getElementById(strNightsFieldId) );
	
	// alten Wert abziehen
	if(objPriceArea2)
		numBookingPriceSummary = parseFloat(numBookingPriceSummary) - parseFloat(objPriceArea2.value);
	
	numTotal	= parseFloat( (numPrice *  numAmount * numNights));
	
	// neuen Wert setzen und dazu addieren
	if(objPriceArea2)
	{
		objPriceArea2.value	= numTotal.toFixed(2).toString(10);
		
		numOverall	= parseFloat(numBookingPriceSummary) + parseFloat(objPriceArea2.value);
		numBookingPriceSummary 	= numOverall.toFixed(2).toString(10);
	}
}

function booking_setOverallPrice(numTotalPrice, strPriceAreaId)
{
	objOverallPriceArea	= document.getElementById(strPriceAreaId);
	
	numTotalPrice	= parseFloat(numTotalPrice) / 100;
	
	if(objOverallPriceArea)
	{
		numOverall	= parseFloat(numTotalPrice) + parseFloat(numBookingPriceSummary);
		objOverallPriceArea.value = numOverall.toFixed(2).toString(10).replace(/\./, strDecSeperator);
	}
}

// selektierten Wert eines Dropdowns auslesen
function getSelectedValue(objSelect)
{
	var selectedValue = 0;
	
	if(objSelect)
		for(var i=0; i<objSelect.length; i++)
			if(true==objSelect.options[i].selected)
				selectedValue = objSelect.options[i].value;
		
	return selectedValue;
}

function getSelectedOptionTxt(objSelect)
{
	var selectedTxt = '';
	
	if(objSelect)
		for(var i=0; i<objSelect.length; i++)
			if(true==objSelect.options[i].selected)
				selectedTxt = objSelect.options[i].text;
		
	return selectedTxt;
}

function show(strObjectId)
{
		document.getElementById(strObjectId).style.display = 'block';
}

function hide(strObjectId)
{
		document.getElementById(strObjectId).style.display = 'none';
}

function copyValueToField(strValue, strFieldId)
{
		var objField = document.getElementById(strFieldId);	
		
		if(objField)
			objField.value = strValue;
}

function mybookings_checkAll(strFormName)
{
	var objForm = document.forms[strFormName];
	var j=0;
	
	for(j=0; j<objForm.elements.length; j++)
	{
		objCheckbox = objForm.elements[j];
		
		if(objCheckbox && objCheckbox.type == 'checkbox' && !objCheckbox.disabled)
			objCheckbox.checked = !objCheckbox.checked;
	}
}

// ### Overlay Zuordnung Objekte
function hideConfigurator(strAnker)
{
	if(document.getElementById('configurator_layer'))
		document.body.removeChild(document.getElementById('configurator_layer'));
		
	if(document.getElementById('configurator_mask'))
		document.body.removeChild(document.getElementById('configurator_mask'));
		
	if(document.getElementById('footer'))
		document.getElementById('footer').style.display = '';
		
	this.location.href = top.document.URL.substr(0, top.document.URL.lastIndexOf('#')) +'#'+strAnker;
}

function loadConfigurator(strTableKey, numRelatedId)
{
	self.scrollTo(0,0);
	
	var arrayPageSize	= getPageSize();
	
	var objConfiguratorMask	= document.createElement("div");
	objConfiguratorMask.setAttribute('id', 'configurator_mask');
	objConfiguratorMask.style.width = arrayPageSize[0] + 'px';
	objConfiguratorMask.style.height = arrayPageSize[0] + 'px';
	
	var objConfiguratorLayer	= document.createElement("div");
	objConfiguratorLayer.setAttribute('id', 'configurator_layer');
	
	var objConfiguratorWrap	= document.createElement("div");
	objConfiguratorWrap.setAttribute('id', 'configurator_wrap');
	
	var strIframe = '<span class="close_link" style="float:right;"><img src="gfx/close.gif" border="0" alt="Fenster schließen" align="absmiddle" /> <a href="#" onclick="hideConfigurator(\''+strTableKey+numRelatedId+'\'); return false;">Fenster schließen</a></span><h1 class="configurator_header">Objekte zuordnen<br />&nbsp;</h1><iframe name="configurator_iframe" id="configurator_iframe" marginwidth="0" marginheight="0" width="760" height="540" src="admin.php5?load=a_objectcollect&do=listRelated&p='+strTableKey+'|'+numRelatedId+'" frameborder="0" scrolling="auto"></iframe>';
	
	objConfiguratorWrap.innerHTML = strIframe;
	
	objConfiguratorLayer.appendChild(objConfiguratorWrap);
	
	document.body.appendChild(objConfiguratorMask);
	document.body.appendChild(objConfiguratorLayer);
	
	if(document.getElementById('footer'))
		document.getElementById('footer').style.display = 'none';
}

function loadConfigurator2(numGalleryId)
{
	self.scrollTo(0,0);
	
	var arrayPageSize	= getPageSize();
	
	var objConfiguratorMask	= document.createElement("div");
	objConfiguratorMask.setAttribute('id', 'configurator_mask');
	objConfiguratorMask.style.width = arrayPageSize[0] + 'px';
	objConfiguratorMask.style.height = arrayPageSize[0] + 'px';
	
	var objConfiguratorLayer	= document.createElement("div");
	objConfiguratorLayer.setAttribute('id', 'configurator_layer');
	
	var objConfiguratorWrap	= document.createElement("div");
	objConfiguratorWrap.setAttribute('id', 'configurator_wrap');
	
	var strIframe = '<span class="close_link" style="float:right;"><img src="gfx/close.gif" border="0" alt="Fenster schließen" align="absmiddle" /> <a href="#" onclick="hideConfigurator(\'gallery'+numGalleryId+'\'); return false;">Fenster schließen</a></span><h1 class="configurator_header">Bilder erstellen<br />&nbsp;</h1><iframe name="configurator_iframe" id="configurator_iframe" marginwidth="0" marginheight="0" width="760" height="540" src="admin.php5?load=a_gallerygen&do=generate&p='+numGalleryId+'" frameborder="0" scrolling="auto"></iframe>';
	
	objConfiguratorWrap.innerHTML = strIframe;
	
	objConfiguratorLayer.appendChild(objConfiguratorWrap);
	
	document.body.appendChild(objConfiguratorMask);
	document.body.appendChild(objConfiguratorLayer);
	
	if(document.getElementById('footer'))
		document.getElementById('footer').style.display = 'none';
}

function loadConfigurator3(numObjectId)
{
	self.scrollTo(0,0);
	
	var arrayPageSize	= getPageSize();
	
	var objConfiguratorMask	= document.createElement("div");
	objConfiguratorMask.setAttribute('id', 'configurator_mask');
	objConfiguratorMask.style.width = arrayPageSize[0] + 'px';
	objConfiguratorMask.style.height = arrayPageSize[0] + 'px';
	
	var objConfiguratorLayer	= document.createElement("div");
	objConfiguratorLayer.setAttribute('id', 'configurator_layer');
	
	var objConfiguratorWrap	= document.createElement("div");
	objConfiguratorWrap.setAttribute('id', 'configurator_wrap');
	
	var strIframe = '<span class="close_link" style="float:right;"><img src="gfx/close.gif" border="0" alt="Fenster schließen" align="absmiddle" /> <a href="#" onclick="hideConfigurator(\'object'+numObjectId+'\'); return false;">Fenster schließen</a></span><h1 class="configurator_header">Objektbilder und Willkommenstext<br />&nbsp;</h1><iframe name="configurator_iframe" id="configurator_iframe" marginwidth="0" marginheight="0" width="760" height="540" src="admin.php5?load=a_objectfiles&do=editTxtPix&p='+numObjectId+'" frameborder="0" scrolling="auto"></iframe>';
	
	objConfiguratorWrap.innerHTML = strIframe;
	
	objConfiguratorLayer.appendChild(objConfiguratorWrap);
	
	document.body.appendChild(objConfiguratorMask);
	document.body.appendChild(objConfiguratorLayer);
	
	if(document.getElementById('footer'))
		document.getElementById('footer').style.display = 'none';
}

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
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//-->