Balten=new Array();
        Mailarray=new Array();

        function hoverBalte(id,color)
        {
                 if ( !isSelected(id) ) document.getElementById("Balte" + id).style.background = color;
        }

        function hoverCharge(id,color,height)
        {
                 document.getElementById("Balte" + id).style.background = color;
                 document.getElementById("Balte" + id).style.height = height;
        }

        function isSelected(id)
        {
                 var gefunden=false;
                 for (var i = 0; i < Balten.length; i++)
                 {
                      if (id==Balten[i])
                      {
                          gefunden=true;
                          return gefunden;
                      }
                 }
                 return false;
        }

        function sendMail()
        {
                 emails=Mailarray.join(";");
                 window.location.href = "mailto:" + emails;
        }

        function selectAll(Anzahl,mails,backgrounds)
        {
                 for (var i = 0; i < Anzahl ; i++)
                 {
                      selectBalte(i,mails[i],backgrounds[i]);
                 }
        }

        function selectBalte(id,mail,background)
        {
                        if ( isSelected(id) )
                        {
                             document.getElementById("Balte" + id).style.background = background;
                             var position;
                             laenge=Balten.length;
                             for (var i = 0; i < laenge; i++)
                             {
                                  if (id==Balten[i])
                                  {
                                       Balten.splice(i,1);
                                       i=laenge;
                                  }
                             }
                             laenge=Mailarray.length;
                             for (var i = 0; i < laenge ; i++)
                             {
                                  if (mail==Mailarray[i])
                                  {
                                       Mailarray.splice(i,1);
                                       i=laenge;
                                  }
                             }
                        }
                        else
                        {
                             Balten.push(id);
                             Mailarray.push(mail);
                             document.getElementById("Balte" + id).style.background = "#8AAEEF";
                        }
                        document.getElementById('empfaenger').innerHTML=Mailarray.join(", ");
                        document.getElementById('input_empfaenger').value=Mailarray.join(", ");
        }
        function selectMail(id,mail,background)
        {
                        Show('writemail');
                        if ( isSelected(id) )
                        {
                             document.getElementById("Balte" + id).style.background = background;
                             var position;
                             laenge=Balten.length;
                             for (var i = 0; i < laenge; i++)
                             {
                                  if (id==Balten[i])
                                  {
                                       Balten.splice(i,1);
                                       i=laenge;
                                  }
                             }
                             laenge=Mailarray.length;
                             for (var i = 0; i < laenge ; i++)
                             {
                                  if (mail==Mailarray[i])
                                  {
                                       Mailarray.splice(i,1);
                                       i=laenge;
                                  }
                             }
                        }
                        else
                        {
                             Balten.push(id);
                             Mailarray.push(mail);
                             document.getElementById("Balte" + id).style.background = "#8AAEEF";
                        }
                        document.getElementById('empfaenger').innerHTML=Mailarray.join(", ");
                        document.getElementById('input_empfaenger').value=Mailarray.join(", ");
        }
        function Login ()
        {
                        document.getElementById('mailadresse').style.display = "none";
                        document.getElementById('mail').style.display = "none";
                        document.getElementById('passwort').style.display = "block";
                        document.getElementById('login').style.display = "block";
                        document.getElementById('login_text').style.display = "none";
                        document.getElementById('mail_text').style.display = "block";
        }
        function Mail ()
        {
                        document.getElementById('mailadresse').style.display = "block";
                        document.getElementById('mail').style.display = "block";
                        document.getElementById('passwort').style.display = "none";
                        document.getElementById('login').style.display = "none";
                        document.getElementById('login_text').style.display = "block";
                        document.getElementById('mail_text').style.display = "none";
        }

        function Toggle (id)
        {
                        if (document.getElementById(id).style.display == "block") Hide(id);
                        else Show(id);
        }

        function Show (id)
        {
                        document.getElementById(id).style.display = "block";
        }
        function Hide (id)
        {
                        document.getElementById(id).style.display = "none";

        }

        function Lang (id)
        {
                        document.getElementById("lang_" + id).style.display = "";
                        document.getElementById("kurz_" + id).style.display = "none";
        }
        function Kurz (id)
        {
                        document.getElementById("lang_" + id).style.display = "none";
                        document.getElementById("kurz_" + id).style.display = "";
        }

        function doIt()
        {
                 writeit('<input name="pictures[]" type="file"><br />','foto_edit');
        }

        function writeit(text,id)
        {
                if (document.getElementById)
                {
                        x = document.getElementById(id);
                        x.innerHTML += text;
                }
                else if (document.all)
                {
                        x = document.all[id];
                        x.innerHTML += text;
                }
        }


        function show_text(text,id){
                if (document.getElementById)
                {
                        x = document.getElementById(id);
                        x.innerHTML = text;
                }
                else if (document.all)
                {
                        x = document.all[id];
                        x.innerHTML = text;
                }
        }

        function resetit(id){
                if (document.getElementById)
                {
                        x = document.getElementById(id);
                        x.innerHTML = "";
                }
                else if (document.all)
                {
                        x = document.all[id];
                        x.innerHTML = "";
                }
        }
