function tippspiel_add_email() {
    var input = document.createElement("input");
    input.setAttribute("class", "text");
    input.setAttribute("name", "empfaenger");
    input.setAttribute("type", "text");
    input.style.width="120px";
    if (window.XMLHttpRequest) {
        input.style.marginLeft = '144px';
    } else { // IE 6 and older browsers
        input.style.marginLeft = '147px';
    }

    var c = $('emails');
    var p = document.createElement("p");
    p.setAttribute("class", "field");
    p.appendChild(input);
    c.appendChild(p);
}


function tippspiel_confirm_leave(isGruender) {
    var text = isGruender
            ? "Do you really want to disband your league?\n" +
              "How about transferring your captain status to another member.\n" +
              "Please note that disbanding your league will expel all members from your league!\n" +
              "Really disband legaue?"
            : "Do you really want to leave your league?";
    return confirm(text);
}

function tippspiel_popup(o) {
    var url = o != undefined && o.href ? o.href : o;

    window.open(url, "popup", "width=800,height=600" +
      ",resizable=yes,location=yes,scrollbars=yes" +
      ",toolbar=yes,status=yes,menubar=yes");
    return false;
}

var PRIVAT = 0;
var VERWAIST = 1;
var FANLIGA = 2;
var FANLIGA_NAME = 3;

var tgid = 0;
var tgPrivat = new Object();

function tippspiel_on_select(sbox, id, fanliga) {
  if (id == null) {
    id = sbox.value;
  }
  if (id != null && id != "0") {
    tippspiel_choosen(tgPrivat[id][PRIVAT], sbox.value, tgPrivat[id][FANLIGA] != '', tgPrivat[id][FANLIGA] == fanliga, tgPrivat[id][FANLIGA_NAME]);
  } else {
    tippspiel_choosen(false, '', '');
  }
}

function tippspiel_choosen(show, id) {
  var pwd = $('tgPasswort');
  var hint = $('tgPasswortHint');
  var mail = $('tgMailAnGruender');
  var beitreten = $('tg-beitreten');

  pwd.style.display = show ? 'block' : 'none';
  hint.style.display = show ? 'none' : 'block';
  mail.style.display = show ? 'inline' : 'none';
  mail.href = show ? "mail_an_gruender.jsp?tippgemeinschaft=" + id : "#";

  tgid = id;
}

function tippspiel_add_tg(id, privat, verwaist, fanliga, fanligaName) {
    tgPrivat[id] = [ privat, verwaist, fanliga, fanligaName ];
}

function tippspiel_hide(element, timeout) {
    if (timeout == null) timeout = 3000;    
    window.setTimeout(function() {
      Element.hide(element);
    }, timeout);
}

