// © DO-IT-SO Automatisering Vivaldistraat 18 5216 EL 's-Hertogenbosch 0 31 (0)73 6141495


function MM_preloadImages() { 
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
    } 
  }
}

function MM_swapImgRestore() { 
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() { 
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
    } 
  }
  document.MM_swapImgData = swapArray; //used for restore
}

function selectrembours(v,t,p) {
var h0 = 0,h3 = 11.5, h4 = 12,k;
k = 0;
   if (t.value < 1000) {k = h3} else
   if ((t.value > 1000)||(t.value == 1000)) {
     if (p.value < 500) {k = h4} 
     if ((p.value > 500)||(p.value == 500)) {k = h0}
   } 
v.value = k;
}

function selectbank(v,t,p) {
var h0 = 0,h1 = 7.5, h2 = 7.5,k;
k = 0;
   if (t.value < 1000) {k = h1} else
   if ((t.value > 1000)||(t.value == 1000)) {
     if (p.value < 500) {k = h2} 
     if ((p.value > 500)||(p.value == 500)) {k = h0}
   } 
 v.value = k;
}

function emailcheck( s ) {
var c,f3,f2;
 
  f2 = 0, f3 = 0;
  
   
  for (i=0; i < s.length  ; i++) {
	if ( s.substring ( i, (i+1) ) == "@" )  {
	  f2++;}
  } 
  
  for (i=0; i < s.length  ; i++) {
	if ( s.substring ( i, (i+1) ) == "." )  {
	  f3++;}
  } 
  
  if ((f2 == 0) || (f3 == 0)) {c = 0;}
    
    
  if (c == 0) {
   return ( 0 );
  } else {
   return ( 1 );
  }
}


function f_euro(s){
  var i;
  voorpunt = "";
  napunt = "";
  pos = -1;
  if ( s == "") 
    {
      return("");
	}
  else {
   
    s = s / 2.20371;
    s = s.toString();
      for (i=0; i < s.length; i++) 
  	  { 
         if ( s.substring ( i, (i+1) ) == "." )
		  { 
	         pos = i;
		     break;
		   }
	  }
	  if (pos > -1) 
	  {
	 	  voorpunt = s.substring(0,pos);
                  if (s.substring(0,pos) == "") {voorpunt="0";}  
		  napunt = s.substring(pos+1,pos+3);
	      if (s.substring(pos+2,pos+3) == "")
		    {
		       voorpunt = s.substring(0,pos);
                       if (s.substring(0,pos) == "") {voorpunt="0";}   
		       napunt = s.substring(pos+1,pos+2)+"0";
		    }
	  }
	  else 
	  {
	    voorpunt = s.substring(0,s.length);
            napunt = "00";
	  } 
	  s = voorpunt +","+ napunt;
	  return(s);
    } // else

} // functie




function kikkejan(lava,vkost,tot,a,b,c) {
 lava.value = ReturnNicePrice(a.value);
 vkost.value = ReturnNicePrice(b.value);
 tot.value = ReturnNicePrice(c.value);
}

function geefeuro(lava,vkost,tot,a,b,c) {
 lava.value = f_euro(a.value);
 vkost.value = f_euro(b.value);
 tot.value = f_euro(c.value);
}


products = new Array()

products[1] = new Array()       
products[1][1] = 'Lavendel Olie (10cc)'
products[1][2] = '8.50' //
products[1][3] = '<input name="lavEssentialOil10" onchange="checkit(1,lavEssentialOil10);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[1][4] = '0'
products[1][5] = '50'
products[1][6] = '0'

products[2] = new Array()       
products[2][1] = 'Lavendel Olie (30cc)'
products[2][2] = '22.95' //
products[2][3] = '<input name="lavEssentialOil30" onchange="checkit(2,lavEssentialOil30);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[2][4] = '0'
products[2][5] = '150'
products[2][6] = '0'

products[3] = new Array()       
products[3][1] = 'Lavendel Crème'
products[3][2] = '5.25' //
products[3][3] = '<input name="lavCream" onchange="checkit(3,lavCream);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[3][4] = '0'
products[3][5] = '100'
products[3][6] = '0'

products[4] = new Array()       
products[4][1] = 'Lavendel Zalf'
products[4][2] = '6.25' //
products[4][3] = '<input name="lavSalve" onchange="checkit(4,lavSalve);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[4][4] = '0'
products[4][5] = '100'
products[4][6] = '0'

products[5] = new Array()       
products[5][1] = 'Lavendel Bad Zeep'
products[5][2] = '6.25' //
products[5][3] = '<input name="lavBathSoak" onchange="checkit(5,lavBathSoak);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[5][4] = '0'
products[5][5] = '175'
products[5][6] = '0'

products[6] = new Array()       
products[6][1] = 'Lavendel Body Balsem'
products[6][2] = '7.50' //
products[6][3] = '<input name="lavBodyBalm" onchange="checkit(6,lavBodyBalm);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[6][4] = '0'
products[6][5] = '175'
products[6][6] = '0'

products[7] = new Array()       
products[7][1] = 'Lavendel Spray'
products[7][2] = '6.25' //
products[7][3] = '<input name="lavDew" onchange="checkit(7,lavDew);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[7][4] = '0'
products[7][5] = '200'
products[7][6] = '0'

products[8] = new Array()       
products[8][1] = 'Lavendel Zeep'
products[8][2] = '2.50' //
products[8][3] = '<input name="lavSoap" onchange="checkit(8,lavSoap);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[8][4] = '0'
products[8][5] = '100'
products[8][6] = '0'

products[9] = new Array()       
products[9][1] = 'Lavendel Lippen balsem'
products[9][2] = '3.25' //
products[9][3] = '<input name="lavlip" onchange="checkit(9,lavlip);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[9][4] = '0'
products[9][5] = '100'
products[9][6] = '0'

products[10] = new Array()       
products[10][1] = 'Lavendel Body Lotion'
products[10][2] = '6.50'
products[10][3] = '<input name="lavBodyLotion" onchange="checkit(10,lavBodyLotion);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[10][4] = '0'
products[10][5] = '275'
products[10][6] = '0'

products[11] = new Array()       
products[11][1] = 'Lavendel Hand &amp; Body Wash'
products[11][2] = '7.75' //
products[11][3] = '<input name="lavHandBodyWash" onchange="checkit(11,lavHandBodyWash);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[11][4] = '0'
products[11][5] = '300'
products[11][6] = '0'

products[12] = new Array()       
products[12][1] = 'Lavendel Talk Poeder'
products[12][2] = '4.95'
products[12][3] = '<input name="lavPowder" onchange="checkit(12,lavPowder);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[12][4] = '0'
products[12][5] = '150'
products[12][6] = '0'

products[13] = new Array()       
products[13][1] = 'Pomp voor Lotion/Hand &amp; Body Wash'
products[13][2] = '1.00'
products[13][3] = '<input name="pomp" onchange="checkit(13,pomp);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[13][4] = '0'
products[13][5] = '100'	
products[13][6] = '0'

products[14] = new Array()       
products[14][1] = 'Lavendel Slaapkussentjes'
products[14][2] = '2.50'
products[14][3] = '<input name="slaapkussentjes" onchange="checkit(14,slaapkussentjes);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[14][4] = '0'
products[14][5] = '100'	
products[14][6] = '0'

products[15] = new Array()       
products[15][1] = 'Lavendel Geurzakjes'
products[15][2] = '1.75'
products[15][3] = '<input name="geurzakjes" onchange="checkit(15,geurzakjes);calcAmount(lavAmount);weeghet(totgewicht);total(totaal,lavAmount,vkosten);kikkejan(lavAmount1,vkosten1,totaal1,lavAmount,vkosten,totaal);geefeuro(lavAmount1euro,vkosten1euro,totaal1euro,lavAmount,vkosten,totaal)" type="text" value="0" size="3" maxlength="3">'
products[15][4] = '0'
products[15][5] = '100'	
products[15][6] = '0'


function checkit ( i,s) {

 if (s.value > -1) {
  k = Math.round(s.value);
  alert('Aantal stuks = ' + k);
  products[i][4] = ( k * products[i][2] );
  products[i][6] = ( k * products[i][5] );    
 }
}

function ReturnNicePrice ( s ) {
var ts,i;

  ts = "";
  c  = 0;
     
  for (i=0; i < s.length  ; i++) {
	if ( s.substring ( i, (i+1) ) != "." ) {
	  ts = ts + s.substring ( i, i + 1 );
	  if (c > 0) 
	    c++; 
	} else {
	  ts = ts + ","
	  c++;
	}
  }
  
  if (c == 0) ts = ts + ",00";
  if (c == 1) ts = ts + "00";
  if (c == 2) ts = ts + "0";

  return ( ts );
}



function weeghet(g) {
var k=0; 
  
  for (i=1; i< products.length; i++) {
	l = parseFloat(products[i][6]);
	k = k + l;
  }
  g.value = k;
}




function calcAmount( a ) {
var k,l,ts;

  k = 0;
    
  for (i=1; i< products.length; i++) {
	l = parseFloat(products[i][4]);
	k = k + l;
  }
  
  k = ( k * 100 );
  
  k = Math.round( k );
  
  k = ( k / 100 );
  
  
  ts = k.toString();
   
  a.value = ts;
 
}

function betaal(s,tot) {
var c;
  if ((s == "0,00") && (tot.value < 500)) {c = 0}
  else {c = 1}
      
  if (c == 0) {
   return ( 0 );
  } else {
   return ( 1 );
  }
}
				 
				 
function validate(fm) 
{
  var fout = "";
  var x = 0;
  
  if ((fm.lavAmount.value == "0")||(fm.lavAmount.value == "0,00")) { (fout += "- Geen Producten besteld\n") && (x += 1); }
  if (emailcheck(fm.email.value) == 0) { (fout += "- E-mail\n")&& (x += 1);}
  if (fm.tel.value == "") { (fout += "- Telefoon nummer\n") && (x += 1); }
  if (fm.username.value == "") { (fout += "- Naam\n") && (x += 1); }
  if (fm.address.value == "") { (fout += "- Adres\n") && (x += 1); }
  if (fm.postcode.value == "") { (fout += "- Postcode \n") && (x += 1); }
  if (fm.city.value == "") { (fout += "- Plaats\n") && (x += 1); }
  if (fm.country.value == "XXX") { (fout += "- Land\n") && (x += 1); }
  if (fm.front.value == "select") { (fout += "- Initialen\n") && (x += 1); }
  if (betaal(fm.vkosten1.value,fm.lavAmount) == 0)  { (fout += "- Betalingswijze\n") && (x += 1); }
  
  if (fout != "") 
         
         { if (fm.email.value == "") {fm.email.focus();}
           if (fm.city.value == "") {fm.city.focus();}
		   if (fm.lavAmount.value == "") {fm.lavAmount.focus();}
           if (fm.postcode.value == "") {fm.postcode.focus();}
           if (fm.address.value == "") {fm.address.focus();}
           if (fm.name.value == "") {fm.name.focus();}
           if (fm.front.value == "") {fm.front.focus();}
		   if (fm.country.value == "") {fm.country.focus();}
		   if (fm.tel.value == "") {fm.tel.focus();}
           if (fm.vkosten1.value == "") {fm.vkosten.focus();}
		   if (x == 1) 
             {
             window.alert("De volgende informatie ontbreekt of is onjuist:\n \n" + fout)
             return false;
             }
           
           if (x > 1)
             {
                 window.alert("De volgende informatie ontbreekt of is onjuist:\n \n" + fout)
                 return false;
             }        
         }
}

function total(s,lav,vkost){
var k,i,j,t;
  
  k = 0;
  
  i = parseFloat(lav.value);
  j = parseFloat(vkost.value);
  
  k = i + j;
  k = k.toString();
  //k = ReturnNicePrice(k);  
  s.value = k;
  //lav.value = ReturnNicePrice(lav.value);
  //vkost.value = ReturnNicePrice(vkost.value);
}

