var eActiveButton = "";
var eActiveSubMenu = "";
var strActiveMenuID = "";
var strActiveSubMenuID = "";
var blnScroll = true;
var intSmiley = 0;

if(self != top){
    top.location = self.location;
}

function stopScrolling(){
    blnScroll = false;
}

function startFastScrollingRight(){
    blnScroll = true;
    scrollFastRight();
}

function scrollFastRight(){
    
    if(
        blnScroll == true
        && intSmiley < 35
    ){
        eFirst = getElementsStyle(("smiley" + intSmiley));
        eNext = getElementsStyle(("smiley" + (intSmiley + 10)));
        eFirst.display = "none";
        eNext.display = "inline";
        intSmiley += 1;
        window.setTimeout("scrollFastRight()", 1000);
    }
}

function startFastScrollingLeft(){
    blnScroll = true;
    scrollFastLeft();
}

function scrollFastLeft(){
    
    if(
        blnScroll == true
        && intSmiley > 0
    ){
        intSmiley -= 1;
        eFirst = getElementsStyle(("smiley" + intSmiley));
        eNext = getElementsStyle(("smiley" + (intSmiley + 10)));
        eFirst.display = "inline";
        eNext.display = "none";
        window.setTimeout("scrollFastLeft()", 1000);
    }
}

function scrollRight(){
    if(
        intSmiley < 35
    ){
        eFirst = getElementsStyle(("smiley" + intSmiley));
        eNext = getElementsStyle(("smiley" + (intSmiley + 10)));
        eFirst.display = "none";
        eNext.display = "inline";
        intSmiley += 1;
    }
}

function scrollLeft(){
    if(
        intSmiley > 0
    ){
        intSmiley -= 1;
        eFirst = getElementsStyle(("smiley" + intSmiley));
        eNext = getElementsStyle(("smiley" + (intSmiley + 10)));
        eFirst.display = "inline";
        eNext.display = "none";
    }
}


function getElementsStyle(strID){
    var e;
    if(document.layers){
        e = document.strID;
    }
    else if(document.all){
        e = document.all[strID].style;
    }
    else if(document.getElementById){
        e = document.getElementById(strID).style;
    }
    return e;
}

function getElement(strID){
    if(
        document.layers
    ){
        return document.strID;
    }
    else if(
        document.all
    ){
        return document.all[strID];
    }
    else if(
        document.getElementById
    ){
        return document.getElementById(strID);
    }
    else{
        alert("Dein Browser scheint nicht DHTML-Fähig zu sein");
    }
}

function openMenu(strSubMenuID, eButton){
    var eSubMenu = getElement(strSubMenuID);

    if(
        strActiveMenuID != ""
    ){
        eActiveButton = getElement(strActiveMenuID);
        eActiveSubMenu = getElement(strActiveSubMenuID);
        strActiveSubMenuID = "";
        strActiveMenuID = "";
    }

    if(
        eButton.className == "menuEntry"
    ){
        if(
            eActiveButton != ""
        ){
            eActiveButton.className = "menuEntry";
            eActiveSubMenu.className = "subMenuEntry";
        }

        eButton.className = "menuEntryActive";
        eActiveButton = eButton;

        eSubMenu.className = "subMenuEntryActive";
        eActiveSubMenu = eSubMenu;
    }
    else{
        eActiveButton = "";
        eButton.className = "menuEntry";

        eActiveSubMenu = "";
        eSubMenu.className = "subMenuEntry";
    }
}

function clearInput(e){
    e.value = "";
}

function closeOpenDiv(strID){
    var e;
    e = getElementsStyle(strID);
    if(
        e.display == 'block'
    ){
        e.display = 'none';
    }
    else{
        e.display = 'block';
    }
}

function openCloseDiv(strID){
    var e;
    e = getElementsStyle(strID);
    if(
        e.display == 'none'
    ){
        e.display = 'block';
    }
    else{
        e.display = 'none';
    }
}

function insert(aTag, eTag){
    var input = getElement('reply');
    input.focus();
    /* für Internet Explorer */
    if(
        typeof document.selection != 'undefined'
    ){
        /* Einfügen des Formatierungscodes */
        var range = document.selection.createRange();
        var insText = range.text;
        range.text = aTag + insText + eTag;
        /* Anpassen der Cursorposition */
        range = document.selection.createRange();
        if(
            insText.length == 0
        ){
            range.move('character', -eTag.length);
        }
        else{
            range.moveStart('character', aTag.length + insText.length + eTag.length);
        }
        range.select();
    }
    /* für neuere auf Gecko basierende Browser */
    else if(
        typeof input.selectionStart != 'undefined'
    ){
        /* Einfügen des Formatierungscodes */
        var start = input.selectionStart;
        var end = input.selectionEnd;
        var insText = input.value.substring(start, end);
        input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
        /* Anpassen der Cursorposition */
        var pos;
        if(
            insText.length == 0
        ){
            pos = start + aTag.length;
        }
        else{
            pos = start + aTag.length + insText.length + eTag.length;
        }
        input.selectionStart = pos;
        input.selectionEnd = pos;
    }
    /* für die übrigen Browser */
    else{
        /* Abfrage der Einfügeposition */
        var pos;
        var re = new RegExp('^[0-9]{0,3}$');
        while(!re.test(pos)){
            pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
        }
        if(
            pos > input.value.length
        ){
            pos = input.value.length;
        }
        /* Einfügen des Formatierungscodes */
        var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
        input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
    }
}

function addBBCode(strCode){
    insert('['+strCode+']', '[/'+strCode+']');
}

function addBBCodeURL(){
    var strURL = prompt("Bitte geben sie die Addresse ein.", "");
    var strText = prompt("Falls ein anderer Text als die Addresse angezeigt werden soll, geben sie ihn bitte nun ein.", "");
    if(
        strURL != null
        && strURL.length > 0
    ){
        if(
            strText != null
            && strText.length > 0
        ){
            insert("[URL=" + strURL + "]" + strText + "[/URL]", "");
        }
        else{
            insert("[URL]" + strURL + "[/URL]", "");
        }
    }
}

function addBBCodeMail(){
    var strURL = prompt("Bitte geben sie die E-Mail-Addresse ein.", "");
    var strText = prompt("Falls ein anderer Text als die Addresse angezeigt werden soll, geben sie ihn bitte nun ein.", "");
    if(
        strURL != null
        && strURL.length > 0
    ){
        if(
            strText != null
            && strText.length > 0
        ){
            insert("[EMAIL=" + strURL + "]" + strText + "[/EMAIL]", "");
        }
        else{
            insert("[EMAIL]" + strURL + "[/EMAIL]", "");
        }
    }
}

function addBBCodeList(){
    var strBullet = prompt("Bitte geben sie den Listen-Typ ein:\na = kleine Buchstaben (a, b, c, ...)\nA = grosse Buchstaben (A, B, C, ...)\ni = kleine roemische Ziffern (i, ii, iii, ...)\nI = grosse roemische Ziffern(I, II, III, ...)\n0 = Zahlen mit fuehrender Null (01, 02, 03, ...)\n1 = Zahlen ohne fuehrende Null (0,1,2,...)\nalpha = griechisches Alphabet (alpha, beta, gamme,...)\ncircle = ungefuellte Kreise\nsquare = Quadrate\ndisc = gefuellte Kreise\nAbbrechen um keine Aufzaehlungssymbole zu verwenden.", "");
    var strText = "";
    var intBreak = 0;
    while(intBreak == 0){
        var strTextTMP = prompt("Bitte geben sie nun den naechsten Listenpunkt ein.", "");

        if(
            strTextTMP != null
            && strTextTMP.length > 0
        ){
            strText += ( "[*]" + strTextTMP );
        }
        else{
            intBreak = 1;
        }
    }
    if(
        strText.length > 0
    ){
        if(
            strBullet != null
            && strBullet.length > 0
        ){
            strText = "[LIST=" + strBullet + "]" + strText;
        }
        else{
            strText = "[LIST]" + strText;
        }
        strText += "[/LIST]";
        insert(strText, "");
    }
}

function addBBCodeColor(eSelect){
    insert("[COLOR=" + eSelect.value + "]", "[/COLOR]");
}

function addSmiley(strSmiley){
    insert(" " + strSmiley + " ", "");
}

function loadChangedValue(e){
    var strHash;
    var strLocation;
    var intHashPos;

    if(
        location.hash != ""
    ){
        strHash = location.hash;
        location.hash = "";
        intHashPos = location.href.indexOf("#");
        strLocation = location.href.slice(0,intHashPos);
    }
    else{
        strLocation = location.href;
        strHash = "";
    }
    if(
        location.search == ""
    ){
        location.href = strLocation + "?" + e.name + "=" + e.value + strHash;
    }
    else{
        location.href = strLocation + "&" + e.name +"=" + e.value + strHash;
    }
}
