var D = function (id) { return document.getElementById(id); };
var et_loc = window.location.protocol;
var uid = "";
var recnr = 0;
var antwoord = "";
var category = 0;
var faqstart = "";
var dialogOut = 0;

var elitechAise = function () {
    this.projectName = "wehkamp";
    this.state = 1;           /* default status */
    this.frame1 = "";          /* default waarde frame 1 */
    this.frame2 = "";          /* default waarde frame 2 */
    this.frame3 = "";          /* default waarde frame 3 */
    this.useIframeIEfix = false;       /* in IE liggen selectboxen en flash etc. altijd met de hoogste z-index. als deze optie op true wordt gezet, wordt achter de divs een iframe geplaatst. Dit iframe kan wel over deze controls heen worden gelegd. */
    this.loadingHTML = "... ...";    /* Tekst wordt getoond tijdens het laden */
    this.doPagePush = true;        /* aanzetten pagepush optie. Handig om uit te zetten tijdens ontwikkelfase */
    this.beoordeling = 0;            /* beoordeling goed is de defaultwaarde */
    this.handigeVragen = true;        /* maak gebruik van handige vragen */
    this.toonvraag = true;        /* De vraag herhalen in aise responsediv */
    this.directCall = false;        /* Wordt gebruikt om te zorgen dat de vraag niet getoond wordt in aise responsediv indien sendQuestionDirect*/
    this.pagepushiframe = false;       /* De pagepush uitvoeren naar een achtergrond frame (in geval van demo|testen) */
    this.ask_custom_welcome = 'ja';    /* NIET VERANDEREN!! */
    this.page_to_be_pushed = 'nee';
    this.lastReceived_uid = "";
    this.lastReceived_antwoord = "";
    this.lastReceived_recnr = 0;
    this.lastReceived_html = "";
    this.lastReceived_category = 0;
    this.lastReceived_faqstart = "";
    this.lastQuestion = "";
    this.testing = false;
    this.feedbacktestfase = false;
    this.defaultvraag = new Array();
    this.callback = "me.putXMLhere();";
    this.oScript = "";
    this.showFeedback = false;
    var me = this;

    this.convertTo = function () {
        me.lastReceived_antwoord = me.lastReceived_antwoord.replace(/&#/gi, "SPECIAL_SIGN");
        me.lastReceived_antwoord = me.lastReceived_antwoord.replace(/;/gi, "PUNT_KOMMA");
    };

    this.convertFrom = function (value) {
        value = value.replace(/SPECIAL_SIGN/gi, "&#");
        value = value.replace(/PUNT_KOMMA/gi, ";");
        return value;
    };

    this.storeAllData = function () {
        me.convertTo();
        var aiseDiv = D('status1div');
        var indexOfJsonStart = top.window.name.indexOf("{");
        var indexOfJsonEnd = top.window.name.lastIndexOf("}");
        var windowNameExternallyAdded = "";
        if (indexOfJsonStart != -1) {
            windowNameExternallyAdded = "\r\n" + top.window.name.substr(indexOfJsonStart, (indexOfJsonEnd - indexOfJsonStart) + 1) + "\r\n";
        }
        top.window.name = "AISE -!-" + me.state + ";"
            + me.ask_custom_welcome + ";"
            + me.page_to_be_pushed + ";"
            + me.lastQuestion + ";"
            + me.lastReceived_antwoord + ";"
            + windowNameExternallyAdded + ";"
            + me.showFeedback + ";"
            + uid + ";"
            + recnr + ";"
            + me.projectID;
    };

    this.repositionFromStorage = function () {
        var aise = D('status1div');
        var indexOfJsonStart = top.window.name.indexOf("{");
        var indexOfJsonEnd = top.window.name.lastIndexOf("}");
        var windowNameExternallyAdded = "";
        if (indexOfJsonStart != -1) {
            windowNameExternallyAdded = "\r\n" + top.window.name.substr(indexOfJsonStart, (indexOfJsonEnd - indexOfJsonStart) + 1) + "\r\n";
        }
        var wname = top.window.name.replace(windowNameExternallyAdded, "").split("-!-");
        if (wname[1]) {
            var storage = wname[1].split(";");

            if (storage[9] != null && storage[9] == this.projectID) {
                this.state = storage[0];
                this.ask_custom_welcome = storage[1];
                this.page_to_be_pushed = storage[2];
                this.lastQuestion = this.convertFrom(storage[3]);
                if (this.lastQuestion == 'custom_welcome' || this.lastQuestion.substr(0, 3) == "cs:") //cs added
                { this.lastQuestion = ''; }

                this.lastReceived_antwoord = this.convertFrom(storage[4]);
                this.showFeedback = (storage[5] == "true") ? true : false;
                uid = storage[6];
                this.lastReceived_uid = uid;
                recnr = storage[7];
                this.lastReceived_recnr = recnr;

                D('et_question').value = this.lastQuestion;
                D('et_aiseResponseDiv').innerHTML = this.lastReceived_antwoord;

                if (this.page_to_be_pushed == 'ja' && this.ask_custom_welcome != 'ja' && this.testing) {
                    this.state = 3;
                    this.changeState();
                }
                return false;
            }
        }
        return true;
    };

    this.changeState = function () {
        if (this.state == 1) {
            D('status1div').style.display = 'block';
            D('status2div').style.display = 'none';
            D('et_status3div').style.display = 'none';
            if (this.useIframeIEfix) {
                D('status1frame').style.display = 'block';
                D('status2frame').style.display = 'none';
                D('status3frame').style.display = 'none';
            }
        }
        if (this.state == 2) {
            D('status1div').style.display = 'block';
            D('status2div').style.display = 'block';
            D('et_status3div').style.display = 'none';
            if (this.useIframeIEfix) {
                D('status1frame').style.display = 'block';
                D('status2frame').style.display = 'block';
                D('status3frame').style.display = 'none';
            }
            if (D('et_aiseResponseDiv').innerHTML == '') {
                return;
            }
            try {
                D('et_question').focus();
                D('et_question').select();
            } catch (e) { }
        }
        if (this.state == 3) {
            D('status1div').style.display = 'block';
            D('status2div').style.display = 'block';
            D('et_status3div').style.display = 'block';
            if (this.useIframeIEfix) {
                D('status1frame').style.display = 'block';
                D('status2frame').style.display = 'block';
                D('status3frame').style.display = 'block';
            }
        }
    };

    this.changeStateFromTopDiv = function () {
        if ((this.state == 2) || (this.state == 3)) {
            this.state = 1;
        } else {
            this.state = 2;
        }
        this.changeState();
    };

    this.parse = function () {
        document.write('<link rel="stylesheet" type="text/css" href="' + this.css + '">');
        document.write(this.frame1);
        document.write(this.frame2);
        document.write(this.frame3);

        if (!isGeldigeIE()) { this.useIframeIEfix = false; }
        if (this.useIframeIEfix) {
            var status1div = D('status1div');
            document.write("<iframe name='status1frame' id='status1frame' frameborder='0' style='moz-opacity:.5;filter:alpha(opacity=0);display:none;z-index:900;position:absolute;' width='" + status1div.style.width + "' height='" + status1div.style.height + "'></iframe>");
            var status2div = D('status2div');
            document.write("<iframe name='status2frame' id='status2frame' frameborder='0' style='moz-opacity:.5;filter:alpha(opacity=0);display:none;z-index:900;position:absolute;' width='" + status2div.style.width + "' height='" + status2div.style.height + "'></iframe>");
        }
        window.onload = this.positionAiseOnLoadHandler;  // Na het laden aise initialiseren
        window.onbeforeunload = this.storeAllData;              // Opslaan positie, vraag en antwoord
    };

    this.positionAiseOnLoadHandler = function () {
        if (me.repositionFromStorage()) {
            this.AskCustomWelcome();
            if (me.handigeVragen) { me.setDefaultVragen(); }
        }
    };

    this.setDefaultVragen = function () {
        var faqDiv = D('et_faq');
        faqDiv.innerHTML = "";
        for (var loop = 0; loop < this.defaultvraag.length; loop++) {
            faqDiv.innerHTML = faqDiv.innerHTML + "<img name='pijl" + loop + "' style='cursor:pointer;' src='" + basicurl + "/img/pijltje.gif' border='0' /> <a href='#' onMouseOver='javascript:swap(&#34;pijl" + loop + "&#34;,&#34;pijlon&#34;);' onMouseOut='javascript:swap(&#34;pijl" + loop + "&#34;,&#34;pijloff&#34;);' onClick=\"" + this.instanceName + ".vraagHandigeVraag('" + this.defaultvraag[loop].question + "', 'cs:" + this.defaultvraag[loop].kbaId + "')\">" + this.defaultvraag[loop].question + '</a><br />'
        }
    };

    this.vraagHandigeVraag = function (vraag, faq) {
        D('et_question').value = vraag;
        this.sendQuestion(faq);
    };

    this.verwerkHandigeVragen = function (hvragen) {
        var faqDiv = D('et_faq');
        faqDiv.innerHTML = "";
        for (var loop = 0; loop < hvragen.length; loop++) {
            faqDiv.innerHTML = faqDiv.innerHTML + "<img name='pijl" + loop + "' style='cursor:pointer;' src='" + basicurl + "/img/pijltje.gif' border='0' /> <a href='#' onMouseOver='javascript:swap(&#34;pijl" + loop + "&#34;,&#34;pijlon&#34;);' onMouseOut='javascript:swap(&#34;pijl" + loop + "&#34;,&#34;pijloff&#34;);' onClick=\"" + this.instanceName + ".vraagHandigeVraag('" + hvragen[loop].question + "', 'cs:" + hvragen[loop].kbaId + "')\">" + hvragen[loop].question + '</a><br />'
        }
        if (hvragen.length == 0) {
            for (var loop = 0; loop < this.defaultvraag.length; loop++) {
                faqDiv.innerHTML = faqDiv.innerHTML + "<img name='pijl" + loop + "' style='cursor:pointer;' src='" + basicurl + "/img/pijltje.gif' border='0' /> <a href='#' onMouseOver='javascript:swap(&#34;pijl" + loop + "&#34;,&#34;pijlon&#34;);' onMouseOut='javascript:swap(&#34;pijl" + loop + "&#34;,&#34;pijloff&#34;);' onClick=\"" + this.instanceName + ".vraagHandigeVraag('" + this.defaultvraag[loop].question + "', 'cs:" + this.defaultvraag[loop].kbaId + "')\">" + this.defaultvraag[loop].question + '</a><br />'
            }
        }
    };

    this.getDataFromServer = function (id, url, vraag) {
        this.lastQuestion = RemoveXSS(vraag);
        this.oScript = D(id);
        var head = document.getElementsByTagName("head").item(0);
        if (this.oScript) {
            // Destory object
            head.removeChild(this.oScript);
        }
        // Create object
        this.oScript = document.createElement("script");
        var callURL = url + '?projectCode=' + this.projectCode + '&projectID=' + this.projectID + '&uid=' + this.lastReceived_uid + '&cat=' + this.lastReceived_category + '&faqstart=' + this.lastReceived_faqstart + '&vraag=' + escape(vraag) + '&getFaqs=1' + '&userguid=';
        if (typeof userguid != "undefined") {
            callURL = callURL + userguid;
        }
        this.oScript.setAttribute("src", callURL);

        head.appendChild(this.oScript);
        var antwoord = '';
        var BROWSER_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
        if (BROWSER_IS_IE) {
            if (this.oScript.readyState == "loaded") {
                eval(this.callback);
                this.oScript.onreadystatechange = null;
            } else {
                this.oScript.onreadystatechange = this.CheckAgain;
            }
        } else {
            //eval(this.callback); // <= zou moeten werken maar de waarden zijn dan toch nog niet geladen. timeout ingebouwd die iedere seconde opnieuw kijkt of het antwoord binnen is..
            aise.mozCheckAgain();
        }
    };

    this.mozCheckAgain = function () {
        var chk = typeof (antwoord);
        if (typeof (antwoord) == "string") {
            if (antwoord == "") {
                // Als antwoorden verwerkt zijn word deze variabele weer leeggemaakt t.b.v. deze controle.
                window.setTimeout("aise.mozCheckAgain()", 1000);
            } else {
                aise.putXMLhere()
            }
        } else {
            window.setTimeout("aise.mozCheckAgain()", 1000);
        }
    };

    this.CheckAgain = function () {
        if (me.oScript.readyState == "loaded") {
            eval(me.callback);
            me.oScript.onreadystatechange = null;
        }
    };

    var custom_welcome_ask = false;
    this.sendQuestion = function (question) {
        if (!question)
            question = RemoveXSS(D('et_question').value);
        this.ask_custom_welcome = 'nee';
        this.directCall = false;
        D('et_aiseResponseDiv').innerHTML = this.loadingHTML;
        custom_welcome_ask = false;
        this.getDataFromServer("ScriptTagID", this.proxyServer, question);
    };

    this.sendQuestionDirect = function (txt) {
        this.directCall = true;
        D('et_aiseResponseDiv').innerHTML = this.loadingHTML;
        this.getDataFromServer("ScriptTagID", this.proxyServer, RemoveXSS(txt));
    };

    this.sendQuestionInit = function () {
        D('et_aiseResponseDiv').innerHTML = this.loadingHTML;
        custom_welcome_ask = true;
        this.getDataFromServer("ScriptTagID", this.proxyServer, 'custom_welcome');
        //return;
    };

    this.putXMLhere = function () {

        if (typeof (uid) != "string") {
            // IE bug: bij abort van call is readystate toch goed maar content is niet valide/gevuld.
            return;
        }

        this.lastReceived_uid = uid;
        this.lastReceived_antwoord = antwoord;
        this.lastReceived_recnr = recnr;
        this.lastReceived_html = html;
        this.lastReceived_category = category;
        this.lastReceived_faqstart = faqstart;

        if (this.toonvraag == true && !this.directCall && this.lastQuestion != 'custom_welcome' && this.lastQuestion.substr(0, 3) != "cs:") {
            D('et_aiseResponseDiv').innerHTML = "<strong>" + this.lastQuestion + "</strong><div id='ruimtegesteldevraag'>&nbsp;</div>" + antwoord;
        } else {
            D('et_aiseResponseDiv').innerHTML = antwoord;
        }

        if (this.handigeVragen && !custom_welcome_ask) {
            this.verwerkHandigeVragen(hvragen);
        }
        if (html != "") {
            if (this.doPagePush) {
                if (this.pagepushiframe == true) {
                    if (D("frame")) {
                        D("frame").src = html;
                    }
                } else {
                    this.page_to_be_pushed = 'ja';
                    window.top.location.href = html;
                }
            } else {
                D('et_aiseResponseDiv').innerHTML += '<br /><a href=' + html + '>Klik hier</a> voor meer informatie'
            }
        }
        if (this.testing) {
            if (custom_welcome_ask) {
                this.state = 2;
            } else {
                this.state = 3;
            }
        }
        this.changeState();
        if (this.state > 1) {
            if (this.toonvraag && !custom_welcome_ask) {
                D('et_question').value = "";
                try { D('et_question').focus(); } catch (e) { }
            } else {
                try {
                    D('et_question').focus();
                    D('et_question').select();
                } catch (e) { }
            }
        }
        antwoord = ""; // Leegmaken ivm firefox wait <- Deze controlleerd of antwoord gezet is.
    };

    var bedankt_teller = 0;
    this.SendOpmerking = function () {
        bedankt_teller = bedankt_teller + 1;
        var rsIframe = D("RSIFrameOpmerking");
        var beoordeling = document.getElementsByName('et_beoordeling');

        var tmpuid = this.lastReceived_uid; tmpuid = tmpuid.replace(/\'/g, "`");
        var tmpant = this.lastReceived_antwoord; tmpant = tmpant.replace(/\'/g, "`"); tmpant = tmpant.replace(/\&\#/g, "|"); tmpant = tmpant.replace(/\&/g, " en ");
        var tmphtm = this.lastReceived_html; tmphtm = tmphtm.replace(/\'/g, "`");
        var tmpque = this.lastQuestion; tmpque = tmpque.replace(/\'/g, "`"); tmpque = tmpque.replace(/\&\#/g, "|"); tmpque = tmpque.replace(/\&/g, " en ");
        var tmpopm = D("et_invoerOpmerking").value; tmpopm = tmpopm.replace(/\'/g, "`"); tmpopm = tmpopm.replace(/\&/g, " en ");
        var tmptestfase = (me.feedbacktestfase == true) ? '1' : '0';
        var tmpscore2 = 1;
        if (this.beoordeling == 0) { tmpscore2 = 2 };

        var url = this.opmerkingUrl +
			'?pro=' + this.projectID +
			'&uid=' + tmpuid +
			'&vraag=' + tmpque +
			'&antwoord=' + tmpant +
			'&rec=' + this.lastReceived_recnr +
			'&cat=' + this.lastReceived_category +
			'&commentaar=' + tmpopm +
			'&score=' + tmpscore2 +
			'&testfase=' + tmptestfase;
        url = url.replace(/</g, "<_");

        if (rsIframe == null) {
            var iframe = document.createElement("iframe");
            iframe.setAttribute("src", url);
            iframe.setAttribute("id", "RSIFrameOpmerking");
            iframe.setAttribute("scrolling", "no");
            iframe.setAttribute("frameBorder", "5");
            iframe.setAttribute("width", "0");
            iframe.setAttribute("height", "0");
            document.body.appendChild(iframe);
        } else {
            rsIframe.src = url;
        }

        if (bedankt_teller > 1) {
            this.SendOpmerking2();
        }
        else {
            D('et_bedankt').style.display = 'block';
            window.setTimeout("aise.SendOpmerking2()", 2000)
        }
    };

    this.SendOpmerking2 = function () {
        this.state = 2;
        this.changeState();
        document.getElementsByName('et_radio')[0].checked = false;
        document.getElementsByName('et_radio')[1].checked = false;
        D('et_invoerOpmerking').value = "";
        D('et_bedankt').style.display = 'none';
        D('et_versturen').style.display = 'none';
        D('et_versturen').style.visibility = 'hidden';
        D('et_opmerking').style.display = 'none';
        D('et_opmerking').style.visibility = 'hidden';
    };

    this.changeBeoordeling = function (newValue) {
        this.beoordeling = newValue;
        if (this.beoordeling == 0) {
            D('et_opmerking').style.display = 'none';
            D('et_opmerking').style.visibility = 'hidden';

            this.SendOpmerking();
        } else {
            D('et_bginvoerf3').style.display = 'block';
            D('et_opmerking').style.display = 'block';
            D('et_opmerking').style.visibility = 'visible';
            D('et_versturen').style.display = 'block';
            D('et_versturen').style.visibility = 'visible';
        }
    };
}

function AskCustomWelcome() {
    //if (!custom_welcome_asked2) {
    if (aise.ask_custom_welcome == 'ja') {
        aise.sendQuestionInit();
    }
}
function findPosLeft(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
        }
    }
    if (parent != self) {
        if (parent.D('iframeKlantenService')) {
            obj = parent.D('iframeKlantenService')
            if (obj.offsetParent) {
                curleft += obj.offsetLeft
                while (obj = obj.offsetParent) {
                    curleft += obj.offsetLeft
                }
            }
        }
    }
    return curleft;
}
function findPosTop(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curtop += obj.offsetTop
        }
    }
    if (parent != self) {
        if (parent.D('iframeKlantenService')) {
            obj = parent.D('iframeKlantenService')
            if (obj.offsetParent) {
                curtop += obj.offsetTop
                while (obj = obj.offsetParent) {
                    curtop += obj.offsetTop
                }
            }
        }
    }
    return curtop;
}

//var serverPath = et_loc + "//192.168.1.30/";
//var basicurl = serverPath + "js/";
var serverPath = et_loc + "//projecten.elitech.nl/";
var basicurl = serverPath + "wehkamp/js";

pijlon = new Image(); pijlon.src = basicurl + "/img/pijltje_on.gif";
pijloff = new Image(); pijloff.src = basicurl + "/img/pijltje_off.gif";
pijldownon = new Image(); pijldownon.src = basicurl + "/img/pijldown1_on.gif";
pijldownoff = new Image(); pijldownoff.src = basicurl + "/img/pijldown1_off.gif";
opslaanon = new Image(); opslaanon.src = basicurl + "/img/ok_on.gif";
opslaanoff = new Image(); opslaanoff.src = basicurl + "/img/ok_off.gif";

function swap() {
    if (document.images) {
        for (var x = 0; x < swap.arguments.length; x += 2) {
            document[swap.arguments[x]].src = eval(swap.arguments[x + 1] + ".src");
        }
    }
}

var aise = new elitechAise();
aise.projectID = "WEHYKJSCWR"; //15;   /* AISE projectID in de database*/
aise.instanceName = 'aise';     /* deze variabele niet veranderen */
aise.defaultvraag[0] = { "question": "Wanneer komt mijn bestelling?", "kbaId": 2022 };
aise.defaultvraag[1] = { "question": "Hoe kan ik mijn bestelling annuleren?", "kbaId": 387 };
aise.defaultvraag[2] = { "question": "Betaal ik verzendkosten?", "kbaId": 1546 };
aise.handigeVragen = true;  	  /* Maak gebruik van handige vragen */
aise.state = 2;     	  /* initiële status op klein blokje. */
aise.doPagePush = true; 	     /* indien false verschijnt onder het antwoord een link naar de page push pagina */
aise.proxyServer = basicurl + "/proxy.asp";
aise.css = basicurl + "/sanne_v4.css.asp";
aise.opmerkingUrl = serverPath + "/receiveopmerkingen.aspx";
aise.loadingHTML = "...";
aise.useIframeIEfix = false;  	  /* aan uitzetten IE fix => wel of geen achterliggende iframes bij de divs. Div kan anders niet over selectboxen en flash heen liggen. */
aise.testing = false;      /* Wel of niet weergeven van de beoordelingsdiv na het krijgen van een antwoord; als niet aan, dan dus geen et_status3div */
aise.feedbacktestfase = false;
aise.pagepushiframe = false;
aise.toonvraag = true;

aise.frame1 += '<div id="status1div" class="status1DivStyle" style="display:block;position:relative;z-index:1000;top:0px;left:0px;width:157px;">';
aise.frame1 += '	<div id="et_imgsanne"><img src="' + basicurl + '/img/sanne_v3_kl.jpg" alt="Virtuele Medewerkster Sanne" border="0" title="Virtuele Medewerkster Sanne" border="0" /></div>';
aise.frame1 += '	<div id="et_blockklsanne">';
//aise.frame1 += '<img src="' + basicurl + '/img/steluwvraagaansanne.gif" class="steluwvraagaansanne" alt="Stel uw vraag aan Sanne" border="0" />';
aise.frame1 += '		<div class="et_txtsanne">Stel je vraag aan Sanne</div>';
aise.frame1 += '		<input type="text" id="et_question" name="et_question" size="22" value="" class="tekstinput" onKeyPress="return checkEnter(event)" autocomplete="off" />';
aise.frame1 += '		<a href="javascript:void(0);" onClick="javascript:aise.sendQuestion();return false;" title="Stel vraag"><img src="' + basicurl + '/img/button_stelvraag.gif" alt="Stel vraag" class="et_stelvraag" border="0" /></a>';
aise.frame1 += '		<div id="et_aiseResponseDiv"></div>';
aise.frame1 += '		<div class="et_txtsanne">Veelgestelde vragen:</div>';
//aise.frame1 += '<img src="' + basicurl + '/img/meestgesteldevragen.gif" class="meestgesteldevragen" border="0" alt="Meestgestelde vragen" />';
aise.frame1 += '		<div id="et_faq"></div>';
aise.frame1 += '		<br /><br />';
aise.frame1 += '	</div>'; /* - afsluiten van et_blockklsanne ! */
aise.frame1 += '</div>';

aise.frame2 += '<div id="status2div" class="status2DivStyle" style="border:0px;display:none;position:relative;z-index:1000;top:0px;left:0px;width:0px;height:0px;">';
aise.frame2 += '</div>'

aise.frame3 += '<div id="et_status3div" style="position:relative;z-index:999;top:1px;left:0px;width:157px;height:auto;display:none;">';
aise.frame3 += '	<div id="et_testing">';
aise.frame3 += '		<div id="et_beoordeling">';
aise.frame3 += '			<span class="et_geholpen">Heeft Sanne je goed geholpen?</span>';
aise.frame3 += '			<div id="et_inputJaNee"><input type="radio" name="et_radio" id="et_radioJa" value="Ja" onClick="aise.changeBeoordeling(0)" /> ja';
aise.frame3 += '			<input type="radio" name="et_radio" id="et_radioNee" value="Nee" onClick="aise.changeBeoordeling(1)" /> nee</div>';
aise.frame3 += '		</div>';
aise.frame3 += '		<div id="et_opmerking" style="display:none;visibility:hidden;">';
aise.frame3 += '			<div id="et_maxchar">(max aantal karakters<br /><span id="et_char">0</span> / 125)</div>';
aise.frame3 += '			<div id="et_bginvoerf3"><textarea cols="10" rows="2" type="text" id="et_invoerOpmerking" name="et_invoerOpmerking" value="" onkeydown="javascript:CharTeller(D(&#34;et_invoerOpmerking&#34;),D(&#34;et_char&#34;),125);" onkeyup="javascript:CharTeller(D(&#34;et_invoerOpmerking&#34;),D(&#34;et_char&#34;),125);" />Omdat, </textarea></div>';
aise.frame3 += '			<div id="et_versturen" style="display:none;visibility:hidden;"><a href="#" onClick="aise.SendOpmerking();" title="Versturen"><img src="' + basicurl + '/img/verstuur.gif" border="0" /></a></div>';
aise.frame3 += '		</div>';
aise.frame3 += '		<div id="et_bedankt" style="display:none;"><strong>Fijn, bedankt!</strong></div>';
aise.frame3 += '	</div>';
aise.frame3 += '</div>';

aise.parse(); /* Start aise */



function isIE50() {
    return isIE5() && !isIE55();
}
function isFF() {
    return navigator.userAgent.indexOf("Firefox") > -1;
}
function isFF15() {
    return navigator.userAgent.indexOf("Firefox/1.5") > -1;
}
function isFF20() {
    return navigator.userAgent.indexOf("Firefox/2.0") > -1;
}
function isIE55() {
    return navigator.userAgent.indexOf("MSIE 5.5") > -1;
}
function isIE() {
    return navigator.userAgent.indexOf("MSIE") > -1;
}
function isIE5() {
    return navigator.userAgent.indexOf("MSIE 5") > -1;
}
function isIE6() {
    return navigator.userAgent.indexOf("MSIE 6") > -1 && navigator.userAgent.indexOf("Opera") == -1;
}
function isIE7() {
    return navigator.userAgent.indexOf("MSIE 7") > -1;
}
function isGeldigeIE() {
    return isIE55() || isIE6() || isIE7();
}
function isSAFARI() {
    return navigator.userAgent.indexOf("Safari") > -1;
}
function isWinXP() {
    if (navigator.userAgent.indexOf('NT 5.1') > 0) {
        return true;
    }
    else {
        return false;
    }
}
function checkEnter(e) {
    /*versturen van de vraag indien op enter toets wordt gedrukt*/
    var key;

    if (window.event) {
        key = window.event.keyCode; //IE
    } else {
        key = e.which;              //firefox
    }
    if (key == 13) {
        aise.sendQuestion();
        return false;
    }
}

function move_up() {
    /* omhoog scrollen in de Faq div */
    D('et_faq').scrollTop = D('et_faq').scrollTop - 15;
}
function move_down() {
    /* omlaag scrollen in de Faq div */
    D('et_faq').scrollTop = D('et_faq').scrollTop + 15;
}

function CharTeller(field, cntdiv, maxlimit) {
    var tel = 0;
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    } else {
        tel = field.value.length;
        cntdiv.innerHTML = tel;
        if (tel >= 0 && tel <= 118) { cntdiv.style.color = "#93ca7a"; }
        if (tel >= 119 && tel <= 120) { cntdiv.style.color = "#67b54b"; }
        if (tel >= 121 && tel <= 122) { cntdiv.style.color = "#45a528"; }
        if (tel >= 123 && tel <= 124) { cntdiv.style.color = "#390"; }
        if (tel == 125) { cntdiv.style.color = "#f00"; }
    }
}

function RemoveXSS(str) {
    str = str.replace(/>/gi, " ").replace(/</gi, " ");          // '<' en '>'.
    str = str.replace(/%3e/gi, " ").replace(/%3c/gi, " ");      // url-encodering '<' en '>'.
    str = str.replace(/&#60;/gi, " ").replace(/&#62;/gi, " ");  // html-encodering '<' en '>'.
    str = str.replace(/javascript\:/gi, " ");                   // javascript-startstring.
    str = str.replace(/document\.\S/g, " ");                    // document-startstring.
    return str;
}

function et_setFeedback(val) {
    var queryString = "sKey=WEHYKJSCWR" +
			"&iKbaId=" + aise.lastReceived_recnr +
			"&sSessionId=" + uid +
			"&sUserInput=" + encodeURIComponent(aise.lastQuestion) +
			"&sTxtOutput=" + encodeURIComponent(aise.lastReceived_antwoord) +
			"&byteScore=" + val +
			"&sComment=" + '' +
			"&bTestFase=" + false +
			"&sLangCode=1&iChannelID=1&iProfileID=1&ssecstring=&sip=" +
			"&js=true&callBack=et_feedbackSent(" + val + ");new function(){}";

    var s = document.createElement('script');
    var url = 'http://projecten.elitech.nl/et3/importexportsvc/importexportservice.svc/SetKbaFeedback?' + queryString;

    s.setAttribute('src', url);
    document.getElementsByTagName('head')[0].appendChild(s);

    D('et_feedbackBox').innerHTML = '';
}

function et_feedbackSent(val) {
    if (val === 2) // ja
        D('et_feedbackBox').innerHTML = '<br /><strong>Bedankt voor je feedback!<strong>';
    else
        D('et_feedbackBox').innerHTML = '<br />Ik kan je helaas niet verder helpen. Wil je de gegevens van onze klantenservice zodat je met een van mijn collega\'s contact kunt opnemen?<br /><label><input type= "radio" name="et_cc" value="1" onClick="et_showContact(1)">&nbsp;Ja</label>&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" name="et_cc" value="0" onClick="et_showContact(0)">&nbsp;Nee</label></div>';

}

function et_showContact(val) {
    if (val === 1) //ja
        D('et_feedbackBox').innerHTML = '<br />Onze klantenservice is op werkdagen van 10:00 tot 19:00 uur te bereiken op telefoonnummer 0900 9809.<br />Klik <a href="https://www.wehkamp.nl/Klantenservice/ContactFormulier.aspx">hier</a> als je een email wilt versturen.<br />Bedankt voor het gesprek. Nog een fijne dag en graag tot ziens.';
    else
        D('et_feedbackBox').innerHTML = '<br /><strong>Bedankt voor je feedback!<strong>';
}
