var NN3 = false;
image1= new Image();
image1.src = "../USA/start.gif";
image1on = new Image();
image1on.src = "../USA/start_on.gif";
image2= new Image();
image2.src = "../USA/info.gif";
image2on = new Image();
image2on.src = "../USA/info_on.gif";
image3= new Image();
image3.src = "../USA/demo.gif";
image3on = new Image();
image3on.src = "../USA/demo_on.gif";
image4= new Image();
image4.src = "../USA/orders.gif";
image4on = new Image();
image4on.src = "../USA/orders_on.gif";
image9= new Image();
image9.src = "../USA/wshop.gif";
image9on = new Image();
image9on.src = "../USA/wshop_on.gif";
image5= new Image();
image5.src = "../USA/news.gif";
image5on = new Image();
image5on.src = "../USA/news_on.gif";
image6= new Image();
image6.src = "../USA/faq.gif";
image6on = new Image();
image6on.src = "../USA/faq_on.gif";
image7= new Image();
image7.src = "../USA/bug_fixes.gif";
image7on = new Image();
image7on.src = "../USA/bug_fixes_on.gif";
image8= new Image();
image8.src = "../USA/impressum.gif";
image8on = new Image();
image8on.src = "../USA/impressum_on.gif";
imageD= new Image();
imageD.src = "../D/lang.gif";
imageDon = new Image();
imageDon.src = "../D/lang_on.gif";
imageE= new Image();
imageE.src = "../E/lang.gif";
imageEon = new Image();
imageEon.src = "../E/lang_on.gif";
imageF= new Image();
imageF.src = "../F/lang.gif";
imageFon = new Image();
imageFon.src = "../F/lang_on.gif";
imageI= new Image();
imageI.src = "../I/lang.gif";
imageIon = new Image();
imageIon.src = "../I/lang_on.gif";
imageUSA= new Image();
imageUSA.src = "../USA/lang.gif";
imageUSAon = new Image();
imageUSAon.src = "../USA/lang_on.gif";

function on(name)
{
        document[name].src = eval(name + "on.src");
}
function off(name)
{
        document[name].src = eval(name + ".src");
}

function agbpop()
{
        agb = open('agb.htm', 'agb', 'height=400,width=500,scrollbars=yes,location=no,resizable=no');
        agb.focus();
}

function widerrufpop()
{
        widerruf = open('widerruf.htm', 'widerruf', 'height=400,width=500,scrollbars=yes,location=no,resizable=no');
        widerruf.focus();
}


/* function Enable...() stellt sicher, dass die bereits angeklickten Radiobuttons für COGPACK Sprache und Handbuchsprache etc. bzw. sonstige Radiobuttons nicht ausgegraut werden, wenn mit dem Back-button des Internet Explorers auf die Seite zurückgesprungen wird und dass die Werte beim nächsten Submit mit übertragen werden  */

function EnableHome()
{
  if (document.Home.CHome[1].checked == true)
 {
        for (var i=0; i<8; i++)
        {
           document.getElementsByName("L1st")[i].disabled = false;
        }
        document.getElementsByName("Lhb")[0].disabled = false;
        document.getElementsByName("Lhb")[1].disabled = false;
  }
}

function EnableProfi()
{
  if (document.Profi.CProfi[1].checked == true)
 {
        for (var i=0; i<8; i++)
        {
           document.getElementsByName("L1st")[i].disabled = false;
        }
        document.getElementsByName("Lhb")[0].disabled = false;
        document.getElementsByName("Lhb")[1].disabled = false;
  }
}


function Disable(tf)
{
        for (var i=0; i<8; i++)
        {
                document.getElementsByName("L1st")[i].disabled = tf;
                document.getElementsByName("L1st")[i].checked = false;
        }

        document.getElementsByName("Lhb")[0].disabled = tf;
        document.getElementsByName("Lhb")[1].disabled = tf;
        document.getElementsByName("Lhb")[0].checked = false;
        document.getElementsByName("Lhb")[1].checked = false;

        document.getElementsByName("D")[0].disabled = false;
        document.getElementsByName("E")[0].disabled = false;
        document.getElementsByName("F")[0].disabled = false;
        document.getElementsByName("I")[0].disabled = false;
        document.getElementsByName("N")[0].disabled = false;
        document.getElementsByName("NL")[0].disabled = false;
        document.getElementsByName("P")[0].disabled = false;
        document.getElementsByName("USA")[0].disabled = false;
}

function zusprache()
{
        document.getElementsByName("D")[0].disabled = false;
        document.getElementsByName("D")[0].checked = false;
        document.getElementsByName("E")[0].disabled = false;
        document.getElementsByName("E")[0].checked = false;
        document.getElementsByName("F")[0].disabled = false;
        document.getElementsByName("F")[0].checked = false;
        document.getElementsByName("I")[0].disabled = false;
        document.getElementsByName("I")[0].checked = false;
        document.getElementsByName("N")[0].disabled = false;
        document.getElementsByName("N")[0].checked = false;
        document.getElementsByName("NL")[0].disabled = false;
        document.getElementsByName("NL")[0].checked = false;
        document.getElementsByName("P")[0].disabled = false;
        document.getElementsByName("P")[0].checked = false;
        document.getElementsByName("USA")[0].disabled = false;
        document.getElementsByName("USA")[0].checked = false;

        if (document.getElementsByName("L1st")[0].checked)
        {
         document.getElementsByName("D")[0].disabled = true;
        }
         if (document.getElementsByName("L1st")[1].checked)
        {
         document.getElementsByName("E")[0].disabled = true;
        }
         if (document.getElementsByName("L1st")[2].checked)
        {
         document.getElementsByName("F")[0].disabled = true;
        }
        if (document.getElementsByName("L1st")[3].checked)
        {
         document.getElementsByName("I")[0].disabled = true;
        }
        if (document.getElementsByName("L1st")[4].checked)
        {
         document.getElementsByName("N")[0].disabled = true;
        }
         if (document.getElementsByName("L1st")[5].checked)
        {
         document.getElementsByName("NL")[0].disabled = true;
        }
        if (document.getElementsByName("L1st")[6].checked)
        {
         document.getElementsByName("P")[0].disabled = true;
        }
        if (document.getElementsByName("L1st")[7].checked)
        {
         document.getElementsByName("USA")[0].disabled = true;
        }

}

/*
function Disablebhf()
{
       if (document.getElementsByName("BahnhofZeit")[0].checked)
       {

          for (var i=0; i<3; i++)

            document.getElementsByName("Bahnhof")[i].disabled = false;

      }
      else
       {
           for (var i=0; i<3; i++)
          {
              document.getElementsByName("Bahnhof")[i].disabled = true;
              document.getElementsByName("Bahnhof")[i].checked = false;
           }
      }
}
*/

function Disableroom()
{
       if (document.getElementsByName("Hotel1")[0].checked ||                                          document.getElementsByName("Hotel2")[0].checked ||                                          document.getElementsByName("Hotel3")[0].checked)
       {

          for (var i=0; i<3; i++)

            document.getElementsByName("Zimmer")[i].disabled = false;

      }
      else
       {
           for (var i=0; i<3; i++)
          {
              document.getElementsByName("Zimmer")[i].disabled = true;
              document.getElementsByName("Zimmer")[i].checked = false;
           }
      }
}


function FormValidator(theForm)
{
        if (theForm.name == "Home")
        {
                if (!theForm.CHome[1].checked &&
                        !theForm.CHome[0].checked &&
                        !theForm.D.checked &&
                        !theForm.E.checked &&
                        !theForm.F.checked &&
                        !theForm.I.checked &&
                        !theForm.N.checked &&
                        !theForm.NL.checked &&
                        !theForm.P.checked &&
                        !theForm.USA.checked)
                {
                        theForm.CHome[1].focus();
                        alert("Please check the article(s) you want to order!");
                        return (false);
                }
                if (theForm.CHome[1].checked)
                {
                        if (!theForm.L1st[0].checked &&
                                !theForm.L1st[1].checked &&
                                !theForm.L1st[2].checked &&
                                !theForm.L1st[3].checked &&
                                !theForm.L1st[4].checked &&
                                !theForm.L1st[5].checked &&
                                !theForm.L1st[6].checked &&
                                !theForm.L1st[7].checked)
                        {
                                theForm.L1st[0].focus();
                                alert("Please select a language! One language is free.");
                                return (false);
                        }
                }
                if (!theForm.Lhb[0].checked &&
                        !theForm.Lhb[1].checked &&
                        theForm.CHome[1].checked)
                {
                        theForm.Lhb[0].focus();
                        alert("Please select a language for the manual! One manual is free.");
                        return (false);
                }

        }
        if (theForm.name == "Profi")
        {
                if (!theForm.CProfi[1].checked &&
                        !theForm.CProfi[0].checked &&
                        !theForm.Zusatzliz[0].checked &&
                        !theForm.Zusatzliz[1].checked &&
                        !theForm.Zusatzliz[2].checked &&
                        !theForm.Zusatzliz[3].checked &&
                        !theForm.Zusatzliz[4].checked &&
                        !theForm.Zusatzliz[5].checked &&
                        !theForm.Zusatzliz[6].checked &&
                        !theForm.Zusatzliz[7].checked &&
                        !theForm.Zusatzliz[8].checked &&
                        !theForm.Zusatzliz[9].checked &&
                        !theForm.D.checked &&
                        !theForm.E.checked &&
                        !theForm.F.checked &&
                        !theForm.I.checked &&
                        !theForm.N.checked &&
                        !theForm.NL.checked &&
                        !theForm.P.checked &&
                        !theForm.USA.checked &&
                        (Number(theForm.HandbuchD.value)==0) &&
                        (Number(theForm.HandbuchUSA.value)==0) &&
                        !theForm.Updateservice2.checked)
                {
                        theForm.CProfi[1].focus();
                        alert("Please check the article(s) you want to order!");
                        return (false);
                }
                if (theForm.CProfi[1].checked)
                {
                        if (!theForm.L1st[0].checked &&
                                !theForm.L1st[1].checked &&
                                !theForm.L1st[2].checked &&
                                !theForm.L1st[3].checked &&
                                !theForm.L1st[4].checked &&
                                !theForm.L1st[5].checked &&
                                !theForm.L1st[6].checked &&
                                !theForm.L1st[7].checked)
                        {
                                theForm.L1st[0].focus();
                                alert("Please select a language! One language is free.");
                                return (false);
                        }
                }
                if (!theForm.Lhb[0].checked &&
                        !theForm.Lhb[1].checked &&
                        theForm.CProfi[1].checked)
                {
                        theForm.Lhb[0].focus();
                        alert("Please select a language for the manual! One manual is free.");
                        return (false);
                }

                if (Number(theForm.HandbuchD.value) < 0 ||
                        Number(theForm.HandbuchD.value) > 99 ||
                        isNaN(theForm.HandbuchD.value))
                {
                        theForm.HandbuchD.focus();
                        alert("Please enter a number between 0 and 99!");
                        return (false);
                }
                if (Number(theForm.HandbuchUSA.value) < 0 ||
                        Number(theForm.HandbuchUSA.value) > 99 ||
                        isNaN(theForm.HandbuchUSA.value))
                {
                        theForm.HandbuchUSA.focus();
                        alert("Please enter a number between 0 and 99!");
                        return (false);
                }
        }

/* folgende Abfrage ist nötig, weil beim Back-button des Internet-Explorers die entsprechende Checkbox dieser Sprache nicht mehr disabled ist, wenn auf die Seite zurückgesprungen wird */

         if (theForm.name == "Profi"
                || theForm.name == "Home")
        {

                 if ((theForm.D.checked && theForm.L1st[0].checked) ||
                        (theForm.E.checked && theForm.L1st[1].checked) ||
                        (theForm.F.checked && theForm.L1st[2].checked) ||
                        (theForm.I.checked && theForm.L1st[3].checked) ||
                        (theForm.N.checked && theForm.L1st[4].checked) ||
                        (theForm.NL.checked && theForm.L1st[5].checked) ||
                        (theForm.P.checked && theForm.L1st[6].checked) ||
                        (theForm.USA.checked && theForm.L1st[7].checked))
                {
                        if (theForm.L1st[0].checked) theForm.D.focus();
                        if (theForm.L1st[1].checked) theForm.E.focus();
                        if (theForm.L1st[2].checked) theForm.F.focus();
                        if (theForm.L1st[3].checked) theForm.I.focus();
                        if (theForm.L1st[4].checked) theForm.N.focus();
                        if (theForm.L1st[5].checked) theForm.NL.focus();
                        if (theForm.L1st[6].checked) theForm.P.focus();
                        if (theForm.L1st[7].checked) theForm.USA.focus();
                        alert("You selected as an Additional Language Set the same language in which you already ordered your COGPACK version. Please deselect this Additional Language Set by clicking in the respective checkbox.");
                        return (false);
                }

        }



        if (theForm.name == "Workshop")
        {
                if (theForm.Vorname.value == "")
                {
                        theForm.Vorname.focus();
                        alert("Please enter the first name of the participant!");
                        return (false);
                }
                if (theForm.Nachname.value == "")
                {
                        theForm.Nachname.focus();
                        alert("Please enter the last name of the participant!");
                        return (false);
                }
        }
        else
        {
                if (theForm.Vorname.value == "")
                {
                        theForm.Vorname.focus();
                        alert("Please enter your first name!");
                        return (false);
                }
                if (theForm.Nachname.value == "")
                {
                        theForm.Nachname.focus();
                        alert("Please enter your last name!");
                        return (false);
                }
        }

        if (theForm.name == "Profi")
        {
                if (theForm.Institution.value == "")
                {
                        theForm.Institution.focus();
                        alert("Please enter the name of your institution!");
                        return (false);
                }
        }

        if (theForm.name == "Profi"
                || theForm.name == "Home"
                || theForm.name == "Demo"
                || theForm.name == "Workshop")
        {
                if (theForm.Strasse.value == "")
                {
                        theForm.Strasse.focus();
                        alert("Please enter street and number!");
                        return (false);
                }


                if (theForm.Postleitzahl.value == "")
                {
                        theForm.Postleitzahl.focus();
                        alert("Please enter the ZIP-code (postcode)!");
                        return (false);
                }

                if (theForm.Ort.value == "")
                {
                        theForm.Ort.focus();
                        alert("Please enter the city!");
                        return (false);
                }

                if (theForm.Land.value == "")
                {
                        theForm.Land.focus();
                        alert("Please enter the country!");
                        return (false);
                }

        }

        if (theForm.name == "Profi"
                || theForm.name == "Home"
                || theForm.name == "Demo"
                || theForm.name == "Workshop")
        {
                if (theForm.Telefon.value == "")
                {
                        theForm.Telefon.focus();
                        alert("Please enter your phone number!");
                        return (false);
                }

          }



        if (theForm.name == "Profi" || theForm.name == "Email")
        {
                if ((theForm.Email.value == "@") || (theForm.Email.value == ""))
                {
                        theForm.Email.focus();
                        alert("Please enter your email-address!");
                        return (false);
                }
                if (theForm.Email.value.indexOf('@') == -1 || theForm.Email.value.indexOf('.') == -1)
                {
                        theForm.Email.focus();
                        alert("Please enter a valid email-address!");
                        return false;
                }
        }

        if (theForm.name == "Profi")
        {
                if (theForm.EUUSTIDNo.value == "")
                {
                        theForm.EUUSTIDNo.focus();
                        alert("Please enter your EU VAT-IDNo. (for EU-countries)! If sold to Germany please enter a \"-\"!");
                        return (false);
                }
        }

        if (theForm.name == "Profi"
           || theForm.name == "Home")
        {
                if (!theForm.AGB.checked)
                {
                        theForm.AGB.focus();
                        alert("You can only order, if you agree to the General Terms and Conditions and to the Right of Revocation conditions. Please mark the corresponding checkbox.");
                        return (false);
                }
        }


        if (theForm.name == "Email")
        {
                if (theForm.Betreff.value == "")
                {
                        theForm.Betreff.focus();
                        alert("Please enter the subject!");
                        return (false);
                }
                if (theForm.Bemerkungen.value == "")
                {
                        theForm.Bemerkungen.focus();
                        alert("Please enter your message!");
                        return (false);
                }
        }

/* Workshop: bei mehr als zwei Terminen müssen auch Termin[3] etc. gescheckt werden */
 if (theForm.name == "Workshop")
        {
                if (!(theForm.Termin[0].checked ||
                        theForm.Termin[1].checked ))
                {
                        theForm.Termin[0].focus();
                        alert("Please check the date, at which you want to attend the workshop!");
                        return (false);
                }

                if ((theForm.Hotel1.checked ||
                       theForm.Hotel2.checked ||
                       theForm.Hotel3.checked) &&
                      !(theForm. Zimmer[0].checked || theForm.Zimmer[1].checked ||                                  theForm.Zimmer[2].checked))
                {
                        theForm.Zimmer[0].focus();
                        alert("Please check the kind of room you want!");
                        return (false);
                }
                if ((theForm.Abholzeit.value == "00:00") &&
                        theForm.Abholen.checked)
                {
                        theForm.Abholzeit.focus();
                        alert("Please tell us the time your train arrives! If you don´t   know yet the time of arrival, please delete the default time 00:00 and enter a question mark! ");
                        return (false);
                }


        }
        return (true);
}
