var prijsPerLand = new Array();

function Land ( land, prijs )
{
  this.land = land;
  this.prijs = prijs;
}



function initLandAantalPrijs ( )
{
  for(i = 0; i < prijsPerLand.length; i++)
    document.abonnementForm.countryJS.options[i] = new Option(prijsPerLand[i].land, i, true, true);
  document.abonnementForm.countryJS.selectedIndex = 0;
  updatePrijs();
}

function updatePrijs ( )
{
  var aantal = 0;
  var land = 0;
  aantal = parseInt(document.abonnementForm.aantal.value);
  land = parseInt(document.abonnementForm.countryJS.value);
  var btw = 1;
  if (land == 0 || document.abonnementForm.btw.value == '') btw = 1.06; 
  document.abonnementForm.prijs.value = "" + Math.round(btw * aantal * prijsPerLand[document.abonnementForm.countryJS.selectedIndex].prijs * 100) / 100;
  document.abonnementForm.country.value = prijsPerLand[document.abonnementForm.countryJS.selectedIndex].land;
}

function eventHandler ( evt )
{
  var iKey = document.layers ? evt.which : document.all ? event.keyCode : evt.keyCode;
  if (iKey == 13 && document.abonnementForm != null)
    sendmail();
  return true;
}
document.onkeydown = eventHandler;

function checkFields() {

  if (document.abonnementForm.company.value=='') {
    alert("Gelieve de naam van uw bedrijf in te vullen.")
    document.abonnementForm.company.focus();
    return(false)
  }
  if (document.abonnementForm.name.value == '') {
    alert("Gelieve uw voornaam in te vullen.")
    document.abonnementForm.name.focus();
    return(false)
  }
  if (document.abonnementForm.lastname.value == '') {
    alert("Gelieve uw naam in te vullen.")
    document.abonnementForm.lastname.focus();
    return(false)
  }
  if (document.abonnementForm.street.value == '') {
    alert("Gelieve uw adres in te vullen (straat).")
    document.abonnementForm.street.focus();
    return(false)
  }
  if (document.abonnementForm.number.value == '') {
    alert("Gelieve uw adres in te vullen (huisnummer).")
    document.abonnementForm.number.focus();
    return(false)
  }
  if (document.abonnementForm.zipcode.value == '') {
    alert("Gelieve uw adres in te vullen (postcode).")
    document.abonnementForm.zipcode.focus();
    return(false)
  }
  if (document.abonnementForm.community.value == '') {
    alert("Gelieve uw adres in te vullen (gemeente).")
    document.abonnementForm.community.focus();
    return(false)
  }
  if (document.abonnementForm.email.value == '') {
    alert("Gelieve uw email adres in te vullen.")
    document.abonnementForm.email.focus();
    return(false)
  }
  return(true)
}

function submitForm()
{
  document.abonnementForm.country.value = prijsPerLand[document.abonnementForm.countryJS.selectedIndex].land;
  if (checkFields()) {
    document.abonnementForm.submit();
  }
}

function showOgoneInfo(context)
{
  var height = 270;
  var width  = 530;
  var newWindow = window.open(context + "/ogone/ogone_info.jsp",
              "OgoneInfo",
              "height=" + height + ",width=" + width + ",screenX=" + (screen.availWidth/2 -(width/2)) +",left=" + (screen.availWidth/2 -(width/2)) +",screenY=" + (screen.availHeight/2 - (height/2)) +",top=" + (screen.availHeight/2 - (height/2)) +",alwaysLowered=0,alwaysRaised=1,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=no,menubar=0,scrollbars=no,resizable=no,status=no,titlebar=0,toolbar=0,z-lock=0");

}

function showOgonePrintConfirmation(context, amount, currency)
{
  var height = 260;
  var width  = 530;
  var newWindow = window.open(context + "/ogone/ogone_confirm_print.jsp?orderID=" + escape(document.dataForm.orderID.value) + "&amount=" + amount + "&currency=" + currency,
              "OgonePrintConfirmation",
              "height=" + height + ",width=" + width + ",screenX=" + (screen.availWidth/2 -(width/2)) +",left=" + (screen.availWidth/2 -(width/2)) +",screenY=" + (screen.availHeight/2 - (height/2)) +",top=" + (screen.availHeight/2 - (height/2)) +",alwaysLowered=0,alwaysRaised=1,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=no,menubar=0,scrollbars=no,resizable=no,status=no,titlebar=0,toolbar=0,z-lock=0");
}

function updateWinkelPrijzen () {

for(i=0; i<document.abonnementForm.elements.length; i++)
{
  var prijs = Math.round(prijsPerLand[i].prijs*100)/100; 
  if (i == 0) prijs = Math.round(prijsPerLand[i].prijs*100*1.06)/100; 
  document.abonnementForm.elements[i].value = prijs; 
}


}