/*  
*/
/**********************************************************************/
/**********************************************************************/
/*********************** DRAG DROP LIBRARY ****************************/
/**********************************************************************/
/**********************************************************************/
var Dragger = "var eve=arguments.length?arguments[0]:event;" +
              "Drag.ox=eve.clientX-this.offsetLeft;" +
              "Drag.oy=eve.clientY-this.offsetTop;" +
              "this.fire=Drag.fire;this.fire();false;";
var Drag = {
    ox: 0, oy: 0,
    minx: null, maxx: null, miny: null, maxy: null,
    mode: 0,
    affine: null,
    initer: null,

    init: function(node, mode, minx, miny, maxx, maxy)
    {
        var retstr = "with(Drag) mode=" + mode + ",minx=" + minx + ",maxx=" + maxx
  			+ ",miny=" + miny + ",maxy=" + maxy + ";Drag.initer=1;" + Dragger;
        node.onmousedown = new Function("e", "return eval(\"" + retstr + "\")");
        return (Drag.initer = retstr);
    },
    add: function(node) { node.out = Drag.out; node.out(null); },
    fire: function()
    {
        var that = this;
        that.run = Drag.run;
        that.out = Drag.out;
        that.style.position = "absolute";
        that.onmousedown = null;
        that.onmouseup = function(e) { return that.out(e); };
        document.onmouseup = function(e) { return that.out(e); };
        document.onmousemove = function(e) { return that.run(e); };
        document.onmouseout = function(e)
        {
            var eve = e ? e : event;
            if (!eve.fromElement)
                eve.fromElement = eve.target, eve.toElement = eve.relatedTarget;
            if (!eve.toElement) that.out(e); return false;
        }; return false;
    },
    run: function(e)
    {
        repositionAfterDrag();
        var eve = e ? e : event;
        var nx = eve.clientX - Drag.ox;
        var ny = eve.clientY - Drag.oy;
        with (Drag)
        {
            if (minx) if (nx < minx) nx = minx;
            if (maxx) if (nx > maxx) nx = maxx;
            if (miny) if (ny < miny) ny = miny;
            if (maxy) if (ny > maxy) ny = maxy;
        } if (this.parentNode.style.position == "absolute")
        {
            nx = nx - this.parentNode.offsetLeft;
            ny = ny - this.parentNode.offsetTop;
        }
        if (Drag.mode < 2) this.style.left = nx + "px";
        if (!(Drag.mode % 2)) this.style.top = ny + "px";
        if (Drag.mode == 3 && Drag.affine)
            Drag.affine(this, nx, ny);
        repositionAfterDrag();
        return false;
    },

    out: function(e)
    {
        var invoker = null;
        document.onmousemove = null;
        document.onmouseup = null;
        document.onmouseout = null;
        this.onmouseup = null;
        with (Drag) { invoker = mode + "," + minx + "," + miny + "," + maxx + "," + maxy; }
        this.onmousedown = new Function("e", "return eval("
  			+ (Drag.initer ? "Drag.init(this," + invoker + ")" : "Dragger") + ")");
        with (Drag) { mode = 0, minx = null, maxx = null, miny = null, maxy = null; initer = null }
        return false;
    }
};

var et_EventTypes = {
    Click: { W3C: "click", MS: "onclick" },
    DblClick: { W3C: "dblclick", MS: "ondblclick" },
    MouseOver: { W3C: "mouseover", MS: "onmouseover" },
    MouseOut: { W3C: "mouseout", MS: "onmouseout" },
    MouseDown: { W3C: "mousedown", MS: "onmousedown" },
    MouseUp: { W3C: "mouseup", MS: "onmouseup" },
    MouseMove: { W3C: "mousemove", MS: "onmousemove" },
    KeyPress: { W3C: "keypress", MS: "onkeypress" },
    KeyDown: { W3C: "keydown", MS: "onkeydown" },
    KeyUp: { W3C: "keyup", MS: "onkeyup" },
    Submit: { W3C: "submit", MS: "onsubmit" },
    Reset: { W3C: "reset", MS: "onreset" },
    Focus: { W3C: "focus", MS: "onfocus" },
    Blur: { W3C: "blur", MS: "onblur" },
    Load: { W3C: "load", MS: "onload" },
    UnLoad: { W3C: "unload", MS: "onunload" },
    Resize: { W3C: "resize", MS: "onresize" },
    Scroll: { W3C: "scroll", MS: "onscroll" }
};

function AddEventToObject(obj, et_EventType, fn)
{
    /* click | dblclick | mouse(over,down,up,out,move) | key(press,down,up) | submit | reset | focus | blur | load | unload | resize | scroll */
    // W3C compliant browsers // false = Bubbling
    if (obj.addEventListener)
    {
        obj.addEventListener(et_EventType.W3C, fn, false);
    }
    // Microsoft // standaard: Bubbling
    else if (obj.attachEvent)
    {
        obj.attachEvent(et_EventType.MS, fn);
    }
}

/**********************************************************************
**********************************************************************
*********************** START AISE LIBRARY ***************************
**********************************************************************
**********************************************************************/

//var globalStateForDragStorage = 1;

var et_history = [];
var elitechAise = function()
{
    this.boturl = "http://www.eon-benelux.com/eonwww/publishing.nsf/Content/VraagHetEllen"; //index_klantenservice.htm destination of where to go when question asked
    this.klantcode = "EON";    /* Probeer hier een unieke afkorting te gebruiken voor een klant */
    this.subject = "HOME";      /* Geef hier met een korte code aan voor welke taal deze AiSE is (bijv. NL, EN, ...) */
    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.showDivSources = false;       /* voor debug/design true zetten */
    this.doPagePush = true;        /* aanzetten pagepush optie. Handig om uit te zetten tijdens ontwikkelfase */
    this.beoordeling = '0';            /* beoordeling goed is de defaultwaarde */
    this.handigeVragen = false;        /* maak gebruik van handige vragen */
    this.toonvraag = true;        /* De vraag herhalen in aise responsediv */
    this.pagepushiframe = false;       /* De pagepush uitvoeren naar een achtergrond frame (in geval van demo|testen) */
    this.testing = false;
    this.RecNr1 = 'leeg';
    this.RecNr2 = 'leeg';
    this.RecNr3 = 'leeg';
    this.DoorverwijzingContact = true;

    this.lastReceived_uid = "";
    this.lastReceived_antwoord = "";
    this.lastReceived_recnr = "";
    this.lastReceived_html = "";
    this.lastReceived_category = "";
    this.lastReceived_character = "";
    this.lastReceived_largeimg = "";
    this.lastQuestion = "";
    this.testing = false;
    this.feedbacktestfase = false;

    this.defaultvraag = new Array();
    this.callback = "me.putXMLhere();";
    this.oScript = "";
    var me = this;


    //	this.Unanswered			=	"";

    this.convertTo = function()
    {
        me.lastReceived_antwoord = me.lastReceived_antwoord.replace(/&#/gi, "SPECIAL_SIGN");
        me.lastReceived_antwoord = me.lastReceived_antwoord.replace(/;/gi, "PUNT_KOMMA");
        //		me.Unanswered = me.Unanswered.replace(/&#/gi, "SPECIAL_SIGN");
        // 	me.Unanswered = me.Unanswered.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 aise = document.getElementById('status1div');
        top.window.name = "AISE -!-" + me.klantcode + ";" + me.subject + ";" + me.lastReceived_uid + ";" + aise.style.top + ";" + aise.style.left + ";" + me.state + ";" + me.lastReceived_character + ";" + me.lastReceived_largeimg + ";" + me.lastQuestion + ";" + me.lastReceived_antwoord // + ";" + me.Unanswered;
    }
    this.repositionFromStorage = function()
    {
        /*
        Zet aise op de juiste top en left.
        Zet status van de aise (1, 2 of 3)
        Zet vraag en antwoord
        */
        var aise = document.getElementById('status1div');
        var wname = top.window.name.split("-!-");
        if (wname[1])
        {
            var storage = wname[1].split(";");
            if (storage[0] == this.klantcode && storage[1] == this.subject)
            {
                this.lastReceived_uid = storage[2];
                aise.style.top = storage[3]; //0
                aise.style.left = storage[4]; //1
                this.state = storage[5]; //2
                this.lastReceived_character = this.convertFrom(storage[6]);
                this.lastReceived_largeimg = this.convertFrom(storage[7]);
                this.lastQuestion = this.convertFrom(storage[8]);
                this.lastReceived_antwoord = this.convertFrom(storage[9]);
                //this.Unanswered            = this.convertFrom(storage[5]);

                //if (this.Unanswered != "") {
                //	document.getElementById('question').value = this.Unanswered;
                //	this.sendQuestion();
                //	return;
                //} else {
                //document.getElementById('question').value = this.lastQuestion;
                //document.getElementById('et_aiseResponseDiv').innerHTML = this.lastReceived_antwoord;
                //}
                //document.getElementById('aiseResponseDiv').innerHTML = this.lastReceived_antwoord;
            }
        }
        else
        {
            aise.style.top = this.defaultFromtop;
            aise.style.left = this.defaultFromLeft;
        }
        this.changeState();
        return true
    }
    this.changeState = function()
    {
        if (this.state == 1)
        {
            //document.getElementById('headerImageA').style.display='inline';
            //document.getElementById('headerImageB').style.display='none';
            document.getElementById('status1div').style.display = 'block';
            document.getElementById('status2div').style.display = 'none';
            document.getElementById('status3div').style.display = 'none';
            if (this.useIframeIEfix)
            {
                document.getElementById('status1frame').style.display = 'block';
                document.getElementById('status2frame').style.display = 'none';
                document.getElementById('status3frame').style.display = 'none';
            }
        }
        if (this.state == 2)
        {
            //document.getElementById('headerImageA').style.display='inline';
            //document.getElementById('headerImageB').style.display='inline';
            document.getElementById('status1div').style.display = 'block';
            document.getElementById('status2div').style.display = 'none';
            document.getElementById('status3div').style.display = 'none';
            if (this.useIframeIEfix)
            {
                document.getElementById('status1frame').style.display = 'block';
                document.getElementById('status2frame').style.display = 'none';
                document.getElementById('status3frame').style.display = 'none';
            }
            //if (document.getElementById('et_aiseResponseDiv').innerHTML == '') {
            //this.sendQuestionInit();
            //    return;
            //}
            //if (document.getElementById('divtext').style.display == "block" && document.getElementById('divtext').style.visibility == "visible")	{
            document.getElementById('et_question').focus();
            //}
        }
        if (this.state == 3)
        {
            //document.getElementById('headerImageA').style.display='inline';
            //document.getElementById('headerImageB').style.display='inline';
            document.getElementById('status1div').style.display = 'block';
            document.getElementById('status2div').style.display = 'block';
            document.getElementById('status3div').style.display = 'block'; // TONEN VOOR TEST_DIALOOG wordt dan display='';   verbergen =>  display='none';
            if (this.useIframeIEfix)
            {
                document.getElementById('status1frame').style.display = 'block';
                document.getElementById('status2frame').style.display = 'block';
                document.getElementById('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 + '">');
        if (this.showDivSources)
        {
            document.write('<textarea style="font-family: Verdana; font-size:11px;width:100%;height:33%;">' + this.frame1 + "</textarea>");
            document.write('<textarea style="font-family: Verdana; font-size:11px;width:100%;height:33%;">' + this.frame2 + "</textarea>");
            document.write('<textarea style="font-family: Verdana; font-size:11px;width:100%;height:33%;">' + this.frame3 + "</textarea>");
        }
        document.write(this.frame1);
        document.write(this.frame2);
        document.write(this.frame3);
        var BROWSER_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
        if (!BROWSER_IS_IE) { this.useIframeIEfix = false; }
        if (this.useIframeIEfix)
        {
            var status1div = document.getElementById('status1div');
            document.write("<iframe name='status1frame' id='status1frame' frameborder='0' style='display:none;z-index:900;position:absolute;background-color:#ff0000;' width='" + status1div.style.width + "' height='" + status1div.style.height + "'></iframe>");
            var status2div = document.getElementById('status2div');
            document.write("<iframe name='status2frame' id='status2frame' frameborder='0' style='display:none;z-index:900;position:absolute;background-color:#00ff00;' width='" + status2div.style.width + "' height='" + status2div.style.height + "'></iframe>");
            var status3div = document.getElementById('status3div');
            document.write("<iframe name='status3frame' id='status3frame' frameborder='0' style='display:none;z-index:900;position:absolute;background-color:#0000ff;' width='" + status3div.style.width + "' height='" + status3div.style.height + "'></iframe>");
        }
        /* Na het laden aise initialiseren*/
        //window.onload = this.positionAiseOnLoadHandler;  
        AddEventToObject(window, et_EventTypes.Load, function() { window.setTimeout("aise.positionAiseOnLoadHandler();", 1000); });
        /* Opslaan positie, vraag en antwoord */
        //window.onunload = this.storeAllData;              
        AddEventToObject(window, et_EventTypes.UnLoad, this.storeAllData);
        //window.onresize = repositionAfterDrag;
    }
    this.positionAiseOnLoadHandler = function()
    {
        /* initialiseer AISE onload */
        if (me.repositionFromStorage())
        {
            //repositionAfterDrag();
            if (me.handigeVragen) { me.setDefaultVragen(); }
        }
        if (isIE6() || isIE5())
        {
            correctPNG();
        }
    }
    this.setDefaultVragen = function()
    {
        var faqDiv = document.getElementById('faq');
        var test = "";
        for (var loop = 0; loop < this.defaultvraag.length; loop++)
        {
            test = "<a href='#' onClick=\"" + this.instanceName + ".vraagHandigeVraag('" + this.defaultvraag[loop] + "')\">" + this.defaultvraag[loop] + "</a><br />";
        }
        faqDiv.innerHTML = "" + test + "";
    }
    this.vraagHandigeVraag = function(vraag)
    {
        document.getElementById('et_question').value = vraag;
        this.sendQuestion();
    }
    this.verwerkHandigeVragen = function(hvragen)
    {
        var faqDiv = document.getElementById('et_faq');
        var test2 = "";
        for (var loop = 0; loop < hvragen.length; loop++)
        {
            test2 = test2 + "<a href='#' onClick=\"" + this.instanceName + ".vraagHandigeVraag('" + hvragen[loop] + "')\">" + hvragen[loop] + "</a><br />";
        }
        if (hvragen.length == 0)
        {
            for (var loop = 0; loop < this.defaultvraag.length; loop++)
            {
                test2 = test2 + "<a href='#' onClick=\"" + this.instanceName + ".vraagHandigeVraag('" + this.defaultvraag[loop] + "')\">" + this.defaultvraag[loop] + "</a><br />";
            }
        }
        faqDiv.innerHTML = "" + test2 + "";
    }
    this.getDataFromServer = function(id, url, vraag)
    {
        this.oScript = document.getElementById(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 + '&vraag=' + vraag;
        //alert("Laatst ontvangen UID: [" + this.lastReceived_uid + "]");
        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()
    {
        //document.getElementById('aiseResponseDiv').innerHTML = this.loadingHTML;
        custom_welcome_ask = false;

        //alvast uitklappen
        //document.getElementById('divtext').style.visibility = "visible";
        //if (typeof(et_character) == "string") {
        //	document.getElementById('imagegroteellen').src = basicurl + '/img/ellen_home.png';
        //}

        this.getDataFromServer("ScriptTagID", this.proxyServer, RemoveXSS(document.getElementById('et_question').value));
    }
    this.sendQuestionDirect = function(vraag) {
        custom_welcome_ask = false;
        this.getDataFromServer("ScriptTagID", this.proxyServer, RemoveXSS(vraag));
    }
    this.sendQuestionInit = function()
    {
        //document.getElementById('aiseResponseDiv').innerHTML = this.loadingHTML;
        custom_welcome_ask = true;

        //alvast uitklappen
        //document.getElementById('divtext').style.visibility = "visible";
        //if (typeof(et_character) == "string") {
        //	document.getElementById('imagegroteellen').src = basicurl + '/img/ellen_home.png';
        //}

        this.getDataFromServer("ScriptTagID", this.proxyServer, 'custom_welcome');
    }
    this.putXMLhere = function()
    {
        //this.Unanswered 		= 	"";
        this.lastReceived_uid = uid;
        this.lastReceived_antwoord = antwoord;
        this.lastReceived_recnr = recnr;
        this.lastReceived_html = html;
        this.lastReceived_category = category;
        this.lastReceived_character = et_character;
        //document.getElementById('divtext').style.visibility = "visible";

        //character aanpassingen
        //   LET OP: background-image in stylesheet uitzetten want moet in code
        //		if (typeof(et_character) == "string") {
        //			document.getElementById('imagegroteellen').src = basicurl + '/img/ellen_home.png';
        //			if (et_character=="") {
        //				
        //			} else {
        //				document.getElementById('imagegroteellen').src = eval("char_"+et_character.toLowerCase()+".src"); 
        //			}
        //		}

        //		antwoord = et_handleUrls(antwoord);

        var tmpinhoud = "";
        this.lastQuestion = RemoveXSS(document.getElementById('et_question').value);
        // et_history
        if (this.lastQuestion != "")
        { //user stelt een vraag
            var d = new Date();
            var aantal_history = et_history.length;
            var sHistory = '';
            var sTime = ((d.getHours() + "").length == 1 ? "0" + d.getHours() : d.getHours()) + ":" + ((d.getMinutes() + "").length == 1 ? "0" + d.getMinutes() : d.getMinutes());
            et_history[et_history.length] = [this.lastQuestion, sTime, this.lastReceived_antwoord];
            for (var i = 0; i < aantal_history; i++)
            {
                sHistory = '<img src="' + basicurl + '/img/pijl.gif" border="0" />&nbsp;<strong>' + et_history[i][0] + '</strong><br /> ' + et_history[i][2] + '<br /><br />' + sHistory;
            }
            //<span class="date">' + et_history[i][1] + ' : </span>  sHistory = '<ul class="historie">' + sHistory + '</ul>';
            if (document.getElementById('et_eerdergestvragen'))
            {
                document.getElementById('et_eerdergestvragen').innerHTML = sHistory;
            }
        }
        if (this.RecNr1 == 'leeg')
        { // nog geen vraag gesteld
            this.RecNr1 = recnr;
        } else if (this.RecNr2 == 'leeg')
        { // pas 1 vraag gesteld
            this.RecNr2 = recnr;
        } else if (this.RecNr3 == 'leeg')
        { // pas 2 vragen gesteld
            this.RecNr3 = recnr;
        } else
        { //alles gevuld; dus meer dan 3 vragen gesteld
            this.RecNr1 = this.RecNr2;
            this.RecNr2 = this.RecNr3;
            this.RecNr3 = recnr;
        }
        if (this.DoorverwijzingContact)
        {
            if ((this.RecNr1 != 'leeg' && this.RecNr2 != 'leeg' && this.RecNr3 != 'leeg') && (this.RecNr1 == this.RecNr2 && this.RecNr2 == this.RecNr3))
            { //afgelopen 3 vragen zijn gelijk.
                html = 'http://www.eon-benelux.com/eonwww/publishing.nsf/Content/ContactForm'; //Contactpagina
                this.lastReceived_html = html;
                antwoord = 'Wellicht kan &#233;&#233;n van mijn collega&rsquo;s u verder helpen. <a href="http://www.eon-benelux.com/eonwww/publishing.nsf/Content/ContactForm" target="_blank">Neem contact op met Eon</a>.';
                this.lastReceived_antwoord = antwoord;
            }
        }

        //if (this.toonvraag == true) {
        //    document.getElementById('et_aiseResponseDiv').innerHTML = "<span class='et_gestvr'>" + this.lastQuestion + "</span><br /><div id='et_ruimtegesteldevraag'></div>" + antwoord;
        //} else {
        //    document.getElementById('et_aiseResponseDiv').innerHTML = antwoord;
        //}
        if (this.handigeVragen)
        {
            this.verwerkHandigeVragen(hvragen);
        }
        if (html != "")
        {
            if (this.doPagePush && html.indexOf('www.eon-benelux.com') == -1)
            { // pagepush naar www.eon-benelux.com => link "meer info" met target="_blank" aan antwoord toevoegen.
                if (this.pagepushiframe == true)
                {
                    if (document.getElementById("frame"))
                    {
                        document.getElementById("frame").src = html;
                    }
                } else
                {
                    document.location.href = html;
                }
            } else
            {
                //    document.getElementById('et_aiseResponseDiv').innerHTML += '<br /><br /><a href=' + html + '>Klik hier voor meer info.</a>'
            }
        }
        if (this.testing) { this.state = 3; }
        this.changeState();
        if (this.state > 1)
        {
            if (this.toonvraag == true)
            {
                //document.getElementById('question').value = "";
                //if (document.getElementById('divtext').style.display == "block" && document.getElementById('divtext').style.visibility == "visible")	{
                document.getElementById('et_question').focus();
                //}
            } else
            {
                //if (document.getElementById('divtext').style.display == "block" && document.getElementById('divtext').style.visibility == "visible")	{
                document.getElementById('et_question').focus();
                document.getElementById('et_question').select();
                //}
            }
        }
        antwoord = ""; // Leegmaken ivm firefox wait <- Deze controlleerd of antwoord gezet is.
    }
    this.SendOpmerking = function()
    {
        var rsIframe = document.getElementById("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 tmprec = this.lastReceived_recnr; tmprec = tmprec.replace(/\'/g, "`");
        var tmphtm = this.lastReceived_html; tmphtm = tmphtm.replace(/\'/g, "`");
        var tmpcat = this.lastReceived_category; tmpcat = tmpcat.replace(/\'/g, "`");
        var tmpque = this.lastQuestion; tmpque = tmpque.replace(/\'/g, "`"); tmpque = tmpque.replace(/\&\#/g, "|"); tmpque = tmpque.replace(/\&/g, " en ");
        var tmpopm = document.getElementById("et_invoerOpmerking").value; tmpopm = tmpopm.replace(/\'/g, "`"); tmpopm = tmpopm.replace(/\&/g, " en ");
        var tmptestfase = (me.feedbacktestfase == true) ? '1' : '0';

        //var url = this.opmerkingUrl + '?uid=' + tmpuid + '&vraag=' + tmpque + '&antwoord=' + tmpant + '&commentaar=' + tmpopm + '&score=' + this.beoordeling;
        //BERT REC en CAT TOEGEVOEGEN
        //var url = this.opmerkingUrl + '?uid=' + tmpuid + '&vraag=' + tmpque + '&antwoord=' + tmpant + '&commentaar=' + tmpopm + '&score=' + this.beoordeling + '&rec=' + tmprec + '&cat=' + tmpcat + '&pro=' + this.projectID;
        var url = this.opmerkingUrl +
			'?pro=' + this.projectID +
			'&uid=' + tmpuid +
			'&vraag=' + tmpque +
			'&antwoord=' + tmpant +
			'&rec=' + tmprec +
			'&cat=' + tmpcat +
			'&commentaar=' + tmpopm +
			'&score=' + this.beoordeling +
			'&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;
        }
        document.getElementById('et_divInvoerOpmerking').style.display = 'none';
        document.getElementById('et_opmerkingtitel').style.display = 'none';
        this.state = 2;
        this.changeState();
        document.getElementsByName('et_beoordeling')[0].checked = false;
        document.getElementsByName('et_beoordeling')[1].checked = false;
        document.getElementsByName('et_beoordeling')[2].checked = false;
        document.getElementById('et_invoerOpmerking').value = "";
    }
    this.changeBeoordeling = function(newValue)
    {
        this.beoordeling = newValue;
        if (this.beoordeling == '0')
        {
            document.getElementById('et_divInvoerOpmerking').style.display = 'none';
            document.getElementById('et_opmerkingtitel').style.display = 'none';
        } else
        {
            document.getElementById('et_divInvoerOpmerking').style.display = '';
            document.getElementById('et_opmerkingtitel').style.display = '';
            if (newValue == 1)
            {
                document.getElementById('et_opmerkingtitel').innerHTML = 'Voeg hier het antwoord voor deze vraag toe:';
            }
            if (newValue == 2)
            {
                document.getElementById('et_opmerkingtitel').innerHTML = 'Verduidelijk de fout in het antwoord:';
            }
        }
    }
}

/**********************************************************************/
/**********************************************************************/
/*********************** EINDE AISE LIBRARY ***************************/
/**********************************************************************/
/**********************************************************************/

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (document.body.filters))
    {
        for (var i = 0; i < document.images.length; i++)
        {
            var img = document.images[i]
            var imgName = img.src.toUpperCase()
            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG")
            {
                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                img.outerHTML = strNewHTML
                i = i - 1
            }
        }
    }
}

function repositionAfterDrag()
{
    /* Positioneren van alle DIV's en IFRAMES relatief aan de div "status1div" */
    var MainDiv = document.getElementById('status1div');
    if (true == true)
    {
        if (isIE7())
        {
            //alert(document.documentElement.clientWidth);
            MainDiv.style.left = ((document.body.clientWidth / 2) - 242) + "px";
            MainDiv.style.top = "138px";
        } else if (isIE())
        {
            MainDiv.style.left = ((document.body.clientWidth / 2) - 235) + "px";
            MainDiv.style.top = "141px";
        } else
        {
            MainDiv.style.left = ((document.body.clientWidth / 2) - 243) + "px";
            MainDiv.style.top = "138px";
        }
    }
    var MainPosLeft = MainDiv.style.left.replace('px', '');
    var MainPosTop = MainDiv.style.top.replace('px', '');
    var MainHeight = MainDiv.style.height.replace('px', '') * 1;
    var MainWidth = MainDiv.style.width.replace('px', '') * 1;

    var status2div = document.getElementById('status2div');
    status2div.style.left = MainPosLeft + "px";
    status2div.style.top = (MainPosTop * 1) + MainHeight + 1 + "px";

    var status3div = document.getElementById('status3div');
    status3div.style.left = (MainPosLeft - status3div.style.width.replace('px', '') * 1 + 319) + "px";
    status3div.style.top = (MainPosTop * 1) + MainHeight + "px";

    if (aise.useIframeIEfix)
    {
        document.getElementById('status1frame').style.top = MainDiv.style.top;
        document.getElementById('status1frame').style.left = MainDiv.style.left;
        document.getElementById('status2frame').style.top = status2div.style.top;
        document.getElementById('status2frame').style.left = status2div.style.left;
        document.getElementById('status3frame').style.top = status3div.style.top;
        document.getElementById('status3frame').style.left = status3div.style.left;
    }
    //if (aise.state>1) {
    //if (document.getElementById('divtext').style.display == "block" && document.getElementById('divtext').style.visibility == "visible")	{
    document.getElementById('et_question').focus();
    document.getElementById('et_question').select();
    //}
    //}
}

/*********************************************************************
*********************************************************************
*********************************************************************
**********************************************************************/
//var basicurl		= "http://192.168.1.65";
var serverPath = "http://projecten.elitech.nl";
var basicurl = serverPath + "/eon/js";

var aise = new elitechAise();
aise.projectID = "EONGUP;"; //44  /* encrypted projectname */
aise.instanceName = 'aise';     /* deze variabele niet veranderen */
aise.defaultFromtop = "0px";    /* startwaarde top van aise */
aise.defaultFromLeft = "0px";    /*307 startwaarde left van aise */
aise.defaultvraag[0] = "Wat is duurzaam opgewekt gas?";
aise.defaultvraag[1] = "Welke energietarieven zijn er?";
aise.defaultvraag[2] = "Welke producten heeft E.on?";
aise.handigeVragen = false;  	   /* 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 + "/ellen_home.css";
aise.opmerkingUrl = serverPath + "/receiveopmerkingen.aspx";
aise.loadingHTML = "<img src='http://projecten.elitech.nl/eon/js/img/ajax-loader.gif' border='0' />"
aise.showDivSources = false;      /* Debug only => laat content van de divs in textarea's zien. Handig tijdens opmaak van div's */
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 status3div */
aise.feedbacktestfase = false;
aise.pagepushiframe = true;
aise.toonvraag = true;
// !! in verband met de javascript code moeten de style-width/height/top/left voor de te repositioneren blokken in onderstaande code gezet worden en niet in de stylesheet.

aise.frame1 += '<div id="status1div" class="status1DivStyle" style="border:0px;display:none;position:relative;z-index:1000;top:0;left:0;width:247px;height:auto;background-color:transparent;">';
aise.frame1 += '	<div id="et_alles">';
aise.frame1 += '		<div id="et_ellen"><img id="et_imagegroteellen" src="' + basicurl + '/img/ellen_home.jpg" border="0" alt="Ellen" /></div>';
aise.frame1 += '		<div id="et_stelvraag_box">';
aise.frame1 += '			<div id="et_kanikuhelpen"><img src="' + basicurl + '/img/kanikuhelpen.gif" border="0" title="Kan ik u helpen?" /></div>';
aise.frame1 += '			<div id="et_titel">Stel een vraag aan Ellen</div>';
aise.frame1 += '			<div id="et_infosmall"><img src="' + basicurl + '/img/info.gif" border="0" onmouseover="javascript:et_ShowInfo();return false;" onmouseout="javascript:et_HideInfo();return false;" /></div>';
aise.frame1 += '			<div id="et_bginput"><textarea cols="10" rows="2" type="text" id="et_question" name="et_question" value="" class="et_tekstinput" onKeyPress="return checkEnter(event)"/></textarea></div>';
aise.frame1 += '			<div id="et_stelvraag"><a href="javascript:void(0);" title="Stel uw vraag aan Ellen" class="et_stelvraag" onClick="return et_popitup()">Stel vraag <img src="' + basicurl + '/img/pijl_home.gif" border="0" alt="Stel uw vraag aan Ellen" /></a><br /><a href="http://www.eon-benelux.com/eonwww/publishing.nsf/Content/Veelgestelde+vragen+consumenten" title="Veelgestelde vragen" class="et_veelgestvr">Veelgestelde vragen <img src="' + basicurl + '/img/pijl_home.gif" border="0" alt="Veel gestelde vragen" /></a></div>';
aise.frame1 += '		</div>';
//aise.frame1 += '		<div id="et_divtext" style="visibility:hidden;display:block;">';
//aise.frame1 += '				<div id="et_aiseResponseDiv"></div>';
//aise.frame1 += '		</div>';
aise.frame1 += '	</div>';
aise.frame1 += '	<div id="et_info">';
aise.frame1 += '		<div id="et_itop"><img src="' + basicurl + '/img/itop.png" border="0" /></div>';
aise.frame1 += '		<div id="et_imiddle"><div id="et_itekst">Ik ben Ellen, ik beantwoord vragen over producten en diensten van E.ON. Stel uw vraag a.u.b. als korte zin of met een kernwoord.</div></div>';
aise.frame1 += '		<div id="et_ibottom"><img src="' + basicurl + '/img/ibottom.png" border="0" /></div>';
aise.frame1 += '	</div>';
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="status3div" style="position:relative;z-index:1000;top:10px;left:172px;width:275px;height:200;display:none;">';
aise.frame3 += '	<div class="et_beoordeling">Geef hier per vraag aan wat u van het antwoord van Ellen vindt: <br /><br />';
aise.frame3 += '		<input type="radio" name="et_beoordeling" id="beoordelingGoed" value="Goed" onClick="aise.changeBeoordeling(0);aise.SendOpmerking();" />De vraag is goed beantwoord.<br />';
aise.frame3 += '		<input type="radio" name="et_beoordeling" id="beoordelingVerkeerdHerkend" value="Verkeerd herkend" onClick="aise.changeBeoordeling(1)" />De vraag wordt niet goed herkend.<br />';
aise.frame3 += '		<input type="radio" name="et_beoordeling" id="beoordelingFout" value="Fout" onClick="aise.changeBeoordeling(2)" />Het antwoord is inhoudelijk niet goed.<br /><br />';
aise.frame3 += '		<div id="et_divInvoerOpmerking" style="display:none;">';
aise.frame3 += '				<div id="et_opmerkingtitel"></div>';
aise.frame3 += '				<textarea id="et_invoerOpmerking" name="et_invoer" cols="20" rows="4" value=""></textarea><br /><br />';
aise.frame3 += '				<button class="et_button" onClick="aise.SendOpmerking();">Opmerking opslaan</button><br /><br />';
aise.frame3 += '		</div>';
aise.frame3 += '	</div>';
aise.frame3 += '</div>';

aise.parse(); /* Start aise */



/**********************************************************************/
/**********************************************************************/
/************** zie ook aise.frame1/2/3 variabelen ********************/
/**********************************************************************/
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();
        et_popitup();
        return false;
    }

}
function move_up()
{
    /* omhoog scrollen in de Faq div */
    document.getElementById('faq').scrollTop = document.getElementById('faq').scrollTop - 15;
}
function move_down()
{
    /* omlaag scrollen in de Faq div */
    document.getElementById('faq').scrollTop = document.getElementById('faq').scrollTop + 15;
}

imgpreload = new Image(); imgpreload.src = basicurl + "/img/ajax-loader.gif";
img1 = new Image(); img1.src = basicurl + "/img/ellen_home.jpg";
//img2 = new Image(); img2.src = basicurl + "/img/info.jpg";
img3 = new Image(); img3.src = basicurl + "/img/kanikuhelpen.gif";
img4 = new Image(); img4.src = basicurl + "/img/pijl_home.gif";
img5 = new Image(); img5.src = basicurl + "/img/bgtextvak.gif";

//verzendon = new Image();  verzendon.src = basicurl + "/img/verzenden_on.jpg";
//verzendoff = new Image(); verzendoff.src = basicurl + "/img/verzenden_off.jpg";
//inklapon = new Image();  inklapon.src = basicurl + "/img/inklap_on.jpg";
//inklapoff = new Image(); inklapoff.src = basicurl + "/img/inklap_off.jpg";
//uitklapon = new Image();  uitklapon.src = basicurl + "/img/uitklap_on.jpg";
//uitklapoff = new Image(); uitklapoff.src = basicurl + "/img/uitklap_off.jpg";
//heleen1 = new Image(); heleen1.src = basicurl + "/img/heleen_grootbottom.gif";
//heleen2 = new Image(); heleen2.src = basicurl + "/img/heleen_kleinbottom.jpg";

// character aanpassingen
//char_start            = new Image(); char_start.src = basicurl + "/img/start.jpg";
//char_onzekerheid      = new Image(); char_onzekerheid.src = basicurl + "/img/onzekerheid.jpg";
//char_zekerheid        = new Image(); char_zekerheid.src = basicurl + "/img/zekerheid.jpg";
//char_nietwenselijk    = new Image(); char_nietwenselijk.src = basicurl + "/img/nietwenselijk.jpg";

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");
        }
    }
}

function et_ShowInfo()
{
    if (document.getElementById('et_info'))
    {
        document.getElementById('et_info').style.visibility = "visible";
        document.body.focus(); // om ervoor te zorgen dat de cursor niet door de infobox te zien is.
    }
}
function et_HideInfo()
{
    if (document.getElementById('et_info'))
    {
        document.getElementById('et_info').style.visibility = "hidden";
    }
}
function et_ShowHistory()
{
    //	document.getElementById('et_divtext').style.visibility = "hidden";
    //	document.getElementById('et_divtext').style.display = "none";
    document.getElementById('et_divtexteerdergestvr').style.display = "block";
    document.getElementById('et_divtexteerdergestvr').style.visibility = "visible";
    document.getElementById('et_info').style.left = "20px";
}
function et_HideHistory()
{
    document.getElementById('et_divtexteerdergestvr').style.visibility = "hidden";
    document.getElementById('et_divtexteerdergestvr').style.display = "none";
    //	document.getElementById('et_divtext').style.display = "block";     
    //	document.getElementById('et_divtext').style.visibility = "visible";
    document.getElementById('et_info').style.left = "190px";
    document.getElementById('et_question').focus();
    document.getElementById('et_question').select();
}
function et_handleUrls(x)
{
    // deze functie om de van oorsprong "vanuit www.eon-benelux.com gedachte"-urls om te zetten naar "vanuit www.welkombijeon.nl gedacht"
    // link naar www.eon-benelux.com => target omzetten van "_top" naar "_blank"
    // link naar www.welkombijeon.nl => target omzetten van "_blank" naar "_top"
    var a, b, c, d, k, l, m, z, y; y = 0;
    while (x.substring(y).indexOf('<a') > -1)
    {
        a = x.indexOf('<a', y);
        b = x.indexOf('>', (a));
        if (x.substring(a, b).indexOf('www.welkombijeon.nl') > -1)
        { // www.welkombijeon.nl
            if (x.substring(a, b).indexOf('target') > -1)
            {
                k = x.substring(a, b).indexOf('target');
                l = x.substring((a + k), b).indexOf("'"); //eerste quote na target
                m = x.substring((a + k + l + 1), b).indexOf("'"); //tweede quote na target
                x = x.substring(0, (a + k + l + 1)) + '_top' + x.substring((a + k + l + m + 1));
            } else
            {
                //alert()
                x = x.substring(0, a + 3) + "target='_top' " + x.substring(a + 3);
            }
        } else if (x.substring(a, b).indexOf('www.eon-benelux.com') > -1)
        { // www.eon-benelux.com
            if (x.substring(a, b).indexOf('target') > -1)
            {
                k = x.substring(a, b).indexOf('target');
                l = x.substring((a + k), b).indexOf("'"); //eerste quote na target
                m = x.substring((a + k + l + 1), b).indexOf("'"); //tweede quote na target
                x = x.substring(0, (a + k + l + 1)) + '_blank' + x.substring((a + k + l + m + 1));
            } else
            {
                x = x.substring(0, a + 3) + "target='_blank' " + x.substring(a + 3);
            }
        }
        y = y + x.substring(y).indexOf('</a>') + 4;
    }
    return x
}


function et_popitup()
{
    /*
    //var url = aise.boturl;
    //	if (document.getElementById('et_question')){
    //		url += "?" + document.getElementById('et_question').value;
    //    }
    //alert(top.window.name);
    //newwindow = window.open(url,'Emma','height=551,width=271,location=0,menubar=0,scrollbars=0,status=0,toolbar=0');
    //if (window.focus) {
    //	newwindow.focus();
    //}
    top.window.name = document.getElementById('et_question').value;
    */
    // in de grote versie moet dan gekeken worden indien de lastQuestion gevuld is maar het lastAntwoord leeg is dan moet de vraag door SendQuestion gehaald worden.
    aise.lastQuestion = document.getElementById('et_question').value;
    aise.lastReceived_antwoord = "";
    window.location = aise.boturl;
    return false;
}
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;
}
