function ResetSavedVisitedNumber() {
	var url = Master_BasePath + "AccoCookies.aspx?Action=Numbers";
	var req = new Request();
	req.GetNoCache(url, ResetSavedVisitedNumberResult);
}
function ResetSavedVisitedNumberResult(result) {
	if (result.readyState != ReadyState.Complete) return;
	if (result.status == HttpStatus.OK && result.responseText != "") {
		var num_array = result.responseText.split(';');
		document.getElementById(MijnSuntip_SavedVak).innerHTML = document.getElementById(MijnSuntip_SavedVakText).value + " (" + num_array[0] + ")";
		document.getElementById(MijnSuntip_VisitedVak).innerHTML = document.getElementById(MijnSuntip_VisitedVakText).value + " (" + num_array[1] + ")";
	}
}
function SetLightboxSize() {
    var pop = document.getElementById("TravelersDiv");
    var pop3 = document.getElementById("newsletterDiv");
    var pop2 = document.getElementById("footerDiv");
    var pop4 = document.getElementById("DestinationMoreInfoDiv");
    var pop5 = document.getElementById("accoMailDiv");
    //var popRoom = document.getElementById("roomDescOverlayMain");
    var popInfo = document.getElementById("infoPopupDiv");
    if(pop == null || pop2 == null) return;
    
    var winy = 0;
    while(pop2 != null) {
        winy += pop2.offsetTop;
        pop2 = pop2.offsetParent;
    }
    pop.style.height = (winy + 40) + "px";
    pop3.style.height = (winy + 40) + "px";
    if(pop4 != null)
    {
        pop4.style.height = (winy + 40) + "px";
    }
    if(pop5 != null) {
        pop5.style.height = (winy + 40) + "px";
    }
    //if (popRoom != null) {
    //    popRoom.style.height = (winy + 40) + "px";
    //}
    if (popInfo != null) {
        popInfo.style.height = (winy + 40) + "px";
    }
}
var setChildrenBack = false;
var oldChildrenValue = -1;
var childrenBackElement;
function OpenTravelersWithIndexes(adultsIndex, childrenIndex, childrenBackElementId) {

    if (childrenIndex == 0) {   
        try
        {
            setChildrenZero();
        }
        catch (err) {
        }
    }
    else {

        document.getElementById("CtrlTravelcompany").style.display = "";
        var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
        document.getElementById("CtrlTravelcompany").style.top = (scrollTop + 50) + "px";
        document.getElementById("popupBackgroundTravelcompany").style.display = "";

        if (oldChildrenValue == -1) {
            oldChildrenValue = document.getElementById("ddlChild").selectedIndex;
        }
        setChildrenBack = true;
        childrenBackElement = document.getElementById(childrenBackElementId);

        document.getElementById("ddlAdults").selectedIndex = adultsIndex;
        document.getElementById("ddlChild").selectedIndex = childrenIndex;
        GetBirthdates(document.getElementById("ddlChild"), 0);
    }   
}
function OpenTravelers() {
    document.getElementById("CtrlTravelcompany").style.display = "";
    document.getElementById("popupBackgroundTravelcompany").style.display = "";
}
function CloseTravelers() {
    document.getElementById("CtrlTravelcompany").style.display = "none";
    document.getElementById("popupBackgroundTravelcompany").style.display = "none";
    if (setChildrenBack) {
        childrenBackElement.selectedIndex = oldChildrenValue;
    }
    setChildrenBack = false;
}
function SelectValueInDropdown(dropdownID, value) {    
  var dropdown = document.getElementById(dropdownID);
  for (i = 0; i < dropdown.length; i++) {
      if (dropdown.options[i].value == value) {
          dropdown.selectedIndex = i;
          return;
      }
  }
}
function scrollToCenterOfElementId(objId) {

    var y = findPosOfElement(document.getElementById(objId));
    if (y != -1) {
        y += (document.getElementById(objId).clientHeight / 2)
        
        //screenheight
        var viewportheight;        
        if (typeof window.innerHeight != 'undefined') {
            viewportheight = window.innerHeight;
        }      
        else if (typeof document.documentElement != 'undefined'
         && typeof document.documentElement.clientHeight != 'undefined' 
         && document.documentElement.clientHeight != 0) {
            viewportheight = document.documentElement.clientHeight;
        }        
        else {
            viewportheight = document.getElementsByTagName('body')[0].clientHeight;
        }

        y -= (viewportheight / 2);

        window.scroll(0, y);    
    }    
}
function findPosOfElement(obj) {
    var curtop = -1;
    if (obj.offsetParent) {
        do {
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return curtop;
    }
}
/**********************/
/*** AIRPORT_SELECT ***/
/**********************/
function OpenAirports() {
    document.getElementById("popupBackgroundAirports").style.display = "";
    document.getElementById("CtrlAirports").style.display = "";
    var scrollTop = document.body.scrollTop || document.documentElement.scrollTop  
    document.getElementById("CtrlAirports").style.top = (scrollTop+50) + "px";
}

function CloseAirports() {
    document.getElementById("popupBackgroundAirports").style.display = "none";
    document.getElementById("CtrlAirports").style.display = "none";
}
var airportSaveHiddenFieldID;
var airportAllHiddenFieldID
var airportMax;
var airportSelected = 0;
function OnAirportChecked(element) {
    if (element.checked) {
        if (document.getElementById(airportSaveHiddenFieldID).value.indexOf("|" + element.id + "|") == -1) {
            airportSelected++;
            document.getElementById(airportSaveHiddenFieldID).value += element.id + "|";
        }
        if (airportSelected >= airportMax) {            
            var splitted = document.getElementById(airportAllHiddenFieldID).value.split("|");
            for (i = 0; i < splitted.length; i++) {
                var id = splitted[i];
                if (id.length > 0) {                                      
                    if (document.getElementById(airportSaveHiddenFieldID).value.indexOf(id) == -1) {
                        document.getElementById(id).disabled = true;
                    }
                }
            }
        }
    }
    else {
        if (airportSelected >= airportMax) {
            var splitted = document.getElementById(airportAllHiddenFieldID).value.split("|");
            for (i = 0; i < splitted.length; i++) {
                var id = splitted[i];
                if (id.length > 0) {                    
                    document.getElementById(id).disabled = false;                    
                }
            }
        }
        airportSelected--;
        document.getElementById(airportSaveHiddenFieldID).value = document.getElementById(airportSaveHiddenFieldID).value.replace(element.id + "|", "");
    }
}
/***************************/
/*** ACCO_PAGE_PHOTO_TOP ***/
/***************************/
function SelectPhotoTop(element, borderStyle) {

    var amountPhotos = 4;
    for (i = 1; i < (amountPhotos + 1); i++) {
        try {
            document.getElementById('photoTop' + i).style.border = '';
        }
        catch(err){}
    }

    document.getElementById('photoTopBig').src = element.src;
    element.style.border = borderStyle;    
}
/************************/
/*** ACCO_VIEWED_SAVED ***/
/************************/
var vs_scrollOffset = 0;
var vs_itemWidth = 180;
var vs_totalItems = -1;
var vs_visibleItems = -1;
var previous = false;
var next = true;
function viewedSavedScrollNext() {
    if (next) {
        vs_scrollOffset += vs_itemWidth;
        $('#divViewedSavedScroll').animate({ scrollLeft: vs_scrollOffset });
        viewedSavedDecideButtonStates();
        viewedSavedDecideLoadNewItem();
    }
}
function viewedSavedScrollPrevious() {
    if (previous) {
        vs_scrollOffset -= vs_itemWidth;
        $('#divViewedSavedScroll').animate({ scrollLeft: vs_scrollOffset });
        viewedSavedDecideButtonStates();
        viewedSavedDecideLoadNewItem();
    }
}
function viewedSavedDecideButtonStates() {
    if (vs_visibleItems == -1 || vs_totalItems == -1) {
        vs_totalItems = document.getElementById('trViewedSaved').getElementsByTagName('table').length/2;
        vs_visibleItems = Math.round((document.getElementById('divViewedSavedScroll').style.width.replace('px', '')) / vs_itemWidth);   
    }

    if (vs_scrollOffset == 0) {
        document.getElementById('imgViewedSavedPrevious').className = "semi-transparent";
        previous = false;
    }
    else {
        document.getElementById('imgViewedSavedPrevious').className = "";
        previous = true;
    }

    if (vs_scrollOffset == ((vs_totalItems-vs_visibleItems)*vs_itemWidth)) {
        document.getElementById('imgViewedSavedNext').className = "semi-transparent";
        next = false;
    }
    else {
        document.getElementById('imgViewedSavedNext').className = "";
        next = true;
    }
}
function viewedSavedDecideLoadNewItem() {
    if (vs_scrollOffset > 0) {        
        var index = (vs_scrollOffset / vs_itemWidth + vs_visibleItems - 1) * 2;
        var listTables = document.getElementById('trViewedSaved').getElementsByTagName('table');
        if (listTables.item(index).style.display != 'none') {
            var accoID = listTables.item(index).id
            if (accoID != 'viewedSavedLinks' && accoID != 'viewedSavedLinks2') {
                accoID = accoID.replace('tableViewedSavedLoading', '');    
                setTimeout("viewedSavedLoadNewItem('" + accoID + "')", 200);
            }
        }
    }
}
function viewedSavedLoadNewItem(accoID) {    
    Suntip_nl.Service.ViewedSavedAccommodationsCarousel_Service.GetAccoInfo(accoID, ReuqestViewedSaveCompleteCallback, ReuqestViewedSaveCompleteErrorCallback);    
}
function ReuqestViewedSaveCompleteCallback(result) {
        
    var json = JSON.parse(result);
    
    document.getElementById('aViewedSavedAcco' + json.AccoID).innerHTML = json.AccoType + " " + json.AccoName;
    document.getElementById('aViewedSavedPlace' + json.AccoID).title = json.PlaceName;
    document.getElementById('aViewedSavedPlace' + json.AccoID).href = json.PlaceUrl;
    document.getElementById('aViewedSavedCountry' + json.AccoID).title = json.CountryName;
    document.getElementById('aViewedSavedCountry' + json.AccoID).href = json.CountryUrl;
    document.getElementById('aViewedSavedAcco' + json.AccoID).href = json.AccoUrl;
    document.getElementById('imgViewedSaved' + json.AccoID).src = json.ImageUrl;
    document.getElementById("tdViewedSavedClassification" + json.AccoID).innerHTML = json.ClassificationHtml;        

    var placeName = json.PlaceName;
    if (placeName.length > 12) {
        placeName = placeName.substring(0, 10) + "..";
    }
    document.getElementById('aViewedSavedPlace' + json.AccoID).innerHTML = placeName;

    var countryName = json.CountryName;
    if (countryName.length > 12) {
        countryName = countryName.substring(0, 10) + "..";
    }
    document.getElementById('aViewedSavedCountry' + json.AccoID).innerHTML = countryName;

    document.getElementById('tableViewedSavedLoading' + json.AccoID).style.display = "none";
    document.getElementById('tableViewedSaved' + json.AccoID).style.display = "";
}
function ReuqestViewedSaveCompleteErrorCallback(error) {

}
function AddViewedSavedValue(value, elementId) {
    var currentValue = parseInt(document.getElementById(elementId).innerHTML.replace('(', '').replace(')', ''));
    currentValue += value;
    document.getElementById(elementId).innerHTML = '(' + currentValue + ')';
}
/***************************/
/*** PRICE_MATRIX ***/
/***************************/
function PriceMatrixHover(colNr, rowNr) {
    //
    var table = document.getElementById("tablePriceMatrix");
    for (var i = 0; i < table.rows.length; i++) {
        var row = table.rows[i];
        for (var j = 0; j < row.cells.length; j++) {
            var cell = row.cells[j];
            try {
                if (parseInt(cell.getAttribute('colnr')) == parseInt(colNr) && parseInt(cell.getAttribute('rownr')) == parseInt(rowNr)) {
                    cell.style.backgroundImage = "url('" + Master_BasePath + "Style/Images/price-hook-selected.png')"
                    cell.style.backgroundPosition = "0px center";
                }
                else if (parseInt(cell.getAttribute('rownr')) < parseInt(rowNr) && parseInt(cell.getAttribute('colnr')) == parseInt(colNr)) {
                    cell.style.backgroundImage = "url('" + Master_BasePath + "Style/Images/price-hook-selected.png')"
                    cell.style.backgroundPosition = "45px center";
                }
                else if (parseInt(cell.getAttribute('colnr')) < parseInt(colNr) && parseInt(cell.getAttribute('rownr')) == parseInt(rowNr)) {
                    cell.style.backgroundImage = "url('" + Master_BasePath + "Style/Images/price-hook-selected.png')"
                    cell.style.backgroundPosition = "90px center";
                }                
            }
            catch (err) {alert(err.Message); }
        }
    }
}
function PriceMatrixHoverOut() {
    var table = document.getElementById("tablePriceMatrix");
    for (var i = 0; i < table.rows.length; i++) {
        var row = table.rows[i];
        for (var j = 0; j < row.cells.length; j++) {
            var cell = row.cells[j];
            try {
                if (cell.getAttribute('rownr') != null && cell.getAttribute('colnr') != null) {                    
                    cell.style.backgroundImage = "";
                }
            }
            catch (err) { alert(err.Message); }
        }
    }
}
/****************************/
/*** RECEIPT_AVAILABILITY ***/
/****************************/
var airportTabPriceHtml1 = '';
var airportTabPriceHtml2 = '';
var airportTabPriceHtml3 = '';
var airportTabPriceTotal1 = '';
var airportTabPriceTotal2 = '';
var airportTabPriceTotal3 = '';
var currentId = 1;
function ReceiptAvailabilityTab(tab, tabLoader, tabContent, tabAvailability, id) {
    currentId = id;
    document.getElementById('Tab_Airport1').style.display = 'none';
    document.getElementById('Tab_Airport2').style.display = 'none';
    document.getElementById('Tab_Airport3').style.display = 'none';
    
    document.getElementById('img_Loading_Tab_Airport1').src = Master_BasePath + 'Style/Images/loader-airport-price-inactive.gif';
    try { document.getElementById('img_Loading_Tab_Airport2').src = Master_BasePath + 'Style/Images/loader-airport-price-inactive.gif'; } catch (err) { }
    try { document.getElementById('img_Loading_Tab_Airport3').src = Master_BasePath + 'Style/Images/loader-airport-price-inactive.gif'; } catch (err) { }

    
    document.getElementById('Tab_Airport1Tab').className = 'Tab_Airport_Inactive';
    try { document.getElementById('Tab_Airport2Tab').className = 'Tab_Airport_Inactive'; } catch (err) { }
    try { document.getElementById('Tab_Airport3Tab').className = 'Tab_Airport_Inactive'; } catch (err) { }

    document.getElementById(tabContent).style.display = '';    
    document.getElementById(tabLoader).src = Master_BasePath + 'Style/Images/loader-airport-price.gif';
    document.getElementById(tab).className = 'Tab_Airport';

    document.getElementById('aAvailability_Next_Enabled').href = Master_BasePath + 'Boeken/StartBooksteps.aspx?id=' + id;

    if (document.getElementById(tabAvailability).innerHTML == 'niet beschikbaar' || document.getElementById(tabAvailability).style.display == 'none') {
        document.getElementById('tdAvailability_Next_Disabled').style.display = '';
        document.getElementById('tdAvailability_Next_Enabled').style.display = 'none';
    }
    else {
        document.getElementById('tdAvailability_Next_Disabled').style.display = 'none';
        document.getElementById('tdAvailability_Next_Enabled').style.display = '';
    }

    if (id == 1) {
        ReceiptAvailabilityPriceInfo(airportTabPriceHtml1, airportTabPriceTotal1, 1)
    }
    else if (id == 2) {
        ReceiptAvailabilityPriceInfo(airportTabPriceHtml2, airportTabPriceTotal2, 2)
    }
    else {
        ReceiptAvailabilityPriceInfo(airportTabPriceHtml3, airportTabPriceTotal3, 3)
    }
}
function ReceiptAvailabilityPriceInfo(priceHtml, priceTotal, id) {
    if (currentId == id) {
        if (priceHtml == '') {
            document.getElementById('trReceiptPriceInfo').style.display = 'none';
            document.getElementById('trReceiptUncertain').style.display = 'none';
        }
        else if (priceHtml == 'uncertain') {
            document.getElementById('trReceiptPriceInfo').style.display = 'none';
            document.getElementById('trReceiptUncertain').style.display = '';
        }
        else {
            document.getElementById('trReceiptPriceInfo').style.display = '';
            document.getElementById('trReceiptUncertain').style.display = 'none';
            document.getElementById('tdPriceInfo_Availability').innerHTML = priceHtml;
            document.getElementById('h2TotalPrice_Availability').innerHTML = '&euro; ' + priceTotal;
        }
    }
}

/*********************/
/*** CONTACT BLOCK ***/
/*********************/
var firstBelMijTerug = true;
function setTab_Communication(tabID, contentID) {

    if (tabID == 'Tab_BelmijterugTab' && firstBelMijTerug) {
        firstBelMijTerug = false;
        document.getElementById('frameFreeCall').src = Master_BasePath + 'Plugins/FreeCall.aspx';
    }

    document.getElementById('Tab_Belons').style.display = 'none';
    document.getElementById('Tab_Belmijterug').style.display = 'none';
    document.getElementById('Tab_Chat').style.display = 'none';
    document.getElementById('Tab_Email').style.display = 'none';
    document.getElementById(contentID).style.display = '';

    document.getElementById('Tab_BelonsTab').className = 'Tab_Belons_Inactive';
    document.getElementById('Tab_BelmijterugTab').className = 'Tab_Belmijterug_Inactive';
    document.getElementById('Tab_ChatTab').className = 'Tab_Chat_Inactive';
    document.getElementById('Tab_EmailTab').className = 'Tab_Email_Inactive';
    document.getElementById(tabID).className = 'Tab' + tabID.replace('Tab', '').replace('Tab', '');    
}
/*********************/
/*** HOLIDAY_MUSIC ***/
/*********************/
function onMovieMusicChange(dropdown, movieID)
{
    var index = dropdown.selectedIndex;
    var value = dropdown.options[index].value;    
    if (value != '-1') {
        document.getElementById('frameHolidayMovieGadget').src = Master_BasePath + 'vakantiefilm-gadget.aspx?mid=' + movieID + '&mu=' + value;
    }
    else {
        document.getElementById('frameHolidayMovieGadget').src = Master_BasePath + 'vakantiefilm-gadget.aspx?mid=' + movieID;
    }
}
/*********************/
/*** HOLIDAY_MOVIE ***/
/*********************/
function onHolidayMovieDidReplay() {
    document.getElementById('imgMoviePause').style.display = '';
    document.getElementById('imgMoviePlay').style.display = 'none';
}
function onHolidayMovieDidEnd() {
    document.getElementById('imgMoviePause').style.display = 'none';
    document.getElementById('imgMoviePlay').style.display = '';
}

/*******************/
/*** MATRIX_DRAG ***/
/*******************/
var Drag = {

    obj: null,

    init: function (o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper) {
        
        o.onmousedown = Drag.start;        
        
        o.hmode = bSwapHorzRef ? false : true;
        o.vmode = bSwapVertRef ? false : true;

        o.root = oRoot && oRoot != null ? oRoot : o;

        if (o.hmode && isNaN(parseInt(o.root.style.left))) o.root.style.left = "0px";
        if (o.vmode && isNaN(parseInt(o.root.style.top))) o.root.style.top = "0px";
        if (!o.hmode && isNaN(parseInt(o.root.style.right))) o.root.style.right = "0px";
        if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

        o.minX = typeof minX != 'undefined' ? minX : null;
        o.minY = typeof minY != 'undefined' ? minY : null;
        o.maxX = typeof maxX != 'undefined' ? maxX : null;
        o.maxY = typeof maxY != 'undefined' ? maxY : null;

        o.xMapper = fXMapper ? fXMapper : null;
        o.yMapper = fYMapper ? fYMapper : null;

        o.root.onDragStart = new Function();
        o.root.onDragEnd = new Function();
        o.root.onDrag = new Function();
    },

    start: function (e) {
        var o = Drag.obj = this;
        e = Drag.fixE(e);
        var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right);
        o.root.onDragStart(x, y);

        o.lastMouseX = e.clientX;
        o.lastMouseY = e.clientY;

        if (o.hmode) {
            if (o.minX != null) o.minMouseX = e.clientX - x + o.minX;
            if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
        } else {
            if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
            if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
        }

        if (o.vmode) {
            if (o.minY != null) o.minMouseY = e.clientY - y + o.minY;
            if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY;
        } else {
            if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
            if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
        }

        document.onmousemove = Drag.drag;
        document.onmouseup = Drag.end;

        return false;
    },

    drag: function (e) {
        e = Drag.fixE(e);
        var o = Drag.obj;

        var ey = e.clientY;
        var ex = e.clientX;
        var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right);
        var nx, ny;

        if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
        if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
        if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
        if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

        nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
        ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

        if (o.xMapper) nx = o.xMapper(y)
        else if (o.yMapper) ny = o.yMapper(x)

        Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
        Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
        Drag.obj.lastMouseX = ex;
        Drag.obj.lastMouseY = ey;

        Drag.obj.root.onDrag(nx, ny);
        return false;
    },

    end: function () {
        document.onmousemove = null;
        document.onmouseup = null;
        Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]),
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
        Drag.obj = null;
    },

    fixE: function (e) {
        if (typeof e == 'undefined') e = window.event;
        if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
        if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
        return e;
    }
};

var dragMonth1;
var dragMonth2;
var dragYear1;
var dragYear2;
var dragMax1;
var dragMax2;
function setupReceiptMatrixDrag() {    
    dragYear1 = parseInt(document.getElementById('hiddenReceiptMatrixParamYear1').value);
    dragYear2 = parseInt(document.getElementById('hiddenReceiptMatrixParamYear2').value); 
    dragMonth1 = parseInt(document.getElementById('hiddenReceiptMatrixParamMonth1').value)-1; 
    dragMonth2 = parseInt(document.getElementById('hiddenReceiptMatrixParamMonth2').value)-1;
    dragMax1 = parseInt(document.getElementById('hiddenReceiptMatrixParamMax1').value);
    dragMax2 = parseInt(document.getElementById('hiddenReceiptMatrixParamMax2').value);
    var currentDay = parseInt(document.getElementById('hiddenReceiptMatrixParamCurrentDay').value);    

    var dragElement = document.getElementById('divReceipt_Matrix_Drag');
    Drag.init(dragElement, null, 0, 248, 0, 0);
    dragElement.onDragStart = function (x, y) {
        document.getElementById('divReceipt_Matrix_Drag_Indicator').style.display = '';
    }
    dragElement.onDragEnd = function (x, y) {
        document.getElementById('divReceipt_Matrix_Drag_Indicator').style.display = 'none';
        ReceiptMatrixDragShowWeek(Math.ceil(x / 4));
    }
    dragElement.onDrag = function (x, y) {
        ReceiptMatrixDragUpdateDate(Math.ceil(x / 4));
    }

    document.getElementById('divReceipt_Matrix_Drag').style.left = (currentDay*4) + 'px';
    document.getElementById('divReceipt_Matrix_Drag').style.display = '';
    ReceiptMatrixDragUpdateDate(currentDay);
}
function ReceiptMatrixDragShowWeek(day) {
    var month = dragMonth1;
    var year = dragYear1;
    if (day > dragMax1) {
        month = dragMonth2;
        year = dragYear2;
        day = day - dragMax1;
        if (day > dragMax2) {
            day = dragMax2;
        }
    }
    if (day == 0) {
        day = 1;
    }

    var date = new Date(year, month, day, 0, 0, 0, 0);
    DragWeek(date.format("yyyyMMdd"));
}

function ReceiptMatrixDragUpdateDate(day) {    
    var month = dragMonth1;
    var year = dragYear1;
    if (day > dragMax1) {
        month = dragMonth2;
        year = dragYear2;
        day = day - dragMax1;
        if (day > dragMax2) {
            day = dragMax2;
        }
    }
    if (day == 0) {
        day = 1;
    }

    var date = new Date(year, month, day, 0, 0, 0, 0);
    while (date.getDay() != 1) {
        date.setDate(date.getDate() - 1);
    } 
    var date2 = new Date(year, month, day, 0, 0, 0, 0);
    date2.setDate(date.getDate() + 6);
    document.getElementById('divReceipt_Matrix_Drag_Indicator').innerHTML = 'Ma' + ' ' + date.getDate() + '-' + date.format("MMM") + ' - ' + 'Zo' + ' ' + date2.getDate() + '-' + date2.format("MMM");
}
/**********************/
/*** ROOM SELECTION ***/
/**********************/
var roomSelectionAmountRooms;
var roomSelectionCurrentPos;
var roomSelectionUnitIDs;
var roomSelectionDropDowns;
function RoomSelectionChanged(dropdown, unitID, unitDescription, minOcc, maxOcc) {
    if (roomSelectionAmountRooms == null) {
        roomSelectionAmountRooms = new Array();
        roomSelectionUnitIDs = new Array('', '', '', '', '', '', '', '');
        roomSelectionDropDowns = new Array();
        roomSelectionCurrentPos = 1;        
    }
    
    //background highlight
    if (dropdown.value == '0') {
        document.getElementById('trUnit' + unitID).className = "Item";
        document.getElementById('trUnitNotes' + unitID).className = "Item";
    }
    else {
        document.getElementById('trUnit' + unitID).className = "Item Selected";
        document.getElementById('trUnitNotes' + unitID).className = "Item Selected";
    }

    roomSelectionDropDowns[unitID] = dropdown;

    //show/not show room assign
    var oldAmount = roomSelectionAmountRooms[unitID];
    roomSelectionAmountRooms[unitID] = parseInt(dropdown.value);
    if (oldAmount == null) {
        oldAmount = 0;
    }
    var add = roomSelectionAmountRooms[unitID] - oldAmount;    

    if (add >= 0) {
        for (var i = 0; i < add; i++) {
            if (roomSelectionCurrentPos < 9) {

                document.getElementById('AssignRoomType' + roomSelectionCurrentPos).innerHTML = unitDescription;

                if (minOcc == maxOcc) {
                    if (minOcc == 1) {
                        document.getElementById('AssignRoomOcc' + roomSelectionCurrentPos).innerHTML = '1 persoon';
                    }
                    else {
                        document.getElementById('AssignRoomOcc' + roomSelectionCurrentPos).innerHTML = minOcc + ' personen';
                    }
                }
                else {
                    document.getElementById('AssignRoomOcc' + roomSelectionCurrentPos).innerHTML = minOcc + ' tot ' + maxOcc + ' personen';
                }

                document.getElementById('AssignRoomMinOcc' + roomSelectionCurrentPos).value = minOcc;
                document.getElementById('AssignRoomMaxOcc' + roomSelectionCurrentPos).value = maxOcc;

                document.getElementById('AssignRoomType' + roomSelectionCurrentPos).style.display = '';
                document.getElementById('AssignRoomRemoveButton' + roomSelectionCurrentPos).style.display = '';               
                document.getElementById('AssignRoomOcc' + roomSelectionCurrentPos).style.display = '';
                for (var j = 1; j < 9; j++) {
                    document.getElementById('AssignRoomRow' + roomSelectionCurrentPos + "_" + j).style.display = '';
                    document.getElementById('AssignRoomRadio' + roomSelectionCurrentPos + "_" + j).checked = false;
                }
                document.getElementById('AssignRoomStatus' + roomSelectionCurrentPos).style.display = '';
                document.getElementById('AssignRoomStatus' + roomSelectionCurrentPos + '_Ok').style.display = 'none';
                document.getElementById('AssignRoomStatus' + roomSelectionCurrentPos + '_NotOk').style.display = '';
                document.getElementById('AssignRoomStatus' + roomSelectionCurrentPos + '_NotOk2').style.display = 'none';
                
                roomSelectionUnitIDs[roomSelectionCurrentPos-1] = unitID;

                roomSelectionCurrentPos++;
            }
        }
    }
    else {
        for (var i = 0; i < (0 - add); i++) {
            for (var j = (roomSelectionCurrentPos - 2); j >= 0; j--) {
                if (roomSelectionUnitIDs[j] == unitID) {                    
                    RoomSelectionRemove(j + 1);                    
                    break;
                }
            }
        }
    }

    if (roomSelectionCurrentPos > 1) {
        document.getElementById('trRoomAssign').style.display = '';
    }
    else {
        document.getElementById('trRoomAssign').style.display = 'none';
    }
}

function RoomSelectionRestore(selectionValue) {    

    roomSelectionAmountRooms = new Array();
    roomSelectionUnitIDs = new Array('', '', '', '', '', '', '', '');
    roomSelectionDropDowns = new Array();
    roomSelectionCurrentPos = 1;    

    var units = selectionValue.split(';');
    for (var i = 0; i < units.length; i++) {        

        if (units[i] != '') {
            var unitID = units[i].split(',')[0];

            roomSelectionUnitIDs[roomSelectionCurrentPos - 1] = unitID;

            if (roomSelectionAmountRooms[unitID] == null) {
                roomSelectionAmountRooms[unitID] = 0;
            }
            roomSelectionAmountRooms[unitID]++;
                        
            roomSelectionDropDowns[unitID] = document.getElementById(document.getElementById('RoomSelectionDropDownID' + unitID).value);
            
            document.getElementById('AssignRoomType' + roomSelectionCurrentPos).innerHTML = document.getElementById('RoomSelectionType' + unitID).value;
            
            var minOcc = parseInt(document.getElementById('RoomSelectionMinOcc' + unitID).value);
            var maxOcc = parseInt(document.getElementById('RoomSelectionMaxOcc' + unitID).value);            
            if (minOcc == maxOcc) {
                if (minOcc == 1) {
                    document.getElementById('AssignRoomOcc' + roomSelectionCurrentPos).innerHTML = '1 persoon';
                }
                else {
                    document.getElementById('AssignRoomOcc' + roomSelectionCurrentPos).innerHTML = minOcc + ' personen';
                }
            }
            else {
                document.getElementById('AssignRoomOcc' + roomSelectionCurrentPos).innerHTML = minOcc + ' tot ' + maxOcc + ' personen';
            }

            document.getElementById('AssignRoomMinOcc' + roomSelectionCurrentPos).value = minOcc;
            document.getElementById('AssignRoomMaxOcc' + roomSelectionCurrentPos).value = maxOcc;

            document.getElementById('AssignRoomType' + roomSelectionCurrentPos).style.display = '';
            document.getElementById('AssignRoomRemoveButton' + roomSelectionCurrentPos).style.display = '';
            document.getElementById('AssignRoomOcc' + roomSelectionCurrentPos).style.display = '';
            for (var j = 1; j < 9; j++) {
                document.getElementById('AssignRoomRow' + roomSelectionCurrentPos + "_" + j).style.display = '';
            }
            var paxes = units[i].split(',');
            for (var j = 0; j < paxes.length; j++) {
                if (j != 0) {
                    paxID = paxes[j];
                    document.getElementById('AssignRoomRadio' + roomSelectionCurrentPos + "_" + paxID).checked = true;
                }
            }
            document.getElementById('AssignRoomStatus' + roomSelectionCurrentPos).style.display = '';
            document.getElementById('AssignRoomStatus' + roomSelectionCurrentPos + '_Ok').style.display = 'none';
            document.getElementById('AssignRoomStatus' + roomSelectionCurrentPos + '_NotOk').style.display = '';
            document.getElementById('AssignRoomStatus' + roomSelectionCurrentPos + '_NotOk2').style.display = 'none';


            roomSelectionCurrentPos++;
        }
    }
        
    for (var i = 0; i < units.length; i++) {
        if (units[i] != '') {
            var unitID = units[i].split(',')[0];
            
            roomSelectionDropDowns[unitID].value = '' + roomSelectionAmountRooms[unitID];            

            document.getElementById('trUnit' + unitID).className = "Item Selected";
            document.getElementById('trUnitNotes' + unitID).className = "Item Selected";
        }
    }    

    if (roomSelectionCurrentPos > 1) {
        document.getElementById('trRoomAssign').style.display = '';
    }
    else {
        document.getElementById('trRoomAssign').style.display = 'none';
    }

    RoomSelectionPaxSelectionChanged();
}

function RoomSelectionManualRemove(position) {    

    var unitID = roomSelectionUnitIDs[position - 1];
    var dropdown = roomSelectionDropDowns[unitID];

    roomSelectionAmountRooms[unitID] = roomSelectionAmountRooms[unitID] - 1;
    dropdown.selectedIndex = dropdown.selectedIndex - 1;

    if (dropdown.value == '0') {
        document.getElementById('trUnit' + unitID).className = "Item";
        document.getElementById('trUnitNotes' + unitID).className = "Item";
    }
    else {
        document.getElementById('trUnit' + unitID).className = "Item Selected";
        document.getElementById('trUnitNotes' + unitID).className = "Item Selected";
    }

    RoomSelectionRemove(position);
    if (roomSelectionCurrentPos > 1) {
        document.getElementById('trRoomAssign').style.display = '';
    }
    else {
        document.getElementById('trRoomAssign').style.display = 'none';
    }
}

function RoomSelectionRemove(position) {
    if (position < (roomSelectionCurrentPos - 1)) {        
        for (var i = position; i < (roomSelectionCurrentPos - 1); i++) {        
            roomSelectionUnitIDs[i - 1] = roomSelectionUnitIDs[i];
            document.getElementById('AssignRoomType' + i).innerHTML = document.getElementById('AssignRoomType' + (i + 1)).innerHTML;            
            document.getElementById('AssignRoomOcc' + i).innerHTML = document.getElementById('AssignRoomOcc' + (i + 1)).innerHTML;
            document.getElementById('AssignRoomMinOcc' + i).value = document.getElementById('AssignRoomMinOcc' + (i+1)).value;
            document.getElementById('AssignRoomMaxOcc' + i).value = document.getElementById('AssignRoomMaxOcc' + (i+1)).value;
            document.getElementById('AssignRoomStatus' + i + '_Ok').style.display = document.getElementById('AssignRoomStatus' + (i+1) + '_Ok').style.display;
            document.getElementById('AssignRoomStatus' + i + '_NotOk').style.display = document.getElementById('AssignRoomStatus' + (i + 1) + '_NotOk').style.display;
            document.getElementById('AssignRoomStatus' + i + '_NotOk2').style.display = document.getElementById('AssignRoomStatus' + (i + 1) + '_NotOk2').style.display;
            for (var j = 1; j < 9; j++) {
                document.getElementById('AssignRoomRadio' + i + "_" + j).checked = document.getElementById('AssignRoomRadio' + (i+1) + "_" + j).checked;
            }
        }
    }
    document.getElementById('AssignRoomType' + (roomSelectionCurrentPos - 1)).style.display = 'none';
    document.getElementById('AssignRoomRemoveButton' + (roomSelectionCurrentPos - 1)).style.display = 'none';
    document.getElementById('AssignRoomOcc' + (roomSelectionCurrentPos - 1)).style.display = 'none';
    for (var j = 1; j < 9; j++) {
        document.getElementById('AssignRoomRow' + (roomSelectionCurrentPos - 1) + "_" + j).style.display = 'none';
    }
    document.getElementById('AssignRoomStatus' + (roomSelectionCurrentPos - 1)).style.display = 'none';
    roomSelectionCurrentPos--;
}

function RoomSelectionPaxSelectionChanged() {
    for (var c = 1; c < (roomSelectionCurrentPos); c++) {
        var totalSelected = 0;
        for (var r = 1; r < 9; r++) {
            if (document.getElementById('AssignRoomRadio' + c + "_" + r).checked) {
                totalSelected++;
            }
        }
        var minOcc = parseInt(document.getElementById('AssignRoomMinOcc' + c).value);
        var maxOcc = parseInt(document.getElementById('AssignRoomMaxOcc' + c).value);
        if (totalSelected >= minOcc && totalSelected <= maxOcc) {
            document.getElementById('AssignRoomStatus' + c + '_Ok').style.display = '';
            document.getElementById('AssignRoomStatus' + c + '_NotOk').style.display = 'none';
            document.getElementById('AssignRoomStatus' + c + '_NotOk2').style.display = 'none';
        }
        else if(totalSelected > maxOcc) {
            document.getElementById('AssignRoomStatus' + c + '_Ok').style.display = 'none';
            document.getElementById('AssignRoomStatus' + c + '_NotOk').style.display = 'none';
            document.getElementById('AssignRoomStatus' + c + '_NotOk2').style.display = '';
        }
        else {
            document.getElementById('AssignRoomStatus' + c + '_Ok').style.display = 'none';
            document.getElementById('AssignRoomStatus' + c + '_NotOk').style.display = '';
            document.getElementById('AssignRoomStatus' + c + '_NotOk2').style.display = 'none';
        }
    }
}
function RoomSelectionSave(fieldForValueId) {

    var fieldForValue = document.getElementById(fieldForValueId);
    fieldForValue.value = '';

    //first test if all rooms have enough persons
    for (var c = 1; c < (roomSelectionCurrentPos); c++) {
        if (document.getElementById('AssignRoomStatus' + c + '_Ok').style.display == 'none') {
            alert('Niet alle kamers hebben genoeg personen toegewezen. Zorg aub dat alle kamers genoeg personen toegewezen hebben gekregen');
            return;
        }
        else {
            //save the information for this one already
            var unitID = roomSelectionUnitIDs[c - 1];
            for (var r = 1; r < 9; r++) {
                if (document.getElementById('trAssignRow' + r).style.display != 'none') {
                    if (document.getElementById('AssignRoomRadio' + c + "_" + r).checked) {
                        unitID += "," + r;    
                    }
                }
            }
            fieldForValue.value += unitID + ";";
        }
    }

    
    //then test if all persons are added to a room.
    for (var r = 1; r < 9; r++) {
        if(document.getElementById('trAssignRow' + r).style.display != 'none') {
            var selected = false;
            for (var c = 1; c < (roomSelectionCurrentPos); c++) {
                if (document.getElementById('AssignRoomRadio' + c + "_" + r).checked) {
                    selected = true;                                        
                }
            }
            if (!selected) {
                alert('Niet alle personen zijn toegewezen aan een kamer. Zorg aub dat ieder persoon aan een kamer is toegewezen');
                return;
            }
        }
    }

    PostMultiRoomSave();
}
/****************/
/*** FAQ_PAGE ***/
/****************/
var faqOpenedQuestionId = '';
function FaqOpenQuestion(id) {    
    FaqCloseQuestion();
    document.getElementById(id).style.display = '';
    faqOpenedQuestionId = id;
}
function FaqCloseQuestion()
{
    if (faqOpenedQuestionId != '') {
        document.getElementById(faqOpenedQuestionId).style.display = 'none';
    }
}

/***************************/



function CheckTravelersDates() {
    var res = true;
    var ddl0 = document.getElementById("ddlAdults");
    var ddl1 = document.getElementById("ddlChild");
    //var ddl2 = document.getElementById("ddlBaby");
    var num0 = parseInt(ddl0.options[ddl0.selectedIndex].text, 10);
    var num1 = parseInt(ddl1.options[ddl1.selectedIndex].text, 10);
    //var num2 = parseInt(ddl2.options[ddl2.selectedIndex].text, 10);
    num2 = 0;
    
    if(num0 + num1 + num2 > 8) {
        res = false;
        alert("Het is helaas niet mogelijk om in een boeking\r\n meer dan 8 personen te boeken.\r\n U kunt eventueel meerdere boekingen maken\r\n of telefonisch contact met ons op nemen.");
    }

    for(var i = 1; i < num1 + 1; i++) {
        var d = document.getElementById("txtChild" + i);
        if(d.value == "" || d.value=="Ongeldig") {
            d.value = "Ongeldig";
            res = false;
        }
    }
    for(var j = 1; j < num2 + 1; j++) {
        var f = document.getElementById("txtBaby" + j);
        if(f.value == "" || f.value=="Ongeldig") {
            f.value = "Ongeldig";
            res = false;
        }
    }
    if(res) {
        CloseTravelers();
    }
    return res;
}
function OpenNewsletter() {
    CenterNewsbriefElement();
    var pop = document.getElementById("newsletterDiv");
    pop.style.visibility = "visible";
}
function CloseNewsletter() {
    var pop = document.getElementById("newsletterDiv");
    pop.style.visibility = "hidden";
}
function GetBirthdates(ddl, type)
{
    var NrOfDates = parseInt(ddl.options[ddl.selectedIndex].text, 10);
    var element = type==0?"Child":"Baby";
    
    for(i=1; i<ddl.options.length; i++)
    {
        var obj = document.getElementById(element + i.toString())
        obj.style.display = "none";
        obj.value = "";
    }
    
    for(i=1; i<=NrOfDates; i++)
    {
        var obj = document.getElementById(element + i.toString())
        obj.style.display = "";
    }

    if (NrOfDates > 0) {
        document.getElementById("TravelCompany_Info").style.display = "";
    }
    else {
        document.getElementById("TravelCompany_Info").style.display = "none";
    }
}
var searchTimeout;
function SearchAccommodation(searchText) {    
    clearTimeout(searchTimeout);
    searchTimeout = setTimeout("SearchAccommodationAfterTimeout('" + searchText + "')", 500);
}
function SearchAccommodationAfterTimeout(searchText) {
    var d = document.getElementById("searchRes");
    var dt = document.getElementById("searchResText");
    searchText = Trim(searchText);
    if (searchText.length < 3) {
        //document.getElementById('imgBtnSearch').style.visibility = "visible";
        d.style.visibility = "hidden";
        return;
    }

    var url = Master_BasePath + "SearchResult.aspx?val=" + searchText;
	var req = new Request();
	req.GetNoCache(url, SearchAccommodationResult);
}
function SearchAccommodationResult(result) {
    if (result.readyState != ReadyState.Complete) {
        return;
    }
	if (result.status == HttpStatus.OK && result.responseText != "") {
        var dt = document.getElementById("searchResText");
        if(dt==null) {
            return;
        }
        dt.innerHTML = result.responseText;
        //document.getElementById('imgBtnSearch').style.visibility = "hidden";
        document.getElementById("searchRes").style.visibility = "visible";
    }
}
function Trim(str){
    return str.replace(/^\s+|\s+$/g, '');
}

function EmailValidation(Input)
{
	apos=Input.indexOf("@");
	dotpos=Input.lastIndexOf(".");
	lastpos=Input.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) return false;
	else return true;
}

function CheckNewsletterFooter() {
    var res = true;
    var sn = document.getElementById("newsletter_emailadresFooter");
    var se = document.getElementById("newsletter_emailadresFooter");    


    if (sn == null || sn.value == null || sn.value == "" || sn.value == "voornaam") {
        //NewsCtrl.innerHTML = 'Geef een geldige voornaam';
        return false;
    }

    if (se == null || se.value == null || se.value == "" || se.value == "emailadres" || !EmailValidation(se.value)) {
        //NewsCtrl.innerHTML = 'Geef een geldig e-mail adres';
        alert('Geef een geldig e-mail adress');
        return false;
    }

    return res;
}

function CheckNewsletter() {
    var res = true;
    var sn = document.getElementById("newsletter_voornaam");
    var se = document.getElementById("newsletter_emailadres");
    var NewsCtrl = document.getElementById("NewsCtrl");
    
        
    if(sn == null || sn.value == null || sn.value == "" || sn.value == "voornaam") {
        NewsCtrl.innerHTML = 'Geef een geldige voornaam';
        return false;
    }
    
    if(se == null || se.value == null || se.value == "" || se.value == "emailadres" || !EmailValidation(se.value)) {
        NewsCtrl.innerHTML = 'Geef een geldig e-mail adres';
        return false;
    }
    
    return res;
}
function CheckNewsletter2() {
    var res = true;
    var sn = document.getElementById("newsletter_voornaam2");
    var se = document.getElementById("newsletter_emailadres2");
    var NewsCtrl = document.getElementById("NewsItem");
        
    if(sn == null || sn.value == null || sn.value == "" || sn.value == "voornaam") {
        NewsCtrl.innerHTML = 'Geef een geldige voornaam';
        return false;
    }
    
    if(se == null || se.value == null || se.value == "" || se.value == "emailadres" || !EmailValidation(se.value)) {
        NewsCtrl.innerHTML = 'Geef een geldig e-mail adres';
        return false;
    }
    
    if(res) {
        CloseNewsletter();
    }
    return res;
}
var mar_plaing = true;
var mar_timer;
var mar_nextTime = 5000;
function mar_DisplayControl() {
    var lis = document.getElementById("mar_numbers");
    lis.innerHTML = "";
    var iBegin = 1;
    var iEnd = 5;
    if(mar_maxEl > 5) {
        if(mar_currentImg <= 3) {
            iBegin = 1;
            iEnd = 5;
        } else {
            if(mar_currentImg >= mar_maxEl - 2) {
                iBegin = mar_maxEl - 4;
                iEnd = mar_maxEl;
            } else {
                iBegin = mar_currentImg - 2;
                iEnd = mar_currentImg + 2;
            }
        }
    } else {
        iBegin = 1;
        iEnd = mar_maxEl;
    }
    var s = "";
    for(var i = iBegin; i <= iEnd; i++) {
        var liTag = document.createElement("li");
        var aTag = document.createElement('a');
        aTag.setAttribute('href', 'javascript:mar_SetImg(' + i + ');');
        if(i == mar_currentImg) {
            aTag.setAttribute("id", "activeLi");
        }
        var oTx = document.createTextNode("" + i);
        aTag.appendChild(oTx);
        liTag.appendChild(aTag);
        lis.appendChild(liTag);
    }
    document.getElementById("activeLi").className = "active";
    document.getElementById("displayedImageDiv").src = document.getElementById("displayedImage").src;
    changeOpac(0, "displayedImage"); 
    document.getElementById("displayedImage").src = mar_imageUrl[mar_currentImg - 1];
    document.getElementById("displayedImage").alt = mar_imageAlt[mar_currentImg - 1];
    for(i = 0; i <= 100; i+=5) {
        setTimeout("changeOpac(" + i + ",'displayedImage')",(i * 5));
    } 
    document.getElementById("mar_imageLink").href = mar_imageLink[mar_currentImg - 1];
    if(mar_plaing) {
        document.getElementById("mar_playpauseBtn").src = Master_BasePath + "Style/Images/Pause.gif";
    } else {
        document.getElementById("mar_playpauseBtn").src = Master_BasePath + "Style/Images/Play.gif";
    }
    
}
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}
function mar_PlayPause() {
    if(mar_plaing) {
        mar_Pause();
    } else {
        mar_Play();
    }
}
function mar_Pause() {
    clearTimeout(mar_timer);
    mar_plaing = false;
    mar_DisplayControl();
}
function mar_Play() {
    mar_plaing = true;
    mar_DisplayControl();
    mar_timer = setTimeout("mar_PlayNextPicture();", mar_nextTime);
}
function mar_NextPict() {
    if(mar_plaing) {
        mar_Pause();
    }
    mar_currentImg += 1;
    if(mar_currentImg > mar_maxEl) {
        mar_currentImg = 1;
    }
    mar_DisplayControl();
}
function mar_PrevPict() {
    if(mar_plaing) {
        mar_Pause();
    }
    mar_currentImg -= 1;
    if(mar_currentImg < 1) {
        mar_currentImg = mar_maxEl;
    }
    mar_DisplayControl();
}
function mar_PlayNextPicture() {
    mar_currentImg += 1;
    if(mar_currentImg > mar_maxEl) {
        mar_currentImg = 1;
    }
    mar_DisplayControl();
    mar_timer = setTimeout("mar_PlayNextPicture();", mar_nextTime);
}
function mar_SetImg(num) {
    if(mar_plaing) {
        mar_Pause();
    }
    mar_currentImg = num;
    mar_DisplayControl();
}
function mar_StartDisplay() {
    mar_DisplayControl();
    mar_Play();
}
function OpenMijnBoeking() {
    window.open('https://www.mijnreisoverzicht.nl/login.php?anvr=47317', '_blank', 'height=600, width=600, directories=no, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no');
}
function CloseSearchRes() {
    var pop = document.getElementById("searchRes");
    pop.style.visibility = "hidden";
    //document.getElementById('imgBtnSearch').style.visibility = "visible";
}
function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function CenterTravelersElement() {
    var pop = document.getElementById("TravelersPopup");
    if(pop == null) return;
    
    var posy = 0;
    var winy = 0;
    var winscroll = 0;
    var poph = pop.offsetHeight;
    
    if(window.pageYOffset){
        winscroll = window.pageYOffset;
        winy = window.innerHeight;
    }else{
        winscroll = iecompattest().scrollTop;
        winy = iecompattest().clientHeight;
    }
    
    if(poph >= winy) {
        posy = winscroll;
    } else {
        posy = ((winy - poph) / 2) + winscroll;
    }

    pop.style.top = posy + "px";
}
function CenterNewsbriefElement() {
    var pop = document.getElementById("newsletterPopup");
    if(pop == null) return;
    
    var posy = 0;
    var winy = 0;
    var winscroll = 0;
    var poph = pop.offsetHeight;
    
    if(window.pageYOffset){
        winscroll = window.pageYOffset;
        winy = window.innerHeight;
    }else{
        winscroll = iecompattest().scrollTop;
        winy = iecompattest().clientHeight;
    }
    
    if(144 >= winy) {
        posy = winscroll;
    } else {
        posy = ((winy - 144) / 2) + winscroll;
    }

    pop.style.top = posy + "px";
}
function OpenAccoMail() {
    CenterAccoMailElement()  
    var pop = document.getElementById("accoMailDiv");
    pop.style.visibility = "visible";
}
function CloseAccoMail() {
    document.getElementById("popupBackground").style.display = "none";
    var pop = document.getElementById("accoMailDiv");
    pop.style.visibility = "hidden";
}
function CenterAccoMailElement() {
    var pop = document.getElementById("accoMailPopup");
    if(pop == null) return;
    
    var posy = 0;
    var winy = 0;
    var winscroll = 0;
    var poph = pop.offsetHeight;
    
    if(window.pageYOffset){
        winscroll = window.pageYOffset;
        winy = window.innerHeight;
    }else{
        winscroll = iecompattest().scrollTop;
        winy = iecompattest().clientHeight;
    }
    if(500 >= winy) { //144
        posy = winscroll;
    } else {
        posy = ((winy - 500) / 2) + winscroll; //144
    }

    pop.style.top = posy + "px";
}
function ClearNewsletterName(ctrl) {
    if(ctrl.value == "voornaam") {
        ctrl.value = "";
    }
}
function FillNewsletterName(ctrl) {
    if(ctrl.value == "") {
        ctrl.value = "voornaam";
    }
}
function ClearNewsletterAddres(ctrl) {
    if(ctrl.value == "emailadres") {
        ctrl.value = "";
    }
}
function FillNewsletterAddres(ctrl) {
    if(ctrl.value == "") {
        ctrl.value = "emailadres";
    }
}
/* search box on 404 page */
var searchTimeout404;
function SearchAccommodation404(searchText) {
    clearTimeout(searchTimeout404);
    searchTimeout404 = setTimeout("SearchAccommodation404AfterTimeout('" + searchText + "')", 500);
}
function SearchAccommodation404AfterTimeout(searchText) {
    var d = document.getElementById("searchRes404");
    var dt = document.getElementById("searchResText404");
    searchText = Trim(searchText);
    if (searchText.length < 3) {
        d.style.visibility = "hidden";
        return;
    }

    var url = Master_BasePath + "SearchResult.aspx?val=" + searchText;
	var req = new Request();
	req.GetNoCache(url, SearchAccommodation404Result);
}
function SearchAccommodation404Result(result) {
    if (result.readyState != ReadyState.Complete) {
        return;
    }
	if (result.status == HttpStatus.OK && result.responseText != "") {
        var dt = document.getElementById("searchResText404");
        if(dt==null) {
            return;
        }
        dt.innerHTML = result.responseText;
        document.getElementById("searchRes404").style.visibility = "visible";
    }
}
function CloseSearchRes404() {
    var pop = document.getElementById("searchRes404");
    pop.style.visibility = "hidden";
}

function ShowPopupInfo(message)
{
    CenterPopupInfoElement();
    
    var msgDiv = document.getElementById("infoPopoupText");
    msgDiv.innerHTML = message;
    var pop = document.getElementById("infoPopupDiv");
    pop.style.visibility = "visible";
    
    setTimeout("HidePopupInfo()", 3000); // 3 sec
}

function HidePopupInfo()
{
    var pop = document.getElementById("infoPopupDiv");
    pop.style.visibility = "hidden";
    
    var msgDiv = document.getElementById("infoPopoupText");
    msgDiv.innerHTML = "";
}

function CenterPopupInfoElement()
{
    var pop = document.getElementById("infoPopup");
    if(pop == null) return;
    
    var posy = 0;
    var winy = 0;
    var winscroll = 0;
    var poph = pop.offsetHeight;
    
    if(window.pageYOffset){
        winscroll = window.pageYOffset;
        winy = window.innerHeight;
    }else{
        winscroll = iecompattest().scrollTop;
        winy = iecompattest().clientHeight;
    }
    
    if(poph >= winy) {
        posy = winscroll;
    } else {
        posy = ((winy - poph) / 2) + winscroll;
    }

    pop.style.top = posy + "px";
}

function printAcco() {
    window.open(Master_BasePath + "AccommodationPrint.aspx");
}

function toggleDisplay(idItem1, idItem2) {
    if (document.getElementById(idItem1).style.display == '') {
        document.getElementById(idItem1).style.display = 'none';
        document.getElementById(idItem2).style.display = '';
    }
    else {
        document.getElementById(idItem1).style.display = '';
        document.getElementById(idItem2).style.display = 'none';
    }
}

/***************************/
/*** Booksteps.aspx ***/
/***************************/
function checkTrav(e) {
    items = e.id.split("_");
    var id = "";
    for (i=0; i<items.length-1; i++)
    id += items[i] + "_"

    if (id == "") return;

    var row = parseInt(items[5].replace("ctl", ""), 10);
    var imgObj = document.getElementById("TravImg" + row);

    var list = document.getElementsByTagName("input");
    var genderOK = false;
    var nameOK = false;
    var surNameOK = false;
    var dateOK = false;
    var allOK = false;

    
    var name = "";
    var infix = "";
    if (document.getElementById(id + "txtMiddelname"))
        infix = document.getElementById(id + "txtMiddelname").value
    var surname = "";
    

    for (i = 0; i < list.length; i++) {
        if (list[i].id.indexOf(id) == 0 && list[i].id.indexOf("txtMiddelname") < 0) {

            if (list[i].id.indexOf("rlTravGender") > 0 && list[i].checked && !genderOK) {
                genderOK = true;
            }
            if (list[i].id.indexOf("txtGivenNames") > 0 && list[i].value != "" && !nameOK)
            {
                nameOK = true;
                name = list[i].value;
            }
            if (list[i].id.indexOf("txtLastName") > 0 && list[i].value != "" && !surNameOK)
            {
                surNameOK = true;
                surname = list[i].value;
            }
            if (list[i].id.indexOf("txtBirthDay") > 0 && list[i].value != "" && !dateOK)
                dateOK = true;


            allOK = genderOK && nameOK && surNameOK && dateOK;
            if (allOK)
                break;
        }
    }
    imgObj.className = allOK ? "Show" : "NoShow";

    var ddlTrav = document.getElementById("ctl00_ctl00_cphMainContent_cphBody_ddlTraveller");
    if (ddlTrav && allOK) {
        var travNr = row + 1;
        name += infix!=""? " " + infix: "";
        name += " " + surname;

        ddlTrav.options[row+1].text = "Reiziger " + travNr.toString() + ": " + name;

        ddlTrav.options[row+1].value = "Reiziger " + travNr.toString() + "," + id
    }
}



function checkValue(obj, x) {
    var img = document.getElementById(x);
    if (img)
        img.className = (obj && obj.value != "") ? "Show" : "NoShow";
}

function checkPhone(obj, x) {
    //Currently just check for empty value
    var img = document.getElementById(x);
    if (img)
        img.className = (obj && obj.value != "") ? "Show" : "NoShow"
}

function checkMail(obj, x) {
    var img = document.getElementById(x);
    if (img)
        img.className = (EmailValidation(obj.value)) ? "Show" : "NoShow";
    
    
}

function EmailValidation(Input) {
    apos = Input.indexOf("@");
    dotpos = Input.lastIndexOf(".");
    lastpos = Input.length - 1;
    if (apos < 1 || dotpos - apos < 2 || lastpos - dotpos > 3 || lastpos - dotpos < 2) return false;
    else return true;
}

function setHomeStayer(obj) {
//    var Homestayer = document.getElementById("Homestayer");
//    Homestayer.style.display = obj.value == "Ja" ? "" : "none";

    var Homestayer = document.getElementById("Homestayer");
    var item = document.getElementById(obj.id + "_1");
    Homestayer.style.display = item.checked ? "" : "none";
}

function OpenVoorwaarden(voorwaarden, date) {
    var h, w, l, t;

    h = 400;
    w = 600;
    l = (screen.width - w) / 2;
    t = (screen.height - h) / 2;

    var url = "Conditions/Conditions.aspx?ID=" + voorwaarden;
    if (typeof (date) != "undefined")
        url += "&Date=" + date

    theWin = window.open(url, "voorwaarden", "scrollbars=yes,resizable=yes,height=" + h + ",width=" + w + ",left=" + l + ",top=" + t);
    theWin.focus();
}

function resize(frameName) {
    if (!closeFrame) {
        if (navigator.appName.indexOf("Explorer") == -1) {	// FireFox & NetScape			
            if (document.getElementById(frameName).src != '') {
                document.getElementById(frameName).style.height = document.getElementById(frameName).contentDocument.body.scrollHeight + 5 + 'px';
                document.getElementById(frameName).style.borderWidth = '2px';
                location.href = "#extras";
                //document.getElementById('ExtraOptions').style.display = 'none';
            }
        }
        else {	//IE
            if (document.all[frameName].src != '') {
                document.all[frameName].style.height = document.all[frameName].Document.body.scrollHeight; +5 + 'px';
                document.all[frameName].style.borderWidth = '2px';
                location.href = "#extras";
                //document.getElementById('ExtraOptions').style.display = 'none';
            }
        }
    }
    else {
        closeFrame = false;
    }
}

function SetPayment(code) {
    if (code == '') {
        document.forms[0].rbPayment[0].checked = true;
    }
    else {
        for (t = 0; t < document.forms[0].rbPayment.length; t++)
            if (document.forms[0].rbPayment[t].value == code)
                document.forms[0].rbPayment[t].checked = true;
    }
}


/***************************/
