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 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";
    
    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";
    }
}
function OpenTravelers() {
    CenterTravelersElement();
    var pop = document.getElementById("TravelersDiv");
    pop.style.visibility = "visible";
}
function CloseTravelers() {
    var pop = document.getElementById("TravelersDiv");
    pop.style.visibility = "hidden";
}
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 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 = "";
    }
}
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) {
        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 = ParseThemedResponse(result.responseText);
        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;
}
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 + "Images/Pause.gif";
    } else {
        document.getElementById("mar_playpauseBtn").src = Master_BasePath + "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";
}
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 OpenAccoMail() {
    CenterAccoMailElement();
    var pop = document.getElementById("accoMailDiv");
    pop.style.visibility = "visible";
}
function CloseAccoMail() {
    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";
}
/* 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";
}



