function toggle_address() {
	 var div = document.getElementById('address');
	 var radio = document.getElementById('order_radio');
	 div.style.display = radio.checked ? 'none' : 'block';
}

function insertAction() {
  //var form = document.getElementById('order_form');
  //form.amount_lic_en_de.value = form.amount_en_de.value - form.amount_base_en_de.value*5
  //form.amount_lic_fr_de.value = form.amount_fr_de.value - form.amount_base_fr_de.value*5
  document.order_form.amount_lic_en_de.value = document.order_form.amount_en_de.value - document.order_form.amount_base_en_de.value*5
  document.order_form.amount_lic_fr_de.value = document.order_form.amount_fr_de.value - document.order_form.amount_base_fr_de.value*5
  if (document.order_form.todo[0].checked) {
    if ((document.order_form.amount_base_en_de.value == 0) && (document.order_form.amount_base_fr_de.value == 0)) {
	alert('Sie haben kein Basispaket ausgewählt. Die Bestellung kann so nicht abgeschickt werden!');
	return false;
    }
  } else {
    /*
    form.target.value = "https://shop.linguatec.net/cgi-bin/netinfo.pl";
    form.action = "https://shop.linguatec.net/cgi-bin/confirm.pl";
    form.submit();
    */
  }
  return true;
}

var novat_base_pts = 671.43;
var novat_plus_pts = 83.19;
novat = new Array();
novat['en_de'] = new Array();
novat['en_de'][0] = 83.19;
novat['en_de'][1] = 83.19;
novat['en_de'][2] = 83.19;
novat['en_de'][3] = 83.19;
novat['fr_de'] = new Array();
novat['fr_de'][0] = 83.19;
novat['fr_de'][1] = 83.19;
novat['fr_de'][2] = 83.19;
novat['fr_de'][3] = 83.19;
var novat_biz = 33.63;
novat['en_biz'] = new Array();
novat['en_biz'][0] = 33.63;
novat['en_biz'][1] = 29.31;
novat['en_biz'][2] = 25.86;
novat['en_biz'][3] = 24.14;
var novat_kfz = 102.58;
novat['en_kfz'] = new Array();
novat['en_kfz'][0] = 85.34;
novat['en_kfz'][1] = 85.34;
novat['en_kfz'][2] = 85.34;
novat['en_kfz'][3] = 85.34;
var novat_med = 102.58;
novat['en_med'] = new Array();
novat['en_med'][0] = 85.34;
novat['en_med'][1] = 85.34;
novat['en_med'][2] = 85.34;
novat['en_med'][3] = 85.34;

var vat_base_pts = 799.00;
var vat_plus_pts = 99.00;
vat = new Array();
vat['en_de'] = new Array();
vat['en_de'][0] = 99.00;
vat['en_de'][1] = 99.00;
vat['en_de'][2] = 99.00;
vat['en_de'][3] = 99.00;
vat['fr_de'] = new Array();
vat['fr_de'][0] = 99.00;
vat['fr_de'][1] = 99.00;
vat['fr_de'][2] = 99.00;
vat['fr_de'][3] = 99.00;
var vat_biz = 39.00;
vat['en_biz'] = new Array();
vat['en_biz'][0] = 39.00;
vat['en_biz'][1] = 34.00;
vat['en_biz'][2] = 30.00;
vat['en_biz'][3] = 28.00;
var vat_kfz = 119.00;
vat['en_kfz'] = new Array();
vat['en_kfz'][0] = 99.00;
vat['en_kfz'][1] = 99.00;
vat['en_kfz'][2] = 99.00;
vat['en_kfz'][3] = 99.00;
var vat_med = 119.00;
vat['en_med'] = new Array();
vat['en_med'][0] = 99.00;
vat['en_med'][1] = 99.00;
vat['en_med'][2] = 99.00;
vat['en_med'][3] = 99.00;
var en_base = 0;

function runde(x, n) {
  if (n < 1 || n > 14) return false;
  var e = Math.pow(10, n);
  var k = (Math.round(x * e) / e).toString();
  if (k.indexOf('.') == -1) k += '.';
  k += e.toString().substring(1);
  return k.substring(0, k.indexOf('.') + n+1);
}

function browser(id){
  var nn4 = (document.layers) ? true : false
  var ie = (document.all) ? true : false
  var dom = (document.getElementById && !document.all) ? true : false
  if(nn4) {
  path = document.layers[id]
  }
  else if(ie) {
  path = document.all[id]
  }
  else {
  path = document.getElementById(id)
  }
return path  //return the path to the css layer depending on which browser is looking at the page
}

function init() {
  changeInput('en_de');
  changeInput('fr_de');
  changeInput('en_biz');
  changeInput('en_med');
  changeInput('en_kfz');
}

//document.onLoad = init();

function getPriceVAT(field, amount) {
    var index = 0;
    if (amount > 500) {
      index = 3;
    } else if (amount > 200) {
      index = 2;
    } else if (amount >100) {
      index = 1;
    }
    return vat[field][index];
}

function getPriceNOVAT(field, amount) {
    var index = 0;
    if (amount > 500) {
      index = 3;
    } else if (amount > 200) {
      index = 2;
    } else if (amount > 100) {
      index = 1;
    }
    return novat[field][index];
}

function changeInput(field) {
  layer = browser(field);
  if ((document.order_form.amount_en_de.value < 5) && (document.order_form.amount_fr_de.value < 5)) {
	//alert('Sie brauchen zunächst mindestens ein Basispaket!');
	alert('Sie brauchen zunächst mindestens ein Basispaket!');
        layer_amnt = browser('amount_'+field);
        layer.innerHTML = '0.00 €';
        layer_amnt.value = '0';
        return;
  }
  if (field == 'en_de') {
    if (isNaN(parseInt(document.order_form.amount_fr_de.value))) document.order_form.amount_fr_de.value = 0;
    amount = parseInt(document.order_form.amount_en_de.value) + document.order_form.amount_fr_de.value;
    price_base = getPriceNOVAT(field,amount);
    price_base_vat = getPriceVAT(field,amount);
    document.order_form.price_eur_lic_en_de.value = price_base_vat;
    document.order_form.price_eur_lic_fr_de.value = price_base_vat;
    if (document.order_form.amount_en_de.value > 4) {
      price = novat_base_pts;
      price = price + (parseInt(document.order_form.amount_en_de.value) - 5) * price_base;
      document.order_form.amount_base_en_de.value = 1;
      en_base = 1;
    } else {
      document.order_form.amount_base_en_de.value = 0;
      en_base = 0;
      price = parseInt(document.order_form.amount_en_de.value) * price_base;
    }
    layer.innerHTML = runde(price,2)+' €';
  }
  if (field == 'fr_de') {
    amount = parseInt(document.order_form.amount_en_de.value)+parseInt(document.order_form.amount_fr_de.value);
    price_base = getPriceNOVAT(field,amount);
    price_base_vat = getPriceVAT(field,amount);
    document.order_form.price_eur_lic_en_de.value = price_base_vat;
    document.order_form.price_eur_lic_fr_de.value = price_base_vat;
      if ((amount > 4) && (en_base == 0)) {
        price = novat_base_pts;
        price = price + (parseInt(document.order_form.amount_fr_de.value) - 5) * price_base;
        document.order_form.amount_base_fr_de.value = 1;
      } else {
        document.order_form.amount_base_fr_de.value = 0;
        price = parseInt(document.order_form.amount_fr_de.value) * price_base;
	}
      layer.innerHTML = runde(price,2)+' €';
  }
  //en_amnt = parseInt(document.order_form.amount_en_de.value);
  if (field == 'en_biz') {
    biz_amnt = parseInt(document.order_form.amount_en_biz.value);
    price_base = getPriceNOVAT(field,biz_amnt);
    price_base_vat = getPriceVAT(field,biz_amnt);
    document.order_form.price_eur_en_biz.value = price_base_vat;
    price =  biz_amnt * price_base;
    layer.innerHTML = runde(price,2)+' €';
    //if (biz_amnt > en_amnt) {
	//alert('Vorsicht: Sie haben mehr Lizenzen für das Add-On als Basislizenzen ausgewählt!');
    //}
  }
  if (field == 'en_kfz') {
    kfz_amnt = parseInt(document.order_form.amount_en_kfz.value);
    price_base = getPriceNOVAT(field,kfz_amnt);
    price_base_vat = getPriceVAT(field,kfz_amnt);
    document.order_form.price_eur_en_kfz.value = price_base_vat;
    price = kfz_amnt * price_base;
    layer.innerHTML = runde(price,2)+' €';
    //if (kfz_amnt > en_amnt) {
	//alert('Vorsicht: Sie haben mehr Lizenzen für das Add-On als Basislizenzen ausgewählt!');
    //}
  }
  if (field == 'en_med') {
    med_amnt = parseInt(document.order_form.amount_en_med.value);
    price_base = getPriceNOVAT(field,med_amnt);
    price_base_vat = getPriceVAT(field,med_amnt);
    document.order_form.price_eur_en_med.value = price_base_vat;
    price = med_amnt * price_base;
    layer.innerHTML = runde(price,2)+' €';
    //if (med_amnt > en_amnt) {
	//alert('Vorsicht: Sie haben mehr Lizenzen für das Add-On als Basislizenzen ausgewählt!');
    //}
  }
  priceNovat = allNovat();
  priceVat = allVat();
  Vat = priceVat - priceNovat;
  layer_novat = browser('price_novat');
  layer_vat = browser('vat');
  layer_priceall = browser('price_all');
  layer_novat.innerHTML = runde(priceNovat,2)+' €';
  layer_vat.innerHTML = runde(Vat,2)+' €';
  layer_priceall.innerHTML = runde(priceVat,2)+' €';
}

function allNovat () {
    price = 0;
    en_de_amnt = parseInt(document.order_form.amount_en_de.value);
    fr_de_amnt = parseInt(document.order_form.amount_fr_de.value);
    if (isNaN(fr_de_amnt)) fr_de_amnt = 0;
    en_biz_amnt = parseInt(document.order_form.amount_en_biz.value);
    en_kfz_amnt = parseInt(document.order_form.amount_en_kfz.value);
    en_med_amnt = parseInt(document.order_form.amount_en_med.value);
    novat_plus_pts = getPriceNOVAT('en_de',en_de_amnt+fr_de_amnt);
    novat_biz = getPriceNOVAT('en_biz',en_biz_amnt);
    novat_kfz = getPriceNOVAT('en_kfz',en_kfz_amnt);
    novat_med = getPriceNOVAT('en_med',en_med_amnt);
    if (document.order_form.amount_en_de.value > 4) {
      price += novat_base_pts;
      price += (document.order_form.amount_en_de.value - 5) * novat_plus_pts;
    } else {
      price += document.order_form.amount_en_de.value * novat_plus_pts;
    }
    if ((document.order_form.amount_fr_de.value > 4) && (en_base == 0)) {
      price += novat_base_pts;
      price += (document.order_form.amount_fr_de.value - 5) * novat_plus_pts;
    } else {
      price += document.order_form.amount_fr_de.value * novat_plus_pts;
    }
    price += en_biz_amnt * novat_biz;
    price += en_kfz_amnt * novat_kfz;
    price += en_med_amnt * novat_med;
    return price;
}

function allVat () {
    price = 0;
    en_de_amnt = parseInt(document.order_form.amount_en_de.value);
    fr_de_amnt = parseInt(document.order_form.amount_fr_de.value);
    en_biz_amnt = parseInt(document.order_form.amount_en_biz.value);
    en_kfz_amnt = parseInt(document.order_form.amount_en_kfz.value);
    en_med_amnt = parseInt(document.order_form.amount_en_med.value);
    vat_plus_pts = getPriceVAT('en_de',en_de_amnt+fr_de_amnt);
    vat_biz = getPriceVAT('en_biz',en_biz_amnt);
    vat_kfz = getPriceVAT('en_kfz',en_kfz_amnt);
    vat_med = getPriceVAT('en_med',en_med_amnt);
    if (document.order_form.amount_en_de.value > 4) {
      price += vat_base_pts;
      price += (document.order_form.amount_en_de.value - 5) * vat_plus_pts;
    } else {
      price += document.order_form.amount_en_de.value * vat_plus_pts;
    }
    if ((document.order_form.amount_fr_de.value > 4) && (en_base == 0)) {
      price += vat_base_pts;
      price += (document.order_form.amount_fr_de.value - 5) * vat_plus_pts;
    } else {
      price += document.order_form.amount_fr_de.value * vat_plus_pts;
    }
    price += en_biz_amnt * vat_biz;
    price += en_kfz_amnt * vat_kfz;
    price += en_med_amnt * vat_med;
    return price;
}

function popup() {
  window.open('prices_net','_blank','height=400,width=600,left=150,top=20,status=no,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=1')
}