<!--
/*
USAGE:
Just put this script-block where you want the current date. 
You may replace the text between quotes to set other month or day names.  
*/

  var now = new Date();
  
  // Array list of days.
  var days = new Array('zondag','maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag');
  
  // Calculate the number of the current day in the week.
  var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
  
  // Array list of months.
  var months = new Array('januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december');
  
  // Calculate four digit year.
  function fourdigits(number)	{
  	return (number < 1000) ? number + 1900 : number;
  								}
  
  // Join it all together
  today =  days[now.getDay()] + ", " +
                date + " " +			  
  			  		months[now.getMonth()] + " " +
                                 (fourdigits(now.getYear())) ;
function Showoverzicht()
{
	if( Form1_Validator(document.forms['Form1'])!= false)
	{

		document.getElementById('bestellijst').style.display = "none";

		document.getElementById('mijngeheim').style.display = "block";
		document.getElementById('verstuurmaar').style.display = "block";


		var objDocument = window.document.forms['Form1'];
		var sBodyRekening = '<table cellspacing="1" cellpadding="0" border="0">';

		sBodyRekening = sBodyRekening + '<tr><td><table cellspacing="1" width="576" cellpadding="0" border="0">';
		sBodyRekening = sBodyRekening + '<tr>';
		sBodyRekening = sBodyRekening + '<td><strong>Bestelbon en Factuur</strong></td>';
		sBodyRekening = sBodyRekening + '<td align=right style="margin-left: 150px;">' + today +'</td></tr>';
		sBodyRekening = sBodyRekening + '<tr>';
		sBodyRekening = sBodyRekening + '<td valign="top">Factuurnummer:</td>';
		sBodyRekening = sBodyRekening + '<td valign="top">' + objDocument.factuurnummer.value  +'<br>&nbsp;</td>';
		sBodyRekening = sBodyRekening + '</tr>';
		sBodyRekening = sBodyRekening + '<tr>';
		sBodyRekening = sBodyRekening + '<td><strong>Afleveradres</strong></td>';
		sBodyRekening = sBodyRekening + '<td></td></tr>';
		sBodyRekening = sBodyRekening + '<tr>';
		sBodyRekening = sBodyRekening + '<td colspan="2">'+ objDocument.bedrijfsnaam.value  +'</td>';
		sBodyRekening = sBodyRekening + '</tr>';
		sBodyRekening = sBodyRekening + '<tr>';

		
		if (document.forms['Form1'].geslacht[0].checked==true) {
		
		sBodyRekening = sBodyRekening + '<td>' + document.forms['Form1'].geslacht[0].value;
			
		
		} else {
		
		sBodyRekening = sBodyRekening + '<td>' + document.forms['Form1'].geslacht[1].value;
		
		}
		

		sBodyRekening = sBodyRekening + '. ' + objDocument.naam.value + '</td>';
		sBodyRekening = sBodyRekening + '</tr>';
		sBodyRekening = sBodyRekening + '<tr>';
		sBodyRekening = sBodyRekening + '<td colspan="2">'+ objDocument.adres.value  +'</td>';
		sBodyRekening = sBodyRekening + '</tr>';
		sBodyRekening = sBodyRekening + '<tr>';
		sBodyRekening = sBodyRekening + '<td>' + objDocument.postcode.value  +' &nbsp; ' + objDocument.plaatsnaam.value +  '</td>';
		sBodyRekening = sBodyRekening + '</tr>';
		sBodyRekening = sBodyRekening + '<tr>';
		
		sBodyRekening = sBodyRekening + '</tr>';
		sBodyRekening = sBodyRekening + '</td></tr></table>';
		
		sBodyRekening = sBodyRekening + '<tr><td>&nbsp;</td></tr><tr>';
		sBodyRekening = sBodyRekening + '<td><table cellspacing="1" cellpadding="0" border="0">';
		sBodyRekening = sBodyRekening + '<tr><td colspan="4"><hr></td></tr>';
		sBodyRekening = sBodyRekening + '<tr><td><b>Bestelling</b><br><b>Omschrijving</b></td>';
		sBodyRekening = sBodyRekening + '<td valign="bottom" align="center"><b>Aantal</b></td>';
		sBodyRekening = sBodyRekening + '<td valign="bottom"  align="right"><b>Prijs</b></td>';
		sBodyRekening = sBodyRekening + '<td valign="bottom"  width="80" align="right"><b>Totaal</b></td>';
		sBodyRekening = sBodyRekening + '</tr>';

		sBodyRekening = sBodyRekening + '<tr><td colspan="4"><hr></td></tr>';


		var iTotaalBedrag = 0;
		var iTotaalBedragInclBtw = 0;
    var iTotaalBedragNatuursteen = 0;
    var iKortingNatuursteen90 = 0;
    var iTotaalBedragNaKorting;

		for( var i = 0; i < objDocument.elements.length; i++)
		{

			if(objDocument.elements[i].id.substring(0,15) == "naam_publicatie")
			{
				if(objDocument.elements[i].type == "text")
				{
					if(!isNaN(objDocument.elements[i].value)  )
					{
						if(objDocument.elements[i].value != '')
						{

							if ( document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value !=0)
							{
								iTotaalBedrag = iTotaalBedrag + (objDocument.elements[i].value * (document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value));
								//iTotaalBedrag = BRS(iTotaalBedrag.toString());
                
                // bestaat de korting property?
                if (document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).korting)
                { // en staat deze op 'ja' 
                	if (document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).korting == 'ja')
                	{
                	// BASIS pakket Natuursteen-90 en
                  // UPDATE pakket Natuursteen-90

									iTotaalBedragNatuursteen = iTotaalBedragNatuursteen + (objDocument.elements[i].value * (document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value));
                  }
                }    
                
							}
							sBodyRekening = sBodyRekening + '<tr>';
							sBodyRekening = sBodyRekening + '<td align="left">' + objDocument.elements[i].name.toString() + '</td>';
							sBodyRekening = sBodyRekening + '<td align="center">' + objDocument.elements[i].value.toString() + '</td>';
							sBodyRekening = sBodyRekening + '<td align="right">&euro; ' + number2string(document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value,2) + '</td>';
							sBodyRekening = sBodyRekening + '<td align="right">&euro; ' + number2string(objDocument.elements[i].value * (document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value),2) + '</td>';
							sBodyRekening = sBodyRekening + '</tr>';
						}
					}
				}

				if(objDocument.elements[i].type == "checkbox" )
				{

					if(objDocument.elements[i].checked)
					{
						sBodyRekening = sBodyRekening + '<tr>';
						sBodyRekening = sBodyRekening + '<td align="left">' + objDocument.elements[i].name.toString() + '</td>';
						sBodyRekening = sBodyRekening + '<td align="center">1</td>';
						sBodyRekening = sBodyRekening + '<td align="right">&euro; ' + number2string(document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value,2) + '</td>';
						// hier stond '1 stuk'
						sBodyRekening = sBodyRekening + '<td align="right">&euro; ' + number2string(document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value,2) + '</td>';
						sBodyRekening = sBodyRekening + '</tr>';

						if ( document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value !=0)
						{
							iTotaalBedrag = iTotaalBedrag + (document.getElementById('prijs_publicatie' + objDocument.elements[i].id.substring(15,17)).value);
							//iTotaalBedrag = BRS(iTotaalBedrag.toString());
						}
					}
				}
			}
		}

    iTotaalBedragNaKorting = iTotaalBedrag;
		if (document.getElementById('korting').checked == true)
    {
    	iKortingNatuursteen90 = 0.15 * iTotaalBedragNatuursteen;
      iTotaalBedragNaKorting = iTotaalBedragNaKorting - iKortingNatuursteen90;
    }
    
		var iBtwBedrag;
		iBtwBedrag = (iTotaalBedragNaKorting * 0.19);

		iTotaalBedragInclBtw = (iTotaalBedragNaKorting * 1.00) + (iBtwBedrag * 1.00);
		
		if (document.getElementById('TotaalBedragInclBtw'))
			document.getElementById('TotaalBedragInclBtw').value = number2string(iTotaalBedragInclBtw,2); // meegeven aan formulier
    
    if (iKortingNatuursteen90 > 0)
    {
  		sBodyRekening = sBodyRekening + '<tr><td>&nbsp;</td></tr><tr>';
  		sBodyRekening = sBodyRekening + '<td></td>';
  		sBodyRekening = sBodyRekening + '<td></td>';
  		sBodyRekening = sBodyRekening + '<td nowrap>Subtotaal : </td>';
  		sBodyRekening = sBodyRekening + '<td align="right">&euro; '+ number2string(iTotaalBedrag,2) +'</td>';
  		sBodyRekening = sBodyRekening + '</tr>';
  		sBodyRekening = sBodyRekening + '<tr>';
  		sBodyRekening = sBodyRekening + '<td></td>';
  		sBodyRekening = sBodyRekening + '<td></td>';
  		sBodyRekening = sBodyRekening + '<td nowrap>Korting (Natuursteen-90) : </td>';
  		sBodyRekening = sBodyRekening + '<td align="right">&euro; -'+ number2string(iKortingNatuursteen90,2) +'</td>';
  		sBodyRekening = sBodyRekening + '</tr>';
    }
    
		sBodyRekening = sBodyRekening + '<tr><td>&nbsp;</td></tr><tr>';
		sBodyRekening = sBodyRekening + '<td></td>';
		sBodyRekening = sBodyRekening + '<td></td>';
		sBodyRekening = sBodyRekening + '<td nowrap>Subtotaal: </td>';
		sBodyRekening = sBodyRekening + '<td align="right">&euro; '+ number2string(iTotaalBedragNaKorting,2) +'</td>';
		sBodyRekening = sBodyRekening + '</tr>';

		sBodyRekening = sBodyRekening + '<tr>';
		sBodyRekening = sBodyRekening + '<td></td>';
		sBodyRekening = sBodyRekening + '<td></td>';
		sBodyRekening = sBodyRekening + '<td nowrap>BTW(19%): </td>';
		sBodyRekening = sBodyRekening + '<td align="right">&euro; '+ number2string(iBtwBedrag,2) +'</td>';
		sBodyRekening = sBodyRekening + '</tr>';

		sBodyRekening = sBodyRekening + '<tr>';
		sBodyRekening = sBodyRekening + '<td></td>';
		sBodyRekening = sBodyRekening + '<td></td>';
		sBodyRekening = sBodyRekening + '<td nowrap><strong>Totaal (incl. BTW en verzendkosten) : </strong></td>';
		sBodyRekening = sBodyRekening + '<td align="right">&euro; '+ number2string(iTotaalBedragInclBtw,2) +'</td>';
		sBodyRekening = sBodyRekening + '</tr>';
		sBodyRekening = sBodyRekening + '</table></td></tr><tr><td>';

		sBodyRekening = sBodyRekening + 'Van BESTELLEN naar UITLEVEREN<br><br>';
		sBodyRekening = sBodyRekening + 'STAP 1: controleer uw bestelling en druk op de knop terug om eventuele correcties aan te brengen.<br><br>';
		sBodyRekening = sBodyRekening + 'STAP 2: druk op de knop afdrukken als u een print wil van deze factuur voor uw eigen administratie. <br><br>';
		sBodyRekening = sBodyRekening + 'STAP 3: maak het totaal bedrag over naar:<br>';
		sBodyRekening = sBodyRekening + '<blockquote>Centrum Natuursteen te Utrecht <br>Giro 96 88 552<br>ING bank 66 76 08 443<br>Vermeld uw (BEDRIJFS)NAAM, ADRES en';
		sBodyRekening = sBodyRekening + ' FACTUURNUMMER:'+objDocument.factuurnummer.value+'</blockquote><br>';
		sBodyRekening = sBodyRekening + 'STAP 4: druk op de knop verzenden om uw bestelling te plaatsen.<br><br>';
		sBodyRekening = sBodyRekening + 'STAP 5: zodra het bedrag op onze rekening staat bijgeschreven, leveren wij uw bestelling zo spoedig mogelijk uit. Indien het totaal bedrag nul is, leveren wij direct uit.<br><br>';
		
		sBodyRekening = sBodyRekening + '</td></tr></table>';

		document.getElementById('mijngeheim').innerHTML = sBodyRekening;

	}
}

//
  // Function    : number2string(f[, iAantalDecimalen])
  // Description : converteer een number naar een string
  // Arguments   : f : number - moet een number zijn, hierop wordt niet gecheckt
  //               in range [-100000..100000] - de functie is enkel getest voor deze getallen maar werkt daarbuiten misschien ook 
  //               iAantalDecimalen : integer - optioneel; moet een integer >= 0 zijn, hierop wordt niet gecheckt
  //                   argument mag ook weggelaten worden, in dat geval wordt het number geconverteerd 
  //                   naar een zo kort mogelijke string dus zo min mogelijk cijfers achter de komma als nodig is
  //                   In range [0..4] - de functie is enkel getest voor deze getallen maar werkt daarbuiten misschien ook  
  //                                              
  function number2string(f, iAantalDecimalen)
  {
    if (arguments.length < 2) iAantalDecimalen = 7;
    var s = (Math.round(Math.abs(f) * Math.pow(10, iAantalDecimalen))).toString();
    var bMinErvoor = ((s!="0") && (f<0.0)) 
    while (s.length <= iAantalDecimalen)
      s = "0" + s;
    if (bMinErvoor) s = "-" + s;
    var t = s.substring(0, s.length-iAantalDecimalen);
    if (iAantalDecimalen > 0) 
      t = t + "." + s.substring(s.length-iAantalDecimalen);
    if (arguments.length < 2)
    {
      while (t.substr(t.length-1,1) == "0")
        t = t.substr(0, t.length - 1);
      if (t.substr(t.length-1,1) == ".")          
        t = t.substr(0, t.length - 1);
    }
    return t;
  }


function BRS(Str)
{

  var L = Str.length;
  var P = Str.indexOf('.');
  var Q;
  if (P<0) return Str + ".00"; // was integer
  if (P==L-2) return Str + "0"; // was tenths
  if (P==L-3) return Str; // was hundredths
  if (Str.charAt(0)=="-") return "-" + BRS(Str.substring(1)) // NEG
  Q = Str.substring(P+3); // tail
  if (Q<"5") return Str.substring(0, P+3);
  if (Q>"5") return BRS(String(0.0125 + +Str.substring(0, P+3)));
  // past here, a Bankers' decision is needed
  //Q = Str.charCodeAt(P+2) % 2  ? +0.001 : -0.001
  return BRS(String(Q + +Str));
}

function Herzien()
{
		document.getElementById('bestellijst').style.display = "block";
		document.getElementById('mijngeheim').style.display = "none";
		document.getElementById('verstuurmaar').style.display = "none";
}




