function set_visibility(val) {
  var e = document.getElementById("magicdiv");
  var r1 = document.getElementById("r_1");
  var r2 = document.getElementById("r_2");
  if(val==0) {
    e.style.display = 'none';
  }
  else {
    e.style.display = 'block';
 }
}

function Fenster (Dateiname,Hoehe)
{
 win = window.open(Dateiname, "Zweitfenster", 'width=700, height='+Hoehe+', top=50, resizable=1, scrollbars=auto');
 win.focus();
}

function FensterLeer (Text,Hoehe)
{
 win = window.open('', "Zweitfenster", 'width=700, height='+Hoehe+', top=50, resizable=1, scrollbars=auto');
 win.document.write(Text);
 win.document.close();
 win.focus();
}

function checkAll(field)
{ for (i = 0; i < field.length; i++)
  field[i].checked = true ;
}
function uncheckAll(field)
{ for (i = 0; i < field.length; i++)
  field[i].checked = false ;
}

function checkAllMail()
{ count = document.MailFormular.elements.length;
  for (i=0; i < count; i++)
  document.MailFormular.elements[i].checked = 1;
}

function uncheckAllMail()
{ count = document.MailFormular.elements.length;
  for (i=0; i < count; i++)
  document.MailFormular.elements[i].checked = 0;
}


function chkconfirm()
{
if(document.Formular.takepart[0].checked == false &&
   document.Formular.takepart[1].checked == false)
 { alert("Reconfirmation of your participation is missing");
   document.Formular.takepart[0].focus();
   return false; }
}

function chkformular()
{

iOrganisation       = "Bitte einen Firmennamen eingeben!";
iStreet     = "Bitte eine Straße eingeben!";
iZIP         = "Bitte eine Postleitzahl eingeben!";
iOrt         = "Bitte einen Ort eingeben!";
iRegion      = "Bitte ein Bundesland auswählen";
iTelefon     = "Bitte eine Telefonnummer eingeben!";
iMail        = "E-Mail addresse fehlt oder fehlerhaft!";
iFoundet       = "Bitte Gründungsjahr angeben";
iEmployees = "Bitte Zahl der Mitarbeiter angeben";
iBusinessTyp = "Bitte den Unternehmenstyp angeben";
iGender      = "Bitte Anrede Herr/Frau angeben";
iFirstname     = "Bitte einen Vornamen angeben!";
iLastname    = "Bitte einen Nachnamen angeben!";
iFunktion    = "Bitte Ihre Position/Funktion angeben!";
iLanguage     = "Welche Sprachen sprechen Sie?";
iBranche     = "Bitte eine Branche auswählen";
iPasswort    = "Bitte ein Passwort angeben (min. 4 Zeichen)!";
iAntispam    = "Bitte gültigen Antispam Code eingeben";
iKooperation = "Für welche Arten von Kooperation interessieren Sie sich?";
iProfilTyp   = "Art der Serviceleistung";
iProfilTitel = "Titel - Über was wollen Sie mit wem reden fehlt.";
iText1       = "Angaben zum Produkt, Service, Know-how fehlen";
iText2       = "Angaben zu Kooperationswunsch fehlen.";
iText3       = "Kurze Firmenbeschreibung fehlt";
iFrage1      = "Ich melde mich an als?  wurde nicht ausgewählt";
iFrage2      = "Sind Sie Mitglied der Wirtschaftskammer Wien";
iFrage3      = "Frage3";
iFrage4      = "An welchen Programmpunkten nehmen Sie teil?";
iFrage5      = "Frage5";


var SelectionOK = false;
if(! document.Formular.update) {
  if(document.Formular.radio1 && document.Formular.radio1_mandatory) {
   for (var i=0; i<document.Formular.radio1.length; i++)
      if (document.Formular.radio1[i].checked) SelectionOK = true;
   if (!SelectionOK) { alert(iFrage1);
                     return false; }
  }
}

if(document.Formular.organisation.value == "")
 { alert(iOrganisation);
   document.Formular.organisation.focus();
   return false; }

if(document.Formular.street.value == "")
 { alert(iStreet);
   document.Formular.street.focus();
   return false; }

if(document.Formular.zip.value == "")
 { alert(iZIP);
   document.Formular.zip.focus();
   return false; }


if(document.Formular.city.value == "")
 { alert(iOrt);
   document.Formular.city.focus();
   return false; }


if(document.Formular.region.type == "select-one") {
  if (document.Formular.region.selectedIndex < 1)
  { alert(iRegion);
    document.Formular.region.focus();
    return false; }
}
else {
  var region_ok = false;
  for (var i=0; i<document.Formular.region.length; i++)
    if (document.Formular.region[i].checked) region_ok = true;

  if (!region_ok) { alert(iRegion);
                    document.Formular.region[0].focus();
                    return false; }
}

if(document.Formular.telefon.value == "")
 { alert(iTelefon);
   document.Formular.telefon.focus();
   return false; }
/*
if(document.Formular.fax.value == "")
 { alert("Bitte eine Faxnunmer eingeben!");
   document.Formular.fax.focus();
   return false; }
*/

if(chk_mail(document.Formular.client_email.value) == false)
 { alert(iMail);
   document.Formular.client_email.focus();
   return false; }


if(document.Formular.founded)
{
 if(document.Formular.founded.value == "")
  { alert(iFoundet);
    document.Formular.founded.focus();
    return false; }
}

if(document.Formular.employees)
{
 var SelectionOK = false;
 for (var i=0; i<document.Formular.employees.length; i++)
    if (document.Formular.employees[i].checked) SelectionOK = true;
 if (!SelectionOK) { alert(iEmployees);
                   document.Formular.employees[0].focus();
                   return false; }
}

if(document.Formular.orgtype)
{
 var orgtype_ok = false;
 for (var i=0; i<document.Formular.orgtype.length; i++)
    if (document.Formular.orgtype[i].checked) orgtype_ok = true;
 if (!orgtype_ok) { alert(iBusinessTyp);
                   document.Formular.orgtype[0].focus();
                   return false; }
}


if(document.Formular.gender[0].checked == false &&
   document.Formular.gender[1].checked == false )
 { alert(iGender);
   document.Formular.gender[0].focus();
   return false; }

if(document.Formular.firstname.value == "")
 { alert(iFirstname);
   document.Formular.firstname.focus();
   return false; }

if(document.Formular.lastname.value == "")
 { alert(iLastname);
   document.Formular.lastname.focus();
   return false; }

if(document.Formular.position.value == "")
 { alert(iFunktion);
   document.Formular.position.focus();
   return false; }


var chks = document.Formular.elements['language[]'];
if(chks)
{
 var count = 0;
 for (var i=0;i<chks.length;i++)
  if (chks[i].checked) count +=1;
 if (count == 0) { alert(iLanguage);
                   chks[0].focus();
                   return false;
                 }
}


/*
 if(document.Formular.orgbackground.value == "")
  { alert(iText3);
    document.Formular.orgbackground.focus();
    return false; }

 if (document.Formular.type1) {
   var ProfilTyp_ok = false;
   for (var i=0; i<document.Formular.type1.length; i++)
     if (document.Formular.type1[i].checked) ProfilTyp_ok = true;
   if (!ProfilTyp_ok) { alert(iProfilTyp);
                        document.Formular.type1[0].focus();
                        return false; }
 }

 if(document.Formular.titel1.value == "")
   { alert(iProfilTitel);
     document.Formular.titel1.focus();
     return false; }

 if(document.Formular.text1.value == "")
  { alert(iText1);
    document.Formular.text1.focus();
    return false; }

*/


var SelectionOK = false;
if(document.Formular.radio2 && document.Formular.radio2_mandatory) {
 for (var i=0; i<document.Formular.radio2.length; i++)
    if (document.Formular.radio2[i].checked) SelectionOK = true;
 if (!SelectionOK) { alert(iFrage2);
                   document.Formular.radio2[0].focus();
                   return false; }
}

var SelectionOK = false;
if(document.Formular.radio3 && document.Formular.radio3_mandatory) {
 for (var i=0; i<document.Formular.radio3.length; i++)
    if (document.Formular.radio3[i].checked) SelectionOK = true;
 if (!SelectionOK) { alert(iFrage3);
                   document.Formular.radio3[0].focus();
                   return false; }
}


var chks = document.Formular.elements['checkbox1[]'];
if(document.Formular.checkbox1_mandatory.value == true && chks)
if(chks)
{
 var count = 0;
 for (var i=0;i<chks.length;i++)
    if (chks[i].checked) count +=1;
 if (count == 0) { alert(iFrage4);
                   chks[0].focus();
                   return false;
                 }
}

var chks = document.Formular.elements['checkbox2[]'];
if(document.Formular.checkbox2_mandatory == true && chks)
{
 var count = 0;
 for (var i=0;i<chks.length;i++)
    if (chks[i].checked) count +=1;
 if (count == 0) { alert(iFrage5);
                   chks[0].focus();
                   return false;
                 }
}

if(document.Formular.client_password.value.length < 4)
 { alert(iPasswort);
   document.Formular.client_password.focus();
   return false; }

if(document.Formular.antispam && document.Formular.antispam.value != document.Formular.antispam2.value)
 { alert(iAntispam);
   document.Formular.antispam.focus();
   return false; }


} // ###############  Ende Check Formular  #############################
  // ###################################################################


function isInt(wert) {
  if (wert == "") return false;
  for (i=0; i<4;i++) {
    if (wert.charAt(i) < "0") { return false; }
    if (wert.charAt(i) > "9") { return false; }
  }
}

function chk_mail(s)
{
 var a = false;
 var res = false;
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

 if(a == true)
 {
  reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                   '(\\.)([a-zA-Z]{2,4})$');
  res = (reg.test(s));
 }
 else
 {
  res = (s.search('@') >= 1 &&
         s.lastIndexOf('.') > s.search('@') &&
         s.lastIndexOf('.') >= s.length-5)
 }
 return(res);
}

function check_talk_number(maxtalks)
{
 var count1 = 0;
 var count2 = 0;

 var chks1 = document.ListTalkFormular.elements['selected_own_talks[]'];
 for (var i=0;i<chks1.length;i++)
   if (chks1[i].checked) count1 +=1;

 var chks2 = document.ListTalkFormular.elements['selected_guest_talks[]'];
 if(typeof(chks2) != 'undefined') {
  for (var i=0;i<chks2.length;i++)
    if (chks2[i].checked) count2 +=1;
 }

 if ( (count1+count2) > maxtalks)
 { alert("The maximum of " + maxtalks + " meetings has been achieved.");
   return false;
 }
 return true;
}
