﻿prefix = 'ctl00_';
var errorMsg = '';
var errorTime = 3000;
var loading = 'loading';
var numNightsID = '';
var anvrNummerID = '';
var Thema = '';

if (document.layers) {
    //Netscape 4 specific code
    pre = 'document.';
    preobj = 'document';
    endobj = '';
    post = '';
} else if (document.getElementById) {
    //Netscape 6 specific code
    pre = 'document.getElementById("';
    preobj = 'document.getElementById("';
    endobj = '")';
    post = '").style';
} else {
    //IE4+ specific code
    pre = 'document.all.';
    preobj = 'document.all';
    endobj = '';
    post = '.style';
}

function ANVRnummer() {
    if (anvrNummerID != '') {
        if (getObj(anvrNummerID)) {
            return getObj(anvrNummerID).value;
        }
    }

    return '';
}


function ClearPanel(panel) {
    var panel = getObj(panel);
    panel.innerHTML = '';
}

function ClearTable(table) {
    var Parent = getObj(table);
    while (Parent.hasChildNodes()) {
        Parent.removeChild(Parent.firstChild);
    }
}

//toegevoegde functies milan
function PopUp(pageURL, title, w, h) {
    var left = (screen.width / 2) - (w / 2);
    var top = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}

function ClosePopUp() {
    targetWin.close()
}

function roll_over(img_name, img_src) {
    document[img_name].src = img_src;
}

function waitForItAgentNieuws(boodschap, melding, id) {
    getObj('screenOverlay').setAttribute('onclick', '');

    var html = '<div style="width: 330px; height: 265px; padding: 10px 10px 0px 10px; padding-top: 20px; background-image: url(\'/App_Image/popup_350_150.png\'); background-repeat: no-repeat">';

    if (melding.length > 40) {
        html = html + '<div style="width: 330px; height: 32px; padding-top: 4px; font-weight: bold; color: #6294CD">' + melding + '</div>';
    } else {
        html = html + '<div style="width: 330px; height: 32px; padding-top: 10px; font-weight: bold; color: #6294CD">' + melding + '</div>';
    }

    html = html + '<div style="width:200px; height: 140px; padding: 10px 10px 0px 10px; padding-left: 120px;"><a href="agentnieuws.aspx?action=delete&id=' + id + '"><img src="App_Image/Confirm.png" border="0"/></a><a href="agentnieuws.aspx"><img src="App_Image/Decline.png" border="0"/></a></div>';
    html = html + '</div>';

    showPopup(350, 275, html);
}

function checkField(melding) {
    showSjors(melding, 5000)
}

function showMenu(panel, img) {

    var showPanel = getObj(panel);
    var foldImage = getObj(img);

    if (showPanel.style.display == 'inline') {
        showPanel.style.display = 'none';
        foldImage.src = '/App_Image/plus.png';
        foldImage.alt = 'Toon menu';
    } else {
        showPanel.style.display = 'inline';
        foldImage.src = '/App_Image/min.png';
        foldImage.alt = 'Verberg menu';
    }
}
//


function Browser() {
    var myagent, s, i;

    this.isIE = false;
    this.isNS = false;
    this.version = null;

    myagent = navigator.userAgent;

    if (((i = myagent.indexOf("MSIE")) >= 0) || ((i = myagent.indexOf("Opera")) >= 0)) {
        this.isIE = true;
        this.version = parseFloat(myagent.substr(i + 4));
        return;
    } else if ((i = myagent.indexOf("Netscape6/")) >= 0) {
        this.isNS = true;
        this.version = parseFloat(myagent.substr(i + 10));
        return;
    } else if ((i = myagent.indexOf("Gecko")) >= 0) {
        this.isNS = true;
        this.version = 6.1;
    }
    return;
}

var browser = new Browser();

function getObj(objname) {
    myObj = eval(preobj + objname + endobj);

    if (!myObj) {
        myObj = eval(preobj + prefix + objname + endobj);
    }

    return myObj;
}

function getStyle(objname) {
    try {
        myObj = eval(preobj + objname + post);
    } catch (err) {
        try {
            myObj = eval(preobj + prefix + objname + post);
        } catch (err) {
            alert(objname + ': ' + err);
        }
    }

    return myObj;
}

function PageScrollY() {
    if (window.pageYOffset) {
        return window.pageYOffset;
    }
    else {
        if (document.documentElement && document.documentElement.scrollTop) {
            return document.documentElement.scrollTop;
        }
        else if (document.body) {
            return document.body.scrollTop;
        }
    }
    return 0;
}

function PageScrollHeight() {
    if (window.innerHeight && window.scrollMaxY) {
        // Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
        // all but Explorer Mac
        yWithScroll = document.body.scrollHeight;
    } else {
        // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.body.offsetHeight;
    }

    return yWithScroll;
}

function PageScrollWidth() {
    if (window.innerWidth && window.scrollMaxX) {
        // Firefox
        yWithScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollWidth > document.body.offsetWidth) {
        // all but Explorer Mac
        yWithScroll = document.body.scrollWidth;
    } else {
        // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.body.offsetWidth;
    }

    return yWithScroll;
}

function BrowserHeight() {
    if (window.innerHeight) {
        return window.innerHeight;
    }

    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            return document.documentElement.clientHeight;
        }
        else if (document.body) {
            return document.body.clientHeight;
        }
    }
}

function BrowserWidth() {
    if (window.innerWidth) {
        return window.innerWidth - 17;
    }
    else {
        if (document.documentElement && document.documentElement.clientWidth) {
            return document.documentElement.clientWidth;
        }
        else if (document.body) {
            return document.body.clientWidth;
        }
    }
    return 0;
}

var persistent = new Array();

function hidePersistent() {

    sIFR.rollback();
    var myCol = document.getElementsByTagName("object");

    for (i = 0; i < myCol.length; i++) {
        var myStyle = getStyle(myCol[i].id);

        //myStyle.visibility='hidden';
    }

    return true;
}

function showPersistent() {
    //sIFR.rollback();
    if (typeof sIFR == "function") {
        sIFR.replaceElement(named({ sSelector: "h2.sectionTitle", sFlashSrc: "/flash/caecilia_bold.swf", sColor: "#FFFFFF", sBgColor: "#6294CD" }));
        sIFR.replaceElement(named({ sSelector: "h2.itemAdjust", sFlashSrc: "/flash/caecilia_bold.swf", sColor: "#6294CD", sBgColor: "#FFFFFF" }));
        sIFR.replaceElement(named({ sSelector: "h2.agTitle", sFlashSrc: "/flash/caecilia_bold.swf", sColor: "#6294CD", sBgColor: "#d6e9ff" }));
        //sIFR.replaceElement(named({sSelector:"h3.tabTitle", sFlashSrc:"/flash/eurostile_bold.swf", sColor:"#000000", sBgColor:"#FFFFFF"}));
    };
}

function toggleOverlay(show) {
    var overObj = getStyle('screenOverlay');

    if (show) {
        overObj.width = PageScrollWidth() + 'px';

        if (PageScrollHeight() < BrowserHeight()) {
            overObj.height = BrowserHeight() + 'px';
        } else {
            overObj.height = PageScrollHeight() + 'px';
        }

        overObj.display = 'inline';

        //hidePersistent();
    } else {
        overObj.display = 'none';

        //showPersistent();
    }
}

function showPopup(width, height, HTML) {
    toggleOverlay(true);

    var myPanel = getObj('showPanel');
    var myStyle = getStyle('showPanel');

    myStyle.width = width.toString() + 'px';
    myStyle.height = height.toString() + 'px';
    myStyle.left = ((parseInt(BrowserWidth()) / 2) - (width / 2)).toString() + 'px';
    myStyle.top = ((parseInt(BrowserHeight()) / 2) - (height / 2) + parseInt(PageScrollY())).toString() + 'px';
    myStyle.display = 'inline';

    myPanel.innerHTML = HTML;
}

function hidePopup() {
    toggleOverlay(false);
    hideSjors();

    getStyle('showPanel').display = 'none';
}

function waitForIt(boodschap, melding) {
    hidePersistent();
    getObj('screenOverlay').setAttribute('onclick', '');

    var html = '<div style="width: 330px; height: 265px; padding: 10px 10px 0px 10px; background-image: url(\'/App_Image/popup_350_275.png\'); background-repeat: no-repeat">';
    html = html + '<div style="width: 323px; height: 148px; padding-top: 80px; padding-left: 7px"><object id="busyContainerObj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" style="width: 305px; height: 66px"><param name="movie" value="/App_Image/flash/busy.swf" /><param name="wmode" value="transparent" /><!-- [if !IE]> --><embed src="App_Image/flash/busy.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="305px" height="66px" name="prijs_tag" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>';

    if (melding.length > 40) {
        html = html + '<div style="width: 330px; height: 32px; padding-top: 4px; font-weight: bold; color: #FFFFFF">' + melding + '</div>';
    } else {
        html = html + '<div style="width: 330px; height: 32px; padding-top: 10px; font-weight: bold; color: #FFFFFF">' + melding + '</div>';
    }

    html = html + '</div>';

    showPopup(350, 275, html);
}

function shadeHeader(objID, tsonts) {
    var myobj = getObj(objID);

    if (tsonts) {
        myobj.style.display = 'none';
    } else {
        myobj.style.display = 'inline';
    }
}

function waitForType() {
    switch (selectedTransport()) {
        case 11:
            waitForIt('', 'Accommodaties en beschikbaarheid worden opgevraagd  ');
            break;

        default:
            waitForIt('', 'Transport wordt opgevraagd  ');
            break;
    }
}

function actionHeader(actie) {
    var actionmsg = 'Gegevens worden opgevraagd.';
    var confirmGo = false;

    switch (actie.toLowerCase()) {
        case 'accommodatie':
            actionmsg = 'Accommodaties worden opgevraagd.';
            break;

        case 'transport':
            actionmsg = 'Transportgegevens worden opgevraagd.';
            break;

        case 'reisplan':
            confirmGo = false;
            break;
    }

    getObj(headerActionID).value = actie;

    if (confirmGo) {
        var html = '<div style="width: 230px; height: 140px; padding: 10px 10px 0px 10px; background-image: url(\'/App_Image/popup_250_150.png\'); background-repeat: no-repeat">';
        html = html + '</div>';

        showPopup(250, 150, html);
    } else {
        waitForIt('', actionmsg);

        var tempTO = setTimeout(submitForm, 500);
    }
}

function submitForm() {
    document.forms['aspnetForm'].submit();
}

var stedenCache = '';

function showCities() {
    if (stedenCache == '') {
        Ajax_Code.toonSteden(SucceededCallback, FailedCallback);
    } else {
        showCityPanel(stedenCache)
    }
}

function showCityPanel(myhtml) {
    var html = '<div style="width: 500px; height: 460px; padding: 10px 10px 0px 10px; background-image: url(\'/App_Image/popup_520_470.png\'); background-repeat: no-repeat">';
    html = html + '<div style="width: 500px; height: 32px; padding-top: 8px; font-weight: bold; font-size: 14px">Stedenoverzicht</div>';
    html = html + '<div style="width: 500px; height: 380px">' + myhtml + '</div>';
    html = html + '<div style="width: 500px; height: 40px; text-align: right"><img style="margin-right: 8px; margin-bottom: 8px; cursor: pointer" onclick="javascript:hidePopup(); " onmouseover="javascript:this.src=\'/App_Image/close_over.png\'; " onmouseout="javascript:this.src=\'/App_Image/close.png\'; " src="/App_Image/close.png" alt="Sluit venster" /></div></div>';
    showPopup(520, 470, html);
}
