function abreise() {
    oFilterForm = document.forms[0];

    if ( ! oFilterForm ) {
        return true;
    }

    oDuration              = oFilterForm.mmc;
    oEarliestDepartureDate = oFilterForm.vnd;
    oLatestReturnDate      = oFilterForm.bsd;

    if ( ! oEarliestDepartureDate || ! oLatestReturnDate ) {
        return true;
    }

    var sDurationValue = 0;

    if ( oDuration ) {
        sDurationValue = oDuration.options[oDuration.selectedIndex].value;
    }

    var iDefaultDuration = 15;

    switch (sDurationValue) {
        case '0':
            iDuration = 28;
            break;
        case '1-5t':
            iDuration = 5;
            break;
        case '1w':
            iDuration = 7;
            break;
        case '6-8t':
            iDuration = 8;
            break;
        case '9-12t':
            iDuration = 12;
            break;
        case '2w':
            iDuration = 14;
            break;
        case '13-16t':
            iDuration = 16;
            break;
        case '3w':
            iDuration = 21;
            break;
        case '17-22t':
            iDuration = 22;
            break;
        case '4w':
            iDuration = 28;
            break;
        case '27-28t':
            iDuration = 28;
            break;
        case 'tr1':
        case 'tr2':
        case 'tr3':
            iDuration =iDefaultDuration;
            break;
        default:
            iDuration =iDefaultDuration;
            break;
    }

    if ( oLatestReturnDate.selectedIndex <
        (oEarliestDepartureDate.selectedIndex + iDuration)) {
        if ( (oEarliestDepartureDate.selectedIndex + iDuration) <=
            oLatestReturnDate.options.length ) {
            oLatestReturnDate.selectedIndex =
                oEarliestDepartureDate.selectedIndex + iDuration;
        } else {
            oLatestReturnDate.selectedIndex =
                oLatestReturnDate.options.length - 1;
        }
    }

    return true;
}

/**
 * included in all booking steps, thought to contain all essential
 * js functions for the tibet engine
 *
 * @author Horst Schwarz, <schwarz@traffics.de>
 * @version  $Id: general.js 0 2008-10-21 00:00:00Z hschwarz $
 */

/**
 * eventHandler for the hotel memorise link, calls the SAJAX wrapper
 *
 * @params string
 */
function vMemoriseHotel(sHSC) {
    x_iMemoriseHotel(sHSC, vSetMemorisedHotelsCounter);

}

/**
 * called from within the SAJAX engine; sets the counter for memorised
 * hotels in the header nav section
 *
 * @params int
 */
function vSetMemorisedHotelsCounter(iCount) {
    if (iCount == 1) {
        oCanvas = document.getElementById('cnvMemorisedHotels');
        if (oCanvas) {
            oCanvas.innerHTML = oCanvas.innerHTML.replace(/<!--|-->/g, '');
        }
    }
    oCounter = document.getElementById('spnMemorisedHotelCount');
    if (oCounter) {
        oCounter.innerHTML = iCount;
    }
    alert('Das Hotel wurde in die Merkliste übernommen.');
}

/**
 * @author   J.Rosswog
 */

function setDay(sDate, field){
	
	var jetzt = new Date(sDate.value * 1000);
	var TagInWoche = jetzt.getDay();
	
	var Wochentag = new Array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");

	document.getElementById(field).firstChild.nodeValue = Wochentag[TagInWoche];						
	
}

/**
 * @author   Johannes Rosswog, <rosswog at traffics dot de>
 *
 * @version  SVN: $Id: search.js 2849 2009-01-28 09:23:28Z hschwarz $
 */

function changeDsi(sFormName, iStep) {
    oForm = document.forms[sFormName.name];

    if ( ! oForm ) {
        return;
    }

    /** Der IE hat im Step 2 hiermit ein Problem warum auch immer ?! **/
    //  mRegionElements = oForm.elements['region'];

    /* Das Problem ist, dass das 'elements' Objekt offenbar nicht vorhanden
       ist  */
//    mRegionElements = oForm.region;
    mRegionElements = document.getElementById('region');
/*
    if( iStep ) {
        mRegionElements = document.getElementById('region');
    } else {
        mRegionElements = oForm.elements['region'];
    }
*/

    sRegion = 'ALLE';

    if ( 'select-one' == mRegionElements.type ) {
        sRegion = mRegionElements.value;
    } else {
        for ( iIndex = 0; iIndex < mRegionElements.length; iIndex++ ) {
            if ( 'select-one' == mRegionElements[iIndex].type ) {
                sRegion = mRegionElements[iIndex].value;

                break;
            }
        }
    }

    /** Der IE hat im Step 2 hiermit ein Problem warum auch immer ?! **/
    // oDestination = oForm.elements['dsi'];
    // oDestination = oForm.dsi;
    oDestination = document.getElementById('dsi');
/*
    if( iStep ) {
        oDestination = document.getElementById('dsi');
    } else {
        oDestination = oForm.elements['dsi'];
    }
*/

    if ( ! oDestination ) {
        return;
    }

    iLength = oDestination.length;

    for (i = 0; i < iLength; i++) {

        if (sRegion == oDestination.options[i].value) {

            oDestination.options[i].selected = true;

            break;

        }

    }

    x_changeDestination(sRegion, changeDsiSelect);

}

function changeDsiSelect(sValue) {

    oDsi = document.getElementById('dsi');

    oDsi.length = 0;

    var cnt = 0;

    for(i in sValue) {

        if( cnt == 0) {
            oDsi.options[cnt] = new Option(sValue[i], i, true, true);
        }
        else {
            oDsi.options[cnt] = new Option(sValue[i], i, false, false);
        }

        cnt++;

    }

    /*
    var sOptions = sValue.split(',');

    oDsi.length = 0;

    for(i = 0; i < sOptions.length; i++) {

        oDsi.options[i] = new Option(sOptions[i].value, false, true);


    }
    */
}

function setKeywords(sValue) {
    document.forms['SUCHE'].elements['fts'].value =
        document.forms['SUCHE'].elements['fts'].value + ' ' + sValue;

    document.forms['SUCHE'].elements['fts'].focus();
}

function clearField() {
   document.forms['SUCHE'].elements['fts'].value = '';
}

/* ========== travel type selector ======================================== */

function changeSearchMask(sType, sPresentation, sSubType, iFlightDirection,
    iStep) {
    if ( ! sType ) {
        sType = '';
    }

    if ( ! sPresentation ) {
        sPresentation = '';
    }

    if ( ! sSubType ) {
        sSubType = '';
    }

    if ( ! iFlightDirection ) {
        iFlightDirection = 0;
    }

    if ( ! iStep ) {
        iStep = 0;
    }

    // -----------------------------------------------------------------------

    var sQueryString = '';

    switch ( sType ) {
        case 'P':
            sQueryString += 'typ=P';

            if ( '' == sPresentation ) {
                sPresentation = 'pauschal';
            }

            break;

        case 'H':
            sQueryString += 'typ=H';

            if ( '' == sPresentation ) {
                sPresentation = 'hotel';
            }

            break;

        case 'N':
            sQueryString += 'typ=N';

            if ( '' == sPresentation ) {
                sPresentation = 'charter';
            }

            break;

        case 'O':
            sQueryString += 'typ=O';

            if ( '' == sPresentation ) {
                sPresentation = 'oneway';
            }

            break;

        default:
            return false;
    }

    // -----------------------------------------------------------------------

    sQueryString += '&ixp=' + sPresentation;

    // -----------------------------------------------------------------------

    if ( '' != sSubType ) {
        sQueryString += '&sub=' + sSubType;
    }

    if ( 0 < iFlightDirection ) {
        sQueryString += '&fdir=' + iFlightDirection;
    }

    if ( 0 < iStep ) {
        sQueryString += '&stp=' + iStep;
    }

    // -----------------------------------------------------------------------

    var aCurrentURL = document.location.href.split('?', 2);

    var aParameters = aCurrentURL[1].split('&');

    var iParameters = aParameters.length;

    for ( var iParameter = 0; iParameter < iParameters; iParameter++ ) {
        sParameter = aParameters[iParameter];

        aParameter = sParameter.split('=', 2);

        sKey = aParameter[0];

        if ( 'typ' == sKey ||
             'ixp' == sKey ||
             'sub' == sKey ||
             'fdir' == sKey ||
             'stp' == sKey ) {
            continue;
        }

        sQueryString += '&' + sParameter;
    }

    sURL = aCurrentURL[0] + '?' + sQueryString;

    // -----------------------------------------------------------------------

    document.location.href = sURL;
}

/* ========== functions for search/filter mask calendar =================== */

var aHiddenForCalendar    = new Array();

var iCalendarRetryCounter     = 0;
var iCalendarMaxRetries       = 30;
var iCalendarRetrySleep       = 100;
var sCalendarInputDepartureId = '';
var sCalendarInputReturnId    = '';
var oCalendarParentForm       = null;
var sSessionID = '';
var sSessionName = '';
var bAutoReturnDate = true;

/**
 * Called from within the search/filter templates, this function puts the
 * calendarframe into these templates and assigns onClick events to
 * the input fields for departure and return date
 */
function inputCalendar(sLicenseId, sTheme, sStyle, sButtons, sColorSet,
    sInputDepartureId, sInputReturnId, iChangePosition) {
    /* alert('inputCalendar("' + sLicenseId + '", "' + sTheme + '", "'
        + sStyle + '", "' + sButtons + '", "' + sColorSet + '", "'
        + sInputDepartureId + '", "' + sInputReturnId + '", "'
        + iChangePosition + '")'); */

    if ( ! document.getElementById('calendar') &&
         ! document.getElementById('calendarframe') ) {
        document.writeln('<div id="calendar">');
        document.writeln('  <iframe id="calendarframe" width="100%" src="" \
                                    marginheight="0" marginwidth="0" \
                                    frameborder="0" framespacing="0" \
                                    scrolling="no" \
                                    allowtransparency="false"></iframe>');

        document.writeln('</div>');
        document.writeln('<div id="calendarspacer" \
                               style="visibility: hidden; height: 0px; \
                               font-size: 0px; line-height: 0px;">');
        document.writeln('&nbsp;</div>');
    }

    // -----------------------------------------------------------------------

    if ( ! sInputDepartureId ) {
        sInputDepartureId = 'vnd';
    }

    oInputDeparture = document.getElementById(sInputDepartureId);

    if ( oInputDeparture ) {
        sCalendarInputDepartureId = sInputDepartureId;

        sCode =  'oInputDeparture.onclick = function(oEvent) { ';
        sCode += '  showCalendar(this, \'departure\', \'' + sLicenseId + '\'';
        sCode += ', \'' + sTheme + '\'';
        sCode += ', \'' + sStyle + '\'';
        sCode += ', \'' + sButtons + '\'';
        sCode += ', \'' + sColorSet + '\'';
        sCode += ', \'' + iChangePosition + '\'';
        sCode += '); };';

        eval(sCode);
    } else {
        sCalendarInputDepartureId = '';
    }

    // -----

    if ( ! sInputReturnId ) {
        sInputReturnId = 'bsd';
    }

    oInputReturn = document.getElementById(sInputReturnId);

    if ( oInputReturn ) {
        sCalendarInputReturnId = sInputReturnId;

        sCode =  'oInputReturn.onclick = function(oEvent) { ';
        sCode += '  showCalendar(this, \'return\', \'' + sLicenseId + '\'';
        sCode += ', \'' + sTheme + '\'';
        sCode += ', \'' + sStyle + '\'';
        sCode += ', \'' + sButtons + '\'';
        sCode += ', \'' + sColorSet + '\'';
        sCode += ', \'' + iChangePosition + '\'';
        sCode += '); };';

        eval(sCode);
    } else {
        sCalendarInputReturnId = '';
    }
}

function vAddCalendarClickHandler(sElement, sDir, sInput, sLicenseId, sTheme,
    sStyle, sButtons, sColorSet, iChangePosition
) {
    oElement = document.getElementById(sElement);
    oInput = document.getElementById(sInput);
    if ( oElement ) {
        sCode =  'oElement.onclick = function(oEvent) { ';
        sCode += 'showCalendar(oInput, \'' + sDir + '\'';
        sCode += ', \'' + sLicenseId + '\'';
        sCode += ', \'' + sTheme + '\'';
        sCode += ', \'' + sStyle + '\'';
        sCode += ', \'' + sButtons + '\'';
        sCode += ', \'' + sColorSet + '\'';
        sCode += ', \'' + iChangePosition + '\'';
        sCode += '); };';
        eval(sCode);
    }
}

/**
 * sets the src for the calendar frame and reloads so the calendar
 * each time when the other direction is requested. We have to do that,
 * because we have only one frame for both dates.
 */
function loadCalendar(sLicenseId, sDirection, sTheme, sStyle, sButtons,
    sColorSet) {
    /* alert('loadCalendar("' + sLicenseId + '", "' + sDirection + '", "'
        + sTheme + '", "' + sStyle + '", "' + sButtons + '", "'
        + sColorSet + '")'); */

    // get the actual departure date from the form input
    var sDepartureDate = '';

    var oDepartureDate = document.getElementById(sCalendarInputDepartureId);

    if ( oDepartureDate ) {
        sDepartureDate = oDepartureDate.value;
    }

    // -----
    // get the actual return date from the form
    var sReturnDate = '';

    var oReturnDate = document.getElementById(sCalendarInputReturnId);

    if ( oReturnDate ) {
        sReturnDate = oReturnDate.value;
    }

    // -----------------------------------------------------------------------
    // collect the url with its parameters
    var sURL = '/interface/addons/Calendar/index.php?cfg=' + sLicenseId
        + '&sda=parent.setDatesFromCalendar&cca=parent.hideCalendar';

    if ( '' != sDepartureDate ) {
        sURL += '&dpd=' + sDepartureDate;
    }

    if ( '' != sReturnDate ) {
        sURL += '&rtd=' + sReturnDate;
    }

    switch ( sDirection ) {
        case 'departure':
            sURL += '&dir=dep';

            break;
        case 'return':
            sURL += '&dir=ret';

            break;
    }

    if ( '' != sTheme ) {
        sURL += '&thm=' + sTheme;
    }

    if ( '' != sStyle ) {
        sURL += '&css=' + sStyle;
    }

    if ( '' != sButtons ) {
        sURL += '&btn=' + sButtons;
    }

    if ( '' != sColorSet ) {
        sURL += '&col=' + sColorSet;
    }

    if ( '' != sSessionID && '' != sSessionName) {
        sURL += '&' + sSessionName + '=' + sSessionID;
    }

    // -----------------------------------------------------------------------
    // get the frame object and set it's src, if src has changed.
    // this is the case each time, when we toggle the direction
    var oCalendarFrame = document.getElementById('calendarframe');

    if ( ! oCalendarFrame ) {
        return true;
    }

    if ( oCalendarFrame.src != sURL ) {
        oCalendarFrame.src = sURL;
    }
}

/**
 * gets the position and dimensions of the date input fields and calls
 * showCalendarWhenLoaded(), which displays the calendar on the
 * appropriate position
 */
function showCalendar(oInputElement, sDirection, sLicenseId,
    sTheme, sStyle, sButtons, sColorSet, iChangePosition) {
    /* alert('showCalendar("' + oInputElement + '", "' + sDirection + '", "'
        + sLicenseId + '", "' + sTheme + '", "' + sStyle + '", "' + sButtons
        + '", "' + sColorSet + '", "' + iChangePosition + '")'); */

    var iInpHeight = oInputElement.offsetHeight || 0;
    var iInpWidth  = oInputElement.offsetWidth  || 0;

    var aPosition = getElementPosition(oInputElement);

    var iInpTop  = aPosition[0];
    var iInpLeft = aPosition[1];

    oCalendarParentForm = oInputElement.form;

    // -----------------------------------------------------------------------

    var oCalendarFrame = document.getElementById('calendarframe');

    if ( ! oCalendarFrame ) {
        return false;
    }

    // -----------------------------------------------------------------------

    iCalendarRetryCounter = 0;

    if ( document.addEventListener ) {
        oCalendarFrame.onload = function(oEvent) {
            showCalendarWhenLoaded(iInpTop, iInpLeft, iInpHeight, iInpWidth,
                iChangePosition);
        };
    }

    loadCalendar(sLicenseId, sDirection, sTheme, sStyle, sButtons, sColorSet);

    if ( ! oCalendarFrame.onload || ! document.addEventListener ) {
        showCalendarWhenLoaded(iInpTop, iInpLeft, iInpHeight, iInpWidth,
            iChangePosition);
    }
}

/**
 * hides the calendar and displays again form elements which we have
 * hidden that they don't shine through the calendar; hides the spacer element
 */
function hideCalendar() {
    var oCalendar = document.getElementById('calendar');

    if ( ! oCalendar ) {
        return true;
    }

    oCalendar.style.visibility = 'hidden';
    oCalendar.style.top = '-999px';

    // -----
    // redisplay form elements
    iHiddenElements = aHiddenForCalendar.length;

    for ( iHiddenIndex = 0; iHiddenIndex < iHiddenElements; iHiddenIndex++ ) {
        aHiddenForCalendar[iHiddenIndex].style.visibility = 'visible';

        aHiddenForCalendar[iHiddenIndex].disabled = false;
    }

    // -----------------------------------------------------------------------
    // Hide the spacer
    var oCalendarSpacer = document.getElementById('calendarspacer');

    if ( oCalendarSpacer ) {
        oCalendarSpacer.style.height     = '0px';
        oCalendarSpacer.style.visibility = 'hidden';
    }

    // -----------------------------------------------------------------------

    var oFooter = document.getElementById('footer');

    if ( ! oFooter ) {
        return true;
    }

    oFooter.style.visibility = 'visible';

    // -----------------------------------------------------------------------

    return false;
}

/**
 * sets the values coming from the calendar into the fields vnd resp. bsd
 * of the search form and hides the calendar
 *
 * @params string
 * @params string
 */
function setDatesFromCalendar(sDepartureDate, sReturnDate) {
    if ( '' != sDepartureDate ) {
        oDepartureDate = document.getElementById(sCalendarInputDepartureId);

        if ( oDepartureDate ) {
            oDepartureDate.value = sDepartureDate;
        }
    }

    // -----------------------------------------------------------------------

    if ( '' != sReturnDate ) {
        oReturnDate = document.getElementById(sCalendarInputReturnId);

        if ( oReturnDate ) {
            oReturnDate.value = sReturnDate;
        }
    }

    // -----------------------------------------------------------------------

    hideCalendar();

    // -----------------------------------------------------------------------

    return true;
}

/**
 * checks whether the frame already exists
 */
function isCalendarReady() {
    var sState = '';

    if ( ! document.all ) {
        var oCalendarFrame = document.getElementById('calendarframe');

        if ( ! oCalendarFrame ) {
            return false;
        }

        sState = oCalendarFrame.contentDocument.readyState;
    } else if ( document.all ) {
        var oCalendarFrame = document.frames('calendarframe');

        if ( ! oCalendarFrame ) {
            return false;
        }

        sState = oCalendarFrame.document.readyState;
    }

    // -----------------------------------------------------------------------

    return ! sState || 'complete' == sState;
}

/**
 * checks whether calendar iframe is loaded; sets the frame's height;
 * calculates the height for a spacer element, which moves elements, which are
 * following the search mask, downwards and sets the spacer visible; hides
 * elements in the form, to avoid that they shine through the calendar
 * and makes the calendar visible
 */
function showCalendarWhenLoaded(iInpTop, iInpLeft, iInpHeight, iInpWidth,
    iChangePosition
) {
    // does the frame already exist
    if ( isCalendarReady() ) {
        iCalendarRetryCounter = 0;

        // -------------------------------------------------------------------

        var oCalendar = document.getElementById('calendar');

        if ( ! oCalendar ) {
            return true;
        }

        // -------------------------------------------------------------------
        // set the frame's height
        var iCalendarContentHeight = 0;

        if ( ! document.all ) {
            var oCalendarFrame = document.getElementById('calendarframe');

            if ( oCalendarFrame ) {
                iCalendarContentHeight =
                    oCalendarFrame.contentDocument.height;

                oCalendarFrame.style.height = iCalendarContentHeight + 'px';
            }
        } else if ( document.all ) {
            var oCalendarFrame = document.frames('calendarframe');

            if ( oCalendarFrame ) {
                iCalendarContentHeight =
                    oCalendarFrame.document.body.scrollHeight;

                document.all.calendarframe.style.height
                    = iCalendarContentHeight + 'px';
            }
        }

        // -------------------------------------------------------------------

        var oFooter = document.getElementById('footer');

        if ( oFooter ) {
            oFooter.style.visibility = 'hidden';
        }

        // -------------------------------------------------------------------
        // Set the calendars top and left position
        var iCalendarTop = iInpTop + iInpHeight + 3;
        oCalendar.style.top = iCalendarTop + 'px';

        // we want to stay in IBE ... ;)
        oCalendar.style.left = '0px';

        // -------------------------------------------------------------------
        // prepare the spacers height and make it visible
        var iCalendarParentFormHeight = oCalendarParentForm.offsetHeight || 0;
        var iDifference = 0;

        if ( 0 < iCalendarParentFormHeight ) {
            var aPosition = getElementPosition(oCalendarParentForm);

            iFormTop  = aPosition[0];
            iFormLeft = aPosition[1];

            iDifference = (iCalendarContentHeight + iInpTop - iFormTop)
                - iCalendarParentFormHeight;

            if ( 0 < iDifference ) {
                var oCalendarSpacer = document.getElementById(
                    'calendarspacer');

                if ( oCalendarSpacer ) {
                    oCalendarSpacer.style.height     = iDifference + 'px';
                    oCalendarSpacer.style.visibility = 'visible';
                }
            }
        }

        // -------------------------------------------------------------------
        // hide form alements which are in the way
        var aHideTags = new Array('input', 'select', 'label');

        aHiddenForCalendar = new Array();

        var iForms = document.forms.length;
        var iTags  = aHideTags.length;

        for ( iFormIndex = 0; iFormIndex < iForms; iFormIndex++ ) {
            for ( iTagIndex = 0; iTagIndex < iTags; iTagIndex++ ) {
                sTag = aHideTags[iTagIndex];

                var aElements =
                    document.forms[iFormIndex].getElementsByTagName(sTag);

                var iElements = aElements.length;

                for ( iElmIndex = 0; iElmIndex < iElements; iElmIndex++ ) {
                    oFormElement = aElements[iElmIndex];

                    if ( 'hidden' == oFormElement.type ) {
                        continue;
                    }

                    var aPosition = getElementPosition(oFormElement);

                    iElementTop  = aPosition[0];
                    iElementLeft = aPosition[1];

                    if (iElementTop <= iInpTop ||
                        iElementTop >= (iInpTop + iCalendarContentHeight + 10)
                    ) {
                        continue;
                    }

                    oFormElement.style.visibility = 'hidden';

                    aHiddenForCalendar.push(oFormElement);
                }
            }
        }

        // -------------------------------------------------------------------

        if( 1 == iChangePosition ) {

        	oCalendarFrame.style.position	= 'absolute';
        	oCalendarFrame.style.top		= iCalendarTop + 'px';

        }

        oCalendar.style.visibility = 'visible';

        return true;
    } else if ( iCalendarRetryCounter < iCalendarMaxRetries ) {
        iCalendarRetryCounter++;

        sFunction = 'showCalendarWhenLoaded('
            + iInpTop + ', ' + iInpLeft + ', '
            + iInpHeight + ', ' + iInpWidth + ')';

        setTimeout(sFunction, iCalendarRetrySleep);
    }
}

function getElementPosition(oElement) {
    var iTop = 0; iLeft = 0;

    while ( oElement && 'complete_block' != oElement.id ) {
        iTop  += oElement.offsetTop  || 0;
        iLeft += oElement.offsetLeft || 0;

        oElement = oElement.offsetParent;
    }

    // -----------------------------------------------------------------------

    return new Array(iTop, iLeft);
}

function vChangeMMC() {
    var iDuration = iGetDuration();
    var oDeparture = oGetDepartureDate();
    var oReturn = oGetReturnDate()
    if (oDeparture.getTime() >= oReturn.getTime()) {
        vAlert(1);
    } else if ((oDeparture.getTime() + iDuration) >
        oReturn.getTime()
    ) {
        vAlert(2);
    }
}

/**
 * returns the duration of the trip in milliseconds; one can use this value
 * to add to the value, returned by the getTime() function of js date object
 */
function iGetDuration() {
    var iDuration = 0;
    var iMilliSecondsPerDay = 60 * 60 * 24 * 1000;
    oMMC = document.getElementById('mmc');
    if (!oMMC) {
        oMMC = document.getElementById('cboMMC');
    }
    if (oMMC) {
        var sRegX = /(\d+)-(\d+)t/;
        oErgebnis = sRegX.exec(oMMC.value);
        if (oErgebnis) {
            return oErgebnis[1] * iMilliSecondsPerDay;
        }
        sRegX = /(\d+)t/;
        oErgebnis = sRegX.exec(oMMC.value);
        if (oErgebnis) {
            return oErgebnis[1] * iMilliSecondsPerDay;
        }
        sRegX = /(\d+)w/;
        oErgebnis = sRegX.exec(oMMC.value);
        if (oErgebnis) {
            return oErgebnis[1] * 7 * iMilliSecondsPerDay;
        }
    }
    return 0;
}

function oGetReturnDate() {
    var oBSD = document.getElementById(sCalendarInputReturnId);
    if (oBSD) {
        aReturn = oBSD.value.split('.');
        oReturn = new Date(aReturn[2], aReturn[1] - 1,
            aReturn[0]);
        return oReturn;
    }
    return false;
}

function oGetDepartureDate() {
    var oVND = document.getElementById(sCalendarInputDepartureId);
    if (oVND) {
        aDeparture = oVND.value.split('.');
        oDeparture = new Date(aDeparture[2], aDeparture[1] - 1,
            aDeparture[0]);
        return oDeparture;
    }
    return false;
}

function vAlert(iErrNo) {
    switch (iErrNo) {
    case 1:
        if (sIBECharset == 'UTF-8') {
            sErrMsg = "Achtung: Das Hinreisedatum, das Sie ausgewÃ¤hlt " +
                "haben, liegt nach dem RÃ¼ckreisedatum. Passen Sie " +
                "bitte auch das RÃ¼ckreisedatum entsprechend an.";
        } else {
            sErrMsg = "Achtung: Das Hinreisedatum, das Sie ausgewählt " +
                "haben, liegt nach dem Rückreisedatum. Passen Sie " +
                "bitte auch das Rückreisedatum entsprechend an.";
        }
        break;
    case 2:
        if (sIBECharset == 'UTF-8') {
            sErrMsg = "Achtung: Die Reisedauer, die Sie eingestellt " +
                "haben, ist lÃ¤nger als der Zeitraum zwischen dem " +
                "An- und Abreisedatum.";
        } else {
            sErrMsg = "Achtung: Die Reisedauer, die Sie eingestellt " +
                "haben, ist länger als der Zeitraum zwischen dem " +
                "An- und Abreisedatum.";
        }
        break;
    default:
        sErrMsg = "Ein unbekannter Fehler ist aufgetreten. ErrNr " + iErrNo;
    }
    alert(sErrMsg);
}

/*
function autoIframe(frameId) {

    try{

        frame = document.getElementById(frameId);
        innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
        objToResize = (frame.style) ? frame.style : frame;
        objToResize.height = innerDoc.body.scrollHeight + 10;

    }
    catch(err){

        window.status = err.message;

    }

}

function getIframeHeight() {

    if(document.getElementById && !(document.all)) {

        h = document.getElementById('VacancyCheck').contentDocument.body.scrollHeight;
        document.getElementById('VacancyCheck').style.height = h+'px';

    }
    else if(document.all) {

        h = document.frames('VacancyCheck').document.body.scrollHeight;
        document.all.VacancyCheck.style.height = h;

    }
    else {

        window.status = err.message;

    }

}

*/

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["VacancyCheck"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {

    var dyniframe=new Array()

    for (i=0; i<iframeids.length; i++){

        if (document.getElementById)

        resizeIframe(iframeids[i])
        //reveal iframe for lower end browsers? (see var above):

        if ((document.all || document.getElementById) && iframehide=="no"){

            var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])

            tempobj.style.display="block"

        }

    }

}

function resizeIframe(frameid) {
    var currentfr=document.getElementById(frameid)
    if (currentfr && !window.opera) {
        currentfr.style.display = "block"

        if (currentfr.contentDocument &&
            !currentfr.contentDocument.documentMode &&
            currentfr.contentDocument.body.offsetHeight
        ) {
            // ns6 syntax
            currentfr.height =
                currentfr.contentDocument.body.offsetHeight+FFextraHeight;
        } else if (currentfr.Document && currentfr.Document.body.scrollHeight
        ) {
            // ie5+ syntax
            currentfr.height = currentfr.Document.body.scrollHeight;
        }

        if (currentfr.addEventListener)
            currentfr.addEventListener("load", readjustIframe, false)
        else if (currentfr.attachEvent) {
            currentfr.detachEvent("onload", readjustIframe) // Bug fix line
            currentfr.attachEvent("onload", readjustIframe)
        }
    }
}

function readjustIframe(loadevt) {

    var crossevt=(window.event)? event : loadevt

    var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement

    if (iframeroot)
        resizeIframe(iframeroot.id);

}

function loadintoIframe(iframeid, url) {

    if (document.getElementById)
        document.getElementById(iframeid).src=url

}

if (window.addEventListener) {
    window.addEventListener("load", resizeCaller, false);
}
else if (window.attachEvent) {
    window.attachEvent("onload", resizeCaller);
}
else {
    window.onload=resizeCaller;
}

/**
 * @author   J.Rosswog
 */

displayed = '';

function show_hotelinfo(sLayerId, sLayerHsc, sType, sUrl) {

	/** set Iframe Src for Video and FlipCat **/

	setIframeSrc('VacancyCheck_', sLayerHsc, sType);

    /** close opened layer **/

    if( displayed ) {

        close_hotelinfo(sLayerId, displayed);

    }

    /* load on demand */
    try {
        oIFrame = document.getElementById('VacancyCheck_' + sLayerHsc);

        if ( oIFrame && '' != sHotelInfoBase ) {
            oIFrame.src = sHotelInfoBase.replace(/&amp;/g, '&')
                + '&hsc=' + sLayerHsc;
        }
    } catch ( oException ) {}

    /** open layer **/

    open_hotelinfo(sLayerId, sLayerHsc);

    /** set iframe-height for the content **/
    /** to set the correct size for the iframe - the iframe should be opened **/

    resizeIframe('VacancyCheck_' + sLayerHsc);

}

function open_hotelinfo(sLayerId, sLayerHsc) {
    /* the media data layer it self */
    oLayer = document.getElementById(sLayerId + sLayerHsc);
    /* the button, to make the media data visible  */
    oBlockImgHotelInfo = document.getElementById(
        'ImageHotelInfo_' + sLayerHsc);
    /* the button to close media info */
    oBlockImgHotelInfoClose = document.getElementById(
        'ImageHotelInfoClose_' + sLayerHsc);
    /* the button at the bootom of the media info to close media info */
    oBlockImgHotelBottomClose = document.getElementById(
        'ImageHotelInfoBottomClose_' + sLayerHsc);
    oBlockMediaData = document.getElementById('hotel_img_block_' + sLayerHsc);

    if( oLayer ) {

        oLayer.style.visibility = 'visible';
        oLayer.style.display    = 'block';
        oLayer.style.height     = '100%';
        //oLayer.style.background = '#f3f4f6';

    }

    if( oBlockImgHotelInfo ) {

        oBlockImgHotelInfo.style.visibility = 'hidden';
        oBlockImgHotelInfo.style.display    = 'none';

    }

    if( oBlockImgHotelInfoClose ) {

        oBlockImgHotelInfoClose.style.visibility    = 'visible';
        oBlockImgHotelInfoClose.style.display       = 'inline';
        oBlockImgHotelInfoClose.style.height        = '25px';

    }

    if( oBlockImgHotelBottomClose ) {

    	oBlockImgHotelBottomClose.style.visibility		= 'visible';
        oBlockImgHotelBottomClose.style.display			= 'inline';
        oBlockImgHotelBottomClose.style.height			= '25px';
        //oBlockImgHotelBottomClose.style.position		= 'absolute';
        //oBlockImgHotelBottomClose.style.right			= '4px';


    }

    if( oBlockMediaData ) {

    	alert(oBlockMediaData.style.visibility);

    	oBlockMediaData.style.visibility	= 'visible';
    	oBlockMediaData.style.display		= 'block';

    }

    displayed = sLayerHsc;

}

function close_hotelinfo(sLayerId, sLayerHsc) {

    oHscLayer = document.getElementById(sLayerId + sLayerHsc);
    oBlockImgHotelInfo = document.getElementById('ImageHotelInfo_' + sLayerHsc);
    oBlockImgHotelInfoClose = document.getElementById('ImageHotelInfoClose_' + sLayerHsc);
    oBlockImgHotelBottomClose = document.getElementById('ImageHotelInfoBottomClose_' + sLayerHsc);

    if( oHscLayer ) {

        oHscLayer.style.visibility = 'hidden';
        oHscLayer.style.display    = 'none';

    }

    /** Close Button Hidden **/

    if ( oBlockImgHotelInfoClose ) {

        oBlockImgHotelInfoClose.style.visibility    = 'hidden';
        oBlockImgHotelInfoClose.style.display       = 'none';

    }

    /** Close Bottom Button Hidden **/

    if ( oBlockImgHotelBottomClose ) {

        oBlockImgHotelBottomClose.style.visibility    = 'hidden';
        oBlockImgHotelBottomClose.style.display       = 'none';

    }

    /** Hotelinfo Button Visible **/

    if( oBlockImgHotelInfo ) {

        oBlockImgHotelInfo.style.visibility = 'visible';
        oBlockImgHotelInfo.style.display    = 'inline';

    }

}

function setIframeSrc(sLayerName, sLayerHsc, sType) {

	oIframe = document.getElementById(sLayerName + sLayerHsc);

    if( oIframe ) {

    	if( sType ) {

    		switch(sType) {

				case 'video' :

					oIframe.src = oIframe.src + '&multimedia_category=video';

					break;

				case 'flipcat' :

					oIframe.src = oIframe.src + '&multimedia_category=flipcat';

					break;

    		}

    	}

    }

}

function showPopUp(w, h, site) {

	x = screen.availWidth/2-w/2;
    y = screen.availHeight/2-h/2;

    var popupWindow = window.open('','','width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y+', scrollbars=yes');

    popupWindow.document.location.href=site;

}

/**
 * @author   J.Rosswog
 */ 
 
function showVoteInfo(sId, sMod) {
    
    oLayer = document.getElementById(sId);
    
    if( oLayer ) {
        
        if( sMod == 'show') {
    
            oLayer.style.visibility = 'visible';
            oLayer.style.display    = 'block';
            oLayer.style.width      = '150px';
            oLayer.style.color      = '#9AB0D0';
            oLayer.style.textAlign  = 'left';
            oLayer.innerHTML        = 'powered by holidaycheck';
            
        }
        else {
            
            oLayer.style.visibility = 'hidden';
            oLayer.style.display    = 'none';
            
        }
        
    }

}


var iVisibleRegion = 0;
/*
var iPadding = 7; // bottom padding of #regionlist
var iMargin = 20; // temporary margin of region
var iLineHeight = 26; // height of a single destination line
*/
var iPadding = 7; // bottom padding of #regionlist
var iMargin = 1; // temporary margin of region
var iLineHeight = 26; // height of a single destination line



function hideDestinations(iId) {
  oRegionNext = findObj('reg' + ( iId + 1 ));
  oRegionSelf = findObj('reg' + iId);

  if ( null != oRegionNext ) {
    if ( oRegionNext.style ) {
      oRegionNext = oRegionNext.style;
    }

    oRegionNext.marginTop = '0px';
  } else {
    oRegionNext = findObj('regionlist');

    if ( oRegionNext.style ) {
      oRegionNext = oRegionNext.style;
    }

    oRegionNext.paddingBottom = iPadding + 'px';
  }

  if ( null != oRegionSelf ) {
    if ( oRegionSelf.style ) {
      oRegionSelf = oRegionSelf.style;
    }

    oRegionSelf.marginTop = '0px';
  }

  showHideLayers('dest' + iId, 'hide');
}

function showDestinations(iId, iRows) {
    if ( 0 < iVisibleRegion ) {
        hideDestinations(iVisibleRegion);
    }

    if ( iId == iVisibleRegion ) {
        iVisibleRegion = 0;
        return;
    }

    iVisibleRegion = 0;

    oRegionSelf = findObj('reg' + iId);
    oRegionNext = findObj('reg' + ( iId + 1 ));

    if ( null != oRegionSelf ) {
        if ( oRegionSelf.style ) {
            oRegionSelf = oRegionSelf.style;
        }

        oRegionSelf.marginTop = iMargin + 'px';

        if ( null != oRegionNext ) {
            if ( oRegionNext.style ) {
                oRegionNext = oRegionNext.style;
            }

            if ( 0 == iLineHeight ) {
                oDestinationsSelf = findObj('dest' + iId);

                oRegionNext.marginTop = oDestinationsSelf.offsetHeight + 'px';
            } else {
                oRegionNext.marginTop =
                    (((iRows * iLineHeight) + 1) + iMargin) + 'px';
            }
        } else {
            oRegionNext = findObj('regionlist');

            if ( oRegionNext.style ) {
                oRegionNext = oRegionNext.style;
            }

            if ( 0 == iLineHeight ) {
                oDestinationsSelf = findObj('dest' + iId);

                oRegionNext.paddingBottom =
                    oDestinationsSelf.offsetHeight + 'px';
            } else {
                oRegionNext.paddingBottom = ((iRows * iLineHeight) + 1) + 'px';
            }
        }

        showHideLayers('dest' + iId, 'show');

        iVisibleRegion = iId;
    }
}

function findObj(sName, oParent) {
  var iPosition, iIndex, oFindMe;

  if ( ! oParent ) {
      oParent = document;
  }

  if ( (iPosition = sName.indexOf('?')) > 0 && parent.frames.length ) {
    oParent = parent.frames[sName.substring(iPosition + 1)].document;
    sName = sName.substring(0, iPosition);
  }

  if ( ! (oFindMe = oParent[sName]) && oParent.all ) {
    oFindMe = oParent.all[sName];
  }

  for ( iIndex = 0; ! oFindMe && iIndex < oParent.forms.length; iIndex++ ) {
    oFindMe = oParent.forms[iIndex][sName];
  }

  for ( iIndex = 0; ! oFindMe && oParent.layers && iIndex < oParent.layers.length; iIndex++ ) {
    oFindMe = findObj(sName, oParent.layers[iIndex].document);
  }

  if ( ! oFindMe && oParent.getElementById ) {
    oFindMe = oParent.getElementById(sName);
  }

  return oFindMe;
}

function showHideLayers() {
  var iIndex, sVisibility, oLayer;
  var aArguments = showHideLayers.arguments;

  for ( iIndex = 0; iIndex < (aArguments.length - 1); iIndex += 2 ) {
    if ( null != (oLayer = findObj(aArguments[iIndex])) ) {
      sVisibility = aArguments[iIndex + 1];

      if ( oLayer.style ) {
        oLayer = oLayer.style;
      }

      if ( sVisibility == 'show' ) {
        sVisibility = 'visible';
      } else if( sVisibility == 'hide' ) {
        sVisibility = 'hidden';
      }

      oLayer.visibility = sVisibility;
    }
  }
}

function openMap(iValue) {

    sRegionParam = '&regid=' + (iValue-1);

    if( iValue ) {

        oIframe = document.getElementById('MapModul');

        sIframeSrc = oIframe.src + sRegionParam;

        oIframe.src = sIframeSrc;

    }

}

/**
 * @author: Johannes Rosswog, <rosswog at traffics dot de>
 */ 

function activateFilterElement(oForm, sId) {
	
	oSortElement = document.getElementById(sId);
	
	oSortElement.checked = false;
		
	if( oForm ) {
		
		oForm.submit();
		
	}
	
}

/**
 * function library to display and hide a hotel image in the biggest
 * format and a couple of thumbnails to toggle the main image
 *
 * @used in step 4
 * @author   <schwarz@traffics.de>
 * @version  $Id: hotelimageswitch.js 0 2008-09-26 10:00:00Z hschwarz $
 */

var oImagePopup;
iMaxRetries = 5;
/**
 * Makes the layer/div visible and fills the image container in the layer
 * with a new image with sImageUrl as source
 *
 * @param string sLayerDivId
 * @param string sImageDivId
 * @param string sImageUrl
 */
function vOpenHotelImage(sLayerDivId, sImageDivId, sImageUrl) {
	if (top == self) {
    
        iRetryCounter = 0;

        /* the Layer to show and hide as global var*/
        oLayerDiv = document.getElementById(sLayerDivId);
        /* the container in which we place a the image as global var */
        oImageDiv = document.getElementById(sImageDivId);

        /* create an image tag */
        oImage = document.createElement('img');
        oImage.src 	= sImageUrl;
        oImage.alt	= 'Hotelbild';
        oImage.id	= 'imgHotelBigFormat';
		
		if (oLayerDiv) {
			// append image into document structure
			if (oImageDiv) {
                if(oImageDiv.hasChildNodes()){
                    /* delete childnodes*/
                    oImageDiv.removeChild(oImageDiv.firstChild);
                }
                oImageDiv.appendChild(oImage);
			}
			oLayerDiv.style.display = 'block';
			// set position of the parent object
			sFunction = 'vSetPositionWhenLoaded()';
			var oImagePopupFlag = setTimeout(sFunction, 300);
		}
	} else {
		
		var sImageTag = '<div align="center"><a href="javascript:self.close()"><img src="' + sImageUrl + '" alt="" /></a></div>';
		
		/* close popup */
		if(oImagePopup != undefined) {
			oImagePopup.close();
		}
		/* open popup */
		oImagePopup = window.open("","oImagePopup","width=10,height=10,resizable=yes,scrollbars=no,location=no");
        
		/* write content */
        oImagePopup.document.open();
        oImagePopup.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\"><html><head><title></title>\n");
        oImagePopup.document.write("<style type=\"text/css\"><!-- body,div,img{border:0;margin:0;padding:0}-->");
        oImagePopup.document.write(" </style></head><body>\n" + sImageTag + "</body></html>\n");
        oImagePopup.document.close();
    
        var oImagePopupFlag = setTimeout(function(){
            oImagePopup.window.resizeTo(oImagePopup.document.images[0].width, oImagePopup.document.images[0].height+70);
            oImagePopup.window.focus();
        }, 300);
	}
}

/**
 * Sets the layer/div to display none and removes the image from the container
 *
 * @param string sLayerDivId
 * @param string sImageDivId
 */
function vCloseHotelImage(sLayerDivId, sImageDivId) {
	var oLayerDiv = document.getElementById(sLayerDivId);
	var oImageDiv = document.getElementById(sImageDivId);
	var oImage = document.getElementById('imgHotelBigFormat');

	if (oLayerDiv) {
		oLayerDiv.style.display = 'none';
	}

	if  (oImage && oImageDiv) {
	    oImageDiv.removeChild(oImage);
	}
}

/**
 * Replaces the big image by this image
 *
 * @param string sImageUrl
 */
function vSetImage(sImageUrl) {
    iRetryCounter = 0;

	/* remove previous image */
    oImage = document.getElementById('imgHotelBigFormat');
	if  (oImage && oImageDiv) {
	   oImageDiv.removeChild(oImage);
	}
    /* create new image tag */
	oImage = document.createElement('img');
	oImage.src 	= sImageUrl;
	oImage.id	= 'imgHotelBigFormat';

	if (oLayerDiv) {
        // append image tag into the document
	    if (oImageDiv) {
			oImageDiv.appendChild(oImage);
		}
        // set position of the parent object
        sFunction = 'vSetPositionWhenLoaded()';
        setTimeout(sFunction, 300);
	}
}

/**
 * sets the position of the container which holds the big hotel image
 * it first checks whether the new picture is already loaded otherwise
 * it calls itself maximal iMaxRetries times
 */
function vSetPositionWhenLoaded() {
    if (oImage.complete == true) {
        iWidth = oImage.width;
    	// set container's left position
	    oParent = oLayerDiv.parentNode;
        iLeft =  Math.floor((oParent.offsetWidth - iWidth) / 2);
		oLayerDiv.style.left = iLeft + 'px';
    } else if (iRetryCounter < iMaxRetries) {
        iRetryCounter++;
        sFunction = 'vSetPositionWhenLoaded()';
        setTimeout(sFunction, 1000);
    }
}

/*  Prototype JavaScript framework
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
/*--------------------------------------------------------------------------*/

//note: modified & stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).

var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	}
}

Object.extend = function(destination, source) {
	for (property in source) destination[property] = source[property];
	return destination;
}

Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

Function.prototype.bindAsEventListener = function(object) {
var __method = this;
	return function(event) {
		__method.call(object, event || window.event);
	}
}

function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;

	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
}

if (!window.Element) var Element = new Object();

Object.extend(Element, {
	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},

	hasClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var hasClass = false;
		element.className.split(' ').each(function(cn){
			if (cn == className) hasClass = true;
		});
		return hasClass;
	},

	addClassName: function(element, className) {
		element = $(element);
		Element.removeClassName(element, className);
		element.className += ' ' + className;
	},
  
	removeClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var newClassName = '';
		element.className.split(' ').each(function(cn, i){
			if (cn != className){
				if (i > 0) newClassName += ' ';
				newClassName += cn;
			}
		});
		element.className = newClassName;
	},

	cleanWhitespace: function(element) {
		element = $(element);
		$c(element.childNodes).each(function(node){
			if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node);
		});
	},

	find: function(element, what) {
		element = $(element)[what];
		while (element.nodeType != 1) element = element[what];
		return element;
	}
});

var Position = {
	cumulativeOffset: function(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop  || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
	}
};

document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = [];
	$c(children).each(function(child){
		if (Element.hasClassName(child, className)) elements.push(child);
	});  
	return elements;
}

//useful array functions
Array.prototype.iterate = function(func){
	for(var i=0;i<this.length;i++) func(this[i], i);
}
if (!Array.prototype.each) Array.prototype.each = Array.prototype.iterate;

function $c(array){
	var nArray = [];
	for (var i=0;i<array.length;i++) nArray.push(array[i]);
	return nArray;
}

/*
moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
for more info (http://moofx.mad4milk.net).
Sunday, March 05, 2006
v 1.2.3
*/

var fx = new Object();
//base
fx.Base = function(){};
fx.Base.prototype = {
	setOptions: function(options) {
	this.options = {
		duration: 500,
		onComplete: '',
		transition: fx.sinoidal
	}
	Object.extend(this.options, options || {});
	},

	step: function() {
		var time  = (new Date).getTime();
		if (time >= this.options.duration+this.startTime) {
			this.now = this.to;
			clearInterval (this.timer);
			this.timer = null;
			if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
		}
		else {
			var Tpos = (time - this.startTime) / (this.options.duration);
			this.now = this.options.transition(Tpos) * (this.to-this.from) + this.from;
		}
		this.increase();
	},

	custom: function(from, to) {
		if (this.timer != null) return;
		this.from = from;
		this.to = to;
		this.startTime = (new Date).getTime();
		this.timer = setInterval (this.step.bind(this), 13);
	},

	hide: function() {
		this.now = 0;
		this.increase();
	},

	clearTimer: function() {
		clearInterval(this.timer);
		this.timer = null;
	}
}

//stretchers
fx.Layout = Class.create();
fx.Layout.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.el.style.overflow = "hidden";
		this.iniWidth = this.el.offsetWidth;
		this.iniHeight = this.el.offsetHeight;
		this.setOptions(options);
	}
});

fx.Height = Class.create();
Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.height = this.now + "px";
	},

	toggle: function() {
		if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
		else this.custom(0, this.el.scrollHeight);
	}
});

fx.Width = Class.create();
Object.extend(Object.extend(fx.Width.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.width = this.now + "px";
	},

	toggle: function(){
		if (this.el.offsetWidth > 0) this.custom(this.el.offsetWidth, 0);
		else this.custom(0, this.iniWidth);
	}
});

//fader
fx.Opacity = Class.create();
fx.Opacity.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.now = 1;
		this.increase();
		this.setOptions(options);
	},

	increase: function() {
		if (this.now == 1 && (/Firefox/.test(navigator.userAgent))) this.now = 0.9999;
		this.setOpacity(this.now);
	},
	
	setOpacity: function(opacity) {
		if (opacity == 0 && this.el.style.visibility != "hidden") this.el.style.visibility = "hidden";
		else if (this.el.style.visibility != "visible") this.el.style.visibility = "visible";
		if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + opacity*100 + ")";
		this.el.style.opacity = opacity;
	},

	toggle: function() {
		if (this.now > 0) this.custom(1, 0);
		else this.custom(0, 1);
	}
});

//transitions
fx.sinoidal = function(pos){
	return ((-Math.cos(pos*Math.PI)/2) + 0.5);
	//this transition is from script.aculo.us
}
fx.linear = function(pos){
	return pos;
}
fx.cubic = function(pos){
	return Math.pow(pos, 3);
}
fx.circ = function(pos){
	return Math.sqrt(pos);
}

/**
 * @author Johannes Rosswog
 */ 

aImages = new Array();
var iCnt = 0;
size = '&size=800';

function init_images(sSrc) {
    
    aImages[iCnt] = sSrc;
    
    iCnt++;
                    
}

function switchPicture(what) {
     
    
    /*
    if(what == 'forward') {
        direction = 1;
    }
    else if(what == 'back') {
        direction = -1;
    }
    */
    
    direction = what;
    
    if (document.images) {
        
        
        ImgNum = ImgNum + direction;
        
        if (ImgNum > ImgLength) {
        
            ImgNum = 0;
        
        }
        
        if (ImgNum < 0) {
        
            ImgNum = ImgLength;
        
        }
        
        /*
        if(ImgNum == ImgLength) {
                        
            document.forward.src = sDisabledForward;
            
        }        
        */
        document.getElementById('link_hotel_image_big').href = aImages[ImgNum].replace(/&size=340/g, size);
        document.getElementById('link_hotel_block_img_bigger').href = aImages[ImgNum].replace(/&size=340/g, size);
        
        document.test_img_block.src = aImages[ImgNum];
   
    }
       
}

function layer_on(sDirection, sLayerId) {
    
    oElementLayer = document.getElementById(sLayerId);
    
    if(oElementLayer) {
    
        if(sDirection == 'back') {
               		
    		oElementLayer.innerHTML = 'Bildnavigation: Zurueck';
    		oElementLayer.style.visibility = 'visible';		
            
        }
        else if(sDirection == 'forward') {
            
            oElementLayer.innerHTML = 'Bildnavigation: Vorwaerts';
    		oElementLayer.style.visibility = 'visible';		
            
        }
        
    }
    else {
        
        return false;
        
    }
    
}

function layer_off(sDirection, sLayerId) {
    
    oElementLayer = document.getElementById(sLayerId);
    
    if(oElementLayer) {
    
        if(sDirection == 'back') {               		
    		
    		oElementLayer.style.visibility = 'hidden';		
            
        }
        
        else if(sDirection == 'forward') {
            
            oElementLayer.style.visibility = 'hidden';
            
        }
        
    }
    else {
        
        return false;
        
    }
    
}


/*
function showClip(sSrc) {

    oNavForwardLink = document.getElementById('Nav_Forward_Link');
    oNavBackLink = document.getElementById('Nav_Back_Link');
    oHotelBlockImages = document.getElementById('hotel_block_images');

    if(oHotelBlockImages) {
        oHotelBlockImages.innerHTML = '<iframe name="MovieClip" border="0" src="' + sSrc + '" width="450" height="400" frameborder="0"></iframe>';
    }

    //document.getElementById('hotel_block_images').innerHTML = '<iframe name="MovieClip" border="0" src="' + sSrc + '" width="450" height="400" frameborder="0"></iframe>';

    if(oNavForwardLink) {
        oNavForwardLink.style.visibility = 'hidden';
    }

    if(oNavBackLink) {
        oNavBackLink.style.visibility = 'hidden';
    }

}
*/

function showClip(w,h,site) {

    x = screen.availWidth/2-w/2;
    y = screen.availHeight/2-h/2;

    var popupWindow = window.open('','','width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y);

    popupWindow.document.location.href=site;

}

function activateHotelVideo(sUrlVideo) {
    oVideoBlock       = document.getElementById('hotel_block_video');
    oVideoIframeBlock = document.getElementById('hotel_block_video_iframe');
    oHotelBlockDetail = document.getElementById('hotel_block_detail');

    if ( oVideoIframeBlock && sUrlVideo ) {
        oVideoIframeBlock.src = sUrlVideo;
    }

    if ( oHotelBlockDetail ) {
        oHotelBlockDetail.style.visibility = 'hidden';
        oHotelBlockDetail.style.display       = 'none';
    }

    if ( oVideoBlock ) {
        oVideoBlock.style.visibility = 'visible';
        oVideoBlock.style.display    = 'block';

        if ( sBlockHeight ) {
            oVideoBlock.style.height = sBlockHeight + 'px';
        }

        // oVideoBlock.innerHTML            = sUrlVideo;
    }
}

function disableHotelVideo(sBlockId) {
    var oBlock            = document.getElementById(sBlockId);
    var oHotelBlockDetail = document.getElementById('hotel_block_detail');
    var oHotelBlockVideo  = document.getElementById('hotel_block_video_iframe');

    if ( oBlock ) {
        sBlockHeight = oBlock.clientHeight;

        oBlock.style.visibility    = 'hidden';
        oBlock.style.block        = 'none';
        oBlock.style.height        = '0px';
    }

    if ( oHotelBlockDetail ) {
        oHotelBlockDetail.style.visibility    = 'visible';
        oHotelBlockDetail.style.display        = 'block';
    }

    if ( oHotelBlockVideo ) {
        oHotelBlockVideo.src = '';
    }

}

/**
 * @author Johannes Rosswog
 */

var sTabNonActiveL = 'tab_non_active_l';
var sTabNonActiveM = 'hotel_block_tabs_non_active';
var sTabNonActiveR = 'tab_non_active_r';

var sTabActiveL = 'tab_active_l';
var sTabActiveM = 'hotel_block_tabs_active';
var sTabActiveR = 'tab_active_r';

var sTabIdL = '_l';
var sTabIdR = '_r';

function changeTabColor(sTabId) {

	oTabIdLeft = document.getElementById(sTabId + sTabIdL);
	oTabIdRight = document.getElementById(sTabId + sTabIdR);

    oTabId = document.getElementById(sTabId);

    for( i = 0; i < aTabs.length; i++ ) {

        if( document.getElementById(aTabs[i]) ) {

        	/** Altes Handling - Keine Runde Tab Navigation **/

        	if( document.getElementById(aTabs[i]) ) {

        		document.getElementById(aTabs[i]).className = 'hotel_block_tabs_non_active';

        	}

        	/** Neues Handling **/

            /** Left **/

            if( document.getElementById(aTabs[i] + sTabIdL) ) {

            	document.getElementById(aTabs[i] + sTabIdL).className = sTabNonActiveL;

            }

            /** Middle **/
            if( document.getElementById(aTabs[i]) ) {

            	document.getElementById(aTabs[i]).className = sTabNonActiveM;

            }

            /** Right **/
            if( document.getElementById(aTabs[i] + sTabIdR) ) {

            	document.getElementById(aTabs[i] + sTabIdR).className = sTabNonActiveR;

            }

        }

    }

    if( oTabId ) {

    	/** Altes Handling - Keine Runde Tab Navigation **/

    	if( !oTabIdLeft && !oTabIdRight ) {

    		oTabId.className = sTabActiveM;

    	}

    	/** Neues Handling **/

    	if( oTabIdLeft && oTabIdRight && oTabId ) {

    	    /** Left **/
	        oTabIdLeft.className = sTabActiveL;
	        /** Middle **/
	        oTabId.className = sTabActiveM;
	        /** Right **/
	        oTabIdRight.className = sTabActiveR;

    	}

    }

}

function setFirstActiveTab(sFirstActiveTab) {

	oTabL = document.getElementById(sFirstActiveTab + sTabIdL);
	oTabR = document.getElementById(sFirstActiveTab + sTabIdR);

    oTab = document.getElementById(sFirstActiveTab);

    if( oTab ) {

    	/** Altes Handling - Keine Runde Tab Navigation **/

    	if( !oTabL && !oTabR ) {

    		oTab.className = sTabActiveM;

    	}

    	/** Neues Handling **/

        if( oTabL && oTabR && oTab ) {

        	/** Left **/
        	oTabL.className = sTabActiveL;
        	/** Middle **/
        	oTab.className = sTabActiveM;
        	/** Right **/
        	oTabR.className = sTabActiveR;

        }

    }

}

function setActiveTab(sActiveTabID) {
    iLength = aTabs.length;

    for ( iIndex = 0; iIndex < iLength; iIndex++ ) {
        sTabID = aTabs[iIndex];

        if ( sActiveTabID == sTabID ) {
            sClassName = 'hotel_block_tab_active';
        } else {
            sClassName = '';
        }

        oTab = document.getElementById(sTabID);

        if ( oTab ) {
        	oTab.className = sClassName;
        }
    }

    return true;
}

/**
 * @author Johannes Rosswog
 */

var sImgBlockId = 'test_img_block';
var sImgLinkBig = 'link_hotel_block_img_bigger';
var sImgLinkHotBig = 'link_hotel_image_big';

function setImage(sImgUrlNormal, sImgUrlBig) {

	oImgBlock = document.getElementById(sImgBlockId);
	oImgBlockLinkBig = document.getElementById(sImgLinkBig);
	oImgBlockLinkHotBig = document.getElementById(sImgLinkHotBig);

	oBigImageLayer = document.getElementById('divHotelImageLayer');

	if (oImgBlock) {
		oImgBlock.src = sImgUrlNormal;
	}

	if (oImgBlockLinkBig) {
	    if (oBigImageLayer) {
		    oImgBlockLinkBig.href = "javascript:vOpenHotelImage(" +
		      "'divHotelImageLayer','divHotelImage','" + sImgUrlBig + "')";
	    } else {
	        oImgBlockLinkBig.href = sImgUrlBig;
	    }
	}

	if (oImgBlockLinkHotBig) {
	    if (oBigImageLayer) {
		    oImgBlockLinkHotBig.href = "javascript:vOpenHotelImage(" +
		      "'divHotelImageLayer','divHotelImage','" + sImgUrlBig + "')";
	    } else {
	        oImgBlockLinkHotBig.href = sImgUrlBig;
	    }
	}

}



//popup position Toni Ivanisevic
//'where' ist beide anfangsbuchstaben von PosX und PosY - Bsp. MR =MiddleRight
//bei weglassen von where is default = Zentriert

//Aufruf TopLeft (TL):  popup('xxx.html','whatever','TL','500','500','resizable=yes,scrollbars=yes');
var win = null;
function pop_up(mypage,myname,where,w,h,extras){    
  switch (where){
    case "TL" :
      LeftPos = 0;
      TopPos = 0;
      break;
    case "TM" :
      LeftPos = (screen.width) ? (screen.width-w)/2 : 0;
      TopPos = 0;
      break;
    case "TR" :
      LeftPos = (screen.width) ? (screen.width-w) : 0;
      TopPos = 0;
      break;
    case "ML" :
      LeftPos = 0;
      TopPos = (screen.height) ? (screen.height-h)/2 : 0;
      break;
    case "MR" :
      LeftPos = (screen.width) ? (screen.width-w) : 0;
      TopPos = (screen.height) ? (screen.height-h)/2 : 0;
      break;
    case "BL" :
      LeftPos = 0;
      TopPos = (screen.height) ? (screen.height-h) : 0;
      break;
    case "BM" :
      LeftPos = (screen.width) ? (screen.width-w)/2 : 0;
      TopPos = (screen.height) ? (screen.height-h) : 0;
      break;
    case "BR" :
      LeftPos = (screen.width) ? (screen.width-w) : 0;
      TopPos = (screen.height) ? (screen.height-h) : 0;
      break;
    default :
      LeftPos = (screen.width) ? (screen.width-w)/2 : 0;
      TopPos = (screen.height) ? (screen.height-h)/2 : 0;
      break;
  }
  TopPos-=25; //wegen Taskleiste
  settings ='height='+h+',width='+w+',top='+TopPos+',left='+LeftPos;
  if(extras!="")
    settings +=","+extras;
  win = window.open(mypage,myname,settings);
  if(win){win.focus();}
}

function showConditions(op){
    newwind(op);
}

function newwind(url) {
    var oben=screen.height;
    var links=screen.width;
    if(((links/2)- 440)>0){
        posx=((links/2)-220);
        }
        else{
        posx=20;
        }
    if(((oben/2)- 500)>0){
        posy=((oben/2)-250);
        }
        else{
        posy=20;
        }
fenster = window.open(url,'AGB','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=440,height=500,screenX='+posx+',screenY='+posy+',left='+posx+',top='+posy+'');
fenster.focus();
}

