function MM_openBrWindow(image) 
{
	windowFeatures ="menubar=no,scrollbars=no,location=no,favorites=no,resizable=no,status=no,toolbar=no,directories=no";
	content	 = "<head><title>Boekhandel Westerhof</title></head>\r\n";
	content	+= "<script language='javascript'>\r\n";
	content	+= "function resize()\n";
	content += "{\nwidth = document.getElementById('img1').offsetWidth + 10; \n"
	content += "height = document.getElementById('img1').offsetHeight + 36; \n";
	content += "window.resizeTo(width, height);\n";
	content += "}\n";
	content	+= "<\/script>";
	content += "<body leftmargin='0' topmargin='0' id='body1'>\r\n";
	content += "\n";
	content	+= "<img id='img1' src='" + image + "' border='0' OnLoad=\"resize();\" >\r\n";
	content	+= "</body>\n";
	content	+= "</html>\n";
	myWin	 = window.open('','windowName','width=200,height=200,left=100,top=100');
	myWin.document.writeln(content);
}

function aanvinken() {

if(document.forms['Lijst'].elements['incasso_banknummer'].value.length!=0)
		{
		document.forms['Lijst'].elements['incasso_akkoord'].checked=true;
		}
}

function boekenAangevinkt(aantal){
legeVelden=0;
for (i=1;i<=aantal;i++)
	{
	var aangevinkt = document.forms['Lijst'].elements['lijst_item'+i];
	if(aangevinkt.checked==true)
		{
		legeVelden++;
		}
	}
if (legeVelden!=0)
	{
	return true;
	}
else
	{
	alert('Er zijn geen boeken aangevinkt!');
	return false;
	}
}

function Verify(aantal){

if (boekenAangevinkt(aantal) && FormControle_Lijst())
	{
	return true;
	}
else
	{
	return false;
	}
}

function changer(its) {
	document.forms['Lijst'].verzendenNaBetaling.checked = false;
	document.forms['Lijst'].afhalenCampus.checked = false;
	document.forms['Lijst'].afhalenBinnenstad.checked = false;
	document.forms['Lijst'].afhalenStadshagen.checked = false;
	document.forms['Lijst'].afhalenNijverdal.checked = false;
	setLive(its);
}

function setLive(its) {
	if (its=='verzendenNaBetaling') {
	document.forms['Lijst'].verzendenNaBetaling.checked=true;
	}
	if (its=='afhalenCampus') {
	document.forms['Lijst'].afhalenCampus.checked=true;
	}
	if (its=='afhalenBinnenstad') {
	document.forms['Lijst'].afhalenBinnenstad.checked=true;
	}
	if (its=='afhalenStadshagen') {
	document.forms['Lijst'].afhalenStadshagen.checked=true;
	}
	if (its=='afhalenNijverdal') {
	document.forms['Lijst'].afhalenNijverdal.checked=true;
	}
}

function openPopup(image,breedte,hoogte){
var win = window.open("about:blank","","toolbar=no,width="+breedte+" ,height="+hoogte+",directories=no,status=no,scrollbars=no,resize=no,menubar=no,left=50,top=50");
win.document.open();
win.document.writeln('<hmtl><head><link href="../lib/stylesheet.css" rel="stylesheet" type="text/css"></head>'); 
win.document.writeln('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
win.document.writeln('<IMG SRC="'+image+'" border="0">');
win.document.writeln('</body></html>');
win.document.close();
}

function alterError(value) 
{
	if (value<=0.99) 
		{
		newPounds = '0';
		} 
	else 
		{
		newPounds = parseInt(value);
		}
	newPence = parseInt((value+.0008 - newPounds)* 100);
	if (eval(newPence) <= 9) newPence='0'+newPence;
	newString = newPounds + '.' + newPence;
	return (newString);
}

function bestel()
{
var titel = escape(document.itemform.titel.value);
var auteur = escape(document.itemform.auteur.value);
var isbn = document.itemform.isbn.value;
var prijs = document.itemform.prijs.value.replace(",", ".");
if (prijs.indexOf(".")==-1){prijs+='.00';}

buyItem(titel +  ' - ' + auteur , isbn , prijs , 1);
self.location='./?p=bestellen';
}

function buyItem(newItem, newCode, newPrice, newQuantity) 
{
	if (newQuantity <= 0) 
		{
		rc = alert('Geef een aantal in a.u.b!');
		} 
	else 
		{
		//if (confirm('Wilt u '+newItem+' bestellen?')) 
		//	{
			var exp = new Date();
			exp.setTime(exp.getTime() + 60*60*1000);
			var expDate = exp.toGMTString();

			index = document.cookie.indexOf("UwBOL");
			countbegin = (document.cookie.indexOf("=", index) + 1);
			countend = document.cookie.indexOf(";", index);
			if (countend == -1) 
				{
				countend = document.cookie.length;
				}
			document.cookie="UwBOL="+document.cookie.substring(countbegin, countend)+"["+newItem+"|"+newCode+"|"+newPrice+"|"+newQuantity+"];expires=" + expDate;
		//	}
		}
}

function wishList(newItem, newPrice, newQuantity) 
{
	if (confirm('Wilt u '+newItem+' toevoegen aan uw verlanglijstje?')) 
		{
		var exp = new Date();
		exp.setTime(exp.getTime() + 60*60*1000);
		var expDate = exp.toGMTString();

		index = document.cookie.indexOf("Verlanglijstje");
		countbegin = (document.cookie.indexOf("=", index) + 1);
		countend = document.cookie.indexOf(";", index);
		if (countend == -1) 
			{
			countend = document.cookie.length;
			}
		document.cookie="Verlanglijstje="+document.cookie.substring(countbegin, countend)+"<"+newItem+"~"+newPrice+"~"+newQuantity+">;expires=" + expDate;
		}
}		


function resetShoppingBasket() 
{
	index = document.cookie.indexOf("UwBOL");
	document.cookie="UwBOL=.";

	if (document.cookie) 
		{
		} 
	else {
		 alert('U heeft het gebruik van cookies uitgeschakeld.\nDeze bestelmethode heeft het gebruik van cookies nodig om te functioneren. Pas uw internetopties aan om van deze functie gebruik te maken en laad de pagina opnieuw.');
		 }

}

function resetWishList() 
	{
		index = document.cookie.indexOf("Verlanglijstje");
		document.cookie="Verlanglijstje=.";

		if (document.cookie) {
                } else {
                  alert('U heeft het gebruik van cookies uitgeschakeld.\nDeze methode heeft het gebruik van cookies nodig om te functioneren. Pas uw internetopties aan om van deze functie gebruik te maken en laad de pagina opnieuw.');
                }

	}

function FormControle(theForm)
{

  if (theForm.voornaam.value == "")
  { 
	alert ("U heeft geen voornaam of voorletters ingevuld.");
	theForm.voornaam.focus();
	return (false);
  }	

  if (theForm.achternaam.value == "")
  {
    alert("U heeft geen achternaam ingevuld.");
    theForm.achternaam.focus();
    return (false);
  }

  if (theForm.adres.value == "")
  {
    alert("U heeft geen adres ingevuld.");
    theForm.adres.focus();
    return (false);
  }

  if (theForm.postcode.value == "")
  {
    alert("U heeft geen postcode ingevuld.");
    theForm.postcode.focus();
    return (false);
  }

  if (theForm.postcode.value.length < 6)
  {
    alert("Ongeldige postcode.");
    theForm.postcode.focus();
    return (false);
  }

  if (theForm.woonplaats.value == "")
  {
    alert("U heeft  geen woonplaats ingevuld.");
    theForm.woonplaats.focus();
    return (false);
  }

  if (theForm.tel.value == "" )
  {
    alert("U heeft geen telefoonnummer ingevuld.");
    theForm.tel.focus();
    return (false);
  }

  if (theForm.email.value != "" && theForm.email.value.indexOf("@") == -1)
  {
    alert("Dit is geen geldig mail adres.\n 'Uwnaam@provider.nl' is een goed voorbeeld.");
    theForm.email.focus();
    return (false);
  }
  
  //return (true);
  return window.confirm("Formulier verzenden?");
}

function FormControle_Lijst()
{
  if (Lijst.voornaam.value == "")
  { 
	alert ("U heeft geen voornaam of voorletters ingevuld.");
	Lijst.voornaam.focus();
	return (false);
  }	

  if (Lijst.achternaam.value == "")
  {
    alert("U heeft geen achternaam ingevuld.");
    Lijst.achternaam.focus();
    return (false);
  }

  if (Lijst.adres.value == "")
  {
    alert("U heeft geen adres ingevuld.");
    Lijst.adres.focus();
    return (false);
  }

  if (Lijst.postcode.value == "")
  {
    alert("U heeft geen postcode ingevuld.");
    Lijst.postcode.focus();
    return (false);
  }

  if (Lijst.postcode.value.length < 6)
  {
    alert("Ongeldige postcode.");
    Lijst.postcode.focus();
    return (false);
  }

  if (Lijst.plaats.value == "")
  {
    alert("U heeft  geen woonplaats ingevuld.");
    Lijst.plaats.focus();
    return (false);
  }

  if (Lijst.telefoon.value == "" )
  {
    alert("U heeft geen telefoonnummer ingevuld.");
    Lijst.telefoon.focus();
    return (false);
  }

  if (Lijst.telefoon.value.length < 7 )
  {
    alert("Uw telefoonnummer heeft niet de goede lengte.");
    Lijst.telefoon.focus();
    return (false);
  }
  
  if (Lijst.email.value == "")
  {
    alert("U heeft uw e-mailadres niet ingevuld.");
    Lijst.email.focus();
    return (false);
  }
  // als incasso aangevinkt, dan ook bankrekening nodig
  if (Lijst.incasso_akkoord.checked == true && Lijst.incasso_banknummer.value=='')
  {
    alert("Er mist een bankrekeningnummer voor de incasso.");
    Lijst.incasso_banknummer.focus();
    return (false);
  }

  // Als incasso aangevinkt en bankrekening is ingevuld. Dan een check op deze laatste
  if (Lijst.incasso_akkoord.checked == true && Lijst.incasso_banknummer.value!='')
  {
	CheckBanknr();
  }
  // als incasso aangevinkt, dan ook naam nodig
  
  if (Lijst.incasso_akkoord.checked == true && Lijst.incasso_voornaam.value=='')
  {
    alert("Vul een naam in voor de incasso.");
    Lijst.incasso_voornaam.focus();
    return (false);
  }
  // als incasso aangevinkt, dan ook naam nodig
  if (Lijst.incasso_akkoord.checked == true && Lijst.incasso_achternaam.value=='')
  {
    alert("Vul een achternaam in voor de incasso.");
    Lijst.incasso_achternaam.focus();
    return (false);
  }
  // als incasso aangevinkt, dan ook adres nodig
  if (Lijst.incasso_akkoord.checked == true && Lijst.incasso_adres.value=='')
  {
    alert("Vul een adres in voor de incasso.");
    Lijst.incasso_adres.focus();
    return (false);
  }
  // als incasso aangevinkt, dan ook postcode nodig
  if (Lijst.incasso_akkoord.checked == true && Lijst.incasso_postcode.value=='')
  {
    alert("Vul een postcode in voor de incasso.");
    Lijst.incasso_postcode.focus();
    return (false);
  }
  // als incasso aangevinkt, dan ook plaats nodig
  if (Lijst.incasso_akkoord.checked == true && Lijst.incasso_plaats.value=='')
  {
    alert("Vul een plaats in voor de incasso.");
    Lijst.incasso_plaats.focus();
    return (false);
  }
  
  /* Checken e-mail adres op spaties */
  if (Lijst.email.value.search(/ /) != "-1")
  {
    alert("Er mogen geen spaties in het e-mail adres zitten.");
    Lijst.email.focus();
    return (false);
  }
  /* checken of het e-mail adres uit het juiste formaat bestaat */
  s1 = Lijst.email.value.split(/@/);
  if ((s1.length != 2) || s1[0] == '' || s1[1] == '')
  {
    alert("E-mail adressen moeten de volgende vorm hebben:\nuwnaam@uwprovider.nl / .com etc.");
    Lijst.email.focus();
    return (false);
  }
  /* checken of er een . in de het gedeelte naar de @ staat */
  check2 = Lijst.email.value.split(/@/);
  if (check2[1].indexOf(".") == "-1")
  {
    alert("Er moet een punt staan u het domein gedeelte van het e-mailadres!");
    Lijst.email.focus();
    return (false);
  }
	
return (true);
  //return window.confirm("Formulier verzenden?");
}

function alterError(value) {
	if (value<=0.99) {
		newPounds = '0';
	} else {
		newPounds = parseInt(value);
	}
	newPence = parseInt((value+.0008 - newPounds)* 100);
	if (eval(newPence) <= 9) newPence='0'+newPence;
	newString = newPounds + '.' + newPence;
	return (newString);
}

function showItems() {
	index = document.cookie.indexOf("UwBOL");
	countbegin = (document.cookie.indexOf("=", index) + 1);
		countend = document.cookie.indexOf(";", index);
		if (countend == -1) {
				countend = document.cookie.length;
		}
	fulllist = document.cookie.substring(countbegin, countend);
	totprice = 0;
	document.writeln('<TABLE BORDER=0 CELLPADDING="2" cellspacing="1" width="100%">');
	document.writeln('<TR><TD><b>Artikel</b></TD><TD align="right"><b>Stukprijs</b><TD align="right"><b>Aantal</b></TD><TD align="right"><b>Totaal</b></TD></TR>');
			

	itemlist = 0;
	for (var i = 0; i <= fulllist.length; i++) {
					
		if (fulllist.substring(i,i+1) == '[') {
			thisitem = 1;
			itemstart = i+1;
		} else if (fulllist.substring(i,i+1) == ']') {
			itemend = i;
			thequantity = fulllist.substring(itemstart, itemend);
			itemtotal = 0;
			itemtotal = (eval(theprice*thequantity));
			temptotal = itemtotal * 100;
			totprice = totprice + itemtotal;
			itemlist=itemlist+1;

			document.write('<tr bgcolor="#F5F5F5"> <td>'+unescape(theitem)+'</td>');
			document.writeln('<td align=right>'+theprice+'</td>');
			document.writeln('<td align=right>'+thequantity+'</td>');
			document.writeln('<INPUT TYPE="hidden" NAME="Boek'+itemlist+'" VALUE="'+unescape(theitem)+'">');
			document.writeln('<INPUT TYPE="hidden" NAME="Code'+itemlist+'" VALUE="'+thecode+'">');
			document.writeln('<INPUT TYPE="hidden" NAME="Aantal'+itemlist+'" VALUE="'+thequantity+'">');
			document.writeln('<INPUT TYPE="hidden" NAME="prijs'+itemlist+'" VALUE="'+theprice+'"></td>				<td valign="top" align="right">'+alterError(itemtotal)+'<INPUT TYPE="hidden" NAME="itemtotaal'+itemlist+'" VALUE="'+alterError(itemtotal)+'"></td></tr>');
			
			
		} else if (fulllist.substring(i,i+1) == '|') {
			if (thisitem==1) theitem = fulllist.substring(itemstart, i);
			if (thisitem==2) thecode = fulllist.substring(itemstart, i);
			if (thisitem==3) theprice = fulllist.substring(itemstart, i);
			thisitem++;
			itemstart=i+1;
		}
	}
	document.writeln('<tr><td colspan="4" align=right><u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+</u></td><tr>');
	document.write('<tr><td><b>Totaalbedrag</b></td><td colspan="3" align="right" valign="top">€ '+alterError(totprice)+'<INPUT TYPE="hidden" NAME="totaal" VALUE="'+alterError(totprice)+'"></td></tr>');
	document.writeln('</TABLE>');
	document.writeln('Het totaalbedrag is exclusief de bedragen voor de titels waar geen prijs bij staat. <br><font size="1">(prijswijzigingen voorbehouden)</font>');

}

function amendItem(itemno, newquant) {
	newItemList = null;
	itemlist = 0;
	for (var i = 0; i <= fulllist.length; i++) {
		if (fulllist.substring(i,i+1) == '[') {
			thisitem = 1;
			itemstart = i+1;
			fullstart = i+1;
		} else if (fulllist.substring(i,i+1) == ']') {
			itemend = i;
			itemlist=itemlist+1;
			if (itemlist != itemno) {
				newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
			} else {
				newItemList = newItemList + '['+theitem+'|'+thecode+'|'+theprice+'|'+newquant+']';
			}
		} else if (fulllist.substring(i,i+1) == '|') {
			if (thisitem==1) theitem = fulllist.substring(itemstart, i);
			if (thisitem==2) thecode = fulllist.substring(itemstart, i);
			if (thisitem==3) theprice = fulllist.substring(itemstart, i);
			thisitem++;
			itemstart=i+1;
		}
	}
	index = document.cookie.indexOf("UwBOL");
	document.cookie="UwBOL="+newItemList;
	self.location = "./?p=bestellen";

}

function removeItem(itemno) {
	newItemList = null;
	itemlist = 0;
	for (var i = 0; i <= fulllist.length; i++) {
		if (fulllist.substring(i,i+1) == '[') {
			itemstart = i+1;
		} else if (fulllist.substring(i,i+1) == ']') {
			itemend = i;
			theitem = fulllist.substring(itemstart, itemend);
			itemlist=itemlist+1;
			if (itemlist != itemno) {
				newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
			}
		}
	}
	index = document.cookie.indexOf("UwBOL");
	document.cookie="UwBOL="+newItemList;
	self.location = "./?p=bestellen";
}

// clearBasket() - removes all items from the basket
function clearBasket() {
	if (confirm('Weet u zeker dat u alles wil wissen?')) {
		index = document.cookie.indexOf("UwBOL");
		document.cookie="UwBOL=.";
		self.location = "./?p=bestellen";
	}
}

function showItems_addItems() {
            index = document.cookie.indexOf("UwBOL");
			countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		document.writeln('<FORM NAME="updateform">');
		document.writeln('<div align="left">');
		document.writeln('<TABLE WIDTH=100% BORDER=0 CELLPADDING="2" cellspacing="1">');
		document.writeln('<TR><TD><b>Boek</b></TD><TD align="right">Prijs</TD><TD align="right">Aantal</TD><TD>Totaal</TD><TD colspan="2">&nbsp;</TD></TR>');


		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
				thisitem = 1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist = itemlist+1;

				document.write('<tr valign="top" bgcolor="#F5F5F5"><td>'+unescape(theitem)+' ('+thecode+')</td>');
				document.writeln('<td align=right width="40">'+theprice+'</td>');
				document.write('<td valign="top" align="right" width="50"><input type=text name="quant'+itemlist+'" value="'+thequantity+'" size=2 style="text-align:right" class="textfield2"></td>');
				document.write('<td valign="top" align="right" width="50">'+alterError(itemtotal)+'</td>');
				document.write('<td valign="center" align="center" width="25"><a href="javascript:removeItem('+itemlist+')"><img src="../img/delete.png" border="0"></td>');
				document.write('<td width="25" valign="center" align="center"><a href="javascript:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><img src="../img/save.png" border="0"></a></td></tr>');

			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) thecode = fulllist.substring(itemstart, i);
				if (thisitem==3) theprice = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}



		}

        
		document.writeln('<tr><td colspan="4" align=right><u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+</u></td><td colspan="2">&nbsp;</td></tr>');
		document.write('<tr><td><b>Totaalbedrag</b></td><td colspan="3" align="right" valign="top">€ '+alterError(totprice)+'<td colspan="2">&nbsp;</td>');
		document.writeln('</TABLE><cr>');
		document.writeln('Het totaalbedrag is exclusief de bedragen voor de titels waar geen prijs bij staat. <br><font size="1">(prijswijzigingen voorbehouden)</font>');
		document.writeln('</FORM>');
}

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_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_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_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_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();
}
MM_reloadPage(true);


/**** function for links ****/
fadeColor = "#FF0000";  // color to fade to
stepIn = 20; // delay when fading in
stepOut = 40; // delay when fading out
autoFade = false;  // when set to true, ALL the links will fade	
sloppyClass = true; // classes with 'fade' in the classname will fade
macCompat = false;

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

document.onmouseover = domouseover;
document.onmouseout = domouseout;

fadeColor = dehexize(fadeColor.toLowerCase());

var fadeId = new Array();

function dehexize(Color){
	var colorArr = new makearray(3);
	for (i=1; i<7; i++){
		for (j=0; j<16; j++){
			if (Color.charAt(i) == hexa[j]){
				if (i%2 !=0)
					colorArr[Math.floor((i-1)/2)]=eval(j)*16;
				else
					colorArr[Math.floor((i-1)/2)]+=eval(j);
			}
		}
	}
	return colorArr;
}

function domouseover() {
	if(document.all){
		var srcElement = event.srcElement;
		if ((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) {
				if (!srcElement.startColor) {
					srcElement.startColor = (srcElement.style.color)? srcElement.style.color: srcElement.currentStyle.color;
					srcElement.startColor = dehexize(srcElement.startColor.toLowerCase());
				}
				var link = (macCompat? srcElement.name: srcElement.uniqueID);
				if (link) fade(srcElement.startColor,fadeColor,link,stepIn);				
				else if (macCompat) alert("Error: Mac Compatility mode enabled, but link has no name.");
		}
	}
}

function domouseout() {
	if (document.all){
		var srcElement = event.srcElement;
		if ((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) {
			var link = (macCompat? srcElement.name: srcElement.uniqueID);
			if (link) fade(fadeColor,srcElement.startColor,link,stepIn);
		}
	}
}

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setColor(r, g, b, element) {
      var hr = hex(r); var hg = hex(g); var hb = hex(b);
      element.style.color = "#"+hr+hg+hb;
}

function fade(s,e,element,step) {
	var sr = s[0]; var sg = s[1]; var sb = s[2];
	var er = e[0]; var eg = e[1]; var eb = e[2];
	
	if (fadeId[0] != null && fade[0] != element && eval(fadeId[0])) {
		var orig = eval(fadeId[0]);
		setColor(orig.startColor[0],orig.startColor[1],orig.startColor[2],orig);
		var i = 1;
		while(i < fadeId.length) {
			clearTimeout(fadeId[i]);
			i++;
		}
	}
		
	for(var i = 0; i <= step; i++) {
		fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +
			step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+
			")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step);
	}
	fadeId[0] = element;
}

function CheckBanknr() {
if ("".replace) 
	{
	var sum = 0;
	
	val = document.forms['Lijst'].elements['incasso_banknummer'];
	waarde = val.value;
	if (waarde=='123456789' || waarde=='012345678')
		{
		alert ('Het rekeningnummer '+waarde+' is een niet bestaande');
		val.select();
		document.forms['Lijst'].elements['incasso_akkoord'].checked=false;
		return false;
		}

	var rekNr = String(waarde).toUpperCase().replace(/[\s\t-\.]/g,""); // Delete white space, hyphens en periods
	
	if (rekNr.match(/[^P^0-9]/g)) 
		{
		// If anything left is not a digit or a P (Postbank) and does not have length 10 then it's not an rekeningnr
		alert ('Het rekeningnummer '+rekNr+' klopt niet!!!');
		val.select();
		document.forms['Lijst'].elements['incasso_akkoord'].checked=false;
		return false;
		}
	
	if (rekNr.length < 9) // girorekeningnummer aanvullen met P en nulletjes
	{
	rekNr = rekNr.replace("P","");
	lengte = (rekNr.length);
	nullen='';
	for(k=1;k<(9-lengte);k++)
		{
		nullen+='0'
		}
	rekNr='P'+nullen+rekNr;
	}
		
	val.value=rekNr;
	
	rekNr = rekNr.match(/[0-9]{9}|P{1}[0-9]{8}/g); // Store matches to 9digits or P+9digits (consecutive)
	if (rekNr)	
		{
		rekNr = rekNr[0]; // Take first match
		}
	else 
		{
		alert ('Het rekeningnummer klopt niet!!!');
		val.select();
		document.forms['Lijst'].elements['incasso_akkoord'].checked=false;
		return false; // No matches, thus not an Rekeningnummer.
		}
	
	if (rekNr.charAt(0)=="P")
		{
		//alert('Postbank is altijd ok');
		document.forms['Lijst'].elements['incasso_akkoord'].checked=true;
		document.forms['Lijst'].elements['bezorgen'].value='j';
		return true;
		}
	else
		{
		// Generate checksum value
		for (var i=0; i<9; ++i) 
			{
			sum += (9 - i) * eval(rekNr.charAt(i)); // Eval() is not nice, but useful here
			}
		var checksumValid = (sum % 11 == 0); // checksum true or false (valid or invalid)
		
		//alert(checksumValid);
		if(checksumValid==false)
			{
			alert('Het rekeningnummer '+rekNr+' klopt niet!')
			val.select();
			document.forms['Lijst'].elements['incasso_akkoord'].checked=false;
			return false;
			}
		else
			{
			document.forms['Lijst'].elements['incasso_akkoord'].checked=true;
			document.forms['Lijst'].elements['bezorgen'].value='j';
			return true;
			}
		}
	}
else 
	{
	return false;
	}
}

function overnemen(){
	document.forms['Lijst'].elements['incasso_voornaam'].value = document.forms['Lijst'].elements['voornaam'].value;
	document.forms['Lijst'].elements['incasso_achternaam'].value = document.forms['Lijst'].elements['achternaam'].value;
	document.forms['Lijst'].elements['incasso_adres'].value = document.forms['Lijst'].elements['adres'].value;
	document.forms['Lijst'].elements['incasso_postcode'].value = document.forms['Lijst'].elements['postcode'].value;
	document.forms['Lijst'].elements['incasso_plaats'].value = document.forms['Lijst'].elements['plaats'].value;
	document.forms['Lijst'].elements['incasso_banknummer'].focus();
}

function open_venster(URL,naam)
	{
	var w=800;
	var h=600;
	var top=(screen.height - h) / 2;
	var left=(screen.width - w) / 2;
	window.open(URL,naam, 'width='+w+', height='+h+',top='+top+',left='+left+', statusbar=1, menubar=no, status=no, location=no, toolbar=no, scrollbars=auto')
	}

function show_incasso()
	{
	if (document.forms['Lijst'].elements['incasso_akkoord'].checked == true)
		{
		document.forms['Lijst'].elements['bezorgen'].value = 'j';
		open_venster('http://www.boekhandelwesterhof.nl/content/?p=inhoud&id=48','Incasso');
		}
	else 
		{
		document.forms['Lijst'].elements['bezorgen'].value = 'n';
		document.forms['Lijst'].elements['incasso_banknummer'].value = '';
		}
	}

function incasso_check()
	{
	if (document.forms['Lijst'].elements['bezorgen'].value == 'j')
		{
		document.forms['Lijst'].elements['incasso_akkoord'].checked = true;
		}
	else 
		{
		document.forms['Lijst'].elements['incasso_akkoord'].checked = false;
		document.forms['Lijst'].elements['incasso_banknummer'].value = '';
		}
	}