// JavaScript Document


function calc(a) {
                a[2] *= 2;
                a[3] *= 5;
                a[4] *= 10;
                return a;
}

// Format:
// ... new Array(Preis 0 Stck, Preis 1 Stck, Preis 2 Stck, Preis 5 Stck, Preis 10 Stck)



// Plastics: nur ein Preis
pricesPlastics  = new Array(0, 20, 0);

pricesCone      = new Array(0, 5, 5, 4, 2.65); pricesCone = calc(pricesCone);

pricesWindow    = new Array(0, 2, 2, 1.60, 1.30); pricesWindow = calc(pricesWindow);

pricesGolfball  = new Array(0, 5, 5, 4, 2.80); pricesGolfball = calc(pricesGolfball);
pricesMultizone = new Array(0, 5, 5, 4, 2.80); pricesMultizone = calc(pricesMultizone);

pricesPyroC172  = new Array(0, 5, 5, 4, 3.45); pricesPyroC172 = calc(pricesPyroC172);
pricesPyro6192  = new Array(0, 6, 6, 5, 4.35); pricesPyro6192 = calc(pricesPyro6192);
pricesPyro7192  = new Array(0, 10, 10, 8, 6.65); pricesPyro7192 = calc(pricesPyro7192);
pricesPyroAR172  = new Array(0, 10, 10, 8, 6.65); pricesPyroAR172 = calc(pricesPyroAR172);

pricesChipTR156 = new Array(0, 5, 5, 4, 3.20); pricesChipTR156 = calc(pricesChipTR156);

pricesModule    = new Array(0, 30, 30, 24, 20); pricesModule = calc(pricesModule);

pricesDemonstrator = new Array(0, 50); pricesDemonstrator = calc(pricesDemonstrator);

pricesFresnel = Array(0, 12, 12, 9.50, 7.50); pricesFresnel = calc(pricesFresnel);



function calcTotal() {

/* Plastics */

if(document.sampleform.form_plastics.checked == true)
        document.sampleform.form_plastics_total.value = pricesPlastics[1] + " EUR";
else
        document.sampleform.form_plastics_total.value = pricesPlastics[0] + " EUR";

/* Window */
//alert(pricesWindow[document.sampleform.form_window.value]);
document.sampleform.form_window_total.value = pricesWindow[document.sampleform.form_window.value] + " EUR";

/* PIR-Module */
document.sampleform.form_modules_total.value = pricesModule[document.sampleform.form_modules.value] + " EUR";

/* Demonstrator */

document.sampleform.form_demonstrator_total.value = pricesDemonstrator[document.sampleform.form_demonstrator.value] + " EUR";

/* Cheque */
if(document.sampleform.form_cheque.checked == true)
        document.sampleform.form_cheque_total.value = "10 EUR";
else
        document.sampleform.form_cheque_total.value = "0 EUR";


/* Calculate total value */

var total = 20; // shipping costs


temp = new String();

temp = document.sampleform.form_plastics_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_konus_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_window_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_golfball_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_multizone_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_pyro_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_chips_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_modules_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_demonstrator_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_fresnel_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));
temp = document.sampleform.form_cheque_total.value; total += Number(temp.slice(0, temp.indexOf(" EUR")));

document.sampleform.form_endtotal.value = String(total + " EUR");

}

function openWin(prod) {
        if (prod == "konus")
                window.open("optics.php", "optics", "width=360, height=300");
        else if (prod == "golfball")
                window.open("golfball.php", "golfball", "width=360, height=300");
        else if (prod == "multizone")
                window.open("multizone.php", "multizone", "width=360, height=440");
        else if (prod == "pyro")
                window.open("pyro.php", "pyro", "width=360, height=300");
        else if (prod == "chips")
                window.open("chips.php", "chips", "width=360, height=300");
        else if (prod == "fresnel")
                window.open("fresnel.php", "fresnel", "width=360, height=500");
}

function checkForm() {


        if (document.sampleform.form_name.value == "") {
                alert("Please fill in your name!");
                document.sampleform.form_name.focus();
                return false;
        }
        if (document.sampleform.form_company.value == "") {
                alert("Please fill in the name of your company!");
                document.sampleform.form_company.focus();
                return false;
        }
        if (document.sampleform.form_address1.value == "" && document.sampleform.form_address2.value == "") {
                alert("Please fill in at least one address!");
                document.sampleform.form_address1.focus();
                return false;
        }
        if (document.sampleform.form_city.value == "") {
                alert("Please fill in your city!");
                document.sampleform.form_city.focus();
                return false;
        }
        if (document.sampleform.form_zip.value == "") {
                alert("Please fill in your zip-code!");
                document.sampleform.form_zip.focus();
                return false;
        }
        if (document.sampleform.form_email.value == "") {
                alert("Please fill in your email-address!");
                document.sampleform.form_email.focus();
                return false;
        }


}




        