// Vasco js-Functies
//
var cancelevents = false;
var tmid = 00000000;
function BrowserInfo()  
{
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function breadCrumbs(base,delStr,defp,cStyle,tStyle,dStyle,nl,taal) { // by Paul Davis - http://www.kaosweaver.com
//alert(window.location.toString());
  loc=window.location.toString();
  if ( loc.indexOf("file:") == 0 ) {
	  	return;
  }
  taalflag = loc.indexOf(base +"/" + taal);
  //alert(taalflag);
  if ( taalflag != -1 ) {
		base = base + "/" + taal;  
  }
  //alert(base);
  subs=loc.substr(loc.indexOf(base)+base.length+1).split("/");
  document.write('<a href="'+getLoc(subs.length-1)+defp+'" class="'+cStyle+'">Home</a>  '+'<span class="'+dStyle+'">'+delStr+'</span> ');
  a=(loc.indexOf(defp)==-1)?1:2;for (i=0;i<(subs.length-a);i++) { subs[i]=makeCaps(unescape(subs[i]));
  document.write('<a href="'+getLoc(subs.length-i-2)+defp+'" class="'+cStyle+'">'+subs[i]+'</a>  '+'<span class="'+dStyle+'">'+delStr+'</span> ');}
  if (nl==1) document.write("<br>");document.write('<span class="'+tStyle+'">'+document.title+'</span>');
}
function makeCaps(a) {
  g=a.split(' ');for (l=0;l<g.length;l++) g[l]=g[l].toUpperCase().slice(0,1)+g[l].slice(1);
  return g.join(" ");
} 
function getLoc(c) {
  var d="";if (c>0) for (k=0;k<c;k++) d=d+"../"; return d;
}
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else 
		if (b=="Microsoft Internet Explorer") this.b = "ie"
		else 
			this.b = b
			this.version = navigator.appVersion
			this.v = parseInt(this.version)
			this.ns = (this.b=="ns" && this.v>=4)
			this.ns4 = (this.b=="ns" && this.v==4)
			this.ns5 = (this.b=="ns" && this.v==5)
			this.ie = (this.b=="ie" && this.v>=4)
			this.ie4 = (this.version.indexOf('MSIE 4')>0)
			this.ie5 = (this.version.indexOf('MSIE 5')>0)
			this.min = (this.ns||this.ie)
}
function setBodyHeight(prod,hd){
	var hh = document.body.clientHeight;
	var ww = document.body.clientWidth;
	
	if(!prod) prod=0;
	if(!hd) hd=0;
	
	if(screen.width<=800){
		document.getElementById('body').style.height = hh - 56;
		document.getElementById('body2').style.height = hh - 158;
		document.getElementById('body3').style.height = hh - 158;
	}
	else if(prod==1){
		if(hd==1){
			document.getElementById('body').style.height = hh - 176;
			document.getElementById('body2').style.height = hh - 158;
			document.getElementById('body3').style.height = hh - 158;
		}
		else{
			document.getElementById('body').style.height = hh - 56;
			document.getElementById('body2').style.height = hh - 158;
			document.getElementById('body3').style.height = hh - 158;
		}
	}
	else{
		document.getElementById('body').style.height = hh - 176;
		document.getElementById('body2').style.height = hh - 158;
		document.getElementById('body3').style.height = hh - 158;
	}
	window.onresize = setBodyHeight;
}

String.prototype.trim = function() {
 // skip leading and trailing whitespace
 // and return everything in between
  var x=this;
  var nbsp = String.fromCharCode(160);  // #!$é#@ !!!!! &NBSP; is ascii 160 !!!!! 
  var re1 = new RegExp("/^" + nbsp + "*(.*)/","");
  var re2 = new RegExp("/(.*)" + nbsp + "*$/","");
  // Unknown Quantifier error in ie5 var re2 = new RegExp("/(.*?)" + nbsp + "*$/","");
  var re3 = new RegExp("/^\s*(.*)/");
  var re4 = new RegExp("/(.*)\s*$/");
  // Unkown Quantifier error in ie5  var re4 = new RegExp("/(.*?)\s*$/");
 
  x=x.replace(re1, "$1");
  x=x.replace(re2, "$1");
  x=x.replace(re3, "$1");
  x=x.replace(re4, "$1");
  return x;
}


// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}
// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}

function resizewindow(prod, hd) {
  var a = new BrowserInfo;
  
  if(!prod) prod=0;
  if(!hd) hd=0;
  
  if (a.screenWidth <= 800) {
		//alert('Moving');
		document.getElementById('top1').style.display='none';
		document.getElementById('body3').style.display='none';
		document.getElementById('top3').style.display='none';
		tmt_DivMove('nav',0,0);
		tmt_DivMove('top2', 620, 38);
		tmt_DivMove('body', 0, 38)
		tmt_DivMove('ppath', 0, 38)
		tmt_DivMove('body2', 620, 38 + 120);	
  } 
  else if (prod == 1) {
		var ww = document.body.clientWidth;
		
		if(hd==0){
			document.getElementById('top1').style.display='none';
			document.getElementById('top3').style.display='none';
		}
		else{
	  		document.getElementById('top1').style.display='';
	  		//document.getElementById('top1').style.width=(ww - 169) + 'px';
		}
		//document.getElementById('body3').style.display='none';
		
		if(hd==0){
			tmt_DivMove('nav',0,0);
			tmt_DivMove('body', 0, 38);
			tmt_DivMove('ppath', 0, 38);
			tmt_DivMove('top2', 690 , 38);
			tmt_DivMove('top3', 850 , 38);
			//tmt_DivMove('body2', ww-169, 38 + 120);  
		}			
		else{
			//tmt_DivMove('top2', ww-169, 0);
			//tmt_DivMove('body2', ww-169, 120 + 38);  
		}
		//resizeLayer('nav',ww-9,32);
		//resizeLayer('body',ww-169,800);
		resizeLayer('nav',995,32);
		resizeLayer('body',690, 800);
		document.getElementById('top3').style.display='';
  }
  else{
  		document.getElementById('top1').style.display='';
  		document.getElementById('top3').style.display='';
		// In Mozilla en Netscape kan de breedte van een Layer 
		// Niet dynamisch breder gemaakt worden.
		// Daarom heeft de body layer initieel de kleinste lengte
		// en wordt deze breder gemaakt bij een hogere resolutie.
		// Dit voorkomt dat de body layer overlapt met de body2 layer
		// Nadeel is wel dat er bij Netscape en Mozilla in hoge
		// resolutie een gat ontstaat tussen body en body2
		resizeLayer('nav',995,32);
		resizeLayer('body',690, 800);
  }
  document.getElementById('top2').style.display='';
}
// Verplaats layer naar nieuwe positie
function tmt_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}
function tmt_DivMove(theDiv, l, t){
	var x = (document.layers) ? ".left" : ".style.left";
	var y = (document.layers) ? ".top" : ".style.top";
	var fun = (document.getElementById) ? "tmt_findObj" : "MM_findObj";
	var obj = eval(fun+"(theDiv)");if(obj){
	eval(fun+"('"+theDiv+"')"+y+"="+t);
	eval(fun+"('"+theDiv+"')"+x+"="+l);}
}
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}
function setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = findObj(objName); if (obj) obj.value = newText;
}
// Verplaats layer naar nieuwe positie
function resizeLayer(theLayer,width,height)
{
  var obj;
  if ((findObj(theLayer))!=null)
  {
    if (document.layers)  //NS
    {
      
      obj = document.layers[theLayer];
      obj.width = width;
      obj.height  = height;
    }
    else if (document.all)//IE
    {
      obj = document.all[theLayer].style;
      obj.pixelWidth = width;
      obj.pixelHeigth  = height;
    }
    showHideLayers(theLayer,'','show');
  }
}
// test op internet explorer
function isMSIE () {
	if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null ) {
		return(true);
	} else {
		return(false);
	}
}
function alertIEonly() {
	alert('This function is only available with Microsoft Internet Explorer!');
}
function setHomePage (url) {
  if ( isMSIE() ) {
	if (document.all && document.getElementById)
		oHomePage.setHomePage(url);
	else if (document.layers && navigator.javaEnabled()) {
		netscape.security.PrivilegeManager.enablePrivilege
		('UniversalPreferencesWrite');
		navigator.preference('browser.startup.homepage', url);
	}
  } else {
	alertIEonly();
  }
  return;
}
function AddFavorite(url,sMessage) {
	if ( isMSIE() ) {
		window.external.addFavorite(url, sMessage);
	} else {
		alertIEonly();
	}
	return;
}
// Functie om de huidige pagina te mailen
function mailpagina() {
	var pagina = location.href;
	// Indien site vanaf cd wordt bekeken staat hier file:driveletter:'
	// Dit eruit gooien omdat we naar de life site gaan
	var re = re = new RegExp('file:.*:');
	pagina=pagina.replace(re,'');
	location = "/mailprod.asp?loc="  + escape(pagina);
}
// functie die de waarde van een tekst veld matcht tov
// de mogelijke items in een selectie list
// 
function MatchText2Select(aForm, aVeld, aSelect, bExact, doSubmit) {
// aForm: Form Object
// aVeld: Tekstveld object
// aSelect: Naam <SELECT> veld
// bExact : Exacte match nodig
// doSubmit: Do een submit van de form indien veld overeenkomt
// maxlen:  Optioneel, ieder element wordt getest tot en met maxlen
//          alles wat erna komt is niet getest
// opm: De waarde van het tekstveld hoeft niet volledig ingevuld worden
// om een match te bekomen
// vb               CAR of CARR, ARR of CARRE matchen allemaal CARRE
//
	var i, aOptions, re, waarde, maxlen,stmp;
	
	if  (cancelevents || aVeld.value == '' ) {
			return true;
	}
	
	// Zesde arg
	if ( arguments.length == 6 ) {
		maxlen = arguments[5];
		//alert(maxlen);
	} else {
		maxlen = 0;
	}
	//alert(aForm.elements[aSelect].selectedIndex);
	j = aForm.elements[aSelect].length;
	bGevonden = false;
	re = new RegExp('.*' + aVeld.value + '.*','i');
	aOptions = aForm.elements[aSelect].options;
	for ( i = 0; i<aForm.elements[aSelect].length; i++ ) {
		stmp = aOptions[i].text;
		if ( maxlen > 1 ) {
			stmp =  stmp.substring(0,maxlen - 1);
			stmp = stmp.trim();
		}
		waarde = stmp
		// Probeer eerst een exacte match op het text veld
		if ( aVeld.value == waarde ) {
			//alert('Exact Match');
			bGevonden = true;
			break;		
		}
		waarde = aOptions[i].value;
		// Dan op de waarde
		if ( aVeld.value == waarde ) {
			//alert('Exact Match');
			bGevonden = true;
			break;		
		}
		waarde = stmp;
		// Dan eern re match
		if ( waarde.match(re) && bExact == false ) {
			//alert("Partial Match");
			bGevonden = true;
			break;
		}
	}
	if ( bGevonden ) {
		aForm.elements[aSelect].selectedIndex = i;
		aVeld.value = aOptions[i].text;
		
		if ( doSubmit ) {
			aForm.submit();
			return true;
		}
		return true;
	} else {
		aVeld.value = '';
		return false;
	}
}
// Zet de waarde van een veld op een bepaalde waarde
// aForm: Form object
// veldnaam: naam van het veld
// veldwaarde: waarde
// bSubmit: true: form submitten na actie
// zetveldwaarde(this.form, "testveld", this.value, false);
function zetveldwaarde(aForm, veldnaam, veldwaarde, bSubmit) {
	if ( aForm.elements[veldnaam].type == 'text' ) {
		aForm.elements[veldnaam].value = veldwaarde;
	}
	if ( bSubmit ) {
		aForm.submit();
		return true;
	}
}
// Kijkt of een formveld numeriek is
// Indien niet numeriek wordt de waarde van het veld
// op iDefault gezet
// iMin en Imax: Min en Max bereik
function checknumeric(aField, iDefault, iMin, iMax) {
	if ( isNaN(aField.value) ) {
		aField.value = iDefault;
		aField.focus();
		cancelevents = true;
		return false;
	} else {
		var a = new Number(aField.value);
		if ( a >= iMin && a <= iMax ) {
			aField.value = a;
			return true;
		} else {
			aField.value = iDefault;
			aField.focus();
			cancelevents = true;
			return false;
		}
	}
}
// cfg Functies
// Functies aangeroepen door de productconfigurator
//
// cfgNextItem: 
//    Na toevoegen van artikel in het winkelwagentje beslist deze
//    functie wat verder te doen, adhv het verwerken van een vraagstelling
//    naar de gebruiker
function cfgNextItem(aForm, what) {
	var artnr = aForm.ART.value;
	// Opnieuw een radiator ingeven
	//if ( aForm["TODONEXT"][0].checked ) {
	if ( what == 1) {
		location = 'bottom.asp' ;
		return;
	}
	// Gekoppeld toebehoor
	//if ( aForm["TODONEXT"][1].checked ) {
	if ( what == 2) {
		location = 'bottom.asp?ACC=1&KOP=1';
		return;
	}
	// Los toebehoor
    //if ( aForm["TODONEXT"][2].checked ) {
	if ( what == 3 ) {
		window.open("index.asp?ACC=1", "_top");
		return;
	}
	if ( what == 30 ) {
		window.open("index.asp?ACC=1", "_parent");
		return;
	}
	// Winkelwagentje
	//if ( aForm["TODONEXT"][3].checked ) {
	if ( what == 4 ) {
		//location = 'basket.asp?inframe=1' ;
		window.open("basket.asp", "_top");
		return;
	}
	if ( what == 40 ) {
		//location = 'basket.asp?inframe=1' ;
		window.open("basket.asp", "_parent");
		return;
	}
	// Afhandelen bestelling
	//if ( aForm["TODONEXT"][4].checked ) {
	if ( what == 5 ) {
		window.open("commit.asp", "_top") ;
		return;
	}
	if ( what == 50 ) {
		window.open("commit.asp", "_parent") ;
		return;
	}
	
}
function cfgOpenBottom(aPgu, aAcc) {
	if (aPgu != "-1") {
		window.open('bottom.asp?ACC=' + aAcc + '&AANTAL=1&PGU=' + escape(aPgu),'bottom');
	}
}
function cfgSetToebehoorFromList(aList) {
	if ( aList.options[aList.selectedIndex].value > 0 ) {
		aList.form.ACC.value=1;
		aList.form.RESETBOTTOM.value=1;
		aList.form.ARTNR.value=aList.options[aList.selectedIndex].value;
		aList.form.submit();
	}
}

// test bij ingave gekoppeld toebehoor
// Ingegeven artikel moet matchen met de lijst lstART
// Indien niet zo, vraag stellen of je dit artikel wil gebruiken. De koppeling wordt wel
// verbroken dan.
function cfgChkGekopToeb(aForm, aVeld, aSelect) {
	var sHold;
	var sMsg;
	var bSubmit = false;
	sHold = aVeld.value;
	//alert(sHold);
	if ( sHold == "" ) {
		return false;
	}
	// Artikel komt voor in artikellijst?
	if ( MatchText2Select(aForm, aVeld, aSelect, true, false) ) { 
				aVeld.value = sHold;
				bSubmit = true;
	} else {
		aVeld.value = "";
		var lang = new String(readCookie("lang"))
		lang = lang.toLowerCase();
		switch (lang) {
			case 'dutch':
				sMsg = "Artikel " + sHold + " is geen toebehoor dat past bij " + aForm.KOPRAD.value + "\n";
				sMsg = sMsg + "Wenst U dit artikel toch te gebruiken?\n";
				sMsg = sMsg + "(Dit artikel wordt dan NIET als een toebehoor aan deze radiator gekoppeld)";
				break;
			case 'french':
				sMsg = "Article  " + sHold + " n’est pas un accessoire qui va avec " + aForm.KOPRAD.value + "\n";
				sMsg = sMsg + "Voulez-vous quand même utiliser cet article?\n";
				sMsg = sMsg + "(Dans ce cas l’article ne sera PAS couplé à ce radiateur comme un accessoire)";
				break;
			case 'german':
				sMsg = "Artikel " + sHold + " ist kein Zubehör, dass passt zum Typ " + aForm.KOPRAD.value + "\n";
				sMsg = sMsg + "Möchten Sie diesen Artikel trotzdem benutzen?\n";
				sMsg = sMsg + "(diesem Fall wird KEINE Kupplung als Zubehör zum Heizkörper gemacht)";
				break;
			case 'italian':
				sMsg = "Articolo " + sHold + " non è un accessorio che va su " + aForm.KOPRAD.value + "\n";
				sMsg = sMsg + "Desiderate di communque usare questo articolo?\n";
				sMsg = sMsg + "(Allora questo articolo non viene accoppiato come accessore a questo radiatore)";
				break;
			default:
				sMsg = "Article " + sHold + " is not an accessory that matches with " + aForm.KOPRAD.value + "\n";
				sMsg = sMsg + "Do you wish to use this article anyway?\n";
				sMsg = sMsg + "(In that case this article will NOT be coupled as an accessory to this radiator)";
				break;
			}
			// Artikel toch gebruiken, verbreek dan de koppeling
			if ( confirm(sMsg) ) {
				aVeld.value = sHold;
				aForm.ACC.value = 0;
				aForm.KOP.value = 0;
				bSubmit = true;
			}
	}
	if ( bSubmit ) {
		aForm.RESETBOTTOM.value=1;
		aForm.submit();
	}
	return bSubmit;
}
// onblur actie bij artikelnr, enkel uitvoeren als is ingevuld
function cfgArtikel() {
	var artnr = document.frmBottom.ARTNR.value;
	if ( artnr.trim() != '' ) {
		document.frmBottom.RESETBOTTOM.value=1;
		document.frmBottom.submit();
	}
}

// Bepalen van de focus van het volgende veld in de productconfigurator
// Gebeurt adhv het hidden field FROMFIELD dat bij door de onblur event van de invulvelden
// wordt opgevuld met het zojuist gewijzigde veld.
// Dit moet zo gebeuren omdat bij wijzigen van een veld, de form gesubmit wordt, waardoor de
// focus naar het volgende veld verloren gaat.
// Principe is dat bij wijzigen van een invulveld de focus altijd naar het volgende invulveld gaat 
// ARTNR -> txtSET1 -> txtSET2 -> txtSET3 -> ...
// De focus wijzigt niet als uit een dropdown list met items wordt geselecteerd
// Deze routine wordt opgeroepen door de onload event in de body tag van /configurator/bottom.asp
function cfgSetFocus() {
	// Tab volgorde van de velden in de configurator
	var velden = ["ARTNR", "txtSET1", "txtSET2", "txtSET3", "txtSET4", "txtKLEUR", "AANTAL", "REGELOPMERKING"];
	var i, index,n, gevonden;
	n = velden.length;
	if ( document.forms.length <= 0 ) {
		return;
	}
	if (document.forms[0].name != "frmBottom" ) {
		return;
	}
	var vorigveld=document.frmBottom.FROMFIELD.value;
	if ( vorigveld == "" ) {
		// Enkel doen bij een nieuwe orderregel
		// Niet doen als je er komt vanuit de basket
		if ( document.frmBottom.ORDERREGEL.value == "0:0" ) {
			document.frmBottom.ARTNR.focus();
			//document.frmBottom.ARTNR.select();
		}
		return;
	}
	index = -1;
	for ( i=0; i<n; i++) {
		if ( velden[i] == vorigveld ) {
			index = i+1;
			break;
		}
	}
	gevonden = false;
	if ( index >= 0 && index < n) {
		while ( index < n && gevonden == false ) {
			for ( i=0; i<document.frmBottom.elements.length; i++) {
			    if (document.frmBottom.elements[i].name == velden[index]) {
					gevonden = true;
					break;
				}
			}
			if ( gevonden ) {
				break;
			}
			index++;
		}
	}
	if ( gevonden ) {
		document.frmBottom.elements[i].focus();
		document.frmBottom.elements[i].select();
	}
}
// resetten van de form van klantgegevens
function ResetKlantGeg() {
	
		document.FRMKLANT.ORDL1.value = "";
		document.FRMKLANT.ORDL2.value = "";
		document.FRMKLANT.ORDL3.value = "";
		document.FRMKLANT.ORDL4.value = "";
		document.FRMKLANT.ORDL5.value = "";
		document.FRMKLANT.PN.value = "";
		document.FRMKLANT.FRMSTATUS.value = "1"; // Aanduiding dat de leverplaats gewist moet worden
		document.FRMKLANT.submit();
}
// Klant heeft een leveradres gekozen uit list
// Vul de formulietvelden op met dit leveradres
function SetLeverAdres(aSelect) {
	var aItems;
	var sTmp;

	sTmp = aSelect.options[aSelect.selectedIndex].value;
	aItems = sTmp.split('|');
	
	document.FRMKLANT.ORDL1.value = aItems[0];
	document.FRMKLANT.ORDL2.value = aItems[1];
	document.FRMKLANT.ORDL3.value = aItems[2];
	document.FRMKLANT.ORDL4.value = aItems[4];
	document.FRMKLANT.ORDL5.value = aItems[5];
	document.FRMKLANT.PN.value = aItems[3];
}		
// Kijkt of het artikel gewijzigd is bij klikken van de update button in de
// configurator
function cfgArtikelGewijzigd (aForm, aField, artnr ) {
	if ( aForm[aField].value != artnr) {
		//alert("Gewijzigd");
		aForm.RESETBOTTOM.value = 1;
	}
	aForm.submit();
}
// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}
// Gaat na of de opgegeven velden van een form wel zijn ingevuld
// Eerste argument is het form object, volgende argument de verschillende
// veldnamen
function chkRequiredFields(aForm) {
	var i;
	var ok;
	ok = true;
	for ( i = 1 ; i < arguments.length; i++ ) {
		if ( aForm.elements[arguments[i]].value == '' ) {
			ok = false;
			
			break;
		}
	}
	if ( ok ) {
		return(true);
	} else {
		var lang = new String(readCookie("lang"))
		lang = lang.toLowerCase();
		switch (lang) {
			case 'dutch':
				alert("Een van de verplichte velden is niet ingevuld");
				break;
			case 'french':
				alert("Un des champs obligatoires n'a pas été rempli");
				break;
			case 'german':
				alert('Eines der verplichteten Felder wurde nicht ausgefuellt');
				break;
			case 'italian':
				alert("Uno dei campi obbligatori non è stato riempito");
				break;
			default:
				alert("One of the required fields was not filled in");
				break;
		}
		aForm.elements[arguments[i]].focus;
		return(false);
	}
	
}

function getfirma() {
	var url = location.href;
	var array1 = url.split('/');
	var array2 = array1[2].split('.');
	var site = array2[1].toLowerCase();
	var firma;
	switch (site) {
		case 'thermic':
			firma = 2;
			break;
		default:
			firma = 1;
			break;
	}
	return(firma);
}
function getstylesheet() {
	var firma = getfirma();
	var stylesheet;
	switch (firma) {
		case 2:
			stylesheet = '/thermic.css';
			break;
		default:
			stylesheet = '/vasco.css';
	}
	return(stylesheet);
}

// Js printing
var prt;
            
function printrt(){
	var innerhtml;
	if ( getfirma() == 2 ) {
		innerhtml = document.getElementById('cttxt').innerHTML + document.getElementById('footertxt').innerHTML
	} else {
		innerhtml = document.getElementById('body').innerHTML
	}
	// FH geen logo innerhtml = document.getElementById('logo').innerHTML +  innerhtml
	//alert(innerhtml);
	prt = window.open('about:blank','prs','directories=no,location=no,height=100,widthy=100,menubar=no,scrollbars=no,status=no,toolbar=no');			
	prt.document.write("<html><head><link href=\"" + getstylesheet() + "\" rel=\"stylesheet\" type=\"text/css\"></head><body>" + innerhtml + "</body></html>");
	setTimeout("doprintrt();",3000);
}

function printBasket() {
	var innerhtml, remark, sLogo,sTitel, sPrinted;
	var now = new Date();
	innerhtml = document.getElementById('basketcontents').innerHTML;
	sTitel = '<H2>' + document.getElementById('PaginaTitel').innerHTML +'</H2>';
	remark = '<P><FONT class="tekst">' + document.frmBasket.txtBasketFreeText.value +'</FONT></P>';
	sPrinted = '<P><FONT class="tekstsmall">' + document.frmBasket.PRINTEDBY.value + '<BR><BR><small>' + now +'</small></FONT></P>';
	//alert(innerhtml);
	//alert(remark);
	// FH geen logo innerhtml = document.getElementById('logo').innerHTML +  innerhtml
	//alert(innerhtml);
	if ( getfirma() == 2 ) {
		sLogo = '<IMG SRC="/images/logo.gif"></IMG>';
	} else {
		sLogo = '<IMG SRC="/images/LOGO.JPG"></IMG>';
	}
	prt = window.open('about:blank','prs','directories=no,location=no,height=400,widthy=100,menubar=no,scrollbars=no,status=no,toolbar=no');			
	prt.document.write("<html><head><link href=\"" + getstylesheet() + "\" rel=\"stylesheet\" type=\"text/css\"></head><body>" + sLogo + sTitel + remark + innerhtml + sPrinted + "</body></html>");
	setTimeout("doprintrt();",3000);
}
// Thermic versie
function NMMPagePrint() {
	printrt();
}
function NMMPagePrint_old() 
{
	is = new BrowserCheck(); 
	if (is.ns) 
	{
		print();
	} 
	else 
	{
		if (navigator.userAgent.indexOf("Mac")>=0) 
		{
			var lang = new String(readCookie("lang"))
			lang = lang.toLowerCase();
			switch (lang) {
				case 'dutch':
					alert("Gebruik het print-commando van je browser in dit venster.");
					break;
				case 'french':
					alert("Utilisez la commande imprimer de votre browser");
					break;
				case 'german':
					alert("Benutzen Sie in diesem Fenster das Abdruckkommando Ihres Browsers");
					break;
				case 'italian':
					alert("Usate il commando di stampa del vostro browser in questa finestra");
					break;
				default:
					alert("Use the print command of your browser in this window");
					break;
			}
		} 
		else 
		{
			var focused = document.activeElement;
			window.focus();
			window.self.print();
			if ( !focused.disabled ) focused.focus();
			return;
			//var OLECMDID_PRINT = 6;
			//var OLECMDEXECOPT_DONTPROMPTUSER = 2;
			//var OLECMDEXECOPT_PROMPTUSER = 1; 
			//var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
			//document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
			//WebBrowser1.ExecWB(OLECMDID_PRINT,   OLECMDEXECOPT_PROMPTUSER);
			//WebBrowser1.outerHTML = "";
		}
	}
}
function doprintrt(){
	try{
		prt.document.execCommand('print',true);
		setTimeout("prt.close();",3000)
	}
	catch(er){
		var lang = new String(readCookie("lang"))
		lang = lang.toLowerCase();
		switch (lang) {
			case 'dutch':
				alert("Gebruik het print-commando van je browser in dit venster.");
				break;
			case 'french':
				alert("Utilisez la commande imprimer de votre browser");
				break;
			case 'german':
				alert("Benutzen Sie in diesem Fenster das Abdruckkommando Ihres Browsers");
				break;
			case 'italian':
				alert("Usate il commando di stampa del vostro browser in questa finestra");
				break;
			default:
				alert("Use the print command of your browser in this window");
				break;
		}
	}
}

// Zet voor een getal voorafgaande nullen, indien lengte kleiner is dan opgegeven
function lzero(s, n) {
	var l = s.length;
	var sTmp = s;
	var i;
	if ( l < n ) {
		for (i=1; i<=(n-l); i++) {
			sTmp = "0" + sTmp;
		}
	}
	return(sTmp);
}

function submitklvert(aform) {
	if ( aform.LSTKLANT.value != '' && aform.LSTKLANT.value != '-1' ) { 
		 aform.KLANT.value=aform.H_ID.value+lzero(aform.LSTKLANT.value,6);
		 aform.KLANT2.value = aform.LSTKLANT.value;
		 aform.submit();
	}
}
// Popupwindows - START
// javascript code om bij mousoverevents op een link een klein textvak te tonen
// met daarover bijkomende informatie. 
// Let op
// Gebruikt de volgende style: (vasco.css en thermic.css)
// .D11
//  {
//  POSITION:absolute;
//  VISIBILITY:hidden;
//  Z-INDEX:200;
// }
// Vooraleer te gebruiken:
// Maak achter de <body> de volgende tags aan:
// <DIV ID="d11" CLASS="d11"></DIV>
// Daarna op het einde van het document (voor </body>):
// <script>
//	initPopUpMsg();
// </script>
// Daarna als volgt gebruiken:
// <A HREF="#" ONMOUSEOVER="popupText('Text Inside<BR>PopUp','white')"
//	                               ONMOUSEOUT="popoutText()">Something of interest</A>
var skn;
var popup_X;
var popup_Y;
function initPopUpMsg()
{
  var isNS4=document.layers?true:false;
  var isIE=document.all?true:false;
  var isNS6=!isIE&&document.getElementById?true:false;
  var old=!isNS4&&!isNS6&&!isIE;
  if(isNS4)skn=document.d11;
  if(isIE)skn=document.all.d11.style;
  if(isNS6)skn=document.getElementById("d11").style;
  if(isNS4)
  	document.captureEvents(Event.MOUSEMOVE); 
  if(isNS6)
  	document.addEventListener("mousemove", get_mouse, true);
  if(isNS4||isIE)
  	document.onmousemove=get_mouse;
}

function popupText(msg, backcolor, bordersize, bordercolor)
{
  var isNS4=document.layers?true:false;
  var isIE=document.all?true:false;
  var isNS6=!isIE&&document.getElementById?true:false;
  var old=!isNS4&&!isNS6&&!isIE;
  var content="<TABLE BORDER=" + bordersize + " BORDERCOLOR=" + bordercolor + " CELLPADDING=2 CELLSPACING=0 BGCOLOR=" +backcolor + "><TD ALIGN=left><FONT COLOR=black SIZE=2>"+msg+"</FONT></TD></TABLE>";
  if(old)
  {
    //alert("You have an old web browser:\n"+_m);
	return;
  }
  else
  {
	if(isNS4)
	{
	  skn.document.open();
	  skn.document.write(content);
	  skn.document.close();
	  skn.visibility="visible";
	}
	if(isNS6)
	{
	  document.getElementById("d11").style.position="absolute";
	  document.getElementById("d11").style.left=popup_X;
	  document.getElementById("d11").style.top=popup_Y;
	  document.getElementById("d11").innerHTML=content;
	  skn.visibility="visible";
	}
	if(isIE)
	{
	  document.all("d11").innerHTML=content;
	  skn.visibility="visible";
	}
  }
}


function get_mouse(e)
{
  var x;
  var y;
  var Xoffset= 0;
  var Yoffset= 20;
  var isNS4=document.layers?true:false;
  var isIE=document.all?true:false;
  var isNS6=!isIE&&document.getElementById?true:false;
  var old=!isNS4&&!isNS6&&!isIE;
  x=(isNS4||isNS6)?e.pageX:event.clientX+document.body.scrollLeft; 
  y=(isNS4||isNS6)?e.pageY:event.clientY+document.body.scrollLeft; 
  if(isIE&&navigator.appVersion.indexOf("MSIE 4")==-1)
	  y+=document.body.scrollTop;
  skn.left=x+Xoffset;
  skn.top=y+Yoffset;
  popup_X = x;
  popup_Y = x;
}

function popoutText()
{
  var isNS4=document.layers?true:false;
  var isIE=document.all?true:false;
  var isNS6=!isIE&&document.getElementById?true:false;
  var old=!isNS4&&!isNS6&&!isIE;
  if(!old)
  {
	skn.visibility="hidden";
  }
}
// Popup Windows -- STOP
// Genereer een mailto link. Gebruik deze functie
// om te voorkomen dat de e-mail adressen zomaar van de site worden geplukt
// email adres = name@domain
// tekst is optioneel en is hetgene wat tussen <a> en </a> wordt geplaats, dus het zichtbare gedeelte
// indien weggelaten wordt hier gewoon name@domain getoond
function MailTo(name, domain, tekst) 
{
	var vTekst;
	if (arguments.length < 3 ) {
		vTekst = name + "@" + domain ;
	} else {
		vTekst = tekst;
	}
	document.write("<a href='mailto:" + name + "@" + domain + "'>");
	document.write("<u>" + vTekst + "</u>");
	document.write("</a>");
}
// Functies die de enter key remappen naar de tab key
// NB : Internet Explorer Only!
// Gebruikt in de configurator
// Om te activeren in de onload event van de form de functie setEnterTab te plaatsen
// <body onload="setEnterTab();">
function entertab(){
	if(event.keyCode==13){
		try{
			event.keyCode = 9;
		}
		catch(e){
		}
	}
}

function setEnterTab(){
	if ( ! document.all ) {
		return;
	}
	var frms = document.getElementsByTagName('FORM');
	for(var i=0;i<frms.length;i++){
		_setEnterTab(frms[i]);
	}
}

function _setEnterTab(frm){
	for(var i=0;i<frm.elements.length;i++){
		if(frm.elements[i].type.toLowerCase()!='submit'){
			frm.elements[i].onkeydown = entertab;
		}
	}
}
// cnsel() uitgevoerd bij:
// ONFOCUS van de invoervelden van de configurator
// ONCLICK van de listboxes van de configurator
// Canceled het ONBLUR event bij de invoervelden van de configurator. 
// Bij het klikken op de listboxes wordt indien de focus op een invulveld staat, het ONBLUR
// event van dat veld geactiveerd. Dit ONBLUR event kijkt na via Matchtext2select of het veld wel
// voorkomt in de overeen komstige list. Zoja, wordt de list op deze waarde gezet en de form gesubmit.
// Dit mag bij het klikken op de list echter niet gebeuren, daar bij wijzigen van de waarde van de list een 
// ONCHANGE event plaatsvindt wat de waarde van het overeenkmostige textveld zet en de form ook submit.
// Indit geval vindt er dus tweemaal een formsubmit plaats, wat niet natuurlijk overkomt bij de gebruiker en
// natuurlijk de configurator in de war brengt.
function cnsel(){
	clearTimeout(tmid);
}
// --------------------------------
// Functie om tekst tussen <SPAN> </SPAN> naar clipboard te kopieren
// Setup:
// Zet de te kopieren tekst tussen <SPAN><SPAN> tags. De ID is argument voor de javascriptfunctie
//  <SPAN ID="copytext">test</SPAN>
// Maak vervolgens een hidden textarea precies zoals hieronder vermeld:
//  <TEXTAREA ID="holdtext" STYLE="display:none;"></TEXTAREA>
// Om nu naar clipboard te kopieren:
// ClipBoard(copytext)   --> copytext = ID van <SPAN>
// ---------------------------------
function ClipBoard(tdObj) {
	document.forms[0].holdtext.innerText = tdObj.innerText;
	Copied = document.forms[0].holdtext.createTextRange();
	Copied.execCommand("Copy");
	//alert(tdObj.innerText + 'copied to clipboard.');
	window.status = tdObj.innerText + ' copied to clipboard.';
	return true;
}
// ---------------------------------

