/**********************************************************************/
/**********************************************************************/
/*********************** 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;
 }
};


/**********************************************************************
 **********************************************************************
 *********************** START AISE LIBRARY ***************************
 **********************************************************************
 **********************************************************************/

//var globalStateForDragStorage = 1;

var et_loc = window.top.location.href.substring(0,5).indexOf('https')!=-1?'https':'http';
var elitechAise = function()
{
	this.klantcode = "ESSENT";    /* Probeer hier een unieke afkorting te gebruiken voor een klant */
	this.subject = "KLEIN";      /* 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 = true;        /* 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.iframe_ssl_page = "";
	this.lastReceived_uid = "";
	this.lastReceived_antwoord = "";
	this.lastReceived_recnr = "";
	this.lastReceived_html = "";
	this.lastReceived_category = "";
	this.lastReceived_character = "";
	this.lastQuestion = "";
	this.testing = false;
	this.feedbacktestfase = false;
	this.StandaardTekst = "";
	this.defaultvraag = new Array();
	this.callback = "me.putXMLhere();";
	this.oScript = "";
	this.reloadFromStorage = "0";
	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.setReloadFromStorage = function()
	{
		me.reloadFromStorage = "1";
	}
	this.storeAllData = function()
	{
		me.convertTo();
		var aise = document.getElementById('status1div');
		top.window.name = "AISE -!-" + me.klantcode + ";" + me.subject + ";" + aise.style.top + ";" + aise.style.left + ";" + me.state + ";" + me.lastReceived_character + ";" + me.reloadFromStorage + ";" + 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[6] == "1") // && storage[1] == this.subject)
			{
				aise.style.top = storage[2]; //0
				aise.style.left = storage[3]; //1
				this.state = storage[4]; //2
				this.lastReceived_character = this.convertFrom(storage[5]);
				//this.reloadFromStorage = this.convertFrom(storage[6]);
				this.lastQuestion = this.convertFrom(storage[7]);
				this.lastReceived_antwoord = this.convertFrom(storage[8]);
				//this.Unanswered = this.convertFrom(storage[5]);

				//if (this.Unanswered != "") {
				//	document.getElementById('et_question').value = this.Unanswered;
				//	this.sendQuestion();
				//	return;
				//} else {
				if (this.toonvraag == true)
				{
					document.getElementById('et_question').value = "";
					document.getElementById('et_innerResponseDiv').innerHTML = "<strong>" + this.lastQuestion + "</strong><br /><div id='ruimtegesteldevraag'></div>" + this.lastReceived_antwoord;
				}
				else
				{
					document.getElementById('et_question').value = this.lastQuestion;
					document.getElementById('et_innerResponseDiv').innerHTML = this.lastReceived_antwoord;
				}
				//}
				//document.getElementById('et_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('sluiten').style.visibility = 'hidden';
			//document.getElementById('bgimgheleen').style.backgroundImage = "url(" + basicurl + "/img/heleen_kleinbottom.gif)";
			//document.getElementById('status1div').style.height = "120px";
			//document.getElementById('et_heleen').style.height = "88px";
			document.getElementById('et_antw').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('sluiten').style.visibility = 'visible';
			//document.getElementById('et_heleen').style.backgroundImage = "url(" + basicurl + "/img/heleen_grootbottom.gif)";
			//document.getElementById('status1div').style.height = "330px";
			//document.getElementById('bgimgheleen').style.height = "181px";
			document.getElementById('et_antw').style.display = 'block';

			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_antw').innerHTML == '')
			{
				this.sendQuestionInit();
				return;
			}
			document.getElementById('et_question').focus();

			/* Voor de scrollbars */
			var resHeight = document.getElementById('et_innerResponseDiv').clientHeight;
			if (resHeight > 180) { resHeight = 180; }
			document.getElementById('et_aiseResponseDiv').style.height = resHeight + 2 + "px"; // +2 vanwege IE6
			document.getElementById('et_aiseResponseDiv').style.overflow = "hidden";
			document.getElementById('et_outerResponseDiv').style.height = resHeight + "px";
			document.getElementById('et_outerResponseDiv').style.overflow = "hidden";
			removeScrollbars();
			setScrollbars();
		}
		if (this.state == 3)
		{
			//document.getElementById('headerImageA').style.display='inline';
			//document.getElementById('headerImageB').style.display='inline';
			//document.getElementById('sluiten').style.visibility = 'visible';
			//document.getElementById('bgimgheleen').style.backgroundImage = "url(" + basicurl + "/img/heleen_grootbottom.gif)";
			//document.getElementById('status1div').style.height = "330px";
			//document.getElementById('bgimgheleen').style.height = "181px";

			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';
			}
		}
		if (typeof setFooter != 'undefined') { setFooter(); } // code specifiek voor Essent.
	}
	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' src='" + me.iframe_ssl_page + "' 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 = document.getElementById('status2div');
			document.write("<iframe name='status2frame' id='status2frame' src='" + me.iframe_ssl_page + "' 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>");
			var status3div = document.getElementById('status3div');
			document.write("<iframe name='status3frame' id='status3frame' src='" + me.iframe_ssl_page + "' frameborder='0' style='moz-opacity:.5;filter:alpha(opacity=0);display:none;z-index:900;position:absolute;' width='" + status3div.style.width + "' height='" + status3div.style.height + "'></iframe>");
		}
		//window.onload = this.positionAiseOnLoadHandler;  // Na het laden aise initialiseren
		//window.onunload = this.storeAllData;             // Opslaan positie, vraag en antwoord
		//window.onresize = repositionAfterDrag;
	}
	this.positionAiseOnLoadHandler = function()
	{
		/* initialiseer AISE onload */
		if (me.repositionFromStorage())
		{
			//repositionAfterDrag();
			if (me.handigeVragen) { me.setDefaultVragen(); }
		}
		initDHTMLAPI();
	}
	this.setDefaultVragen = function()
	{
		var faqDiv = document.getElementById('faq');
		faqDiv.innerHTML = "";
		for (var loop = 0; loop < this.defaultvraag.length; loop++)
		{
			faqDiv.innerHTML = faqDiv.innerHTML + "<img style='cursor:pointer;' src='" + basicurl + "/img/pijl_off.gif' border='0' /><a href='#' onClick=\"" + this.instanceName + ".vraagHandigeVraag('" + this.defaultvraag[loop] + "')\">" + this.defaultvraag[loop] + '</a><br />'
		}
	}
	this.vraagHandigeVraag = function(vraag)
	{
		document.getElementById('et_question').value = vraag;
		this.sendQuestion();
	}
	this.verwerkHandigeVragen = function(hvragen)
	{
		var faqDiv = document.getElementById('faq');
		faqDiv.innerHTML = "";
		for (var loop = 0; loop < hvragen.length; loop++)
		{
			faqDiv.innerHTML = faqDiv.innerHTML + "<img style='cursor:pointer;' src='" + basicurl + "/img/pijl_off.gif' border='0' /><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++)
			{
				faqDiv.innerHTML = faqDiv.innerHTML + "<img style='cursor:pointer;' src='" + basicurl + "/img/pijl_off.gif' border='0' /><a href='#' onClick=\"" + this.instanceName + ".vraagHandigeVraag('" + this.defaultvraag[loop] + "')\">" + this.defaultvraag[loop] + '</a><br />'
			}
		}
	}
	this.getDataFromServer = function(id, url, vraag)
	{
		document.getElementById('et_antw').style.display = 'block';

		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;
		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" || this.oScript.readyState == "complete")
			{
				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" || me.oScript.readyState == "complete")
		{
			eval(me.callback);
			me.oScript.onreadystatechange = null;
		}
	}
	var custom_welcome_ask = false;
	this.sendQuestion = function()
	{
		if (isIE6())
		{
			document.getElementById('et_aiseResponseDiv').style.height = "50px";
			document.getElementById('et_aiseResponseDiv').style.overflowX = "hidden";
			document.getElementById('et_aiseResponseDiv').style.overflowY = "auto";
			document.getElementById('et_outerResponseDiv').style.height = "auto";
		}
		document.getElementById('et_innerResponseDiv').innerHTML = this.loadingHTML;
		custom_welcome_ask = false;
		this.getDataFromServer("ScriptTagID", this.proxyServer, RemoveXSS(document.getElementById('et_question').value));
	}
	this.sendQuestionInit = function()
	{
		document.getElementById('et_innerResponseDiv').innerHTML = this.loadingHTML;
		custom_welcome_ask = true;
		this.getDataFromServer("ScriptTagID", this.proxyServer, 'custom_welcome');
	}
	this.putXMLhere = function()
	{
		//this.Unanswered 		= 	"";
		this.lastReceived_uid = uid;
		/*** added by RMB ***/
		if (window.location.toString().indexOf("www.essent.nl/mijnessent") > -1) //we zitten in 'mijn essent'
		{
			var startPos = 0;
			while ((startPos = antwoord.indexOf("<a href", startPos)) > -1) //zoekt in het antwoord naar de eerstvolgende href
			{
				var endPos = antwoord.indexOf(">", startPos) + 1; //het einde van de <a> wordt bepaald + 1 om de < mee te nemen
				var url = antwoord.substring(startPos, endPos);
				if (url.indexOf("www.essent.nl/mijnessent") == -1)
				{
					//als de url in het antwoord NIET verwijst naar een 'mijn essent' pagina opent deze in een nieuw venster
					if (url.indexOf("target") > -1)//er staat een target in de url
					{
						antwoord = antwoord.replace(url, url.replace(/\_top/gi, '_blank'));
					}
					else
					{
						//als er geen target in de url staat, wordt deze toegevoegd
						antwoord = antwoord.replace(url, url.replace(/>/g, ' target="_blank">'));
					}
				}
				startPos = endPos; //de startpositie wordt opgehoogd om naar verdere <a> tags te zoeken
			}
		}
		else //we zitten NIET in 'mijn essent'
		{
			var startPos = 0;
			while ((startPos = antwoord.indexOf("<a href", startPos)) > -1) //zoekt in het antwoord naar de eerstvolgende url
			{
				var endPos = antwoord.indexOf(">", startPos); //het einde van de <a> wordt bepaald
				var url = antwoord.substring(startPos, endPos);
				if (url.indexOf("www.essent.nl/mijnessent") > -1 || url.indexOf("www.essent.nl/content/mijnessent/index.jsp") > -1)
				{
					//als de url in het antwoord verwijst naar een 'mijn essent' pagina OF de inlogpagina van mijn essent
					//opent deze in een nieuw venster
					if (url.indexOf("target") > -1)//er staat een target in de url
					{
						antwoord = antwoord.replace(url, url.replace(/\_top/gi, '_blank'));
					}
					else
					{
						//als er geen target in de url staat, wordt deze toegevoegd
						antwoord = antwoord.replace(url, url.replace(/>/g, ' target="_blank">'));
					}
				}
				startPos = endPos; //de startpositie wordt opgehoogd om naar verdere <a> tags te zoeken
			}
		}
		/*** end addition ***/

		antwoord = unescape(antwoord);
		// PP: Aanpassen href's zodat gegevens worden onthouden tussen heleen's.
		HrefAdj = new ET_HrefAdjuster(antwoord);
		for (var i = 0; i < HrefAdj.Hrefs.length; i++)
		{
			if (HrefAdj.Hrefs[i].Target != '_blank')
			{
				HrefAdj.Hrefs[i].AddOnClick('aise.setReloadFromStorage();');
			}
		}
		antwoord = HrefAdj.GetAdjustedText();
		this.lastReceived_antwoord = antwoord;

		this.lastReceived_recnr = recnr;
		this.lastReceived_html = html;
		this.lastReceived_category = category;
		this.lastReceived_character = et_character;
		this.lastQuestion = RemoveXSS(document.getElementById('et_question').value);

		//character aanpassingen
		//   LET OP: background-image in stylesheet uitzetten want moet in code
		if (typeof (et_character) == "string")
		{
			if (et_character == "")
			{
				document.getElementById('heleenimage').src = basicurl + "/img/heleen_kl.jpg";
			} else
			{
				document.getElementById('heleenimage').src = eval("char_" + et_character.toLowerCase() + ".src");
			}
		}

		if (this.toonvraag == true)
		{
			document.getElementById('et_innerResponseDiv').innerHTML = "<strong>" + this.lastQuestion + "</strong><br /><div id='ruimtegesteldevraag'></div>" + antwoord;
		} else
		{
			document.getElementById('et_innerResponseDiv').innerHTML = antwoord;
		}
		if (this.handigeVragen)
		{
			this.verwerkHandigeVragen(hvragen);
		}
		if (html != "")
		{
			if (this.doPagePush)
			{
				if (this.pagepushiframe == true)
				{
					if (document.getElementById("frame"))
					{
						document.getElementById("frame").src = html;
					}
				} else
				{
					document.location.href = html;
				}
			} else
			{
				document.getElementById('et_innerResponseDiv').innerHTML += '<br /><br /><a href=' + html + '>Meer info</a>'
			}
		}
		/* Opmerkingen uitklappen na ontvangen van een antwoord */
		if (custom_welcome_ask == true)
		{
			//this.state = 2; 
		} else
		{
			if (this.testing)
			{
				this.state = 3;
			} else
			{
				this.state = 2;
			}
		}
		this.changeState();
		if (this.state > 1)
		{
			if (this.toonvraag == true)
			{
				document.getElementById('et_question').value = "";
				document.getElementById('et_question').focus();
			} else
			{
				document.getElementById('et_question').focus();
				document.getElementById('et_question').select();
			}
		}
		antwoord = ""; // Leegmaken ivm firefox wait <- Deze controlleerd of antwoord gezet is.
		if (typeof setFooter != 'undefined') { setFooter(); } // code specifiek voor Essent.

		// <HitBox-stats integratie>
		if (custom_welcome_ask == false)
		{
			et_HandleHitBox(et_HitBoxTypes.AskHeleen);
		}
		// </HitBox-stats integratie>
	}
	this.SendOpmerking = function()
	{
		var rsIframe = document.getElementById("RSIFrameOpmerking");
		var beoordeling = document.getElementsByName('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("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('divInvoerOpmerking').style.display = 'none';
		document.getElementById('opmerkingtitel').style.display = 'none';
		this.state = 2;
		this.changeState();
		document.getElementsByName('beoordeling')[0].checked = false;
		document.getElementsByName('beoordeling')[1].checked = false;
		document.getElementsByName('beoordeling')[2].checked = false;
		document.getElementById('invoerOpmerking').value = "";
	}
	this.changeBeoordeling = function(newValue)
	{
		this.beoordeling = newValue;
		if (this.beoordeling == '0')
		{
			document.getElementById('divInvoerOpmerking').style.display = 'none';
			document.getElementById('opmerkingtitel').style.display = 'none';
		} else
		{
			document.getElementById('divInvoerOpmerking').style.display = '';
			document.getElementById('opmerkingtitel').style.display = '';
			if (newValue == 1)
			{
				document.getElementById('opmerkingtitel').innerHTML = 'Voeg hier het antwoord voor deze vraag toe:';
			}
			if (newValue == 2)
			{
				document.getElementById('opmerkingtitel').innerHTML = 'Verduidelijk de fout in het antwoord:';
			}
		}
		if (typeof setFooter != 'undefined') { setFooter(); } // code specifiek voor Essent.
	}
}

/**********************************************************************/
/**********************************************************************/
/*********************** EINDE AISE LIBRARY ***************************/
/**********************************************************************/
/**********************************************************************/

function repositionAfterDrag()
{
	/* Positioneren van alle DIV's en IFRAMES relatief aan de div "status1div" */
	var MainDiv = document.getElementById('status1div');
	if (true==true) {
		if (isIE7()) {
			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) {
		document.getElementById('et_question').focus();
		document.getElementById('et_question').select();
	}
}

/*********************************************************************
 *********************************************************************
 *********************************************************************
 **********************************************************************/
//var basicurl		= et_loc + "://192.168.1.97/";
var serverPath = et_loc + "://projecten.elitech.nl";
var basicurl = serverPath + "/essent2/JS";

var aise = new elitechAise();
aise.projectID       = 22;   /* AISE projectID in de database*/
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] = "FAQ";
aise.defaultvraag[1] = "FAQ";
aise.handigeVragen   = false;  	   /* Maak gebruik van handige vragen */
aise.state           = 1;     	   /* 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 + "/heleen_190px" + ((et_loc=='https')?'_ssl':'') + ".css";
aise.iframe_ssl_page = basicurl + "/iframe_content.htm";
aise.opmerkingUrl    = serverPath + "/receiveopmerkingen.aspx";
aise.loadingHTML 	 = "<div id='et_preloadposition'><img src='http://projecten.elitech.nl/essent2/js/img/ajax-loader.gif' border='0' /></div>"; 	     
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;
aise.StandaardTekst  = "Vraag het Heleen";
// !! 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:190px;">';
aise.frame1 += '	<div id="et_bgcolorh">';
aise.frame1 += '		<div id="et_heleen"><img id="heleenimage" src="' + basicurl + '/img/heleen_kl.jpg" border="0" alt="Virtuele medewerkster Heleen" /></div>';
aise.frame1 += '		<div id="et_bgwhite"></div>';
aise.frame1 += '	</div>';
aise.frame1 += '	<div id="et_vraagbox"><div id="et_input"><input type="text" id="et_question" name="et_question" size="40" value="'  + aise.StandaardTekst + '" onClick="javascript:doTextClick();" class="tekstinput" onKeyPress="return checkEnter(event)" /></div><div id="et_stelvraag"><a href="javascript:void(0);" onClick="javascript:aise.sendQuestion();return false;"><img src="' + basicurl + '/img/stelvraagpijl.gif" border="0" alt="Vraag het Heleen" class="et_img" /></a></div></div>';
aise.frame1 += '	<div id="et_antw" style="display:block;visibility:visible;">';
aise.frame1 += '		<div id="et_aiseResponseDiv">';
aise.frame1 += '			<div id="et_outerResponseDiv">';
aise.frame1 += '				<div id="et_innerResponseDiv">';
aise.frame1 += '				</div>';
aise.frame1 += '			</div>';
aise.frame1 += '		</div>';
aise.frame1 += '	    <div id="et_meervinden"><a href="javascript:et_getMoreInfo()" title="Meer vinden" class="et_meervinden">meer vinden ></a></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:364px;left:781px;width:275px;height:200;display:none;">';
aise.frame3 += '	<div class="beoordeling">Geef hier per vraag aan wat u van het antwoord van Heleen vindt: <br /><br />';
aise.frame3 += '		<input type="radio" name="beoordeling" id="beoordelingGoed" value="Goed" onClick="aise.changeBeoordeling(0);aise.SendOpmerking();" />De vraag is goed beantwoord.<br />';
aise.frame3 += '		<input type="radio" name="beoordeling" id="beoordelingVerkeerdHerkend" value="Verkeerd herkend" onClick="aise.changeBeoordeling(1)" />De vraag wordt niet goed herkend.<br />';
aise.frame3 += '		<input type="radio" name="beoordeling" id="beoordelingFout" value="Fout" onClick="aise.changeBeoordeling(2)" />Het antwoord is inhoudelijk niet goed.<br /><br />';
aise.frame3 += '		<div id="divInvoerOpmerking" style="display:none;">';
aise.frame3 += '				<div id="opmerkingtitel"></div>';
aise.frame3 += '				<textarea id="invoerOpmerking" name="invoer" cols="20" rows="4" value=""></textarea><br /><br />';
aise.frame3 += '				<button class="heleenbutton" 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 isIE() {
  return navigator.userAgent.indexOf("MSIE") > -1;
}
function isIE55() {
  return navigator.userAgent.indexOf("MSIE 5.5") > -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 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 */
	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;
}

//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/heleen_kl.jpg";
char_onzekerheid      = new Image(); char_onzekerheid.src = basicurl + "/img/heleen_kl_onzekerheid.jpg";
//char_onzekerheidmet   = new Image(); char_onzekerheidmet.src = basicurl + "/img/heleen_kl_onzekerheidmet.jpg";
char_zekerheid        = new Image(); char_zekerheid.src = basicurl + "/img/heleen_kl_zekerheid.jpg";
//char_zekerheidmet     = new Image(); char_zekerheidmet.src = basicurl + "/img/heleen_kl_zekerheidmet.jpg";
char_nietwenselijk    = new Image(); char_nietwenselijk.src = basicurl + "/img/heleen_kl_nietwenselijk.jpg";
//char_nietwenselijkmet = new Image(); char_nietwenselijkmet.src = basicurl + "/img/heleen_kl_nietwenselijkmet.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_getMoreInfo()
{
	var q = aise.lastQuestion.replace(/\ /g, "+");
	//window.location = "http://wwwacc.essent.local/content/backlinks/heleen/searchresult.jsp?allterms=" + escape(q);
	window.location = "/content/backlinks/heleen/searchresult.jsp?allterms=" + escape(q);
}
function doTextClick() {
	if (document.getElementById('et_question').value == aise.StandaardTekst) {
		document.getElementById('et_question').value = "";
		document.getElementById('et_question').focus();
	}
}
function ET_HrefAdjuster(text) {
	// 
	// Variables ====================================================================================================
	//
	this.OriginalText = text;                                                   // Text with full href's
	this.NormalizedText = "";                                                   // Text where href's are replaced by placeholders
	this.Hrefs = [];                                                            // Collection of all href's in the original text
	//
	// Public Functions =============================================================================================
	//
	this.GetAdjustedText = function() {
		for(var i=0; i<this.Hrefs.length; i++) {
			this.NormalizedText = this.NormalizedText.replace('[H' + i + ']',this.Hrefs[i].GetAdjustedHref());
		}
		return this.NormalizedText;
	};
	//
	// Private Functions ============================================================================================
	//
	this._addHref = function(/* ET_Href-object */ oHref ) {                     // add href-object to hrefs-array
		this.Hrefs[this.Hrefs.length] = oHref;
	};
	//
	// Constructor ==================================================================================================
	//
	this._constructor = function(o) {                                           // processes the whole text so this object can work with it
		var _txt = o.OriginalText;
		var _href = '';
		var _y = 0;                                                             // start of next <a>
		var _z = 0;                                                             // end of next </a>
		var _i = 0;                                                             // counter for numbering href's
		_y = _txt.indexOf('<a',_y);                                             // start of first <a>
		_z = _txt.indexOf('</a>',_y) + 4;                                       // end of first </a>
		while (_y > -1) {
			_href = _txt.substring(_y,_z);                                      // extract href
			o._addHref(new ET_Href(_href));                                     // add href object to array
			_txt = _txt.substring(0,_y) + '[H' + _i + ']' + _txt.substring(_z); // replace href with placeholder in original text
			_y = _txt.indexOf('<a',_y+2);                                       // new base (after previous </a>
			_y = _txt.indexOf('<a',_y);                                         // start of next <a>
			_z = _txt.indexOf('</a>',_y) + 4;                                   // end of next </a> 
			_i++;
		}
		o.NormalizedText = _txt;
	}(this);
};
function ET_Href(text) {
	//
	// Variables ====================================================================================================
	//
	this.OriginalFullHref = text;
	this.VisualText = "";
	this.Href = "";
	this.isHrefPresent = false;
	this.Target = "";
	this.isTargetPresent = false;
	this.OnClick = "";
	this.isOnClickPresent = false;
	this.isOnClickReturnFalsePresent = false;
	//
	// Public Functions =============================================================================================
	//
	this.GetAdjustedHref = function() {
		var _txt = "<a ";
		if (this.isHrefPresent) { 
			_txt += "href='" + this.Href + "' ";
		}
		if (this.isTargetPresent) {
			_txt += "target='" + this.Target + "' ";
		}
		if (this.isOnClickPresent) {
			_txt += "onclick='" + this.OnClick + (this.isOnClickReturnFalsePresent?"return false;":"") + "' ";
		}
		_txt += ">" + this.VisualText + "</a>";
		return _txt;
	};
	this.AddOnClick = function(code) {
		if (code.substring(0,11) == 'javascript:') { 
			code = code.substring(12); 
		};
		if (code.substring(0,12) == 'return false') {
			this.isOnClickReturnFalsePresent = true;
		} else {
			if (this.isOnClickPresent) {
				this.OnClick += code;
			} else {
				this.isOnClickPresent = true;
				this.OnClick = 'javascript:' + code;
			}
		}
	};
	//
	// Constructor ==================================================================================================
	//
	this._constructor = function(o) {                                           // processes the href-text so this object can work with it
		var _txt = o.OriginalFullHref; 
		_txt = _txt.replace(' = ','=');                                         // clean up the string
		_txt = _txt.replace(/\<\/a\>/gi,'');                                    // strip the </a>
		var _txt_search = _txt.toLowerCase();                                   // copy it into a search-string because indexOf doesn't support case-insensitivity.
		var _href = '';
		var _onclick = '';
		var _y = 0;
		var _z = 0;
		// VisualText ===================================================================================================
		o.VisualText = _txt.substring(_txt.indexOf('>')+1);                     // from > to the end is VisualText
		// Href =========================================================================================================
		_y = _txt_search.indexOf('href');                                       // begin href
		if (_y > -1) { o.isHrefPresent = true; }                                  // set boolean
		_href = _txt.substring( _y + _txt.substring(_y).indexOf("'") + 1  );    // set _href-start-text
		_z = _href.indexOf("'");                                                // check for next quote
		_href = _href.substring(0,_z);                                          // cut off href at next quote
		o.Href = _href;
		// Target =======================================================================================================
		_y = _txt_search.indexOf('target');                                     // begin href
		if (_y > -1) { o.isTargetPresent = true; }                                // set boolean
		_target = _txt.substring( _y + _txt.substring(_y).indexOf("'") + 1  );  // set _href-start-text
		_z = _target.indexOf("'");                                              // check for next quote
		_target = _target.substring(0,_z);                                      // cut off href at next quote
		o.Target = _target;
		// OnClick ======================================================================================================
		_y = _txt_search.indexOf('onclick');                                    // begin href
		if (_y > -1) { o.isOnClickPresent = true; }                               // set boolean
		_onclick = _txt.substring( _y + _txt.substring(_y).indexOf("'") + 1  ); // set _href-start-text
		_z = _onclick.indexOf("'");                                             // check for next quote
		_onclick = _onclick.substring(0,_z);                                    // cut off href at next quote
		if (_onclick.indexOf('return false')>-1) {                              // controleren op return false
			o.isOnClickReturnFalsePresent = true;                               // set boolean
			_onclick = _onclick.substring(0,_onclick.indexOf("return false"));  // strip return false
		};	
		o.OnClick = _onclick;
	}(this);
}
// ==========================================================================================================================================

var isCSS, isW3C, isIE4, isNN4, isIE6CSS;
function initDHTMLAPI() {
    if (document.images) {
        isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isIE4 = (isCSS && document.all) ? true : false;
        isNN4 = (document.layers) ? true : false;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
    }
}
function getObject(obj) { var theObj = getRawObject(obj); if (theObj && isCSS) { theObj = theObj.style; } return theObj; }
function setZIndex(obj, zOrder) { var theObj = getObject(obj); if (theObj) { theObj.zIndex = zOrder; } }
function setBGColor(obj, color) { var theObj = getObject(obj); if (theObj) { if (isNN4) { theObj.bgColor = color; } else if (isCSS) { theObj.backgroundColor = color; } } }
function show(obj) { var theObj = getObject(obj); if (theObj) { theObj.visibility = "visible"; } }
function hide(obj) { var theObj = getObject(obj); if (theObj) { theObj.visibility = "hidden"; } }

function seekLayer(doc, name) {
    var theObj;
    for (var i = 0; i < doc.layers.length; i++) {
        if (doc.layers[i].name == name) { theObj = doc.layers[i]; break; }
        if (doc.layers[i].document.layers.length > 0) { theObj = seekLayer(document.layers[i].document, name); }
    }
    return theObj;
}
function getRawObject(obj) {
    var theObj;
    if (typeof obj == "string") {
        if (isW3C) {        theObj = document.getElementById(obj); } 
		else if (isIE4) { theObj = document.all(obj); } 
		else if (isNN4) { theObj = seekLayer(document, obj); }
    } else { theObj = obj; }
    return theObj;
}
function shiftTo(obj, x, y) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
			var units = (typeof theObj.left == "string") ? "px" : 0 
            theObj.left = x + units;
            theObj.top = y + units;
        } else if (isNN4) {
            theObj.moveTo(x,y)
        }
    }
}
function shiftBy(obj, deltaX, deltaY) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
            var units = (typeof theObj.left == "string") ? "px" : 0 
            theObj.left = getObjectLeft(obj) + deltaX + units;
            theObj.top = getObjectTop(obj) + deltaY + units;
        } else if (isNN4) {
            theObj.moveBy(deltaX, deltaY);
        }
    }
}
function getObjectLeft(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("left");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.left;
    } else if (elem.style) {
        result = elem.style.left;
    } else if (isNN4) {
        result = elem.left;
    }
    return parseInt(result);
}
function getObjectTop(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("top");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.top;
    } else if (elem.style) {
        result = elem.style.top;
    } else if (isNN4) {
        result = elem.top;
    }
    return parseInt(result);
}
function getObjectWidth(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetWidth) {
        result = elem.offsetWidth;
    } else if (elem.clip && elem.clip.width) {
        result = elem.clip.width;
    } else if (elem.style && elem.style.pixelWidth) {
        result = elem.style.pixelWidth;
    }
    return parseInt(result);
}
function getObjectHeight(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetHeight) {
        result = elem.offsetHeight;
    } else if (elem.clip && elem.clip.height) {
        result = elem.clip.height;
    } else if (elem.style && elem.style.pixelHeight) {
        result = elem.style.pixelHeight;
    }
    return parseInt(result);
}
function getInsideWindowWidth() {
    if (window.innerWidth) {
        return window.innerWidth;
    } else if (isIE6CSS) {
        return document.body.parentElement.clientWidth
    } else if (document.body && document.body.clientWidth) {
        return document.body.clientWidth;
    }
    return 0;
}
function getInsideWindowHeight() {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (isIE6CSS) {
        return document.body.parentElement.clientHeight
    } else if (document.body && document.body.clientHeight) {
        return document.body.clientHeight;
    }
    return 0;
}
/***********************
    SCROLLBAR CREATION
************************/
var scrollEngaged = false;
var scrollInterval;
var scrollBars = new Array();
function getElementStyle(elemID, IEStyleAttr, CSSStyleAttr) {
    var elem = document.getElementById(elemID);
    if (elem.currentStyle) { return elem.currentStyle[IEStyleAttr]; } 
	else if (window.getComputedStyle) { var compStyle = window.getComputedStyle(elem, ""); return compStyle.getPropertyValue(CSSStyleAttr); }
    return "";
}
//                ("et_aiseResponseDiv", "et_outerResponseDiv", "et_innerResponseDiv")
function scrollBar(rootID, ownerID, ownerContentID) {
    this.rootID = rootID;
    this.ownerID = ownerID;
    this.ownerContentID = ownerContentID;
    this.index = scrollBars.length;
    this.rootElem = document.getElementById(rootID);
    this.ownerElem = document.getElementById(ownerID);
    this.contentElem = document.getElementById(ownerContentID);
    //this.ownerHeight = parseInt(getElementStyle(ownerID, "height", "height"));
    this.ownerHeight = parseInt(document.getElementById(ownerID).clientHeight);
    this.ownerWidth = parseInt(getElementStyle(ownerID, "width", "width"));
    this.ownerBorder = parseInt(getElementStyle(ownerID, "borderTopWidth", "border-top-width")) * 2;
    this.contentHeight = Math.abs(parseInt(this.contentElem.style.top));
    this.contentWidth = this.contentElem.offsetWidth;
    this.contentFontSize = parseInt(getElementStyle(this.ownerContentID, "fontSize", "font-size"));
    this.contentScrollHeight = this.contentElem.scrollHeight;
    // create quirks object whose default (CSS-compatible) values are zero; pertinent values for quirks mode filled in later  
    this.quirks = {on:false, ownerBorder:0, scrollBorder:0, contentPadding:0};
    if (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Win") != -1 && (typeof document.compatMode == "undefined" || document.compatMode == "BackCompat")) {
        //this.quirks.on = true;
        //this.quirks.ownerBorder = this.ownerBorder;
        //this.quirks.contentPadding = parseInt(getElementStyle(ownerContentID, "padding", "padding"));
	}
    this.scrollWrapper = null;
    this.upButton = null;
    this.dnButton = null;
    this.thumb = null;
    this.buttonLength = 0;
    this.thumbLength = 0;
    this.scrollWrapperLength = 0
    this.dragZone = {left:0, top:0, right:0, bottom:0 }
    this.appendScroll = appendScrollBar;
	this.removeScroll = removeScrollBar;
}
function removeScrollBar() {
	document.getElementById('thumb' + (scrollBars.length - 1)).removeChild(document.getElementById('slidetop' + (scrollBars.length - 1)));
	document.getElementById('thumb' + (scrollBars.length - 1)).removeChild(document.getElementById('slidebtm' + (scrollBars.length - 1)));
	document.getElementById('scrollWrapper' + (scrollBars.length - 1)).removeChild(document.getElementById('thumb' + (scrollBars.length - 1)));
	document.getElementById('scrollWrapper' + (scrollBars.length - 1)).removeChild(document.getElementById('linedown' + (scrollBars.length - 1)));
	document.getElementById('scrollWrapper' + (scrollBars.length - 1)).removeChild(document.getElementById('lineup' + (scrollBars.length - 1)));
	this.rootElem.removeChild(document.getElementById('scrollWrapper' + (scrollBars.length - 1)));
}
function appendScrollBar() {
    var imgH = 13;
    var imgW = 7;
    var thumbH = 0;
	thumbH = this.ownerHeight + (this.ownerBorder - 0) - (this.quirks.scrollBorder * 2) - (imgH * 2);
	thumbH = (document.getElementById('et_outerResponseDiv').clientHeight / document.getElementById('et_innerResponseDiv').clientHeight) * thumbH;
	if (thumbH < 15) { thumbH = 15; }

    // "up" arrow, needed first to help size scrollWrapper
    var lineup = document.createElement("img");
    lineup.id = "lineup" + (scrollBars.length - 1);
    lineup.className = "lineup";
    lineup.index = this.index;
    lineup.src = "" + basicurl + "/img/scroll_top.gif";
    lineup.height = imgH;
    lineup.width = imgW;
    lineup.alt = "Scroll Up";
	lineup.style.backgroundImage = "url('" + basicurl + "/img/scroll_top.gif')";
	lineup.style.backgroundRepeat = "no-repeat";
    lineup.style.position = "absolute";
    lineup.style.top = "0px";
    lineup.style.left = "0px";

    // scrollWrapper defines "page" region color and 3-D borders
    var wrapper = document.createElement("div");
    wrapper.id = "scrollWrapper" + (scrollBars.length - 1);
    wrapper.className = "scrollWrapper";
    wrapper.index = this.index;
    wrapper.style.position = "absolute";
    wrapper.style.visibility = "hidden";
    wrapper.style.top = "0px";
	wrapper.style.left = this.ownerWidth + this.ownerBorder - this.quirks.ownerBorder + "px";
    wrapper.style.borderTop = "0px solid #000000";
    wrapper.style.borderLeft = "0px solid #000000";
    wrapper.style.borderRight= "0px solid #000000";
    wrapper.style.borderBottom= "0px solid #000000";
    wrapper.style.backgroundColor = "#E6E7E9";
    if (this.quirks.on) { this.quirks.scrollBorder = 2; }
    wrapper.style.width = lineup.width + (this.quirks.scrollBorder * 2) + "px";
    wrapper.style.height = this.ownerHeight + (this.ownerBorder - 0) - (this.quirks.scrollBorder * 2) + "px";

    // "down" arrow
    var linedn = document.createElement("img");
    linedn.id = "linedown" + (scrollBars.length - 1);
    linedn.className = "linedown";
    linedn.index = this.index;
    linedn.src = "" + basicurl + "/img/scroll_btm.gif";
    linedn.height = imgH;
    linedn.width = imgW;
    linedn.alt = "Scroll Down";
    linedn.style.position = "absolute";
    linedn.style.top = parseInt(this.ownerHeight) + (this.ownerBorder - 0) - (this.quirks.ownerBorder) - linedn.height + "px";
    linedn.style.left = "0px";

    // fixed-size draggable thumb 
    var thumb = document.createElement("div");
    thumb.id = "thumb" + (scrollBars.length - 1);
    thumb.index = this.index;
    thumb.src = "" + basicurl + "/img/slider_middle.gif";
    thumb.height = thumbH;
    thumb.width = imgW;
    thumb.alt = "Scroll Dragger";
	thumb.style.backgroundImage = "url('" + basicurl + "/img/slider_middle.gif')";
	thumb.style.backgroundRepeat = "repeat-y";
	thumb.style.borderTop = "0px solid #000000"
	thumb.style.borderBottom = "0px solid #000000"
	thumb.style.borderLeft = "0px solid #000000"
	thumb.style.borderRight = "0px solid #000000"
	thumb.style.position = "absolute";
    thumb.style.top = lineup.height + "px";
    thumb.style.width = imgW + "px";
    thumb.style.height = thumbH + "px";
    thumb.style.left = "0px";

    // "top" slider image
    var thumbtop = document.createElement("img");
    thumbtop.id = "slidetop" + (scrollBars.length - 1);
    thumbtop.index = this.index;
    thumbtop.src = "" + basicurl + "/img/slider_top.gif";
    thumbtop.height = 4;
    thumbtop.width = 7;
    thumbtop.alt = "Scroll Dragger";
    thumbtop.style.position = "absolute";
    thumbtop.style.top = "0px";
    thumbtop.style.left = "0px";

    // "bottom" slider image
    var thumbbtm = document.createElement("img");
    thumbbtm.id = "slidebtm" + (scrollBars.length - 1);
    thumbbtm.index = this.index;
    thumbbtm.src = "" + basicurl + "/img/slider_btm.gif";
    thumbbtm.height = 4;
    thumbbtm.width = 7;
    thumbbtm.alt = "Scroll Dragger";
    thumbbtm.style.position = "absolute";
    thumbbtm.style.bottom = "0px";
    thumbbtm.style.left = "0px";

    // fill in scrollBar object properties from rendered elements
	thumb.appendChild(thumbtop);
	thumb.appendChild(thumbbtm);
    this.upButton = wrapper.appendChild(lineup);
    this.thumb = wrapper.appendChild(thumb);
    this.dnButton = wrapper.appendChild(linedn);
    this.scrollWrapper = this.rootElem.appendChild(wrapper);
    this.buttonLength = imgH;
    this.thumbLength = thumbH;
    this.scrollWrapperLength = parseInt(getElementStyle(this.scrollWrapper.id, "height", "height"));
    this.dragZone.left = 0;
    this.dragZone.top = this.buttonLength;
    this.dragZone.right = imgW;
    this.dragZone.bottom = this.scrollWrapperLength - this.buttonLength - (this.quirks.scrollBorder * 2)
    // all events processed by scrollWrapper element
    this.scrollWrapper.onmousedown = handleScrollClick;
    this.scrollWrapper.onmouseup = handleScrollStop;
    this.scrollWrapper.oncontextmenu = blockEvent;
    this.scrollWrapper.ondrag = blockEvent;
    // OK to show
    this.scrollWrapper.style.visibility = "visible";
}

/***************************
    EVENT HANDLER FUNCTIONS
****************************/
// onmouse up handler
function handleScrollStop() { scrollEngaged = false; }
// Prevent Mac context menu while holding down mouse button
function blockEvent(evt) { evt = (evt) ? evt : event; evt.cancelBubble = true; return false; }
// click event handler
function handleScrollClick(evt) {
    var fontSize, contentHeight;
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    target = (target.nodeType == 3) ? target.parentNode : target;
    var index = target.index;
    fontSize = scrollBars[index].contentFontSize;
    switch (target.className) {
        case "lineup" :
            scrollEngaged = true;
            scrollBy(index, parseInt(fontSize));
            scrollInterval = setInterval("scrollBy(" + index + ", " + parseInt(fontSize) + ")", 100);
            evt.cancelBubble = true;
            return false;
            break;
        case "linedown" :
            scrollEngaged = true;
            scrollBy(index, -(parseInt(fontSize)));
            scrollInterval = setInterval("scrollBy(" + index + ", -" + parseInt(fontSize) + ")", 100);
            evt.cancelBubble = true;
            return false;
            break;
        case "scrollWrapper" :
            scrollEngaged = true;
            var evtY = (evt.offsetY) ? evt.offsetY : ((evt.layerY) ? evt.layerY : -1);
            if (evtY >= 0) {
                var pageSize = scrollBars[index].ownerHeight - fontSize;
                var thumbElemStyle = scrollBars[index].thumb.style;
                // set value negative to push document upward
                if (evtY > (parseInt(thumbElemStyle.top) + scrollBars[index].thumbLength)) { pageSize = -pageSize; }
                scrollBy(index, pageSize);
                scrollInterval = setInterval("scrollBy(" + index + ", " + pageSize + ")", 100);
                evt.cancelBubble = true;
                return false;
            }
    }
    return false;
}
// Activate scroll of inner content
function scrollBy(index, px) {
    var scroller = scrollBars[index];
    var elem = document.getElementById(scroller.ownerContentID);
    var top = parseInt(elem.style.top);
    var scrollHeight = parseInt(elem.scrollHeight);
    var height = scroller.ownerHeight;
    if (scrollEngaged && top + px >= -scrollHeight + height && top + px <= 0) { shiftBy(elem, 0, px); updateThumb(index); } 
	else if (top + px < -scrollHeight + height) { shiftTo(elem, 0, -scrollHeight + height - scroller.quirks.contentPadding); updateThumb(index); clearInterval(scrollInterval); } 
	else if (top + px > 0) { shiftTo(elem, 0, 0); updateThumb(index); clearInterval(scrollInterval); } 
	else { clearInterval(scrollInterval); }
}
/**********************
    SCROLLBAR TRACKING
***********************/
// Position thumb after scrolling by arrow/page region
function updateThumb(index) {
    var scroll = scrollBars[index];
    var barLength = scroll.scrollWrapperLength - (scroll.quirks.scrollBorder * 2);
    var buttonLength = scroll.buttonLength;
    barLength -= buttonLength * 2;
    var docElem = scroll.contentElem;
    var docTop = Math.abs(parseInt(docElem.style.top));
    var scrollFactor = docTop/(scroll.contentScrollHeight - scroll.ownerHeight);
    shiftTo(scroll.thumb, 0, Math.round((barLength - scroll.thumbLength) * scrollFactor) + buttonLength);
}
// Position content per thumb location
function updateScroll() {
    var index = selectedObj.index;
    var scroller = scrollBars[index];
    var barLength = scroller.scrollWrapperLength - (scroller.quirks.scrollBorder * 2);
    var buttonLength = scroller.buttonLength;
    var thumbLength = scroller.thumbLength;
    var wellTop = buttonLength;
    var wellBottom = barLength - buttonLength - thumbLength;
    var wellSize = wellBottom - wellTop;
    var thumbTop = parseInt(getElementStyle(scroller.thumb.id, "top", "top"));
    var scrollFactor = (thumbTop - buttonLength)/wellSize;
    var docElem = scroller.contentElem;
    var docTop = Math.abs(parseInt(docElem.style.top));
    var scrollHeight = scroller.contentScrollHeight;
    var height = scroller.ownerHeight;   
    shiftTo(scroller.ownerContentID, 0, -(Math.round((scrollHeight - height) * scrollFactor)));
}
/*******************
   ELEMENT DRAGGING
********************/
var selectedObj, offsetX, offsetY;
var zone = {left:0, top:16, right:16, bottom:88};

function setSelectedElem(evt) {
    var target = (evt.target) ? evt.target : evt.srcElement;
    target = (target.nodeType && target.nodeType == 3) ? target.parentNode : target;
    var divID = (target.id.indexOf("thumb") != -1) ? target.id : "";
    if (divID) {
        if (document.layers) { selectedObj = document.layers[divID]; } 
		else if (document.all) { selectedObj = document.all(divID); } 
		else if (document.getElementById) { selectedObj = document.getElementById(divID); }
        setZIndex(selectedObj, 100);
        return;
    }
    selectedObj = null;
    return;
}
// Drag thumb only within scrollbar region
function dragIt(evt) {
    evt = (evt) ? evt : event;
    var x, y, width, height;
    if (selectedObj) {
        if (evt.pageX) { x = evt.pageX - offsetX; y = evt.pageY - offsetY; } 
		else if (evt.clientX || evt.clientY) { x = evt.clientX - offsetX; y = evt.clientY - offsetY; }
        var index = selectedObj.index;
        var scroller = scrollBars[index];
        var zone = scroller.dragZone;
        width = scroller.thumb.width;
        height = scroller.thumb.height;
        x = (x < zone.left) ? zone.left : ((x + width > zone.right) ? zone.right - width : x);
        y = (y < zone.top) ? zone.top : ((y + height > zone.bottom) ? zone.bottom - height : y);
        shiftTo(selectedObj, x, y);
        updateScroll();
        evt.cancelBubble = true;
        return false;
    }
}
// Turn selected element on and set cursor offsets
function engage(evt) {
    evt = (evt) ? evt : event;
    setSelectedElem(evt);
    if (selectedObj) {
        if (document.body && document.body.setCapture) { document.body.setCapture(); }
        if (evt.pageX) {
            offsetX = evt.pageX - ((typeof selectedObj.offsetLeft != "undefined") ? selectedObj.offsetLeft : selectedObj.left);
            offsetY = evt.pageY - ((selectedObj.offsetTop) ? selectedObj.offsetTop : selectedObj.top);
        } else if (typeof evt.clientX != "undefined") {
            offsetX = evt.clientX - ((selectedObj.offsetLeft) ? selectedObj.offsetLeft : 0);
            offsetY = evt.clientY - ((selectedObj.offsetTop) ? selectedObj.offsetTop : 0);
        }
        return false;
    }
}
// Turn selected element off
function release(evt) {
    if (selectedObj) {
        setZIndex(selectedObj, 0);
        if (document.body && document.body.releaseCapture) { document.body.releaseCapture(); }
        selectedObj = null;
    }
}
// Assign event handlers used by both Navigator and IE
function initDrag() {
    if (document.layers) { document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP); return; } 
	else if (document.body & document.body.addEventListener) {
		document.addEventListener("mousedown", engage, true);
		document.addEventListener("mousemove", dragIt, true);
		document.addEventListener("mouseup", release, true);
		return;
    }
	document.onmousedown = engage;
	document.onmousemove = dragIt;
	document.onmouseup = release;
    return;
}
function initScrollbars() {
	if (document.getElementById('et_innerResponseDiv').clientHeight > document.getElementById('et_outerResponseDiv').clientHeight) {
		scrollBars[0] = new scrollBar("et_aiseResponseDiv", "et_outerResponseDiv", "et_innerResponseDiv");
		scrollBars[0].appendScroll();
	}
}
function setScrollbars() {
	initDrag();
	initScrollbars();
}
function removeScrollbars() {
	//try {
		if (scrollBars.length > 0) {
			scrollBars[0].removeScroll();
		}
		scrollBars = [];
	//} 
	//catch (e) {}
}
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;
}
// <HitBox Integratie> ===========================================================================================
et_HitBoxTypes = 
{
	AskHeleen: 1,
	AskFaq: 2
}
function et_HandleHitBox(/* et_HitBoxTypes */ hbtype, /*string*/ faq)
{
	try
	{
		if (hbtype == et_HitBoxTypes.AskHeleen)
		{// er wordt een vraag aan heleen gesteld
			var res = (isNaN(Number(aise.lastReceived_recnr)) ? Number("0") : Number(aise.lastReceived_recnr));
			_hbSet("n", "resultaat");
			_hbSet("search.keywords", et_HandleHitBox_StripIllegalChars(aise.lastQuestion));  
			_hbSet("search.attr1", "kleine heleen");  
			if (res > 0) 
			{// resultaat ja ('1')...
				_hbSet("search.results", "1");
			}
			else
			{// ...of nee ('0')
				_hbSet("search.results", "0");
			}
			_hbSend();
		}
		if (hbtype == et_HitBoxTypes.AskFaq)
		{// er wordt een faq opgevraagd
			_hbPageView(et_HandleHitBox_StripIllegalChars(faq),"/essent/consument/heleen/faq");
		}
	}
	catch(e)
	{
	}
}
function et_HandleHitBox_StripIllegalChars(txt)
{
	txt = txt.replace(/[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\(\)\+\,\-\.\=\?\@\[\]\_\`\{\}\ ]/g,'');
	return txt;
}
function et_HandleHitBox_MakeNameString(id,txt)
{
	return (id + '_' + txt).substring(0,50);
}
// </HitBox Integratie> ==========================================================================================
