var ok=false; // Kein Popup-Blocker angenommen
var Lang = "E";

// **** Funktion zum Formular per Mail senden
function sendFormular(sprache, docForm, email, weite, hoehe)
{
  if (docForm.Concept_or_plan.value.length == 0)
  {
   if (sprache == "E")
    alert ("You did not enter any text!");
   else if (sprache == "S")
    alert ("¡No ha introducido ningún texto!");
   else
    alert ("Sie haben keinen Text eingegeben!");
   docForm.Concept_or_plan.focus();
   return false;
  }
//  if (navigator.appName != "Microsoft Internet Explorer") return true; // Evtl. auskommentieren
  var t = new Array();
  if (sprache == "E")
  {
   t[0] = "Request via www.MoSysReal.net";
   t[1] = "[Name/company]: " + docForm.Name_and_company.value + ".";
   t[3] = "[Concept/plan]: \n" + docForm.Concept_or_plan.value;
   t[2] = "[Wish]: ";
   if (docForm.Feasibility_check.checked == true)
   {
    t[2] += "feasibility check";
    if (docForm.Consultation.checked == true) t[2] += " and consultation";
   }
   else
   {
    if (docForm.Consultation.checked == true) t[2] += "consultation";
    else t[2] += "no special wish"
   }
   if (docForm.Status[0].checked == true)
     t[2] += " (non-committal).";
   else if (docForm.Status[1].checked == true)
     t[2] += ", as official order!";
  }
  else if (sprache == "S")
  {
   t[0] = "Demanda vía www.MoSysReal.net";
   t[1] = "[Nombre/empresa]: " + docForm.Name_and_company.value + ".";
   t[3] = "[Concepto/plan]: \n" + docForm.Concept_or_plan.value;
   t[2] = "[Deseo]: ";
   if (docForm.Feasibility_check.checked == true)
   {
    t[2] += "informe de factibilidad";
    if (docForm.Consultation.checked == true) t[2] += " y consulta";
   }
   else
   {
    if (docForm.Consultation.checked == true) t[2] += "consulta";
    else t[2] += "ningún deseo especial"
   }
   if (docForm.Status[0].checked == true)
     t[2] += " (sin compromiso).";
   else if (docForm.Status[1].checked == true)
     t[2] += " de orden oficial!";
  }
  else
  {
   t[0] = "Anfrage über www.MoSysReal.net";
   t[1] = "[Name/Firma]: " + docForm.Name_and_company.value + ".";
   t[3] = "[Konzept/Plan]: \n" + docForm.Concept_or_plan.value;
   t[2] = "[Wunsch]: ";
   if (docForm.Feasibility_check.checked == true)
   {
    t[2] += "Machbarkeitsprüfung";
    if (docForm.Consultation.checked == true) t[2] += " und Konsultation";
   }
   else
   {
    if (docForm.Consultation.checked == true) t[2] += "Konsultation";
    else t[2] += "kein spezieller Wunsch"
   }
   if (docForm.Status[0].checked == true)
     t[2] += " (unverbindlich).";
   else if (docForm.Status[1].checked == true)
     t[2] += " - als offizieller Auftrag!";
  }

  var x = (screen.width - weite - 10) / 2;
  var y = (screen.height - hoehe - 32) / 2;
  var fenster = "width=" + weite + ",height=" + hoehe;
  fenster += ",left=" + x + ",top=" + y + ",scrollbars=yes";
  var Formular = window.open("","PopUp",fenster); Formular.focus();
  Formular.document.open();
  if (sprache == "E")
   Formular.document.write("<html><head><title>Concept / Project plan<\/title><\/head>");
  else if (sprache == "S")
   Formular.document.write("<html><head><title>Concepto / plan de proyecto<\/title><\/head>");
  else
   Formular.document.write("<html><head><title>Konzept / Projektplan<\/title><\/head>");
///////
   Formular.document.write("<script language=\"JavaScript\" type=\"text/JavaScript\">window.opener.ok = true;</script>");
   setTimeout("Check()", 1500);
   Lang=sprache;
///////
  Formular.document.write("<body style=\"font:91% Arial,sans-serif;\"");

  Formular.document.writeln("><p>");


  var name = navigator.appName;
  var vers = navigator.appVersion;
  var ua = navigator.userAgent;
  var ausgabe = "";

  if (ua.indexOf("Opera") != -1) {
   ausgabe = "OP";
  } else if (name == "Konqueror") {
   ausgabe = "KO";
  } else if (ua.indexOf("Firefox") >= 0) {
   ausgabe = "FF";
  } else if ((name == "Netscape") && (ua.indexOf("Netscape") == -1) && (parseFloat(vers) >= 5)) {
   ausgabe = "MO";
  } else if (name == "Netscape") {
   ausgabe = "NN";
  } else if (name == "Microsoft Internet Explorer") {
   ausgabe = "IE";
  } else {
   ausgabe= "NB";
  }
  var versIE = 0;
  var pos = ua.indexOf("MSIE");
  if ((pos >= 0) && (ua.length > pos+9)){
   var strv = ua.substring(pos+5, pos+9);
   versIE = parseFloat(strv);
  }
  var versFF = 0;
  var pos = ua.indexOf("Firefox");
  if ((pos >= 0) && (ua.length > pos+13)){
   var strv = ua.substring(pos+8, pos+13);
   versFF = parseFloat(strv);
  }

  // Für den Mozilla-Browser 1.x und Netscape sowie solche unter Version 6 keine Sonderzeichen
  var KeineSonderzeichen =
       (((ua.toLowerCase().indexOf('rv:1.') != -1) && (ausgabe == "MO")) ||
        (ausgabe == "NN") ||
        ((ausgabe == "IE") && (parseFloat(versIE) < 6)) ||
        ((ausgabe == "FF") && (parseFloat(versIE) < 1.5)))

  var m = "";
  for (var i = 0; i <= 3; i++)
  {
    var z = ""; var cr = 0;
    for (var y = 0; y < Number(t[i].length); y++)
    {

     if (KeineSonderzeichen)
      switch(t[i].charCodeAt(y))
      {
        case 13: z += "¦"; cr = 1; break;
        case 10: if (!cr) z += "¦"; break;
        case 32: z += "&#32;"; break;
        case 34: z += "&#34;"; break;
        case 38: z += "+"; break;
        case 60: z += "&#60;"; break;
        case 61: z += "&#61;"; break;
        case 62: z += "&#62;"; break;
        case 64: z += "&#64;"; break;
        case 161: z += "!"; break;
        case 162: z += "cent"; break;
        case 163: z += "pound"; break;
        case 167: z += "Paragraph"; break;
        case 169: z += "(C)"; break;
        case 174: z += "(R)"; break;
        case 177: z += "+/-"; break;
        case 183: z += "*"; break;
        case 187: z += "''"; break;
        case 191: z += "?"; break;
        case 192: z += "A"; break;
        case 193: z += "A"; break;
        case 196: z += "Ae"; break;
        case 199: z += "C"; break;
        case 200: z += "E"; break;
        case 201: z += "E"; break;
        case 204: z += "I"; break;
        case 205: z += "I"; break;
        case 209: z += "N"; break;
        case 210: z += "O"; break;
        case 211: z += "O"; break;
        case 214: z += "Oe"; break;
        case 215: z += "*"; break;
        case 217: z += "U"; break;
        case 218: z += "U"; break;
        case 220: z += "Ue"; break;
        case 221: z += "Y"; break;
        case 223: z += "ss"; break;
        case 224: z += "a"; break;
        case 225: z += "a"; break;
        case 227: z += "a"; break;
        case 228: z += "ae"; break;
        case 231: z += "c"; break;
        case 232: z += "e"; break;
        case 233: z += "e"; break;
        case 235: z += "e"; break;
        case 236: z += "i"; break;
        case 237: z += "i"; break;
        case 239: z += "i"; break;
        case 241: z += "n"; break;
        case 242: z += "o"; break;
        case 243: z += "o"; break;
        case 245: z += "o"; break;
        case 246: z += "oe"; break;
        case 247: z += "/"; break;
        case 249: z += "u"; break;
        case 250: z += "u"; break;
        case 252: z += "ue"; break;
        case 253: z += "y"; break;
        case 254: z += "y"; break;
        case 8364: z += "EUR"; break;
        default:
         if ((t[i].charCodeAt(y) > 160) && (t[i].charCodeAt(y) < 256))
          z += "&#"+t[i].charCodeAt(y)+";";
         else if (t[i].charCodeAt(y) > 32 && t[i].charCodeAt(y) < 127)
          z += t[i].charAt(y);
         else z += "&#191;";
      }
     else
      switch(t[i].charCodeAt(y))
      {
        case 13: z += "¦"; cr = 1; break;
        case 10: if (!cr) z += "¦"; break;
        case 32: z += "&#32;"; break;
        case 34: z += "&#34;"; break;
        case 38: z += "+"; break;
        case 60: z += "&#60;"; break;
        case 61: z += "&#61;"; break;
        case 62: z += "&#62;"; break;
        case 64: z += "&#64;"; break;
        case 8364: z += "EUR"; break;
        default:
         if ((t[i].charCodeAt(y) > 160) && (t[i].charCodeAt(y) < 256))
          z += "&#"+t[i].charCodeAt(y)+";";
         else if (t[i].charCodeAt(y) > 32 && t[i].charCodeAt(y) < 127)
          z += t[i].charAt(y);
         else z += "&#191;";
      }
    }
    
    var crString = "&#32;&#32;%0D%0A";

    // Für den Mozilla-Browser 1.x und Netscape ist CR "<br>"
    var uAgent = ua.toLowerCase();
    if (((uAgent.indexOf('rv:1.') != -1) && (ausgabe == "MO")) ||
          (ausgabe == "NN"))
     crString = "%0D%0A";

    t[i] = z; z = ""; var e = "";
    for (y = 0; y < Number(t[i].length); y++)
    {
      if (t[i].charAt(y) == "¦") {
        z += "<br>"; e += crString;
      }
      else {
        z += t[i].charAt(y);
        if (t[i].charAt(y) == "?") e += "%3F";
        else {
          e += t[i].charAt(y);
          if (t[i].charAt(y) == "%") e += "25";
        }
      }
    }
    Formular.document.writeln(z + "<br>"); t[i] = e;
    if (i > 0) m += t[i] + crString;
    if (i < 3)
    {
      Formular.document.writeln("<br>"); m += crString;
    }
  }
  Formular.document.writeln("<\/p>");
  if (m.length > 1750)
  {
   if (sprache == "E")
   {
     Formular.document.write("<hr><p><b><i>You entered very lot of ");
     Formular.document.write("text,<br>so that an automatic take over ");
     Formular.document.write("is unfortunately not possible.<br>");
     Formular.document.write("Please copy your above text ");
     Formular.document.write("(Ctrl-C) and<br>paste it then ");
     Formular.document.writeln("into your e-mail programm (Ctrl-V).<\/b><\/i><\/p>");
     m = "- insert your text here please -";
   }
   else if (sprache == "S")
   {
     Formular.document.write("<hr><p><b><i>Ha introducido mucho ");
     Formular.document.write("texto<br>de manera que una toma automatica ");
     Formular.document.write("desgraciadamente no es posible.<br>");
     Formular.document.write("Por favor copie su texto mencionado ");
     Formular.document.write("(Ctrl-C) y<br>lo inserte a continuacion ");
     Formular.document.writeln("en su programa de e-mail (Ctrl-V).<\/b><\/i><\/p>");
     m = "- insertar su texto aqui por favor -";
   }
   else
   {
     Formular.document.write("<hr><p><b><i>Sie haben sehr viel Text ");
     Formular.document.write("eingegeben,<br>so dass eine automatische ");
     Formular.document.write("Uebernahme leider nicht moeglich ist.<br>");
     Formular.document.write("Bitte kopieren Sie Ihren obenstehenden Text ");
     Formular.document.write("(Strg-C) und<br>fuegen ihn anschliessend ");
     Formular.document.writeln("in Ihr E-Mail-Programm ein (Strg-V).<\/b><\/i><\/p>");
     m = "- hier bitte Ihren Text einfuegen -";
   }
  }
  Formular.document.write("<p><a href=\"mailto:" + email);
  Formular.document.write("?subject=" + t[0] + "&amp;body=" + m + "\"");
  Formular.document.write(" method=\"post\" enctype=\"text/plain\" onclick=\"window.setTimeout('self.close()',100)\"");
  if (sprache == "E")
   Formular.document.writeln(">Send e-mail<\/a><\/p><\/body><\/html>");
  else if (sprache == "S")
   Formular.document.writeln(">Envío de e-mail<\/a><\/p><\/body><\/html>");
  else
   Formular.document.writeln(">E-Mail versenden<\/a><\/p><\/body><\/html>");
  Formular.document.close();
  return false;
}

function Check()
{
 if (ok==false){
  if (Lang == "E")
   alert("For checking / sending you must now allow this pop-up.");
  else if (Lang == "S")
   alert("Para chequear / enviar ahora permitir este pop-up.");
  else
   alert("Zum Prüfen / Senden müssen Sie dieses Pop-up jetzt zulassen."); 
 }
}

