/*---------------------------------------------------------------------------------------------*/
// Routensuche
/*---------------------------------------------------------------------------------------------*/
  function check(form) {
    if ((form=="side_bar") || (form=="search")) {
      var doc = document.search_form;
    }
    if (form=="header") {
      var doc = document.search_form_nav;
    }
    var finish="true";
    var checkdate="true";
    if(doc.dest.value=="") {
     if(doc.date1.value=="") {
      if(doc.date2.value=="") {
       if(doc.ship.value=="") {
        if(doc.port.value=="") {
         if(doc.duration.value=="") {
          if(doc.special_search.checked == false) {
            var finish = "false";
          }
         }
        }
       }
      }
     }
    }
    if(doc.date1.value!="") {
      if(doc.date1.value>doc.date2.value) {
        checkdate = "false";
      }
    }
    if (checkdate=="false") {
      alert ("Please check your date.");
    } else {
      if(finish=="false") {
        alert ("Plaese check your search options.")
      } else {
        doc.submit();
      }
    }
  }
/*---------------------------------------------------------------------------------------------*/
// Hotelsuche
/*---------------------------------------------------------------------------------------------*/

  function checkHotel() {
    var finish="true";
    var text="";
    if(document.search_form.dest.value=="Choose a destination") {
      text ="Please choose a destination";
      var finish = "false";
    } else {
      if(document.search_form.port.value=="Choose your port") {
        text ="Please choose your port";
        var finish = "false";
      }
    }
    if(finish=="false") {
      alert (text)
    } else {
      document.search_form.submit();
    }
  }

  function updatePortsHotel(id,form) {
    delPort(form);
    for (i=0;i<a_hotel.items.length;i++) {
      if(document.search_form.dest.value == a_hotel.items[i][1]) {
        document.search_form.port.value = a_hotel.items[i][2];
        element = new Option(a_hotel.items[i][2], a_hotel.items[i][0], false, true);
        document.search_form.port.options[document.search_form.port.options.length] = element;
      }
    }
    for (i=0;i<a_hotel.items.length;i++) {
      if (document.search_form.dest.value == "Choose a destination") {
        document.search_form.port.options[0].selected = true;
      }
    }
    document.search_form.port.options[0].selected = true;
  }

  function setSelectedDestPortHotel() {
    if (dest_hotel=="Choose a destination") {dest_hotel =0; }
      document.search_form.dest.options[dest_hotel].selected = true;
      updatePortsHotel(dest_hotel,'hotel');
      for (i=0;i<document.search_form.port.length;i++) {
        if(document.search_form.port.options[i].value == port_hotel) {
          document.search_form.port.options[i].selected = true;
        }
      }
  }



/* Aufbau eines 2Dimensionalen Arrays */
  function Array2D(x_hotel,y_hotel) {
    this.items = new Array(x_hotel);
   for(i=0;i<y_hotel;i++) {
      this.items[i] = new Array(x_hotel);
    }
  }
  var zahl_hotel = "30";
  a_hotel = new Array2D(zahl2_hotel,zahl_hotel);
  var x_hotel=0;

/* Aufbau eines 2Dimensionalen Arrays */
  function Array2D(xx_hotel,y_hotel) {
    this.items = new Array(xx_hotel);
    for(i=0;i<y_hotel;i++) {
      this.items[i] = new Array(xx_hotel);
    }
  }
  var zahl2_hotel = "10";
  aa_hotel = new Array2D(zahl2_hotel,zahl2_hotel);
  var xx_hotel=0;

  /* Aufbau eines 2Dimensionalen Arrays */
  function Array2D(x,y) {
    this.items = new Array(x);
   for(i=0;i<y;i++) {
      this.items[i] = new Array(x);
    }
  }
  var zahl = "36";
  a = new Array2D(16,zahl);
  var x=0;

/* Aufbau eines 2Dimensionalen Arrays */
  function Array2D(xx,y) {
    this.items = new Array(xx);
    for(i=0;i<y;i++) {
      this.items[i] = new Array(xx);
    }
  }
  var zahl2 = "36";
  aa = new Array2D(16,zahl2);
  var xx=0;

/* Aufbau eines 2Dimensionalen Arrays */
  function Array2D(z,y) {
    this.items = new Array(z);
    for(i=0;i<y;i++) {
      this.items[i] = new Array(y);
    }
  }
  var zahl1 = 12;
  b = new Array2D(12,zahl1);
  var z=0;

/* Function delSelect() löscht alle Einträge aus der Dropdownliste der Ports ab der 1.Position, damit*/
/* der Default-Wert nicht gelöscht wird */
  function delPort(form) {
    if ((form=="side_bar") || (form=="search") || (form=="hotel")) {
      var doc = document.search_form;
    }
    if (form=="header") {
      var doc = document.search_form_nav;
    }
    for(i=1; i < doc.port.length;) {
        doc.port.options[doc.port.length - 1] = null;
    }
  }

  function delShip(form) {
    if ((form=="side_bar") || (form=="search")) {
      var doc = document.search_form;
    }
    if (form=="header") {
      var doc = document.search_form_nav;
    }
    for(i=1; i < doc.ship.length;) {
        doc.ship.options[doc.ship.length - 1] = null;
    }
  }

  function updateShipByDestination(id,form) {
    if ((form=="side_bar") || (form=="search")) {
      var doc = document.search_form;
    }
    if (form=="header") {
      var doc = document.search_form_nav;
    }
    delShip(form);
    for (i=0;i<b.items.length;i++) {
      if (doc.dest.value == "") {
        doc.ship.value = b.items[i][1];
        element = new Option(b.items[i][1], b.items[i][0], false, true);
        doc.ship.options[doc.ship.options.length] = element;
      }
      if(doc.dest.value == 1) {
        if(b.items[i][2]==1) {
          doc.ship.value = b.items[i][1];
          element = new Option(b.items[i][1], b.items[i][0], false, true);
          doc.ship.options[doc.ship.options.length] = element;
        }
      }
      if(doc.dest.value == 2) {
        if(b.items[i][3]==1) {
          doc.ship.value = b.items[i][1];
          element = new Option(b.items[i][1], b.items[i][0], false, true);
          doc.ship.options[doc.ship.options.length] = element;
        }
      }
      if(doc.dest.value == 3) {
        if(b.items[i][4]==1) {
          doc.ship.value = b.items[i][1];
          element = new Option(b.items[i][1], b.items[i][0], false, true);
          doc.ship.options[doc.ship.options.length] = element;
        }
      }
      if(doc.dest.value == 4) {
        if(b.items[i][5]==1) {
          doc.ship.value = b.items[i][1];
          element = new Option(b.items[i][1], b.items[i][0], false, true);
          doc.ship.options[doc.ship.options.length] = element;
        }
      }
      if(doc.dest.value == 5) {
        if(b.items[i][6]==1) {
          doc.ship.value = b.items[i][1];
          element = new Option(b.items[i][1], b.items[i][0], false, true);
          doc.ship.options[doc.ship.options.length] = element;
        }
      }
      if(doc.dest.value == 6) {
        if(b.items[i][7]==1) {
          doc.ship.value = b.items[i][1];
          element = new Option(b.items[i][1], b.items[i][0], false, true);
          doc.ship.options[doc.ship.options.length] = element;
        }
      }
    }
    doc.ship.options[0].selected = true;
  }


/* Startet zuerst die Function delSelect() zum Löschen der Einträge in der Ports-Dropdown-Box. Danach werden in  */
/* Abhängigkeit der Destinations-ID (document.search_form.dest.value) aus der Destinations-Dropdown-Box die dazu gehörigen */
/* Ports aus den Array (a.items[i][1]) in die Ports-Dropdown-Box geschrieben. a.items[i][2] ist der Portname, */
/* a.items[i][0] ist die Port-ID und a.items[i][1] ist die Detsination-ID. */
  function updatePorts(id,form) {
    if ((form=="side_bar") || (form=="search")) {
      var doc = document.search_form;
    }
    if (form=="header") {
      var doc = document.search_form_nav;
    }
    delPort(form);
    for (i=0;i<a.items.length;i++) {
      if(doc.dest.value == a.items[i][1]) {
        doc.port.value = a.items[i][2];
        element = new Option(a.items[i][2], a.items[i][0], false, true);
        doc.port.options[doc.port.options.length] = element;
      }
    }
    for (i=0;i<aa.items.length;i++) {
      if (doc.dest.value == "") {
        doc.port.value = aa.items[i][2];
        element = new Option(aa.items[i][2], aa.items[i][0], false, true);
        doc.port.options[doc.port.options.length] = element;
      }
    }
    doc.port.options[0].selected = true;
    updateShipByDestination(id,form);
  }

  function updatePortByShip(id,form) {
    if ((form=="side_bar") || (form=="search")) {
      var doc = document.search_form;
    }
    if (form=="header") {
      var doc = document.search_form_nav;
    }
    if (doc.ship.value == "") {
      updatePorts("",form);
    }
    if (doc.ship.value == "DWN") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][4]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][4]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "GEM") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][3]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][3]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }

    if (doc.ship.value == "PRL") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][5]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][5]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "JWL") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][6]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][6]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "JAD") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][7]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][7]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "STA") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][8]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][8]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "SUN") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][9]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][9]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "SPR") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][10]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][10]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "SKY") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][11]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][11]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "AME") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][12]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][12]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "EPC") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][14]=="1") {
            if(a.items[i][13]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][13]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    if (doc.ship.value == "BWY") {
      delPort(form);
      for(i=0;i<a.items.length;i++) {
        if(doc.dest.value == a.items[i][1]) {
          if(a.items[i][15]=="1") {
            if(a.items[i][14]=="1") {
              doc.port.value = a.items[i][2];
              element = new Option(a.items[i][2], a.items[i][0], false, true);
              doc.port.options[doc.port.options.length] = element;
            }
          }
        }
      }
      for (i=0;i<aa.items.length;i++) {
        if(doc.dest.value == "") {
          if(aa.items[i][14]=="1") {
            doc.port.value = aa.items[i][2];
            element = new Option(aa.items[i][2], aa.items[i][0], false, true);
            doc.port.options[doc.port.options.length] = element;
          }
        }
      }
    }
    doc.port.options[0].selected = true;
  }

  function openNews(Title,Text) {
    var titleText = Title;
    Modalbox.show("http://www.ncl.eu/news.php", {title: titleText, height: 375, width: 725}); return false;
  }

  function showMore() {
    if (document.search_form.more.checked == true) {
      document.getElementById('advanced_search').style.display="";
    }
    else {
      document.getElementById('advanced_search').style.display="none";
    }
  }
  function setPorts(test){
    var ausgabe ="";
    ausgabe = ausgabe + '<option name="port" value="+test+">+test+</option>';
    div = document.getElementById('port_div');
    div.innerHTML = ausgabe;
  }

  function openModalWM() {
    var test="<p>You won't miss a single goal with us. On all our European cruises aboard Norwegian Gem, Norwegian Jade and Norwegian Sun, as well as the inaugural cruises of Norwegian Epic, NCL will be showing the World Championship. We will follow selected matches and of course show all games as of the quarter final live on board.</p>";
    Modalbox.show(test, {title: "Experience the soccer world cup on board the NCL fleet in Europe!", height: 150, width: 650 }); return false;
  }

 function openModalWindowsOnStart() {
    if(tempModalVar=="0") {
      openModalWindows();
    } else {
      if(tempNews=="1") {
        openModalNewsletter();
      }
    }
  }

  function checkEmailNewsletter() {
    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 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 = checkEmailNewsletter();
        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("Please fill in a valid email address.");
        } else {
          alert("Please fill in all mendatory fields.");
        }
        return (false);
      }
    }
  }

  function checkMandatoryFieldsNewsletterPage() {
    var complete ="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("last_name").value!="") {
      lastname_error ="true";document.getElementById("last_name_text").style.color="#666666";
    } 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="#666666";
    }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="#666666";
    } else {country_error ="false";document.getElementById("country_text").style.color="red";}
    if (document.getElementById("email_address").value!="") {
      emailCheck=checkEmailNewsletter();
      if (emailCheck==true) {
        email_error ="true";document.getElementById("e_mail_text").style.color="#666666";
      } 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="#666666";
    } 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="#666666";
    } 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("Please fill in a valid email address.");
      } else {
        alert("Please fill in all mendatory fields.");
      }
      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() {
    Modalbox.show("http://www.ncl.eu/itinerary/news_form.php", {title: "NCL Specials-Letter", height: 520, width: 700 }); return false;
  }

  function openModalNewsletter() {
    var test="<p class=\"billing\">Thank you very much for your NCL Newsletter registration.<br><br>You will soon receive an e-mail with a confirmation link. If you wish to receive the NCL Newsletter in future, all you have to do is click the link in the email.<br><br>Your NCL Freestyle Cruising Team</p>";
    Modalbox.show(test, {title: "Your NCL Newsletter registration", height: 250, width: 450 }); return false;
  }

  var search="0";
  function showSearchForm() {
    if (search=="0") {
      document.getElementById('advanced_search1').style.display="";
      search="1";
    } else {
      document.getElementById('advanced_search1').style.display="none";
      search="0";
    }
  }

  function checkEmailShoreEx() {
    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_shorex").value) == false){
      //alert("email falsch");
      return (false);
    } else {
      //alert("email richtig");
      return (true);
    }
  }

  function checkMandatoryFieldsShorex() {
    var complete ="false";
    var defaultValues ="false";
    var title_error ="true";
    var firstname_error ="true";
    var lastname_error ="true";
    var areacode_error ="true";
    var phone_error ="true";
    var country_error ="true";
    var contact_error ="true";
    var dest_error ="true";
    var contact_complete ="true";

    if (document.getElementById("country_shorex").value=="") {
      if (document.getElementById("title_shorex").value=="") {
        if (document.getElementById("last_name_shorex").value=="") {
          if (document.getElementById("first_name_shorex").value=="") {
            if (document.getElementById("area_code_shorex").value=="") {
              if (document.getElementById("phone_shorex").value=="") {
                if (document.getElementById("dest_shorex").value=="") {
                  if (document.getElementById("ship_shorex").value=="") {
                    if (document.getElementById("contact_select_value").value=="0") {
                      defaultValues="true";
                    } else {defaultValues ="false"}
                  } else {defaultValues ="false"}
                } else {defaultValues ="false"}
              } 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("title_shorex").value!="") {
        title_error ="true";document.getElementById("titletext").style.color="black";
      } else {title_error ="false";document.getElementById("titletext").style.color="red";}

      if (document.getElementById("last_name_shorex").value!="") {
        lastname_error ="true";document.getElementById("lastnametext").style.color="black";
      }else {lastname_error ="false";document.getElementById("lastnametext").style.color="red";}

      if (document.getElementById("first_name_shorex").value!="") {
        firstname_error ="true";document.getElementById("firstnametext").style.color="black";
      }else {firstname_error ="false";document.getElementById("firstnametext").style.color="red";}

      if (document.getElementById("country_shorex").value!="") {
        county_error ="true";document.getElementById("countrytext").style.color="black";
      } else {county_error ="false";document.getElementById("countrytext").style.color="red";}

      if (document.getElementById("dest_shorex").value!="") {
        dest_error ="true";document.getElementById("desttext").style.color="black";
      } else {dest_error ="false";document.getElementById("desttext").style.color="red";}

      if (document.getElementById("contact_select_value").value!="0") {
        contact_error ="true";document.getElementById("contact_select_text").style.color="black";
      } else {contact_error ="false";document.getElementById("contact_select_text").style.color="red";}

      if ((document.getElementById("contact_select_value").value=="mail") && (document.getElementById("email_address_shorex").value!="")) {
         emailCheck=checkEmailShoreEx();
         if (emailCheck==true) {
           contact_complete_error="true";email_error ="true";document.getElementById("email_label_shorex").style.color="black";
         } else {contact_complete_error="false";email_error ="false";document.getElementById("email_label_shorex").style.color="red";}
      } else {contact_complete_error="false";email_error ="true";document.getElementById("email_label_shorex").style.color="red"; }

      if (document.getElementById("contact_select_value").value=="phone") {
        if (document.getElementById("area_code_shorex").value!=""){
          areacode_error ="true";document.getElementById("phone_area_text").style.color="black";
        } else {areacode_error ="false";document.getElementById("phone_area_text").style.color="red";}

        if (document.getElementById("phone_shorex").value!="") {
         phone_error ="true";document.getElementById("phone_area_text").style.color="black";
        } else {phone_error ="false";document.getElementById("phone_area_text").style.color="red";}

        if ((phone_error =="false") || (areacode_error =="false")) {
          document.getElementById("phone_area_text").style.color="red";
          contact_complete_error="false";
        } else {
          contact_complete_error="true";
        }
      }


      if ((title_error =="false") || (lastname_error =="false") || (firstname_error =="false") || (contact_complete_error =="false") || (country_error =="false") || (dest_error =="false")) {
        complete = "false";
      } else {complete = "true";}
      if (complete=="true") {
        return (true);
      } else if (complete=="false"){
        if (email_error =="false") {
          alert("Please fill in a valid email address.");
        } else {
          alert("Please fill in all mendatory fields.");
        }
        return (false);
      }
    }
  }

  function showAgencyShorex(show) {
    if (show==1) {
      document.getElementById('agencylabel_shorex').style.display="";
      document.getElementById('agencyname_shorex').style.display="";
    }
    if (show==2) {
      document.getElementById('agencylabel_shorex').style.display="none";
      document.getElementById('agencyname_shorex').style.display="none";
      document.getElementById('agencyname_shorex').value="";
    }
  }

  function showContactMethod(id) {
    if (id==1) {
      document.getElementById('contact_mail').style.display="";
      document.getElementById('contact_phone').style.display="none";
      document.getElementById('contact_select_value').value="mail";
    }
    if (id==2) {
      document.getElementById('contact_mail').style.display="none";
      document.getElementById('contact_phone').style.display="";
      document.getElementById('contact_select_value').value="phone";
    }
  }

  function setEmailShorex() {
    if (document.getElementById("allowemailspecial_shorex").checked == true) {
      document.getElementById("email_label_shorex").style.display="";
      document.getElementById("email_address_shorex").style.display="";
    } else {
      document.getElementById("email_label_shorex").style.display="none";
      document.getElementById("email_label_shorex").value="";
      document.getElementById("email_address_shorex").style.display="none";
      document.getElementById("email_address_shorex").value="";
    }
  }

  function openModalClickToCallShorex() {
    Modalbox.show("http://www.ncl.eu/shorex/shorex_ctc_form.php", {title: "&nbsp;", height: 560, width: 735}); return false;
  }

  function openModalShoreExCTC() {
    if (shoreex_ctc=="1") {
      var test="<p class=\"billing\">Thank you very much for your registration.</p><p>We will handle you request and contact you as soon as possible.<br><br>Your NCL Freestyle Cruising Team</p>";
      Modalbox.show(test, {title: "Thank you very much for your registration.", height: 250, width: 450 }); return false;
    }
  }

/*---------------------------------------------------------------------------------------------*/
// Miles and More
/*---------------------------------------------------------------------------------------------*/

  function showConditions() {
    var ShowText ="<p>With NCL Freestyle Cruising you can go your own way and do whatever you would like to do during your holidays at sea. For Miles & More members this also applies to the mode of payment: The stated mile price is per person based on double occupancy. But only one person per booking has to pay in miles. The second person can also choose to pay the brochure or special price of the cruise in euro. At the time of booking, simply let us know how you would like to pay. For more information and reservations contact us at +49-611-36 07 024 or <a href=\"milesandmore@ncl.com\" style=\"text-decoration:underline;\">milesandmore@ncl.com</a>.</p>";
    ShowText +="<p><b>Conditions:</b><br>";
    ShowText += "<p class=\"arrow_white\">Spending award miles with NCL is only possible for Miles & More members from Continental Europe (including Russia, excluding Great Britain and Ireland).</p>";
    ShowText += "<p class=\"arrow_white\">All \"spend miles\" offers are \"cruise only\". The journey to and from the port is not included.</p>";
    ShowText += "<p class=\"arrow_white\">The mentioned mileage offers are per person based on double occupancy.</p>";
    ShowText += "<p class=\"arrow_white\">Fee charged for booking changes or cancellations. Bookings subject to availability. </p>";
    ShowText +="<p class=\"arrow_white\">The person redeeming miles must travel.</p>";
    ShowText += "<p class=\"arrow_white\">The  <a href=\"../termsandconditions.php\" style=\"text-decoration:underline\">general Terms & Conditions</a> of NCL (Bahamas) Ltd. apply.</p>";
    ShowText += "<p><b>Notice for Cruise Rewards & Latitudes Club: </b><br>If you spend award miles for the full cruise fare on one of the above mentioned cruises, you are paying a specially calculated rate. Therefore, the redemption of a Cruise Reward voucher for the same cruise is not possible.<br><br>For the same reason, it is not possible to profit from Latitudes rates for the same cruise. All other Latitudes privileges on board are of course granted, and the cruise fully counts towards your Latitudes status.</p>";
    Modalbox.show(ShowText, {title: "Conditions", height: 430, width: 700}); return false;
  }
  function showConditionsNewReedemModel() {
    var ShowText ="<p class=\"arrow_white\">Spending award miles with NCL is only possible for Miles & More members from Continental Europe (including Russia, excluding Great Britain and Ireland).</p>";
    ShowText +="<p class=\"arrow_white\">You can only redeem award miles for partial amounts of your cruise fare (\"cruise only\")</p>";
    ShowText +="<p class=\"arrow_white\">The offer is valid for all available published rates in Euro, including Specials. A combination with Latitudes pricing and Cruise Rewards is possible.</p>";
    ShowText +="<p class=\"arrow_white\">Bookings: up to 15 work days in advance</p>";
    ShowText +="<p class=\"arrow_white\">Fee charged for booking changes or cancellations. Bookings subject to availability.</p>";
    ShowText +="<p class=\"arrow_white\">The person redeeming miles must travel.</p>";
    ShowText +="<p class=\"arrow_white\">The <a href=\"../termsandconditions.php\" style=\"text-decoration:underline\">general Terms & Conditions</a> of NCL (Bahamas) Ltd. apply.</p>";
    Modalbox.show(ShowText, {title: "Conditions", height: 230, width: 700}); return false;
  }

/*---------------------------------------------------------------------------------------------*/
// ShoreEx
/*---------------------------------------------------------------------------------------------*/
  function Array2D(x,y) {
    this.items = new Array(x);
    for(i=0;i<y;i++) {
      this.items[i] = new Array(y);
    }
  }
  var zahl = 250;
  ashore = new Array2D(7,zahl);
  var x=0;

  function makePortsShown(id) {
    delSelect();
    var count=0;
    for (i=0;i<ashore.items.length;i++) {
      if(document.edt_port_to_dest.dest.value == ashore.items[i][1]) {
        document.edt_port_to_dest.port.value = ashore.items[i][2];
        element = new Option(ashore.items[i][2], ashore.items[i][0], false, true);
        document.edt_port_to_dest.port.options[document.edt_port_to_dest.port.options.length] = element;
        count++;
      }
    }
    document.edt_port_to_dest.port.options[0].selected = true;
    return count;
  }

  function delSelect() {
    for(i=1;i<document.edt_port_to_dest.port.length;) {
      document.edt_port_to_dest.port.options[document.edt_port_to_dest.port.length - 1] = null;
    }
  }

  function setSelectedDestPort() {
    if (dest_shorex=="Make your selection") {dest_shorex =0; }
    document.edt_port_to_dest.dest.options[dest_shorex].selected = true;
    var count = makePortsShown(dest_shorex);
    for (i=0;i<=count;i++) {
      if(document.edt_port_to_dest.port.options[i].value == port_shorex) {
        document.edt_port_to_dest.port.options[i].selected = true;
      }
    }
  }

  function checkShoreEx() {
    var finish = "true";
    if(document.edt_port_to_dest.dest.value=="Make your selection") {
      text ="Please choose a destination";
      var finish = "false";
    } else {
      if(document.edt_port_to_dest.port.value=="Make your selection") {
        text ="Please choose your port";
        var finish = "false";
      }
    }
    if(finish=="false") {
      alert (text)
    } else {
      document.edt_port_to_dest.submit();
    }
  }

/*---------------------------------------------------------------------------------------------*/
// ShoreEx System Outage
/*---------------------------------------------------------------------------------------------*/
  function systemOutageShoreEx(Title) {
    var titleText = Title;
    Modalbox.show("http://www.ncl.eu/shorex/outage.php", {title: titleText, height: 300, width: 400}); return false;
  }

/*---------------------------------------------------------------------------------------------*/
// OBE System Outage
/*---------------------------------------------------------------------------------------------*/
  function systemOutageObe(Title) {
    var titleText = Title;
    Modalbox.show("http://www.ncl.eu/itinerary/outage.php", {title: titleText, height: 300, width: 400}); return false;
  }

/*---------------------------------------------------------------------------------------------*/
// Variable und Funktion zum steuern der Kreuzfahrtsuche in der Navigation
/*---------------------------------------------------------------------------------------------*/
  var showFind = '1';
  function show_find_a_cruise(id) {
    if (id =='1') {
      document.getElementById('nav_search').style.display='none';
      showFind='1';
    } else {
      if(showFind=='1') {
        document.getElementById('nav_search').style.display='block';
        showFind='0';
      } else {
        document.getElementById('nav_search').style.display='none';
        showFind='1';
      }
    }
  }

/*---------------------------------------------------------------------------------------------*/
// Ship Section link dropdownin nav_right
/*---------------------------------------------------------------------------------------------*/
  function linkShip(url) {
    window.location='http://www.ncl.eu/'+url;
  }

/*---------------------------------------------------------------------------------------------*/
// Terms and Conditions Latitudes Rewards
/*---------------------------------------------------------------------------------------------*/
  function openModalLat() {
    var titleText = "Terms & Conditions Latitudes Rewards";
    var text="<p>Terms & Conditions Latitudes Rewards: You can only enhance your membership level through the booking of full tariff cruises. Cruises of five nights or less count towards your Latitudes level but on board benefits are only available on sailings of five nights or more. If you should receive an on board credit (e.g. as part of the Latitudes Insider Offer), it can be used for expenses on board, e.g. for speciality restaurant surcharges and drinks, shore excursions and other services. It is only valid for the booked cruise and non-disbursable. ";
    text+="<br><br>Latitudes Insider Offers are only valid for new bookings. On board credits are applicable per stateroom (amount varies per category) and based on two adults sharing the stateroom. On board credits are not applicable for 3rd/4th person, children or infants. Single occupancy receives the same amount of OBC per stateroom. Latitudes Insider Offers are combinable with specials and promotions but are only valid for full tariff cruises. Offers are limited and subject to availability. ";
    text+="<br><br>Except where indicated, all fares are per person in Euro based on double/twin occupancy and for bookings from Continental Europe. Aboard our ships a US $ 12 discretionary service charge applies per guest and day which can be paid in advance. For more information please contact your travel agency or visit ncl.eu. The general terms and conditions of Norwegian Cruise Line apply. ";
    text+="<br><br>In some cases priority check-in might not be available. <br>Terms & Conditions of our Latitudes Rewards programme may vary depending on the country in which the cruise was booked. <br>Errors and omissions excepted.</p>";
    text+="<button onclick=\"Modalbox.hide();\" id=\"search_cruises_button_search_details\" value=\"Close\">Close</button> ";
    Modalbox.show(text, {title: titleText, height: 375, width: 725}); return false;
  }
