var ThPrice, ThUsage, ThShip, ThSoftw = 0;
var ThInst, ThCurr, ThProd = 1;

var aiSee = new Array("Error: Please reload page",
"aiSee Professional",
"aiSee Academic",
"aiSee Site License 2+",
"aiSee Academic Site License 2+",
"aiSee Site License 11+",
"aiSee Academic Site License 11+",
"aiSee Site License 101+",
"aiSee Academic Site License 101+",
"aiSee Light");

var aiCallC = new Array("Error: Please reload page",
"aiCall for C Professional",
"aiCall for C Site License 2+",
"aiCall for C Site License 11+",
"aiCall for C Light");

var aiCall16x = new Array("Error: Please reload page",
"aiCall for C16x/ST10",
"aiCall for C16x/ST10 Site License 2+");

var aiSeePrices = new Array(0,395,237,296,180,198,128,79,69,395);
var aiCallCPrices = new Array(0,789,592,395,789);
var aiCall16xPrices = new Array(0,1490,1120);

var ArtNrs = new Array(0,1,3,9,10,11,12,13,14,2,0,4,7,8,5,0,6,27,0,17,16,15,28,29,30,0);
var DevVal = new Array(0,1,
1.320,
0.688,
128.3,
1.469,
1.615,
1.795,
8.590,
33.54,
9.222,
9.117,
244.9,
7.947,
1.967,
1.911,
46.81,
52.65,
8.751,
3.866,
1342.6,
4.185,
3.724);
var DevNam = new Array('','EUR ',
'US $',
'GBP ',
'JPY ',
'sFr ',
'CAD ',
'AUD ',
'HKD ',
'RUB ',
'SEK ',
'CNY ',
'HUF ',
'NOK ',
'NZD ',
'SGD ',
'THB ',
'INR ',
'ZAR ',
'BRL ',
'KRW ',
'MYR ',
'PLZ ');

var NatFlg = new Array('','flageu.gif',
'flagus.gif',
'flaguk.gif',
'flagjp.gif',
'flagch.gif',
'flagcan.gif',
'flagaus.gif',
'flaghk.gif',
'flagrus.gif',
'flagswe.gif',
'flagchn.gif',
'flaghun.gif',
'flagnor.gif',
'flagnz.gif',
'flagsgp.gif',
'flagthai.gif',
'flagind.gif',
'flagrsa.gif',
'flagbra.gif',
'flagkor.gif',
'flagmy.gif',
'flagpl.gif');

function ComputePrice()
{
  var NewInst = parseInt(document.Rechner.Inst.value);
  if(isNaN(NewInst) || NewInst<1) {ThInst=1} else {ThInst=NewInst}
  document.Rechner.Inst.value = ThInst;

  ThSoftw = eval(document.Rechner.Product.options[document.Rechner.Product.options.selectedIndex].value);
  ThUsage = eval(document.Rechner.Usage.options[document.Rechner.Usage.options.selectedIndex].value);
  ThShip  = eval(document.Rechner.Ship.options[document.Rechner.Ship.options.selectedIndex].value);
  ThCurr  = eval(document.Rechner.Curr.options[document.Rechner.Curr.options.selectedIndex].value);

  if(ThSoftw == 0)
  {
    if (ThInst==1 && ThShip==1 && ThUsage==0) { ThProd=9 }
    else { if (ThInst== 1) { ThProd=ThUsage+1 }
    else { if (ThInst< 11) { ThProd=ThUsage+3 }
    else { if (ThInst<101) { ThProd=ThUsage+5 }
    else {                   ThProd=ThUsage+7 } } } }
    ThPrice = aiSeePrices[ThProd];
    document.Rechner.License.value = aiSee[ThProd];
    ThPrice = ThInst*ThPrice;

    document.ViewCart.cdman.value = 'noe';
    if (ThShip==0 && ThInst<11)
    {
      ThPrice = ThPrice + 110;
      if (ThProd>1)
      {
        document.ViewCart.cdman.value = 18;
      }
    }
  }
  if(ThSoftw == 1)
  {
    if (ThInst==1 && ThShip==1) { ThProd=4 }
    else { if (ThInst== 1) { ThProd=1 }
    else { if (ThInst< 11) { ThProd=2 }
    else {                   ThProd=3 } } }
    ThPrice = aiCallCPrices[ThProd];
    document.Rechner.License.value = aiCallC[ThProd];
    ThPrice = ThInst*ThPrice;

    document.ViewCart.cdman.value = 'noe';
    if (ThShip==0 && ThInst<11)
    {
      ThPrice = ThPrice + 110;
      if (ThProd>1)
      {
        document.ViewCart.cdman.value = 19;
      }
    }
    ThProd = ThProd+10;
  }
  if(ThSoftw == 2)
  {
    if (ThInst== 1) { ThProd=1 }
    else            { ThProd=2 }
    ThPrice = aiCall16xPrices[ThProd];
    document.Rechner.License.value = aiCall16x[ThProd];
    ThPrice = ThInst*ThPrice;
    document.ViewCart.cdman.value = 'noe';
    ThProd = ThProd+15;
  }
  if(ThSoftw == 3)
  {
    document.Rechner.License.value = 'Upgrade from aiSee 2.1.1x';
    ThPrice = ThInst*159;
    document.ViewCart.cdman.value = 'noe';
    if (ThShip==0)
    {
      ThPrice = ThPrice + 110;
      document.ViewCart.cdman.value = 18;
    }
    ThProd = 19;
  }
  if(ThSoftw == 4)
  {
    document.Rechner.License.value = 'Upgrade from aiSee 2.1.2x/3x';
    ThPrice = ThInst*159;
    document.ViewCart.cdman.value = 'noe';
    if (ThShip==0)
    {
      ThPrice = ThPrice + 110;
      document.ViewCart.cdman.value = 18;
    }
    ThProd = 20;
  }
  if(ThSoftw == 5)
  {
    document.Rechner.License.value = 'Upgrade from aiSee 2.1.4x';
    ThPrice = ThInst*139;
    document.ViewCart.cdman.value = 'noe';
    if (ThShip==0)
    {
      ThPrice = ThPrice + 110;
      document.ViewCart.cdman.value = 18;
    }
    ThProd = 21;
  }
  if(ThSoftw == 6)
  {
    document.Rechner.License.value = 'aiCall for PowerPC';
    ThPrice = ThInst*1490;
    document.ViewCart.cdman.value = 'noe';
    ThProd = 22;
  }
  if(ThSoftw == 7)
  {
    document.Rechner.License.value = 'aiCall for HC12';
    ThPrice = ThInst*1490;
    document.ViewCart.cdman.value = 'noe';
    ThProd = 23;
  }
  if(ThSoftw == 8)
  {
    document.Rechner.License.value = 'Upgrade from aiSee 2.1.5x/6x';
    ThPrice = ThInst*119;
    document.ViewCart.cdman.value = 'noe';
    if (ThShip==0)
    {
      ThPrice = ThPrice + 110;
      document.ViewCart.cdman.value = 18;
    }
    ThProd = 24;
  }
  if (ThCurr==1)
  {
    ThPrice = 'EUR ' + ThPrice + '*';
  }
  else
  {
    ThDvVal = DevVal[ThCurr];
    ThDvNam = DevNam[ThCurr];
    ThPrice = Math.ceil(ThPrice * ThDvVal);
    ThPrice = '~' + ThDvNam + ThPrice + '**';
  }
  ThPrice = 'Total: ' + ThPrice;
  document.Rechner.Result.value = ThPrice;
  document.ViewCart.newart.value = ArtNrs[ThProd];
  document.ViewCart.inst.value = ThInst;
  document.images['Cflag'].src = NatFlg[ThCurr];
}

