﻿var doOnce=false;

function updateAvailIndividual(depDate, retDate)
{
    var mySubSet = hotelSubset();

    for (i=0; i<mySubSet.length; i++)
    {
        var hotid=mySubSet[i].id;
        var divCont = '<img src="/App_Image/icon/avail_wait.gif" style="padding-right: 8px; vertical-align: middle;" alt="Beschikbaarheid accommodatie wordt opgevraagd" />';
        divCont = divCont + '<span style="font-size:12px;color:#857663; vertical-align: middle">Beschikbaarheid accommodatie wordt opgevraagd</span>';
        
        var myAvailObj=gO('hotBesch_'+hotid);
        myAvailObj.innerHTML=divCont;
        
        Ajax_Code.ajaxAvailIndicator(hotid, depDate, retDate, SucceededCallbackThree, FailedCallback);
    }
    
    gO('alleenBeschikbaar').disabled=false;
    gO('alleenBeschikbaar').title='Toon alleen beschikbare hotels';
}   

function updateAvailAll(depDate, retDate, aantKamer, volw, kind)
{
    var depParts = new Array();
    var retParts = new Array();

    depParts = depDate.split('-');
    retParts = retDate.split('-');
    
    var isgo = true;
    
    if ((depParts.length>0)&&(retParts.length>0))
    {
        var depTmp = new Date(depParts[2],depParts[1]-1,depParts[0]);
        var retTmp = new Date(retParts[2],retParts[1]-1,retParts[0]);
        
        if (retTmp<=depTmp)
        {
            isgo=false;
        }
        
        if ((depTmp.getMonth()!=depParts[1]-1) || (depTmp.getMonth()!=depParts[1]-1))
        {
            isgo=false;
        } else {
            
        }
    }
    
    if (isgo)
    {
        var mySubSet = hotelSubset();

        for (i=0; i<mySubSet.length; i++)
        {
            var hotid=mySubSet[i].id;
            var divCont = '<img src="/App_Image/icon/avail_wait.gif" style="padding-right: 8px; vertical-align: middle;" alt="Beschikbaarheid accommodatie wordt opgevraagd" />';
            divCont = divCont + '<span style="font-size:12px;color:#857663; vertical-align: middle">Beschikbaarheid accommodatie wordt opgevraagd</span>';
            
            var myAvailObj=gO('hotBesch_'+hotid);
            myAvailObj.innerHTML=divCont;
        }
        
        if (stadID==0) 
        {
            if (bestemmingID!='')
            {
                var bestemmingObj = gO(bestemmingID);
                
                if (bestemmingObj)
                {
                    stadID=parseInt(bestemmingObj.value);
                }
            }
        }
        
        //Ajax_Code.saveTravel(selectedTransport(), stadID, depDate, retDate, volw, kind);
        //Ajax_Code.ajaxAvailIndicators(selectedTransport(), stadID, depDate, retDate, pageSpecial, aantKamer, volw, kind, SucceededCallbackThree, FailedCallback);
        
        Ajax_Code.ajaxUpdateHotel(selectedTransport(), stadID, depDate, retDate, pageSpecial, aantKamer, volw, kind, SucceededCallbackThree, FailedCallback);
    }
}   

function showPackagePrice(resultObj)
{
    priceSpec='';
    
    priceObj = resultObj;
    
    var myobj = gO('prijsContents');

    if (priceObj.refresh == 'true' || priceObj.totaal==-1) {
        window.location.reload(true);
    } else {
        if (priceObj.alert != '') {
            if (priceObj.failed) {
                gO('foutMelding').innerHTML = priceObj.alert;
                gO('foutOmschrijving').innerHTML = priceObj.alertomschrijving;

                getStyle('alertContainer').display = 'inline';
                getStyle('prijsContainer').display = 'none';
            } else {
                alert(priceObj.alert);
                getStyle('prijsContainer').display = 'none';
            }
        } else {
            var html = '';

            html = html + '<table cellpadding="0" cellspacing="0" style="font-size: 10px; width: 100%; text-align: left">';
            //if (priceObj.transportType == '13') {
              //  html = html + '<tr><td style="text-align: center"><img onmouseover="javascript:showPriceSpec(event, true);" onmouseout="javascript:closePopup();" style="float: left; vertical-align: middle" src="/App_Image/price_info.png" alt="Prijs specificatie" /><div style="padding-top: 1px; width: 100%; font-size: 10px; font-weight: bold">Basisprijs treinreis.</div></td></tr>'
            //} else {
                html = html + '<tr><td style="text-align: center"><img onmouseover="javascript:showPriceSpec(event, true);" onmouseout="javascript:closePopup();" style="float: left; vertical-align: middle" src="/App_Image/price_info.png" alt="Prijs specificatie" /><span style="padding-top: 1px; width: 100%; font-size: 10px; font-weight: bold">Prijs incl. alle toeslagen!</span></td></tr>'
            //}

            var priceStr = priceObj.totaal.toString();
            var priceamount = priceStr.substr(0, priceStr.indexOf('.'));
            var pricedeciml = priceStr.substr(priceStr.indexOf('.') + 1);

            html = html + '<tr><td style="text-align: right"><div style="font-size: 20px; font-weight: bold; float: left; padding-top: 15px">&euro;</div><div id="totaalPrijs" style="font-size: 36px; font-weight: bold; float: right"><table cellpadding="0" cellspacing="0"><tr><td>' + priceamount + '</td><td style="vertical-align: top; font-size: 14px; padding-top: 5px">' + pricedeciml + '</td></tr></table></div></td></tr>'
            html = html + '<tr><td style="height: 5px"><div style="height: 5px; overflow: hidden">&nbsp;</div></td></tr>';

            switch (parseInt(priceObj.transportType)) {
                case 11:
                    // Eigen vervoer                        
                    html = html + '<tr><td><b>per eigen vervoer</b></td></tr>';
                    break;

                case 13:
                    // Inclusief transport (trein)
                    showTabs('transport');

                    html = html + '<tr><td><b>Vervoer</b>&nbsp;&nbsp;<img style="float: right; cursor: pointer" onclick="javascript:toggleTo(\'transportnoinit\');" src="/App_image/button/aanpassen.png" alt="Aanpassen" /><br /><table cellpadding="0" cellspacing="0" style="width: 100%; font-size: 10px">';
                    html = html + '<div id="transOut" style="text-align: left">' + priceObj.transheen + '</div><div id="transIn" style="text-align: left">' + priceObj.transterug + '</div>';
                    // html = html + '</table>N.B. Deze prijs is op basis van de goedkoopste boekingsklasse. <a href="/service/veel_gestelde_vragen/trein_toeslagen" target="_blank"><u><b>Meer info</b></u></a></td></tr>';
                    break;

                default:
                    // Inclusief transport
                    showTabs('transport');

                    html = html + '<tr><td><b>Vervoer</b>&nbsp;&nbsp;<img style="float: right; cursor: pointer" onclick="javascript:toggleTo(\'transportnoinit\');" src="/App_image/button/aanpassen.png" alt="Aanpassen" /><br /><table cellpadding="0" cellspacing="0" style="width: 100%; font-size: 10px">';
                    html = html + '<div id="transOut" style="text-align: left">' + priceObj.transheen + '</div><div id="transIn" style="text-align: left">' + priceObj.transterug + '</div>';
                    if (priceObj.transportAlert != '') {
                        html = html + '</table><b>' + priceObj.transportAlert + '</b></td></tr>';
                    } else {
                        html = html + '</table></td></tr>';
                    }
                    break;
            }

            html = html + '</table>';

            myobj.innerHTML = html;

            getStyle('prijsContainer').display = 'inline';
            gO('groenRond').style.display = 'inline';

            if (!priceObj.extrascalculated) {
                initExtra(0, false);
            }
        }
    }

    if (pricechange) {
        showAlert(e, 'Prijs aangepast naar: &euro; ' + priceObj.totaal.toString());
        pricechange = false;
    }
}

function setTotaalPrijs(prijs)
{
    var priceStr=prijs.toString();
    var priceamount;
    var pricedeciml;
    
    if (priceStr.indexOf('.')==-1)
    {
        priceamount=priceStr;
        pricedeciml='00';    
    } else {
        priceamount=priceStr.substr(0,priceStr.indexOf('.'));
        pricedeciml=priceStr.substr(priceStr.indexOf('.')+1);
    }

    gO('totaalPrijs').innerHTML='<table cellpadding="0" cellspacing="0"><tr><td>'+priceamount+'</td><td style="vertical-align: top; font-size: 14px; padding-top: 5px">'+pricedeciml+'</td></tr></table>';
}

function initTransportTimes()
{
    var errorMsg = checkPackage();
    if (errorMsg.message=='')
    {
        var changeHTML = '<div style="width: 742px; position: relative; height: 320px; background-color: #FFFFFF">';
        changeHTML = changeHTML + '<div style="width: 742px; padding-top: 100px; text-align: center">' + jsFlash('', '/flash/wait_steden.swf', 'cursor: pointer', 'middle', '100', '100', '<param name="wmode" value="transparent" />') + '<br/><span style="font-size: 10px; color: #857663">Transportgegevens<br/>worden opgevraagd</span></div>';
        // <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" style="width: 100px; height: 100px; cursor: pointer"><param name="movie" value="/flash/wait_steden.swf" /><param name="wmode" value="transparent" /><!-- [if !IE]> --><em_bed src="/flash/wait_steden.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="100px" height="100px" name="prijs_tag" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>
        changeHTML=changeHTML+'</div>';
        //showPopup(752, 502, changeHTML);

        gO('transContainer').innerHTML=changeHTML;
        gO('transContainer').style.display='inline';

        var objDep = gO(departureID);
        var objDst = gO(destinationID);

        Ajax_Code.getTransportTimes(formVolw[formVolw.selectedIndex].value, formKind[formKind.selectedIndex].value, formBaby[formBaby.selectedIndex].value, formHeen.value, formTerug.value, roomStr(), formTransport, objDep[objDep.selectedIndex].value, objDst[objDst.selectedIndex].value, hotelid, myBoard(), SucceededCallback, FailedCallback);    
    } else {
        alert(errorMsg);
    }
    
}

function updateAvailCal() {
    var selectedMon = gO(formHeen.id.replace('_selectedDate', '_maandenLijst'));
    var selectedVal = selectedMon[selectedMon.selectedIndex].value;

    fillHotelAvailability(huCodeList(), formHeen.id.substr(0, formHeen.id.length - 12), selectedVal.substr(0, 2), selectedVal.substr(2), true);
}

function huCodeList() {
    var retList = '';

    var ddcol = new Array();
    ddcol = document.getElementsByTagName("select");

    for (i = 0; i < ddcol.length; i++) {
        if (ddcol[i].id.indexOf('HUC:') > -1) {
            if (parseInt(ddcol[i].value) > 0) {
                var actHUC = ddcol[i].id.substr(ddcol[i].id.indexOf('HUC:') + 4);
                actHUC = actHUC.substr(0, actHUC.indexOf('_'));

                if (retList == '') {
                    retList = actHUC;
                } else {
                    retList = retList + '_' + actHUC;
                }
            }
        }
    }

    return retList;
}

function fillHotelAvailability(huCode, calendarID, monthstr, yearstr, init)
{
    var heenReis = false;
    var heenCalendar;
    var terugCalendar;

    var month = parseFloat(monthstr);
    var year = parseFloat(yearstr);

    if (calendarID.toLowerCase().indexOf('kalender_heen')>-1)
    {
        heenReis = true;
        heenCalendar = gO(calendarID+'maandenLijst');
        terugCalendar = gO(calendarID.replace("Kalender_Heen", "Kalender_Terug")+'maandenLijst');
    } else {
        heenReis = false;
        heenCalendar = gO(calendarID.replace("Kalender_Terug", "Kalender_Heen")+'maandenLijst');
        terugCalendar = gO(calendarID+'maandenLijst');
    }
    
    var selMonth = gO(calendarID+'maandenLijst');
    selMonth.value=((month>9)? month.toString() : '0'+month.toString())+year.toString();

    checkUnitsMinMaxDate(selMonth);

    if (heenCalendar && terugCalendar)
    {
        var heenDate = new Date(heenCalendar.value.substr(2,4),parseFloat(heenCalendar.value.substr(0,2))-1,1);
        var terugDate = new Date(terugCalendar.value.substr(2,4),parseFloat(terugCalendar.value.substr(0,2))-1,1);
        
        if (terugDate<heenDate)
        {
            var monthDif = Math.round((heenDate - terugDate) / 2592000000);
            
            if (heenReis)
            {
                changeAvailMonth(monthDif, terugCalendar);
            } else {
                changeAvailMonth(-1*monthDif, heenCalendar);
            }
        }
    }
    
    if (selMonth.selectedIndex==0)
    {
        gO(calendarID+'vorigeMaand').src='/App_Image/button/vorige_disabled.png';
    } else {
        gO(calendarID+'vorigeMaand').src='/App_Image/button/vorige.png';
    }
    
    if (selMonth.selectedIndex==selMonth.length-1)
    {
        gO(calendarID+'volgendeMaand').src='/App_Image/button/volgende_disabled.png';
    } else {
        gO(calendarID+'volgendeMaand').src='/App_Image/button/volgende.png';
    }
        
    getStyle(calendarID+'waitPanel').display='inline';
    getStyle(calendarID+'calendarTable').display='none';

    if (init) { Ajax_Code.fillAvailability(huCode, calendarID, month, year, SucceededCallback, FailedCallback); }
}

function fillCalendar(calendarID, monthstr, yearstr)
{
    var heenReis = false;
    var heenCalendar;
    var terugCalendar;

    var month = parseFloat(monthstr);
    var year = parseFloat(yearstr);

    if (calendarID.toLowerCase().indexOf('kalender_heen')>-1)
    {
        if (calendarID.toLowerCase().indexOf('kalender_heen')>-1)
        {
            heenReis = true;
            heenCalendar = gO(calendarID+'maandenLijst');
            terugCalendar = gO(calendarID.replace("Kalender_Heen", "Kalender_Terug")+'maandenLijst');
        } else {
            heenReis = false;
            heenCalendar = gO(calendarID.replace("Kalender_Terug", "Kalender_Heen")+'maandenLijst');
            terugCalendar = gO(calendarID+'maandenLijst');
        }
    } else {
        if (calendarID.toLowerCase().indexOf('datumheen')>-1)
        {
            heenReis = true;
            heenCalendar = gO(calendarID+'maandenLijst');
            terugCalendar = gO(calendarID.replace("datumHeen", "datumTerug")+'maandenLijst');
        } else {
            heenReis = false;
            heenCalendar = gO(calendarID.replace("datumTerug", "datumHeen")+'maandenLijst');
            terugCalendar = gO(calendarID+'maandenLijst');
        }
    }
    
    var selMonth = gO(calendarID+'maandenLijst');
    if (selMonth)
    {
        selMonth.value=((month>9)? month.toString() : '0'+month.toString())+year.toString();
    }
    
    
    if (heenCalendar && terugCalendar)
    {
        var heenDate = new Date(heenCalendar.value.substr(2,4),parseFloat(heenCalendar.value.substr(0,2))-1,1);
        var terugDate = new Date(terugCalendar.value.substr(2,4),parseFloat(terugCalendar.value.substr(0,2))-1,1);
        
        if (terugDate<heenDate)
        {
            var monthDif = Math.round((heenDate - terugDate) / 2592000000);
            
            if (heenReis)
            {
                changeAvailMonth(monthDif, terugCalendar);
            } else {
                changeAvailMonth(-1*monthDif, heenCalendar);
            }
        }
    }
    
    if (selMonth)
    {
        if (selMonth.selectedIndex==0)
        {
            gO(calendarID+'vorigeMaand').src='/App_Image/button/vorige_disabled_small.png';
        } else {
            gO(calendarID+'vorigeMaand').src='/App_Image/button/vorige_small.png';
        }
        
        if (selMonth.selectedIndex==selMonth.length-1)
        {
            gO(calendarID+'volgendeMaand').src='/App_Image/button/volgende_disabled_small.png';
        } else {
            gO(calendarID+'volgendeMaand').src='/App_Image/button/volgende_small.png';
        }
            
        getStyle(calendarID+'waitPanel').display='inline';
        getStyle(calendarID+'calendarTable').display='none';

        Ajax_Code.fillCalendarDays(calendarID, month, year, SucceededCallback, FailedCallback);    
    }
}

//function fillHotelTable(stadID)
//{
//    Ajax_Code.getHotels(stadID, SucceededCallback, FailedCallback);
//}

//function fillOfferTable()
//{
//    Ajax_Code.getOffers(SucceededCallback, FailedCallback);
//}

function registerHotelLocation(hotelID, hotlat, hotlon)
{
    Ajax_Code.ajax_registerHotelLocation(hotelID, hotlat, hotlon, SucceededCallback, FailedCallback);
}

function removeFaultyAddress(hotelID)
{
    Ajax_Code.ajax_removeFaultyAddress(hotelID, SucceededCallback, FailedCallback);
}

function registerCityLocation(cityID, citlat, citlon)
{
    Ajax_Code.ajax_registerCityLocation(cityID, citlat, citlon, SucceededCallback, FailedCallback);
}

function SucceededCallbackToo(result, userContext, methodName)
{
    switch (methodName)
    {
        case "loadCities":
            var myObj = gO(stadPanelID);
            var myStyle = getStyle(stadPanelID);
        
            myObj.innerHTML = result;
        
            //hidePersistent();
            myStyle.display = 'inline';        
        break;
        
        default:
            alert(':(: '+result);
        break;  
    }              
}

function SucceededCallbackThree(result, userContext, methodName)
{
    switch (methodName)
    {
        case "ajaxUpdateHotel":
            var updatedHotels = '~';

            for (hotI = 0; hotI < result.hotels.length; hotI++) {
                var imgstr = 'avail_ok';
                var avtxt = 'Deze accommodatie is beschikbaar';

                if (hotelCol[result.hotels[hotI].id.toString()] != null) {
                    switch (result.hotels[hotI].avl.toUpperCase()) {
                        case 'OK':
                            imgstr = 'avail_ok';
                            avtxt = 'Deze accommodatie is beschikbaar';
                            hotelCol[result.hotels[hotI].id.toString()].status = 'ok';
                            break;

                        case 'RQ':
                            imgstr = 'avail_oa';
                            avtxt = 'Deze accommodatie is op aanvraag';
                            hotelCol[result.hotels[hotI].id.toString()].status = 'rq';
                            break;

                        default:
                            imgstr = 'avail_nb';
                            avtxt = 'Deze accommodatie is niet beschikbaar';
                            hotelCol[result.hotels[hotI].id.toString()].status = 'nb';
                            break;
                    }

                    var divCont = '<img src="/App_Image/icon/' + imgstr + '.png" style="padding-right: 8px; vertical-align: middle;" alt="' + avtxt + '" />';
                    divCont = divCont + '<span style="font-size:12px;color:#857663; vertical-align: middle">';
                    divCont = divCont + avtxt;
                    divCont = divCont + '</span>';

                    var myAvailObj = gO('hotBesch_' + result.hotels[hotI].id.toString());
                    myAvailObj.innerHTML = divCont;

                    if (imgstr == 'avail_nb') {
                        gO('hotPrijs_' + result.hotels[hotI].id.toString()).innerHTML = '';
                        // '<i>Probeer een andere periode, of klik door naar de hotelinformatie om de beschikbaarheid te bekijken.</i>';
                        hotelCol[result.hotels[hotI].id.toString()].prijs = "9999";

                        gO('if_' + result.hotels[hotI].id.toString()).innerHTML = '<span style="font-size: 11px; font-style: italic; text-align: left; position: relative; top: -30px">Probeer een andere periode, of klik door naar de hotelinformatie om de beschikbaarheid te bekijken.</span>';
                        gO('pa_' + result.hotels[hotI].id.toString()).innerHTML = '';
                        gO('ic_' + result.hotels[hotI].id.toString()).innerHTML = '';
                    } else {
                        gO('hotPrijs_' + result.hotels[hotI].id.toString()).innerHTML = '&euro; ' + result.hotels[hotI].prc;
                        hotelCol[result.hotels[hotI].id.toString()].prijs = result.hotels[hotI].prc.toString();

                        gO('if_' + result.hotels[hotI].id.toString()).innerHTML = '';
                        gO('pa_' + result.hotels[hotI].id.toString()).innerHTML = result.hotels[hotI].pck;
                        gO('ic_' + result.hotels[hotI].id.toString()).innerHTML = '<img onmouseover="javascript:showPriceInfo();" onmouseout="javascript:closePopup();" src="/App_Image/price_info.png" alt="info" />';
                    }
                }

                updatedHotels = updatedHotels + result.hotels[hotI].id.toString() + '~';
            }

            setBoundaries(hotelCol);

            var mySubSet = hotelSubset();

            for (i = 0; i < mySubSet.length; i++) {
                var hotid = mySubSet[i].id;

                if (updatedHotels.indexOf('~' + hotid.toString() + '~') == -1) {
                    hotelCol[hotid.toString()].status = 'nb';
                    gO('hotBesch_' + hotid.toString()).innerHTML = '<img src="/App_Image/icon/avail_nb.png" style="padding-right: 8px; vertical-align: middle;" alt="Deze accommodatie is niet beschikbaar" /><span style="font-size:12px;color:#857663; vertical-align: middle">Deze accommodatie is niet beschikbaar</span>';
                }
            }

            gO('alleenBeschikbaar').disabled = false;

            resortTable(sorting);
            break;
        
        case "updatePrices":
            var updatedHotels='';
      
            for (hotI=0; hotI<result.hotelprice.length; hotI++)
            {
                var calcprice = 0;
                calcprice = result.fixed + result.transport;
                calcprice = calcprice + ((result.nights - result.hotelprice[hotI].fnt)*result.hotelprice[hotI].prc); 
                                
                if (gO('hotPrijs_'+result.hotelprice[hotI].id)) { gO('hotPrijs_'+result.hotelprice[hotI].id).innerHTML='<span id="hotPrijs_' + result.hotelprice[hotI].id + '">' + calcprice + '</span>'; }
                
                var imgstr = 'avail_ok';
                var avtxt = 'Deze accommodatie is beschikbaar';
                
                switch(result.hotelprice[hotI].avl.toUpperCase())
                {
                    case 'OK':
                        imgstr = 'avail_ok';
                        avtxt = 'Deze accommodatie is beschikbaar';
                        hotelCol[hotParts[0]].status='ok';                        
                    break;
                    
                    case 'RQ':
                        imgstr = 'avail_oa';
                        avtxt = 'Deze accommodatie is op aanvraag';
                        hotelCol[hotParts[0]].status='rq';
                    break;
                    
                    default:
                        imgstr = 'avail_nb';    
                        avtxt = 'Deze accommodatie is niet beschikbaar';
                        hotelCol[hotParts[0]].status='nb';
                    break;
                }
                
                var divCont = '<img src="/App_Image/icon/'+imgstr+'.png" style="padding-right: 8px; vertical-align: middle;" alt="'+avtxt+'" />';
                divCont = divCont + '<span style="font-size:12px;color:#857663; vertical-align: middle">';
                divCont = divCont + avtxt;
                divCont = divCont + '</span>';
                
                var myAvailObj=gO('hotBesch_'+hotParts[0].toString());
                updatedHotels=updatedHotels+hotParts[0].toString()+'~';
                myAvailObj.innerHTML=divCont;
                
                updatedHotels=updatedHotels+result[hotI].id+'~';
            }
        
            var mySubSet = hotelSubset();
        
            for (i=0; i<mySubSet.length; i++)
            {
                var hotid=mySubSet[i].id;
                
                if (updatedHotels.indexOf('~'+hotid.toString()+'~')==-1)
                {
                    hotelCol[hotid.toString()].prijs='???';

                    gO('hotBesch_'+hotid.toString()).innerHTML=divCont;
                    gO('hotPrijs_'+hotid.toString()).innerHTML='<span id="hotPrijs_' +hotid.toString() + '">???</span>';
                }
            }
            
            resortTable(sorting);
        break;
        
        case "ajaxAvailIndicators":
            var myTemp = new Array();
            myTemp = result.split('|');
            var myHotels = new Array();
            myHotels = myTemp[0].split('~');
            var myVariables = new Array();
            myVariables = myTemp[1].split('~');
                        
            var updatedHotels='~';
            
            for (hotI=0; hotI<myHotels.length; hotI++)
            {
                var hotParts = new Array();
                hotParts = myHotels[hotI].split('=');
                
                var imgstr = 'avail_ok';
                var avtxt = 'Deze accommodatie is beschikbaar';
                
                if (hotelCol[hotParts[0]])
                {
                    switch(hotParts[1].toUpperCase())
                    {
                        case 'OK':
                            imgstr = 'avail_ok';
                            avtxt = 'Deze accommodatie is beschikbaar';
                            hotelCol[hotParts[0]].status='ok';                        
                        break;
                        
                        case 'RQ':
                            imgstr = 'avail_oa';
                            avtxt = 'Deze accommodatie is op aanvraag';
                            hotelCol[hotParts[0]].status='rq';
                        break;
                        
                        default:
                            imgstr = 'avail_nb';    
                            avtxt = 'Deze accommodatie is niet beschikbaar';
                            hotelCol[hotParts[0]].status='nb';
                        break;
                    }
                    
                    var divCont = '<img src="/App_Image/icon/'+imgstr+'.png" style="padding-right: 8px; vertical-align: middle;" alt="'+avtxt+'" />';
                    divCont = divCont + '<span style="font-size:12px;color:#857663; vertical-align: middle">';
                    divCont = divCont + avtxt;
                    divCont = divCont + '</span>';
                    
                    var myAvailObj=gO('hotBesch_'+hotParts[0].toString());
                    updatedHotels=updatedHotels+hotParts[0].toString()+'~';
                    myAvailObj.innerHTML=divCont;
                }
            }
        
            var mySubSet = hotelSubset();
        
            for (i=0; i<mySubSet.length; i++)
            {
                var hotid=mySubSet[i].id;
                
                if (updatedHotels.indexOf('~'+hotid.toString()+'~')==-1)
                {
                    var divCont = '<img src="/App_Image/icon/avail_nb.png" style="padding-right: 8px; vertical-align: middle;" alt="Deze accommodatie is niet beschikbaar" /><span style="font-size:12px;color:#857663; vertical-align: middle">Deze accommodatie is niet beschikbaar</span>';

                    if (hotelCol[hotid.toString()])
                    {
                        hotelCol[hotid.toString()].status='nb';
                    } else {
                        hotelCol[hotid.toString()] = new jsHot();
                        hotelCol[hotid.toString()].status='nb';                       
                    }

                    var myAvailObj=gO('hotBesch_'+hotid.toString());
                    myAvailObj.innerHTML=divCont;
                }
            }
            
            resortTable(sorting);
             
            gO('alleenBeschikbaar').disabled=false;
            gO('alleenBeschikbaar').title='Toon alleen beschikbare hotels';
            
            Ajax_Code.updatePrices(myVariables[0], myVariables[1], myVariables[2], myVariables[3], myVariables[4], myVariables[5], myVariables[6], myVariables[7], SucceededCallbackThree, FailedCallback);
        break;
        
        case "ajaxAvailIndicator":
            var myHotels = new Array();
            myHotels = result.split('~');
            
            for (hotI=0; hotI<myHotels.length; hotI++)
            {
                var hotParts = new Array();
                hotParts = myHotels[hotI].split('=');
                
                var imgstr = 'avail_ok';
                var avtxt = 'Deze accommodatie is beschikbaar';
                
                switch(hotParts[1].toUpperCase())
                {
                    case 'OK':
                        imgstr = 'avail_ok';
                        avtxt = 'Deze accommodatie is beschikbaar';
                        hotelCol[hotParts[0]].status='ok';                        
                    break;
                    
                    case 'RQ':
                        imgstr = 'avail_oa';
                        avtxt = 'Deze accommodatie is op aanvraag';
                        hotelCol[hotParts[0]].status='rq';
                    break;
                    
                    default:
                        imgstr = 'avail_nb';
                        avtxt = 'Deze accommodatie is niet beschikbaar';
                        hotelCol[hotParts[0]].status='nb';
                    break;
                }
                
                var divCont = '<img src="/App_Image/icon/'+imgstr+'.png" style="padding-right: 8px; vertical-align: middle;" alt="'+avtxt+'" />';
                divCont = divCont + '<span style="font-size:12px;color:#857663; vertical-align: middle">';
                divCont = divCont + avtxt;
                divCont = divCont + '</span>';
                
                var myAvailObj=gO('hotBesch_'+hotParts[0].toString());
                myAvailObj.innerHTML=divCont;
            }
        break;
        
        default:
            alert(':(: '+result);
        break;  
    }              
}

function SucceededCallback(result, userContext, methodName)
{
    switch (methodName)
    {
        case "ajax_registerHotelLocation":

        break;
    case "checkEmail":
        if (result == 'true') {
            var actiePanel = gO('actionPanel');
            actiePanel.innerHTML = 'Dank u voor uw deelname aan deze actie! Zie onderstaand uw actiecode.<br/> Houdt u er rekening mee dat de actiecode geldig is tm 29 februari 2012 en enkel geldig bij een boeking vanaf &euro; 250,-.<div style="border-top: solid 2px #FF8c01;width:650px;margin-top:3px;">&nbsp;</div><img src="http://www.stedentrips.nl/actie/facebook/uniekecode.png" alt="I like Stedentrips.nl" style="height:62px;margin-bottom:10px;margin-top:8px;"/>';
        } else {
            checkSubmit('checkmail');
        }
        break;
    case "loginManual":
        if (result == 0) {
            showBigAlert('De inloggegevens zijn niet correct. Probeer het opnieuw, of vraag uw wachtwoord op.');
        } else {
            window.location.reload(true);
        }
        break;

    case "passRequest":
        if (result == 0) {
            showBigAlert('Van dit e-mailadres is bij ons geen profiel bekend.');
        } else {
            window.location.reload(true);
        }
    break;

        case "ajax_registerCityLocation":

        break;

        case "CheckEmail":
            
        break;

        case "ajax_removeFaultyAddress":
            gO(mapID).innerHTML = '<div style="font-family: verdana, font-size: 10px">Weet u waar dit hotel ligt? Laat het ons weten.</div>';
            getStyle(mapID).backgroundColor = '#FFFFFF';
            break;
        
        case "getHotels":
            if (hotelCol) 
            { 
                hotelCol.clear(); 
            } else {
                hotelCol = new Array();
            }
            
            for (i=0; i<result.length; i++)
            {
                hotelCol[result[i].id]=result[i];   
            }
            
            //hotelCol=result;
            fillTableResult(false);
        break;
        
        case "getOffers":
            if (hotelCol) 
            { 
                hotelCol.clear(); 
            } else {
                hotelCol = new Array();
            }
            
            for (i=0; i<result.length; i++)
            {
                hotelCol[result[i].id]=result[i];   
            }
            
            //hotelCol=result;
            fillTableResult(false);
            break;

        case "confirmExtrasTL":
            var splitResult = new Array();
            splitResult = result.split('~')
            var retDiv = splitResult[0];
            var mydiv = '';

            mydiv = '<div style="width: 650px; height: 600px; background-color: #dad1c2">';

            mydiv = mydiv + '<table cellpadding="0" style="width: 650px" cellspacing="0">';

            mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
            mydiv = mydiv + '<td style="width: 642px; padding-top: 6px"><div onclick="javascript: hidePopup();" style="width: 642px; height: 22px; overflow: hidden; font-size: 14px; color: #FFFFFF; font-weight: bold"><img src="/App_Image/icon/close.gif" alt="Sluit venster" style="cursor: pointer; float: right" /><img src="/App_Image/button/add_orange.png" alt="Extra toevoegen" style="vertical-align: top; margin-right: 6px" />Extra&#39;s toevoegen - controle boeking</div></td>';
            mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

            mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
            mydiv = mydiv + '<td style="width: 642px"><div style="padding: 10px 10px 10px 10px; width: 622px; height: 492px; overflow: hidden; font-size: 12px; color: #000000; background-color: #FFFFFF">';

            mydiv = mydiv + retDiv

            mydiv = mydiv + '</div></td>';
            mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

            mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
            mydiv = mydiv + '<td style="width: 642px"><div style="width: 642px; height: 28px; border-top: solid 4px #dad1c2; overflow: hidden; font-size: 14px; color: #000000; background-color: #FFFFFF"><div id="ePi" style="padding: 6px 10px 8px 10px; width: 572px; height: 12px; overflow: hidden; font-size: 12px; color: #000000">';

            mydiv = mydiv + '<i>Indien u kiest voor &#39;Voeg toe&#39; wordt u doorverwezen ivm. de bijbetaling voor de toevoegde optie&#39;s.</i>';

            mydiv = mydiv + '</div></td>';
            mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

            mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';

            mydiv = mydiv + '<td style="width: 642px; padding-top: 6px"><div style="width: 642px; height: 22px; vertical-align: middle; overflow: hidden"><img src="/App_Image/extra_voeg_toe.png" alt="Extra toevoegen" onclick="" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: right" /><img src="/App_Image/extra_sluit.png" alt="Extra sluiten" onclick="javascript: hidePopup();" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: left" /></div></td>';

            mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

            mydiv = mydiv + '</table>';

            mydiv = mydiv + '</div>';

            stopWaitForIt();

            showPopup(710, 450, mydiv)

            break;
        case "ajax_bugreport":
            alert('Bug rapport is verstuurd!');
        break;               
                    
        case "fillAvailability":
            var splitResult = new Array();
            splitResult = result.split('~');
                
            var calID = splitResult[0];
            var tmpCSS = splitResult[1];
            
            var cssCol = new Array();
            cssCol = tmpCSS.split(";");
            
            loadCalendarDates(calID, cssCol, false);
            
            if ((calID.toLowerCase().indexOf('kalender_heen')>-1) && (!doOnce))
            {
                doOnce=true;
                Ajax_Code.fillAvailability(splitResult[4], calID.replace("Kalender_Heen", "Kalender_Terug"), parseInt(splitResult[2]), parseInt(splitResult[3]), SucceededCallback, FailedCallback);
            } else {
                doOnce=false;
            }
        break;
        
        case "fillCalendarDays":
            var splitResult = new Array();
            splitResult = result.split('~');
                
            var calID = splitResult[0];
            var tmpCSS = splitResult[1];
            
            var cssCol = new Array();
            cssCol = tmpCSS.split(";");
            
            loadCalendarDates(calID, cssCol, true);
        break;
        
//             case "getTransportTimes":        OLD
//            var splitRows = result.split('|');

//            var heenRows='';
//            var terugRows='';
//                                        
//            for (i=0; i<splitRows.length; i++)
//            {
//                var altClass = 'lightRow';

//                var rowParts = splitRows[i].split('~');
//                
//                var legs = new Array();
//                legs = rowParts[1].split('}');
//                
//                if (legs.length>0)
//                {
//                    var legParts = new Array();
//                    var secParts = new Array();
//                                        
//                    legParts = legs[0].split('_');
//                    if (legs.length>1)
//                    {
//                        secParts = legs[1].split('_');
//                        
//                        var sdepDate = secParts[4].substr(0,8);
//                        var sdepTime = secParts[4].substr(8,4);

//                        var sarrDate = secParts[7].substr(0,8);
//                        var sarrTime = secParts[7].substr(8,4);
//                        
//                        sdepTime = sdepTime.substr(0,2)+':'+sdepTime.substr(2,2)
//                        sarrTime = sarrTime.substr(0,2)+':'+sarrTime.substr(2,2)                        
//                    }
//                    
//                    var depDate = legParts[4].substr(0,8);
//                    var depTime = legParts[4].substr(8,4);

//                    var arrDate = legParts[7].substr(0,8);
//                    var arrTime = legParts[7].substr(8,4);
//                    
//                    depTime = depTime.substr(0,2)+':'+depTime.substr(2,2)
//                    arrTime = arrTime.substr(0,2)+':'+arrTime.substr(2,2)

//                    var flightIcon = '';

//                    var rowChecked=(rowParts[2]=='1')?' checked="checked"':'';
//                    var rowName=(rowParts[0].toLowerCase()=='o')?'heen':'terug';
//                    
//                    if (legs.length>1)
//                    {
//                        flightIcon='<img src="/App_Image/icon/via_vlucht.gif" alt="Via vlucht" />';
//                        var newRow = '<tr><td style="vertical-align: top" class="'+altClass+'"><input type="radio" name="'+rowName+'" value="'+legParts[8]+'"'+rowChecked+' /></td><td class="'+altClass+'">'+legParts[2]+'&nbsp;('+legParts[3]+')<br/>'+secParts[2]+'&nbsp;('+secParts[3]+')</td><td class="'+altClass+'">'+depTime+'<br/>'+sdepTime+'</td><td class="'+altClass+'">'+legParts[5]+'&nbsp;('+legParts[6]+')<br/>'+secParts[5]+'&nbsp;('+secParts[6]+')</td><td class="'+altClass+'">'+arrTime+'<br/>'+sarrTime+'</td><td class="'+altClass+'">'+legParts[0]+legParts[1]+'<br/>'+secParts[0]+secParts[1]+'</td><td class="'+altClass+'">'+flightIcon+'</td></tr>';
//                    } else {
//                        var newRow = '<tr><td class="'+altClass+'" style="vertical-align: middle"><input type="radio" name="'+rowName+'" value="'+legParts[8]+'"'+rowChecked+' /></td><td class="'+altClass+'">'+legParts[2]+'&nbsp;('+legParts[3]+')</td><td class="'+altClass+'">'+depTime+'</td><td class="'+altClass+'">'+legParts[5]+'&nbsp;('+legParts[6]+')</td><td class="'+altClass+'">'+arrTime+'</td><td class="'+altClass+'">'+legParts[0]+legParts[1]+'</td><td class="'+altClass+'">'+flightIcon+'</td></tr>';
//                    }
//                                   
////                    if (altClass=='lightRow')
////                    {
////                        altClass='darkRow';
////                    } else {
////                        altClass='lightRow';
////                    }
//                                        
//                    if (rowParts[0].toLowerCase()=='o')
//                    {
//                        heenRows=heenRows+newRow;
//                    } else {
//                        terugRows=terugRows+newRow;
//                    }
//                }
//            }
//            
//            updateTransportTimes(heenRows, terugRows);
//        break;
           
        case "getTransportTimes":
            while (combos.length>0)
            {
                combos.pop();
            }
            
            eval(result.allowedScript);
            
            updateTransportTimes(result.heen, result.terug, result.heenselected, result.terugselected, result.intro, result.rates, result.isbene);
        break;
       
        case "loadDepDest":
            var ddDep = gO(departureID);
            var ddDst = gO(destinationID);

            var lblDep = gO('fromLbl');
            var lblDst = gO('toLbl');
            
            if (result.length>0)
            {
                if (result.substr(0,1)=='~')
                {
                    ddDep.style.display='none';
                    ddDst.style.display='none';
                    lblDep.style.display='none';
                    lblDst.style.display='none';
                } else {
                    ddDep.style.display='inline';
                    ddDst.style.display='inline';
                    lblDep.style.display='inline';
                    lblDst.style.display='inline';
                                                
                    var splitRes = new Array();
                    splitRes = result.split('~');
                    
                    if (splitRes.length>2)
                    {
                        if (splitRes[2].length>=6) 
                        {
                            selectedDep=splitRes[2].substr(0,splitRes[2].length/2);
                            selectedDst=splitRes[2].substr(splitRes[2].length/2,splitRes[2].length/2);
                        }
                    }
                    
                    var splitDep = new Array();
                    splitDep = splitRes[0].split('|');

                    var splitDst = new Array();
                    splitDst = splitRes[1].split('|');
                    
                    while (ddDep.length>0) { ddDep.remove(0); }
                    while (ddDst.length>0) { ddDst.remove(0); }
                    
                    var depOption = document.createElement('option');
                    depOption.value="0";
                    depOption.label="Maak een keuze...";
                    depOption.text="Maak een keuze...";
                    //ddDep.appendChild(depOption);
                    addDDitem(ddDep, depOption);
                    
                    var depIdx=0;
                    var selIdx=0;
                    for (addDep in splitDep)
                    {
                        var depSpl = new Array();
                        depSpl = splitDep[addDep].split('_');
                        
                        var newOption = document.createElement('option');
                        newOption.value=depSpl[0];
                        if (selectedDep==depSpl[0]) { selIdx=ddDep.options.length; }
                        newOption.label=depSpl[1];
                        newOption.text=depSpl[1];
                        //ddDep.appendChild(newOption);
                        addDDitem(ddDep, newOption);
                    }
                    
                    ddDep.selectedIndex = selIdx;
                    
                    var dstOption = document.createElement('option');
                    dstOption.value="0";
                    dstOption.label="Maak een keuze...";
                    dstOption.text="Maak een keuze...";
                    //ddDst.appendChild(dstOption);
                    addDDitem(ddDst, dstOption);
                                        
                    var dstIdx=0;
                    selIdx=0;
                    for (addDst in splitDst)
                    {
                        var dstSpl = new Array();
                        dstSpl = splitDst[addDst].split('_');
                        
                        var newOption = document.createElement('option');
                        newOption.value=dstSpl[0];
                        if (selectedDst==dstSpl[0]) { selIdx=ddDst.options.length; }
                        newOption.label=dstSpl[1];
                        newOption.text=dstSpl[1];                    
                        //ddDst.appendChild(newOption);
                        addDDitem(ddDst, newOption);
                    }        
                        
                    ddDst.selectedIndex = selIdx;

                    if (splitDep.length==1) { while (ddDep.length>1) { ddDep.remove(0); } }                
                    if (splitDst.length==1) { while (ddDst.length>1) { ddDst.remove(0); } }                
                    
                    eval(splitRes[3]);
                }            
            } else {
                ddDep.style.display='none';
                ddDst.style.display='none';
                lblDep.style.display='none';
                lblDst.style.display='none';
            }
            
        break;

    case "calculatePrice":
        showPackagePrice(result);
        
        if ((result.transporten != null) && (priceObj.alert=='')) {
            while (combos.length > 0) {
                combos.pop();
            }

            eval(result.transporten.allowedScript);

            updateTransportTimes(result.transporten.heen, result.transporten.terug, result.transporten.heenselected, result.transporten.terugselected, result.transporten.intro, result.transporten.rates, result.transporten.isbene);

            toggleTo('transportnoinit');
        }
        break;
       
        case "updateFlightPrice":
            setTotaalPrijs(result);
            //gO('totaalPrijs').innerHTML=result;
        break;
        
        case "showPrice":
            showPackagePrice(result);
        break;
        
        case "loadCityData":
            contentPanel.innerHTML=result;
        break;
       
        case "ajaxHotelInfo":
            var splitresult = new Array();
            splitresult = result.split('~');
//        
//            var myPoint = new GLatLng(splitresult[0], splitresult[1]);
//        
//            var mydiv = document.createElement('div');
//            mydiv.style.fontSize='11px';
//            //mydiv.style.width='100px';
//            mydiv.innerHTML=splitresult[2];

//            map.openInfoWindow(myPoint, mydiv);
            gO('hotelInfoPanel').innerHTML=splitresult[2];
            sOp(gO('hotelInfoBorder'), 100);
//            (gO('hotelInfoBorder').style.display='block';
        break;
        
        case "ajaxSightInfo":
            var splitresult = new Array();
            splitresult = result.split('~');

            gO('hotelInfoPanel').innerHTML=splitresult[2];
            sOp(gO('hotelInfoBorder'), 100);
        break;
        
        case "loadQuestion":
            qstContent.innerHTML=result;
            qstPanel.style.display='block';
            window.location.href='#topofpage';
            break;
//    case "datesExtra":
//        var dateDrop = gO('datesDiv');
//        dateDrop.innerHTML = result;
//        break;
//    case "datesExtraTL":
//        var dateDrop = gO('datesDiv');
//        dateDrop.innerHTML = result;
//        break;
//    case "showExtra":
//     var extParts = result.split('~');

//        var mydiv = '';


//        var nodates = true;
//        if (extParts.length == 1) {

//            mydiv = '<div style="width: 650px; height: 600px; background-color: #dad1c2">';

//            mydiv = mydiv + '<div style="font-size: 12px; width: 625px; margin-left: 12px;margin-top:10px; font-weight: bold"><img src="/App_Image/alert_extra.png" alt="Let op" style="float: left; margin-right: 10px; margin-top: 5px" />Deze extra is niet beschikbaar binnen uw reisperiode</div>';

//            mydiv = mydiv + '</div>';

//        } else {

//            if (extParts[7] != 'true') {
//                nodates = false;
//            }

//            //        eval(extParts[5]);

//            if (extParts[0] == 'error') {
//                mydiv = '<div style="width: 650px; height: 600px; background-color: #dad1c2">';

//                mydiv = mydiv + '<div style="font-size: 12px; width: 625px; margin-left: 12px; font-weight: bold"><img src="/App_Image/alert_extra.png" alt="Let op" style="float: left; margin-right: 10px; margin-top: 5px" />' + extParts[1] + '</div>';

//                mydiv = mydiv + '</div>';
//            } else {
//                mydiv = '<input type="hidden" id="extraID" value="' + extParts[4] + '" /><div style="width: 650px; height: 600px; background-color: #dad1c2">';

//                mydiv = mydiv + '<table cellpadding="0" style="width: 650px" cellspacing="0">';

//                mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
//                mydiv = mydiv + '<td style="width: 642px; padding-top: 6px"><div onclick="javascript: hidePopup();" style="width: 642px; height: 22px; overflow: hidden; font-size: 14px; color: #FFFFFF; font-weight: bold"><img src="/App_Image/icon/close.gif" alt="Sluit venster" style="cursor: pointer; float: right" /><img src="/App_Image/button/add_orange.png" alt="Extra toevoegen" style="vertical-align: top; margin-right: 6px" />Extra toevoegen</div></td>';
//                mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

//                mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
//                mydiv = mydiv + '<td style="width: 642px"><div style="padding: 10px 10px 10px 10px; width: 622px; height: 492px; overflow: hidden; font-size: 12px; color: #000000; background-color: #FFFFFF">';

//                mydiv = mydiv + '<img src="' + extParts[2] + '" style="width: 231px; height 180px; float: right; margin-left: 10px; margin-bottom: 10px" alt="Extra image" /><div style="font-size: 14px; font-weight: bold">' + extParts[0] + '</div><div style="padding-top: 8px; padding-bottom: 8px; border-bottom: solid 1px #857663">';
//                mydiv = mydiv + extParts[1];

//                mydiv = mydiv + '</div><div style="padding-top: 8px; padding-bottom: 8px; border-bottom: solid 1px #857663">';


//                if (nodates) {
//                    mydiv = mydiv + '<input type="hidden" id="subServices" value="" /><input type="hidden" id="subServiceDates" value="" />'
//                } else {
//                    if (extParts[5] == '<input type="hidden" id="subServices" value="" /></select>') {
//                        mydiv = mydiv + extParts[5] + '<br/>';
//                    } else {
//                        mydiv = mydiv + extParts[5] + '<br/><br/>';
//                    }
//                    mydiv = mydiv + extParts[6] + '<br/>';
//                }

//                mydiv = mydiv + '</div>';

//                mydiv = mydiv + '</div></td>';
//                mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

//                mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
//                mydiv = mydiv + '<td style="width: 642px"><div style="width: 642px; height: 28px; border-top: solid 4px #dad1c2; overflow: hidden; font-size: 14px; color: #000000; background-color: #FFFFFF"><div id="ePi" style="padding: 6px 10px 8px 10px; width: 572px; height: 12px; overflow: hidden; font-size: 12px; color: #000000">';
//                if (nodates) {
//                    mydiv = mydiv + '<i>De prijs is afhankelijk van de datum en het aantal personen. Vul uw vertrekdata en aantal personen in.</i>';
//                } else {
//                    mydiv = mydiv + '';
//                }

//                mydiv = mydiv + '</div></td>';
//                mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

//                mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';

//                if (extParts[8] != 'true') {
//                    mydiv = mydiv + '<td style="width: 642px; padding-top: 6px"><div style="width: 642px; height: 22px; vertical-align: middle; overflow: hidden"><img src="/App_Image/extra_voeg_toe.png" alt="Extra toevoegen" onclick="javascript:addExtra(' + extParts[4] + ', roomStr() );" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: right" /><img src="/App_Image/extra_sluit.png" alt="Extra sluiten" onclick="javascript: hidePopup();" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: left" /></div></td>';
//                } else {
//                    mydiv = mydiv + '<td style="width: 642px; padding-top: 6px"><div style="width: 642px; height: 22px; vertical-align: middle; overflow: hidden"><img src="/App_Image/extra_voeg_toe.png" alt="Extra toevoegen" onclick="javascript:addExtraTL(' + extParts[4] + ' );" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: right" /><img src="/App_Image/extra_sluit.png" alt="Extra sluiten" onclick="javascript: hidePopup();" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: left" /></div></td>';
//                }

//                mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

//                mydiv = mydiv + '</table>';

//                mydiv = mydiv + '</div>';

//                eval('extPersons = ' + extParts[3].toString());

//            }

//        }

//        showPopup(650, 600, mydiv)
//        break;

//    case "showExtraTL":
//        var extParts = result.split('~');

//        var mydiv = '';


//        var nodates = true;
//        if (extParts.length == 1) {

//            mydiv = '<div style="width: 650px; height: 600px; background-color: #dad1c2">';

//            mydiv = mydiv + '<div style="font-size: 12px; width: 625px; margin-left: 12px;margin-top:10px; font-weight: bold"><img src="/App_Image/alert_extra.png" alt="Let op" style="float: left; margin-right: 10px; margin-top: 5px" />Deze extra is niet beschikbaar binnen uw reisperiode</div>';

//            mydiv = mydiv + '</div>';

//        } else {

//            if (extParts[7] != 'true') {
//                nodates = false;
//            }

//            //        eval(extParts[5]);

//            if (extParts[0] == 'error') {
//                mydiv = '<div style="width: 650px; height: 600px; background-color: #dad1c2">';

//                mydiv = mydiv + '<div style="font-size: 12px; width: 625px; margin-left: 12px; font-weight: bold"><img src="/App_Image/alert_extra.png" alt="Let op" style="float: left; margin-right: 10px; margin-top: 5px" />' + extParts[1] + '</div>';

//                mydiv = mydiv + '</div>';
//            } else {
//                mydiv = '<input type="hidden" id="extraID" value="' + extParts[4] + '" /><div style="width: 650px; height: 600px; background-color: #dad1c2">';

//                mydiv = mydiv + '<table cellpadding="0" style="width: 650px" cellspacing="0">';

//                mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
//                mydiv = mydiv + '<td style="width: 642px; padding-top: 6px"><div onclick="javascript: hidePopup();" style="width: 642px; height: 22px; overflow: hidden; font-size: 14px; color: #FFFFFF; font-weight: bold"><img src="/App_Image/icon/close.gif" alt="Sluit venster" style="cursor: pointer; float: right" /><img src="/App_Image/button/add_orange.png" alt="Extra toevoegen" style="vertical-align: top; margin-right: 6px" />Extra toevoegen</div></td>';
//                mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

//                mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
//                mydiv = mydiv + '<td style="width: 642px"><div style="padding: 10px 10px 10px 10px; width: 622px; height: 492px; overflow: hidden; font-size: 12px; color: #000000; background-color: #FFFFFF">';

//                mydiv = mydiv + '<img src="' + extParts[2] + '" style="width: 231px; height 180px; float: right; margin-left: 10px; margin-bottom: 10px" alt="Extra image" /><div style="font-size: 14px; font-weight: bold">' + extParts[0] + '</div><div style="padding-top: 8px; padding-bottom: 8px; border-bottom: solid 1px #857663">';
//                mydiv = mydiv + extParts[1];

//                mydiv = mydiv + '</div><div style="padding-top: 8px; padding-bottom: 8px; border-bottom: solid 1px #857663">';


//                if (nodates) {
//                    mydiv = mydiv + '<input type="hidden" id="subServices" value="" /><input type="hidden" id="subServiceDates" value="" />'
//                } else {
//                    if (extParts[5] == '<input type="hidden" id="subServices" value="" /></select>') {
//                        mydiv = mydiv + extParts[5] + '<br/>';
//                    } else {
//                        mydiv = mydiv + extParts[5] + '<br/><br/>';
//                    }
//                    mydiv = mydiv + extParts[6] + '<br/>';
//                }

//                mydiv = mydiv + '</div>';

//                mydiv = mydiv + '</div></td>';
//                mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

//                mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
//                mydiv = mydiv + '<td style="width: 642px"><div style="width: 642px; height: 28px; border-top: solid 4px #dad1c2; overflow: hidden; font-size: 14px; color: #000000; background-color: #FFFFFF"><div id="ePi" style="padding: 6px 10px 8px 10px; width: 572px; height: 12px; overflow: hidden; font-size: 12px; color: #000000">';
//                if (nodates) {
//                    mydiv = mydiv + '<i>De prijs is afhankelijk van de datum en het aantal personen. Vul uw vertrekdata en aantal personen in.</i>';
//                } else {
//                    mydiv = mydiv + '';
//                }

//                mydiv = mydiv + '</div></td>';
//                mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

//                mydiv = mydiv + '<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';

//                if (extParts[8] != 'true') {
//                    mydiv = mydiv + '<td style="width: 642px; padding-top: 6px"><div style="width: 642px; height: 22px; vertical-align: middle; overflow: hidden"><img src="/App_Image/extra_voeg_toe.png" alt="Extra toevoegen" onclick="javascript:addExtra(' + extParts[4] + ', roomStr() );" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: right" /><img src="/App_Image/extra_sluit.png" alt="Extra sluiten" onclick="javascript: hidePopup();" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: left" /></div></td>';
//                } else {
//                    mydiv = mydiv + '<td style="width: 642px; padding-top: 6px"><div style="width: 642px; height: 22px; vertical-align: middle; overflow: hidden"><img src="/App_Image/extra_voeg_toe.png" alt="Extra toevoegen" onclick="javascript:addExtraTL(' + extParts[4] + ' );" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: right" /><img src="/App_Image/extra_sluit.png" alt="Extra sluiten" onclick="javascript: hidePopup();" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: left" /></div></td>';
//                }

//                mydiv = mydiv + '<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

//                mydiv = mydiv + '</table>';

//                mydiv = mydiv + '</div>';

//                eval('extPersons = ' + extParts[3].toString());

//            }

//        }

//        showPopup(650, 600, mydiv)
//        break;
        
//        case "extraPrice":
//            gO('ePi').innerHTML=result;
//        break;
//    case "addExtraTL":
//        var splitResult = new Array();
//        var showDiv = gO('divConfirm');

//        splitResult = result.split('~');
//        var extraObj = gO('extobj_' + splitResult[1]);

//        extraObj.innerHTML = '<div style="float:right;cursor:pointer;" onclick="javascript:Ajax_Code.removeExtraTL(\'' + splitResult[0] + '\', SucceededCallback, FailedCallback);"><img src="/App_image/extra_verwijder.png" alt="Extra verwijderen"  style="margin-right:5px;"/></div>';
//        showDiv.style.display = 'inline';
//        hidePopup();

//        break;
//    case "addExtra":
//        var splitResult = new Array();
//        splitResult = result.split('~');

//        hidePopup();
//        Ajax_Code.calculatePrice(splitResult[0], splitResult[1], splitResult[2], splitResult[3], splitResult[4], splitResult[5], splitResult[6], splitResult[7], splitResult[8], splitResult[9], splitResult[10], SucceededCallback, FailedCallback);

//        tPp(true);
//        break;

        case "nw_addExtra":
            var splitResult = new Array();
            splitResult = result.split('~');

            bookedExtras.push(splitResult[0]);

            resetExtraOptions();

            var myobj = gO('prijsContainer');

            if (myobj) {
                if (myobj.style.display == 'inline') {
                    pricechange = true;
                    Ajax_Code.showPrice(SucceededCallback, FailedCallback);
                }
            }

            break;

case "removeExtra":
    var extids = new Array();
    extids = result.split('~');
    for (j = extids.length - 1; j >= 0; j--) {
        for (i = bookedExtras.length - 1; i >= 0; i--) {
            if (bookedExtras[i] == extids[j]) {
                bookedExtras.splice(i, 1);
            }
        }
    }

    resetExtraOptions();

    var myobj = gO('prijsContainer');

    if (myobj) {
        if (myobj.style.display == 'inline') {
            pricechange = true;
            Ajax_Code.showPrice(SucceededCallback, FailedCallback);
        }
    }
    break;

//        case "removeExtraTL":
//            var splitResult = new Array();
//            splitResult = result.split('~');
//            var extraObj = gO('extobj_' + splitResult[0]);

//            extraObj.innerHTML = '<div style="float:right;cursor:pointer;" onclick="javascript:initExtraFromBoeking(' + splitResult[0] + ', false);"><img src="/App_Image/extra_voeg_toe.png" alt="Extra toevoegen" style="margin-right:5px;"/></div>';

//            break;
       

        case "addFavCity":
            var targetObj = gO('cityList');
            
            favCities.push(result);
            
            targetObj.innerHTML=targetObj.innerHTML+result;
            
            if (favCities.length==5)
            {
                gO('addCity').style.display='none';
            }
        break;
        
        case "getTafData":
            var splitResult = new Array();
            splitResult = result.split('~');
            
            var mydiv='<div style="width: 550px; height: 472px; background-color: #dad1c2">';
        
            mydiv=mydiv+'<table cellpadding="0" style="width: 550px" cellspacing="0">';
            
            mydiv=mydiv+'<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
            mydiv=mydiv+'<td style="width: 542px; padding-top: 6px"><div onclick="javascript: hidePopup();" style="width: 542px; height: 22px; overflow: hidden; font-size: 14px; color: #FFFFFF; font-weight: bold"><img src="/App_Image/icon/close.gif" alt="Sluit venster" style="cursor: pointer; float: right" /><img src="/App_Image/icon/mail.png" alt="Mail naar vriend(in)" style="vertical-align: top; margin-right: 6px" />Mail naar vriend(in)</div></td>';
            mydiv=mydiv+'<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';

            mydiv=mydiv+'<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
            mydiv=mydiv+'<td style="width: 542px"><div style="padding: 10px 10px 10px 10px; width: 522px; height:342px; overflow: hidden; font-size: 12px; color: #000000; background-color: #FFFFFF">';
            
            mydiv=mydiv+'Beste&nbsp;<input type="input" style="width: 100px" id="friendName" onfocus="javascript:if (this.value.substr(0,1)==\'[\') { this.value=\'\'; }" onblur="javascript:if (this.value.substr(0,1)==\'\') { this.value=\'[Naam vriend(in)]\'; }" value="[Naam vriend(in)]" />,<br/>';
            mydiv=mydiv+'<textarea id="friendMessage" style="width: 518px; margin-top: 3px; margin-bottom: 3px" cols="3" onfocus="javascript:if (this.value.substr(0,1)==\'[\') { this.value=\'\'; }" onblur="javascript:if (this.value.substr(0,1)==\'\') { this.value=\'[Bericht]\'; }">[Bericht]</textarea>';
            
            mydiv=mydiv+'<div style="float: right; color: #857663; font-weight: bold; font-size: 14px"><a href="'+splitResult[1]+'">'+splitResult[0]+'&nbsp;<img src="/App_Image/mail/link.png" alt="Link" /></a></div><div style="margin-top: 2px">Onderstaande stedentrip naar <b>'+splitResult[0]+'</b> wil ik graag met je delen:</div>';

            mydiv=mydiv+'<br/>';

            mydiv = mydiv + splitResult[2];

            mydiv=mydiv+'<div style="float: right; color: #857663; font-weight: bold; font-size: 14px"><a href=""'+splitResult[4]+'"">'+splitResult[3]+'&nbsp;<img src="/App_Image/mail/link.png" alt="Link" /></a></div><div style="margin-top: 2px; font-weight: bold; font-size: 13px">Hotel</div>';
            mydiv=mydiv+'<div style="font-size: 12px">'+splitResult[3]+' '+splitResult[5]+'</div>';
            mydiv=mydiv+'<div style="font-size: 12px">'+splitResult[6]+'</div>';

            mydiv=mydiv+'<br/>';
            
            mydiv=mydiv+'Groet,<br/><input type="input" style="width: 100px" id="eigenName" onfocus="javascript:if (this.value.substr(0,1)==\'[\') { this.value=\'\'; }" onblur="javascript:if (this.value.substr(0,1)==\'\') { this.value=\'[Uw naam]\'; }" value="'+splitResult[8]+'" />';
            
            
            mydiv=mydiv+'</div></td>';
            mydiv=mydiv+'<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';
         
            mydiv=mydiv+'<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td><td style="width: 542px"><div style="padding: 5px 5px 5px 10px; width: 527px; height: 38px; border-top: solid 4px #dad1c2; overflow: hidden; font-size: 10px; color: #000000; background-color: #FFFFFF">';
            mydiv=mydiv+'<table cellpadding="0" cellspacing="0"><tr><td>Uw eigen e-mailadres:</td><td>E-mailadres vriend(in):</td></tr><tr><td style="width: 180px"><input type="input" style="width: 150px" value="'+splitResult[7]+'" id="eigenMail" /></td><td><input type="input" style="width: 150px" id="friendMail" /></td></tr></table>';
            mydiv=mydiv+'</div></td><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';
                        
            mydiv=mydiv+'<tr><td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td>';
            mydiv=mydiv+'<td style="width: 542px; padding-top: 6px"><div style="width: 542px; height: 22px; vertical-align: middle; overflow: hidden"><img src="/App_Image/stuur_door.png" alt="Extra toevoegen" onclick="javascript:sendTafMail(); hidePopup();" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: right" /><img src="/App_Image/extra_sluit.png" alt="Venster sluiten" onclick="javascript: hidePopup();" style="cursor: pointer; margin-top: auto; margin-bottom: auto; float: left" /></div></td>';
            mydiv=mydiv+'<td style="width: 4px"><div style="width: 4px; overflow: hidden">&nbsp;</div></td></tr>';
            
            mydiv=mydiv+'</table>';
           
            mydiv=mydiv+'</div>';
                    
            showPopup(550, 560, mydiv);
        break;
        
        case "loadPriceSpec":
            priceSpec = result;

            showPriceSpec(null, false);
        break;
        
        case "zbSelectCity":
            var baseResults = new Array();
            baseResults = result.split('|');
            
            var transportResult = new Array();
            transportResult = baseResults[0].split('~');
            
            gO(tpID).innerHTML = dynamicTransport(transportResult, baseResults[1]);
            break;
        case "getExtraCat3":
            var splitResult = new Array();
            splitResult = result.split('~');

            var cat3obj = gO('cat3_' + splitResult[0]);

            while (cat3obj.length > 0) { cat3obj.remove(0); }

            if (splitResult[1] != '') {
                var cat3opt = new Array();
                cat3opt = splitResult[1].split('|');

                for (i = 0; i < cat3opt.length; i++) {
                    var c3parts = new Array();
                    c3parts = cat3opt[i].split('^');

                    var c3Option = document.createElement('option');
                    c3Option.value = c3parts[0];
                    c3Option.label = c3parts[1];
                    c3Option.text = c3parts[1];
                    addDDitem(cat3obj, c3Option);
                }
            } else {
                var c3Option = document.createElement('option');
                c3Option.value = "";
                c3Option.label = "";
                c3Option.text = "";
                addDDitem(cat3obj, c3Option);
            }


            break;

        case "loadRegioLuchthavens":
            var splitResult = new Array();
            splitResult = result.split('^');

            gO('stedenoverzicht').innerHTML = splitResult[0];
            eval(splitResult[1]);

            break;

        case "getExtraPrice":
            var splitResult = new Array();
            splitResult = result.split('~');

            var priceobj = gO('prijs_' + splitResult[0]);

            if (splitResult[1] == -1) {
                priceobj.innerHTML = '<div style="font-size: 11px"><b>niet beschikbaar</b><br/><i>Selecteer een andere categorie of ingangsdatum</i></div>';
                gO('prijstype_' + splitResult[0]).style.display='none';
            } else {
                priceobj.innerHTML = '&euro; ' + splitResult[1];
                gO('prijstype_' + splitResult[0]).style.display = 'inline'
            }

            break;

        case "sndTafMail":
            alert('De e-mail is verstuurd.');
        break;                
        
        default:
        
            alert(':(: '+result);
        break;
    }
}

function FailedCallback(error, userContext, methodName) 
{
    if(error !== null) 
    {
        switch (methodName)
        {
            default:
                //alert('Error with '+methodName+': '+error.get_message());
            break;
        }
    }    
}

