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 = '164px';
    } else { // IE 6 and older browsers
        input.style.marginLeft = '167px';
    }

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

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;
}


function tippspiel_on_select(select_box, id, my_fanliga) {
    var option = select_box.options[select_box.selectedIndex];
    if (id == null) {
        id = option.value;
    } else {
        for (var i = 0; i < select_box.options.length; i++) {
            var o = select_box.options[i];            
            if (o.value == id) {
                select_box.selectedIndex = i;
                option = o;
                break;
            }
        }
    }
    var classNames = Element.classNames(option);
    // Reset
    $$('.func-tg-fanligen').each(function (e) { e.hide() });
    $('tg-fanliga-alle').style.display = '';
    $('tg-fanliga-verboten').style.display = 'none';
    $('tg-beitreten').disabled = false;
    // Privat
    var is_privat = classNames.include('func-tg-privat');
    $('tg-password-required').style.display = is_privat ? '' : 'none';
    $('tg-password-not-required').style.display = !is_privat ? '' : 'none';
    $('tg-mail-an-gruender').href = is_privat ? 'mail_an_gruender.jsp?tippgemeinschaft=' + id : '#';
    // Fanliga
    var fanligaListe = classNames.grep(/func-tg-fanliga-\d+/);
    if (fanligaListe.length == 1) {
        var fanliga = fanligaListe.first();
        $('tg-fanliga-alle').style.display = 'none';
        $(fanliga.replace('func-', '')).style.display = '';
        if ("func-tg-fanliga-" + my_fanliga != fanliga) {
            $('tg-fanliga-verboten').style.display = '';
            $('tg-beitreten').disabled = true;
        }
    }
}

function neoIsIE() {
    return document.all != null;
}

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

function tippspiel_toggle_sportler_wechsel_box(uid) {
    var selbst = $('sportler-wechsel-box-' + uid);
    if (!selbst) return;
    var tmp = selbst.visible();
    $$('.sportler-wechsel-box-group').each(function(element){ element.hide(); } );
    if(tmp) {
        selbst.hide();
    } else {
        selbst.show();
    }
}