//---------------------------------------------------------------------
// simple orderform system (C)2005 Sichemsoft V.o.F.
// product constants: product.js
// Based of free JavaScript snippets provided by http://javascriptsource.com
//---------------------------------------------------------------------

var BTW      =19;   // sales tax percentage
var HANDLING = 9;   // postage and handling in euro
var DISCOUNT =40;   // nonprofit discount percentage
var STUDENT  =80;   // student discount percentage
var ACTION   = 0;   // action discount percentage (for =0 action is left out)

var NL       = 0;   // dutch
var UK       = 1;   // english

var XY = [ "nl", "uk" ];

//---------------------------------------------------------------------

// products:
var numberOfProducts = 9;
var productNames = new Array(
    "StruktoGraaf",
    "StruktoGraafUpgrade",
    "StruktoGraafNet",
    "StruktoGraafNetUpgrade",
    "StruktoGraafCombi",
    "StruktoPas",
    "StruktoGraafPas",
    "StruktoGraafPasNet",
    "StruktoGraafPasCombi"
);
var productPrices = [
    84,
    25,
    399,
    115,
    450,
    49,
    115,
    425,
    470
];
var productCaptions = [
[ // NL
    "StruktoGraaf 4.0 normaal (werkt alleen standalone)",
    "StruktoGraaf 4.0 normaal upgrade",
    "StruktoGraaf 4.0 netwerk (werkt alleen via netwerk)",
    "StruktoGraaf 4.0 netwerk upgrade",
    "StruktoGraaf 4.0 normaal + netwerk",
    "StruktoPas 1.0 (heeft StruktoGraaf 4.0 nodig)",
    "StruktoPas 1.0 + StruktoGraaf 4.0 normaal",
    "StruktoPas 1.0 + StruktoGraaf 4.0 netwerk",    
    "StruktoPas 1.0 + StruktoGraaf 4.0 normaal + netwerk",    
],
[ // UK
    "StruktoGraaf 4.0 normal (only for standalone use)",
    "StruktoGraaf 4.0 normal upgrade",
    "StruktoGraaf 4.0 network (only for network use)",
    "StruktoGraaf 4.0 network upgrade",
    "StruktoGraaf 4.0 normal + network",
    "StruktoPas 1.0 (needs StruktoGraaf 4.0)",
    "StruktoPas 1.0 + StruktoGraaf 4.0 normal",
    "StruktoPas 1.0 + StruktoGraaf 4.0 network",    
    "StruktoPas 1.0 + StruktoGraaf 4.0 normal + network",    
]];

//---------------------------------------------------------------------

function FormatCurrency(num)
{
    if (isNaN(num))
	{ 
		num="0";
    }
    var sign =(num==(num=Math.abs(num)));
    num  =Math.floor(num*100+0.50000000001);
	var cents=num%100;
	num  =Math.floor(num/100).toString();
	if (cents<10)
	{
	    cents="0"+cents;
    }
    return (((sign)?'':'-') + num + '.' + cents);
}

//---------------------------------------------------------------------

function LinearSearch(theArray, key)
{
    for (var element in theArray)
    {
        if (theArray[element]==key)
        {
            return element;
        }
    }
    return -1;
}

//---------------------------------------------------------------------