 function openModalWindowsOnStart() {
    if(tempModalVar=="0") {
      openModalWindows();
    } else {
      if(tempNews=="1") {
        openModalNewsletter();
      }
    }
  }

  function checkEmailNews() {
    reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+    //Name
                  '(\\@)'+                       //@-Zeichen
                  '([a-zA-Z0-9\\-\\.]+)'+        //Domain
                  '(\\.)'+                       //Punkt
                  '([a-zA-Z]{2,4})$');           //TLD

    if(reg.test(document.getElementById("email_address").value) == false){
      //alert("email falsch");
      return (false);
    } else {
      //alert("email richtig");
      return (true);
    }
  }

  function setAgency(id) {
    if (id=="1") {
      document.getElementById("agency").value="true";          //Agentur
      document.getElementById('agencylabel').style.display="";
      document.getElementById('agencyname').style.display="";
    }
    if (id=="2") {
      document.getElementById("agency").value="false";   //Endkunde
      document.getElementById('agencylabel').style.display="none";
      document.getElementById('agencyname').style.display="none";
      document.getElementById('agencyname').value="";
    }
  }

  function checkMandatoryFieldsNewsletter() {
    var complete ="false";
    var defaultValues ="false";
    var firstnamne_error ="true";
    var lastname_error ="true";
    var email_error ="true";
    var country_error ="true";
    var title_error ="true";
    var notice_error ="true";

    if (document.getElementById("country").value=="") {
        if (document.getElementById("last_name").value=="") {
          if (document.getElementById("first_name").value=="") {
            if (document.getElementById("email_address").value=="") {
              if (document.getElementById("titlename").value=="") {
                if (document.getElementById("notice_news").value=="") {
                  defaultValues="true";
                } else {defaultValues ="false"}
              } else {defaultValues ="false"}
            } else {defaultValues ="false"}
          } else {defaultValues ="false"}
        } else {defaultValues ="false"}
    } else {defaultValues ="false"}

    if (defaultValues =="true") {
      Modalbox.hide();
      return (false);
    } else {

      if (document.getElementById("last_name").value!="") {
        lastname_error ="true";document.getElementById("last_name_text").style.color="black";
      } else {lastname_error ="false";document.getElementById("last_name_text").style.color="red";}

      if (document.getElementById("first_name").value!="") {
        firstname_error ="true";document.getElementById("first_name_text").style.color="black";
      }else {firstname_error ="false";document.getElementById("first_name_text").style.color="red";}

      if (document.getElementById("country").value!="") {
        country_error ="true";document.getElementById("country_text").style.color="black";
      } else {country_error ="false";document.getElementById("country_text").style.color="red";}

      if (document.getElementById("email_address").value!="") {
        emailCheck = checkEmailNews();
        if (emailCheck==true) {
          email_error ="true";document.getElementById("e_mail_text").style.color="black";
        } else {email_error ="false";document.getElementById("e_mail_text").style.color="red";}
      } else {email_error ="false";document.getElementById("e_mail_text").style.color="red";}

      if (document.getElementById("titlename").value!="") {
        title_error ="true";document.getElementById("title_text").style.color="black";
      } else {title_error ="false";document.getElementById("title_text").style.color="red";}

      if (document.getElementById("notice_news").value!="") {
        notice_error ="true";document.getElementById("notice_news_text").style.color="black";
      } else {notice_error ="false";document.getElementById("notice_news_text").style.color="red";}

      if ((title_error =="false") || (lastname_error =="false") || (firstname_error =="false") || (country_error =="false") || (email_error =="false") || (notice_error =="false")) {
        complete = "false";
      } else {complete = "true";}

      if (complete=="true") {
        uniInden=document.callback_form.first_name.value+document.callback_form.last_name.value+document.callback_form.email_address.value+document.callback_form.country.value;
        document.callback_form.uniqueIdentifier.value=uniInden;
        return (true);
      } else if (complete=="false"){
        if (email_error =="false") {
          alert("Bitte geben Sie eine gültige E-Mail Adresse an.");
        } else {
          alert("Bitte füllen sie alle Pflichtfelder aus.");
        }
        return (false);
      }
    }
  }

  function checkValueNewsletter() {
    if (document.getElementById('notice_news').value=="others") {
      document.getElementById('others').style.display="";
    } else {
      document.getElementById('others').style.display="none";
      document.getElementById('others').value="";
    }
  }

  function openModalWindows() {
    var ShowText = "<form class=\"new_signup_request\" id=\"callback_form\" name=\"callback_form\" method=\"post\" action=\"newsletterreg.php\" onsubmit=\"return checkMandatoryFieldsNewsletter(this)\">";
    var header= "<div class=\"block\"><table><tr><td rowspan=\"2\"> <img alt=\"Signup_header\" src=\"http://www.ncl.de/itinerary/images/signup_header.jpg\" /></td><td valign=\"bottom\"><h6 class=\"title16px\">Registrieren Sie sich jetzt, um keine NCL News mehr zu verpassen!</h6></div></td></tr>";
    header += "<td><h3>Immer als Erster über NCL Promotions informiert sein.</h3></td></tr></table>";
    header += "<p class=\"small_text\">* Pflichtfeld</p><br>";
    var text = "<table id=\"cb_layout\"><tr><td>";
    text += "<label><p style=\"margin-bottom:0px\" name=\"country_text\" id=\"country_text\">In welchem Land wohnen Sie?*</p></label>";
    text += "<select name=\"country\" id=\"country\" size=\"1\" style=\"font-size:13px\" tabindex=\"4\"><option value=\"\">Bitte wählen Sie aus<option value=\"DE\">Deutschland<option value=\"AT\">Österreich<option value=\"CH\">Schweiz<option value=\"LI\">Liechtenstein<option value=\"LU\">Luxemburg<option value=\"\">----------<option value=\"AL\">Albanien<option value=\"AD\">Andorra<option value=\"BE\">Belgien<option value=\"BA\">Bosnien-Herzegowina<option value=\"BG\">Bulgarien Sofia<option value=\"DE\">Deutschland<option value=\"DK\">Dänemark<option value=\"EE\">Estland<option value=\"FO\">Faröer<option value=\"FI\">Finnland<option value=\"FR\">Frankreich<option value=\"GR\">Griechenland<option value=\"IS\">Island<option value=\"IT\">Italien<option value=\"YU\">Jugoslawien<option value=\"HR\">Kroatien<option value=\"LV\">Lettland<option value=\"LT\">Litauen<option value=\"MK\">Makedonien<option value=\"MT\">Malta<option value=\"MD\">Moldavien<option value=\"MC\">Monaco<option value=\"NL\">Niederlande<option value=\"NO\">Norwegen<option value=\"PL\">Polen<option value=\"PT\">Portugal<option value=\"RO\">Rumänien<option value=\"RU\">Russland<option value=\"SM\">San Marino<option value=\"SE\">Schweden<option value=\"SK\">Slowakei<option value=\"SI\">Slowenien<option value=\"ES\">Spanien<option value=\"CZ\">Tschechien<option value=\"TR\">Türkei<option value=\"UA\">Ukraine<option value=\"HU\">Ungarn<option value=\"VA\">Vatikanstadt<option value=\"BY\">Weißrussland<option value=\"CY\">Zypern</select>";
    text += "</td><td>";
    text += "<label><p style=\"margin-bottom:0px\" name=\"title_text\" id=\"title_text\">Anrede?*</p></label>";
    text += "<select name=\"titlename\" id=\"titlename\" size=\"1\" style=\"font-size:13px\" tabindex=\"4\"><option value=\"\">Bitte wählen Sie aus<option value=\"Herr\">Herr<option value=\"Frau\">Frau<option value=\"Familie\">Familie</select>";
    text += "</td>";
    text += "<td rowspan=\"4\" valign=\"top\"><h2 style=\"margin-left:10px;\">Ihr klarer Vorteil:</h2><ul>";
    text += "<li><p style=\"margin-top:0px;margin-bottom:0px;\">Sie erhalten immer als Erster brandheiße NCL News & Specials per E-Mail um Ihr nächstes Kreuzfahrtabenteuer auf See zu planen.<br></p></li>";
    text += "<li><p style=\"margin-top:5px;margin-bottom:0px;\">Unsere Kreuzfahrtexperten kontaktieren Sie bei Angabe Ihrer Telefonnummer mit unschlagbaren Angeboten.</p></li>";
    text += "</td></tr><tr>";
    text += "<td valign=\"top\">";
    text += "<label><p style=\"margin-bottom:0px;margin-top:0px;\" name=\"first_name_text\" id=\"first_name_text\">Vorname*</p></label>";
    text += "<input name=\"first_name\" id=\"first_name\" size=\"25\" tabindex=\"1\" type=\"text\" >";
    text += "</td><td valign=\"top\">";
    text += "<label><p style=\"margin-bottom:0px;margin-top:0px;\" name=\"last_name_text\" id=\"last_name_text\">Nachname*</p></label>";
    text += "<input name=\"last_name\" id=\"last_name\" size=\"25\" tabindex=\"3\" type=\"text\">";
    text += "</td></tr><tr><td valign=\"top\">";
    text += "<label><p style=\"margin-bottom:0px;margin-top:0px;\" name=\"e_mail_text\" id=\"e_mail_text\">E-Mail-Adresse*</p></label>";
    text += "<input name=\"email_address\" id=\"email_address\" size=\"25\" tabindex=\"2\" type=\"text\"><br><span style=\"font-size:9px\">Wenn Sie in einem Reisebüro arbeiten,<br>geben Sie bitte Ihre Reisebüro E-Mail-<br>Adresse an.</span>";
    text += "</td><td valign=\"top\">";
    text += "<label><p style=\"margin-bottom:0px;margin-top:0px;\">Vorwahl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;Telefon</p></label>";
    text += "<input name=\"area_code\" id=\"area_code\" size=\"5\" tabindex=\"5\" type=\"text\" > / <input name=\"phone\" id=\"phone\" size=\"14\" tabindex=\"7\" type=\"text\" >";
    text += "</td></tr></table>";
    text += "<table width=\"100%\"><tr><td colspan=\"2\" width=\"450px\"><p style=\"margin-bottom:0px;margin-top:0px;\" name=\"agent_text\" id=\"agent_text\">Arbeiten Sie in einem Reisebüro?*</p></td>";
    text += "</tr>";
    text += "<tr><td valign=\"top\"><p style=\"margin-bottom:0px;margin-top:0px;\"><input name=\"agents\" id=\"agents\" type=\"radio\" value=\"true\" tabindex=\"7\" onclick=\"javascript:setAgency(1)\">";
    text += "<label>Ja</label>&nbsp;&nbsp;&nbsp;&nbsp;";
    text += "<input name=\"agents\" id=\"agents\" type=\"radio\" value=\"false\" checked=\"checked\" tabindex=\"8\" onclick=\"javascript:setAgency(2)\">";
    text += "<label>Nein</label></p></td><td>&nbsp;</td></tr>";
    text += "<tr><td style=\"width:450px\"><label><p style=\"margin-bottom:0px;margin-top:0px;display:none\" name=\"agencylabel\" id=\"agencylabel\">Agenturname&nbsp;&nbsp;</label>";
    text += "<input name=\"agencyname\" id=\"agencyname\" type=\"text\" style=\"width:275px;display:none\"></p></td><td rowspan=\"4\" valign=\"bottom\"><img src=\"../web/images/icons/Award.jpg\" align=\"right\" valign=\"top\" style=\"margin-bottom:0px;margin-top:0px;\"></p></td></tr>";
    text += "<tr><td><label><p style=\"margin-left:3px;margin-bottom:0px;margin-top:0px;\" id=\"notice_news_text\" name=\"notice_news_text\">Wie sind Sie auf NCL aufmerksam geworden?*</label></p></td></tr>";
    text += "<tr><td><label><p><select name=\"notice_news\" id=\"notice_news\" size=\"1\" style=\"margin-left:3px;font-size:9pt;width:170px;\" onChange=\"javascript:checkValueNewsletter();\"><option value=\"\">Bitte wählen Sie aus<option value=\"customer\">Ich bin bereits Kunde<option value=\"searchengine\">Suchmaschine (z. B. Google)<option value=\"travel_agency\">Reisebüro<option value=\"friends\">Bekannte/Freunde<option value=\"advertising_newspaper\">Werbung in Zeitungen/Magazinen<option value=\"advertising_online\">Werbung im Internet<option value=\"others\">Sonstiges</select>";
    text += "<input name=\"others\" id=\"others\" type=\"text\" style=\"margin-left:3px;display:none;width:180px;font-size:9pt\"></p></td></tr>";

    text += "<tr><td><p style=\"margin-bottom:0px;margin-top:0px;\"><input type=\"submit\" value=\"Senden/Schliessen\"></p></td></tr>";
    text += "<tr><td><p style=\"margin-bottom:0px;margin-top:0px;\" class=\"small_text\">Ihre Daten werden nicht an Dritte weitergegeben.</p></td></tr></table>";
    text += "<input type=\"hidden\" name=\"uniqueIdentifier\">";
    text += "<input type=\"hidden\" name=\"agency\" id=\"agency\" value=\"false\">";
    ShowText += header + text;
    ShowText += "</form>";
    Modalbox.show(ShowText, {title: "NCL Specials-Letter", height: 510, width: 700 }); return false;
  }

  function openModalNewsletter() {
    var test="<p class=\"billing\">Vielen Dank für Ihre NCL Newsletteranmeldung.<br><br>Sie erhalten in Kürze eine E-Mail mit Bestätigungslink von uns. Um den NCL Newsletter zukünftig zu erhalten, müssen Sie einfach nur auf den Link in der E-Mail klicken.<br><br>Ihr NCL Freestyle Cruising Team</p>";
    Modalbox.show(test, {title: "Ihre NCL Newsletteranmeldung", height: 250, width: 450 }); return false;
  }