var Cart_products = new Array()
var Cart_lineItems = new Array()
var Cart_total = 0 // current total
var Cart_description = "" // single string description of all items in cart
var Cart_allItems = "" // a ; seperated list of product codes and qtys
var Cart_packSizeIndex = 0
var Cart_packSizeText = "1"
var Cart_rates = new Array()
var Cart_currencySymbols = new Array()
var Cart_text_empty = "Shopping cart is emtpy. Click on one of the 'add to cart' links above."
var Cart_currency = "EUR"
var Cart_text_total = "Total";
var Cart_text_remove = "remove";
var Cart_text_add = "add to cart";
var Cart_tax = 1.19
var Cart_rabatt = 1
var Cart_packSize = 5;
var Cart_lang = "de"
///////////////////////////////////////////////////////////////////
// product data -
// ------- being auto generated by int/preise.php alcprices.php
//alert(Cart_lang)
if ( Cart_lang== "de")
{
Cart_products["PDFM-OFF"] = new Product("PDFM-OFF", "pdfMachine Office", new Array(59,275,500,1125,2000,3500));
Cart_products["PDFM-PRO"] = new Product("PDFM-PRO", "pdfMachine Pro", new Array(99,395,690,1475,2450,3900));
Cart_products["PDFM-ULT"] = new Product("PDFM-ULT", "pdfMachine Ultimate", new Array(129,595,990,1975,3450,5900));
Cart_products["PDFM-O2U"] = new Product("PDFM-O2U", "pdfMachine Office auf pdfMachine Ultimate", new Array(80,375,700,1625,3000,5500));
Cart_products["PDFM-P2U"] = new Product("PDFM-P2U", "pdfMachine Pro auf pdfMachine Ultimate", new Array(60,275,500,1125,2000,3500));
Cart_products["PDFM-UP1"] = new Product("PDFM-UP1", "pdfMachine 1 Jahr Service Verlängerung", new Array(25,100,150,312.5,500,900));
Cart_products["PDFM-UP2"] = new Product("PDFM-UP2", "pdfMachine 2 Jahre Service Verlängerung", new Array(39,175,275,500,875,1500));
Cart_products["PDFO"] = new Product("PDFO", "pdfOffice Pro", new Array(99,445,690,1475,2450,3900));
Cart_products["PDFSM"] = new Product("PDFSM", "pdfServMachine", new Array(600,3000,6000,15000,30000,60000));
Cart_products["PDFRE"] = new Product("PDFRE", "pdfReconverter", new Array(29,135,250,500,850,1500));
}
//----- end auto generated code
if ( Cart_lang== "en")
{
Cart_products["PDFM"] = new Product("PDFM", "pdfMachine", new Array(59,275,500,1125,2000,3500));
Cart_products["PDFM-S"] = new Product("PDFM-S", "pdfMachine Signer", new Array(99,395,690,1475,2450,3900));
Cart_products["PDFM-WMM"] = new Product("PDFM-WMM", "pdfMachine Serienbrief (Mail Merge)", new Array(99,395,690,1475,2450,3900));
Cart_products["PDFM-FULL"] = new Product("PDFM-FULL", "pdfMachine Pro", new Array(129,595,990,1975,3450,5900));
Cart_products["PDFM-SU"] = new Product("PDFM-SU", "Upgrade auf pdfMachine Signer", new Array(40,175,300,625,1000,1500));
Cart_products["PDFM-WMMU"] = new Product("PDFM-WMMU", "Upgrade auf pdfMachine Serienbrief", new Array(55,225,350,625,750,1000));
Cart_products["PDFM-FULLU"] = new Product("PDFM-FULLU", "Upgrade auf pdfMachine Pro", new Array(89,425,800,1875,3500,6000));
Cart_products["PDFM-UP1"] = new Product("PDFM-UP1", "pdfMachine 1 Jahr Service Verlängerung", new Array(25,100,150,312.5,500,900));
Cart_products["PDFM-UP2"] = new Product("PDFM-UP2", "pdfMachine 2 Jahre Service Verlängerung", new Array(39,175,275,500,875,1500));
}
Cart_currency = "EUR"
Cart_rates["EUR"] = 1
Cart_rates["AUD"] = 1.63
Cart_rates["SFR"] = 0.931
Cart_rates["CHF"] = 1.655
Cart_currencySymbols["USD"] = "$"
Cart_currencySymbols["AUD"] = "$"
Cart_currencySymbols["CHF"] = "CHF "
Cart_currencySymbols["EUR"] = "€"
///////////////////////////////////////
function getObj(name)
{
if (document.getElementById)
{
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
this.obj = document.layers[name];
this.style = document.layers[name];
}
return this;
}
////////////////////////////////////////////
function Product(code, desc, prices)
{
this.code = code;
this.desc = desc;
this.prices = new Array()
this.prices = prices;
return this;
}
function formatPrice(expr)
{
var decplaces = 2;
var str = "" + Math.round(eval(expr)*Math.pow(10,decplaces));
while(str.length <= decplaces)
str = "0"+str;
var decpoint = str.length - decplaces;
return Cart_currencySymbols[Cart_currency] + str.substring(0, decpoint)+"."+ str.substring(decpoint, str.length);
}
function formatNum(expr)
{
var decplaces = 2;
var str = "" + Math.round(eval(expr)*Math.pow(10,decplaces));
while(str.length <= decplaces)
str = "0"+str;
var decpoint = str.length - decplaces;
return str.substring(0, decpoint)+"."+ str.substring(decpoint, str.length);
}
// iterate thru products array building a html table
function Product_makePriceTable()
{
var s = ""
s += '
\n'
var i = 1
for (var code in Cart_products)
{
var prod = Cart_products[code];
if ( i == 6)
{
s += "| Software Upgrades und Services |
"
i = i +1
}
if ( i == 9)
{
s += "| Alles für PDF Formulare |
"
i = i +1
}
if ( i == 11)
{
s += "| Server Produkte |
"
i = i +1
}
if ( i == 13)
{
s += "| pdfReconverter |
"
i = i +1
}
i = i +1
s += "\n";
s += "| \n"
// s += ""+ prod.desc + ""
s += ""+ prod.desc + ""
s += " | \n"
//wegen museum
// if ( i > 17)
// {
// Cart_packSizeIndex = 0
// }
if (Cart_packSizeIndex == 0) Cart_packSize = 1
if (Cart_packSizeIndex == 1) Cart_packSize = 5
if (Cart_packSizeIndex == 2) Cart_packSize = 10
if (Cart_packSizeIndex == 3) Cart_packSize = 25
if (Cart_packSizeIndex == 4) Cart_packSize = 50
if (Cart_packSizeIndex == 5) Cart_packSize = 100
s += "\n"
s += formatPrice(prod.prices[Cart_packSizeIndex]/Cart_packSize *Cart_rates[Cart_currency])
s += " | \n"
s += "\n"
s += formatPrice(prod.prices[Cart_packSizeIndex] *Cart_rates[Cart_currency])
s += " | \n"
s += "\n"
s += formatPrice(prod.prices[Cart_packSizeIndex] *Cart_rates[Cart_currency]*Cart_tax)
s += " | \n"
s += "\n"
s += ""
s += Cart_text_add
s += ""
s += " | \n"
s += "
\n"
}
s += "
"
return s
}
// replaces the innerHTML with a price table for the document identifed by 'tagName'
function Products_redraw(tagName)
{
var priceTableDiv = new getObj(tagName) ;
priceTableDiv.obj.innerHTML = Product_makePriceTable()
}
////////////////////////////////////////////////////////
function Cart_LineItem(product, qty)
{
this.product = product;
this.packSizeIndex = Cart_packSizeIndex ;
//this.packSizeText = Cart_packSizeText;
this.packSizeText = Cart_packSize;
this.qty = qty;
return this;
}
// makes a html table of the current state of the shopping cart
function Cart_makeTable()
{
var gotone = false
var s = ''
Cart_total = 0
Cart_description = ""
Cart_allItems = ""
for (var i = 0; i < Cart_lineItems.length; i++)
{
var li = Cart_lineItems[i]
if (li == null)
continue
var amt = li.qty * li.product.prices[li.packSizeIndex]
var desc = ""
// desc = li.qty + " x " + Cart_packSize + " Stück "
desc = li.qty + " x " + li.packSizeText + " Stück "
//if (li.packSizeIndex > 0)
//desc = li.qty + " x " + li.packSizeText + " Stück "
// desc = li.qty + " x " + Cart_packSize + " Stück "
//else
// desc = li.qty + " x "
s += "\n";
s += "| "
s += desc
if (gotone)
Cart_description += ", "+desc + " " + li.product.desc ;
else
Cart_description += desc + " " + li.product.desc ;
Cart_allItems += li.product.code + ";" + li.qty + ";" + li.packSizeText + ";" + Cart_currency + ";" +formatNum(amt) +";"
s += ""+ li.product.desc + ""
s += " | \n"
if (Cart_packSizeIndex == 0) Cart_packSize = 1
if (Cart_packSizeIndex == 1) Cart_packSize = 5
if (Cart_packSizeIndex == 2) Cart_packSize = 10
if (Cart_packSizeIndex == 3) Cart_packSize = 25
if (Cart_packSizeIndex == 4) Cart_packSize = 50
if (Cart_packSizeIndex == 5) Cart_packSize = 100
s += ""
Cart_total += amt
// s += formatPrice(amt *Cart_rates[Cart_currency]/Cart_packSize)
s += formatPrice(amt *Cart_rates[Cart_currency]/li.packSizeText)
// s +=(li.packSizeText)
s += " | \n"
s += ""
s += formatPrice(amt *Cart_rates[Cart_currency])
s += " | \n"
s += ""
s += formatPrice(amt *Cart_rates[Cart_currency]*Cart_tax)
s += " | \n"
s += ""
s += ""
s += Cart_text_remove
s += ""
s += " | \n"
s += "
\n"
gotone =true
}
if (!gotone)
return ""
s += "
\n";
return s}
// replaces the innerHTML with a table representing the current cart
// looks for a div with a tag of "cart".
function Cart_redraw()
{
var s = Cart_makeTable();
if (s.length == 0)
{ s = "| "
s += Cart_text_empty
s += " |
";
}
Cart_total *= Cart_rates[Cart_currency]
s += "| "
s += Cart_text_total
s += " | "
s += "Netto "
s += formatPrice(Cart_total)
s += " | "
s += "Brutto "
s += formatPrice(Cart_total*Cart_tax)
//s += " | \n"
if (Cart_rabatt < 1)
{
s += " | HEK Netto "
s += formatPrice(Cart_total*Cart_rabatt)
s += " | ";
}
s += "
\n"
var cartDiv = new getObj("cart")
cartDiv.obj.innerHTML = s
}
// adds an item to the cart
function Cart_add(code)
{
alert('Produkt wurde weiter unten dem Warenkorb hinzugefügt.')
// first see if it already exists
for (var i = 0; i < Cart_lineItems.length; i++)
{
var li = Cart_lineItems[i]
if (li == null)
continue
if (li.product.code == code && li.packSizeIndex == Cart_packSizeIndex )
{
li.qty++
Cart_redraw()
return
}
}
Cart_lineItems[Cart_lineItems.length] = new Cart_LineItem(Cart_products[code], 1)
Cart_redraw()
}
// removes an item from the cart
function Cart_remove(i)
{
delete Cart_lineItems[i];
Cart_lineItems[i] = null
Cart_redraw()
}