/*-------------------------------------------------------------*/
/* Copyright 2008 42 Pixel b.v.							       */
/* Progammierung: Leonhard Kronast                             */
/*-------------------------------------------------------------*/

/*-------------------------------------------------------------*/
/* Favoriten- und Community-Updates                            */
/*-------------------------------------------------------------*/
if (typeof(imgsToShow) == 'undefined') var imgsToShow = [];
if (typeof(Bids) == 'undefined') var Bids = [];
if (typeof(vidsToShow) == 'undefined') var vidsToShow = [];
function oneVid(id,n){return {id:parseInt(id,10),nick:n}};
function oneImg(id,n,url,txt,w,h,t,g){Bids[Bids.length] = id;return {id:parseInt(id,10),nick:n,src:url,title:txt,x:parseInt(w,10),y:parseInt(h,10),unfiltered:t,gal:g}}
function openVids(sN){var i;for (i=0;i<vidsToShow.length;i++){if (vidsToShow[i].nick == sN)break;} 
	i=(i>(vidsToShow.length-1))?0:i;
	var v1 = window.open('/videogalerie/fplayer.asp?ID='+vidsToShow[i].id,'video','toolbar=no,status=no,scrollbars=yes,resizable=yes,width=480,height=400,screenX=0,screenY=0,top=0,left=0,dependent=1'); 
	v1.focus();return false;}
function openGalPics(sN){var i;for (i=0;i<imgsToShow.length;i++){if (imgsToShow[i].nick == sN)break;}
    i = (i > (imgsToShow.length - 1)) ? 0 : i; OpenImage(imgsToShow[i].id, imgsToShow[i].x, imgsToShow[i].y); return false;
}

/*-------------------------------------------------------------*/
/* Externe RSS-Feeds                                           */
/*-------------------------------------------------------------*/

var aktRss = null;
var aktRssGaydget = null;
var aktInputRSS = null;
var tempAni;
var maxText = top.grnav.wWidth == 864 ? 55 : 40;
function getRSS(href, RssID) {
    hideMostUsed();
    var aktUl = document.getElementById("RSSFeed" + RssID);
    if (aktUl == null)
        return;
    if (window.event) {
        top.stopEvent(window.event);
    }
    tempAni = isAni;
    isAni = false;
    if (aktUl.hasChildNodes()) {
        aktUl.style.display = 'none';
         while (aktUl.hasChildNodes()){
            aktUl.removeChild(aktUl.firstChild);
        }
        for (var i = 0; i < gaydgets.length; i++) {
            if (gaydgets[i].id == aktUl.parentNode.parentNode.parentNode.id) {
                gaydgets[i].closed = true;
                gaydgets[i].visibleHeight = 0;
                gaydgets[i].visibleContent.style.height = '';
                gaydgets[i].maxHeight = 0;
                gaydgets[i].slide();
                break;
            }
        }
        isAni = tempAni;
    } else {
    var span = document.createElement("SPAN");
    var txt = document.createTextNode(waitText);
    span.appendChild(txt);
    document.getElementById("RssLink" + RssID).parentNode.appendChild(span);
    document.getElementById("RssLink" + RssID).style.display = 'none';
        makePOSTRequest(href, '1=1', getRSSContent, 'text/xml; charset=ISO-8859-1');
        aktRSS = RssID;
    }
}


function delRSSFeed(targetEl, RssID) {
    var targetID = targetEl.parentNode.parentNode.parentNode.parentNode.id;
    for (var i = 0; i < gaydgets.length; i++) {
        if (gaydgets[i].id == targetID) {
            aktRssGaydget = i;
            break;
        }
    }
    sendRequest('/start/gaydgets/getRSS.asp?action=delete&lg=' + top.grnav.uGUID + '&RSSID=' + RssID, getNewRss);
}

function getNewRss() {
    if (aktRssGaydget != null) {
        gaydgets[aktRssGaydget].loadRSS();
    }
}

function cutString(text, length) {
    if (text.length > length) {
        text = text.substring(0, length - 2) + '...';
    }
    return text;
}
function saveRSSFeed(targetEl, FormID) {
    var targetID = targetEl.parentNode.parentNode.parentNode.parentNode.id;
    for (i = 0; i < gaydgets.length; i++) {
        if (gaydgets[i].id == targetID) {
            aktRssGaydget = i;
            break;
        }
    }
    hideMostUsed();
    sendRequest('/start/gaydgets/getRSS.asp?action=insert&lg=' + top.grnav.uGUID + '&URL=' + escape(document.getElementById('rssUrl' + FormID).value), getNewRss);
}

function getRSSContent(val) {
    var newLI, newA, newText, newTitle, items, feedTitle, targetLink;
    if (typeof (val) == 'object' && document.getElementById("RSSFeed" + aktRSS) != null) {
        var docType = val.documentElement.localName || val.documentElement.baseName || val.documentElement.nodeName;
        if (docType.indexOf(':') > -1) {
            docType = docType.substring(docType.indexOf(':') + 1, docType.length)
        }
        docType = docType.toLowerCase();
        switch (docType) {
            case 'rss':
                try {
                    feedTitle = val.documentElement.getElementsByTagName("channel")[0].getElementsByTagName("title")[0].firstChild.nodeValue;
                } catch (e) { feedTitle = document.getElementById("RssTitle" + aktRSS).lastChild.firstChild.nodeValue; }
                baseLink = '';
                for (var i = 0; i < val.documentElement.getElementsByTagName("channel")[0].childNodes.length; i++) {
                    if (val.documentElement.getElementsByTagName("channel")[0].childNodes[i].nodeName == 'link') {
                        baseLink = val.documentElement.getElementsByTagName("channel")[0].childNodes[i].firstChild.nodeValue;
                        break;
                    }
                }
                items = val.documentElement.getElementsByTagName("channel")[0].getElementsByTagName("item");
                break;
            case 'feed':
                feedTitle = val.documentElement.getElementsByTagName("title")[0].firstChild.nodeValue;
                baseLink = "";
                items = val.documentElement.getElementsByTagName("entry");
                break;
            case "rdf":
                feedTitle = val.documentElement.getElementsByTagName("channel")[0].getElementsByTagName("title")[0].firstChild.nodeValue;
                baseLink = "";
                items = val.documentElement.getElementsByTagName("item");
                break;
            default:
                feedTitle = document.getElementById("RssLink" + aktRSS).firstChild.nodeValue;
                break;
        }
        var targetUL = document.getElementById("RSSFeed" + aktRSS);
        var titleLink = document.getElementById("RssLink" + aktRSS);
        newText = cutString(feedTitle, maxText);
        if (newText != feedTitle)
            titleLink.title = feedTitle;
        newText = document.createTextNode(newText);
        titleLink.parentNode.removeChild(titleLink.parentNode.lastChild);
        titleLink.replaceChild(newText,titleLink.firstChild);
        titleLink.style.display = 'inline';
        if (items != null) {
            for (i = 0; i < items.length && i < 10; i++) {
                targetLink = "";
                newLI = document.createElement("LI");
                newA = document.createElement("A");
                for (j = 0; j < items[i].childNodes.length; j++) {
                    switch (items[i].childNodes[j].nodeName) {
                        case "title":
                            if (items[i].childNodes[j].hasChildNodes()) {
                                newTitle = items[i].childNodes[j].firstChild.nodeValue;
                            } else {
                                newTitle = document.createTextNode(items[i].childNodes[j].nodeValue);
                            }
                            newText = cutString(newTitle, maxText);
                            if (newText != newTitle)
                                newA.title = newTitle;
                            newText = document.createTextNode(newText);
                            newA.appendChild(newText);
                            break;
                        case 'link':
                            if (items[i].childNodes[j].hasChildNodes())
                                targetLink = items[i].childNodes[j].firstChild.nodeValue;
                            else
                                targetLink = items[i].childNodes[j].getAttribute('href');
                            if (baseLink != "" && targetLink.indexOf("http://") == -1)
                                targetLink = baseLink + targetLink;
                            newA.setAttribute("href", targetLink);
                            newA.className = "externallink";
                            newA.setAttribute("target", "_blank");
                            break;
                        case 'description':
                        case 'content:encoded':
                            while (items[i].childNodes[j].hasChildNodes() && items[i].childNodes[j].firstChild.nodeName != '#cdata-section') {
                                items[i].childNodes[j].removeChild(items[i].childNodes[j].firstChild);
                            }
                            if (items[i].childNodes[j].hasChildNodes()) {
                                str = items[i].childNodes[j].firstChild.nodeValue;
                                var expr = /(<img.+src=["|'])(.+\.jpg|.+\.gif)/i;
                                if (expr.exec(str)) {
                                    newA.setAttribute("onmouseover", "showImg('" + RegExp.$2 + "');");
                                    newA.setAttribute("onmouseout", "hideImg();");
                                }
                            }
                            break;
                        default: break; 	
                    }
                }
                newLI.appendChild(newA);
                targetUL.appendChild(newLI);
            }
            targetUL.style.display = 'block';
        } else {
            alert(errorText);
        }
        for (i = 0; i < gaydgets.length; i++) {
            if (gaydgets[i].id == targetUL.parentNode.parentNode.parentNode.id) {
                gaydgets[i].closed = true;
                gaydgets[i].maxHeight = 0;
                gaydgets[i].slide();
                break;
            }
        } 
        isAni = tempAni;
    } else {
        alert(errorText);
    }
}


function getDim(e) {
    var x = y = h = w = 0;
    w = e.offsetWidth || e.clientWidth;
    h = e.offsetHeight || e.clientHeight;
    while (e.offsetParent) { x += e.offsetLeft; y += e.offsetTop; e = e.offsetParent; }
    return { x: x, y: y, h: h, w: w };
}


function showMostUsedRssFeed(el) {
    var mostUsed;
    var elDim = getDim(el);
    aktInputRSS = el;
    if (document.getElementById("MostUsedRSS") == null) {
        mostUsed = document.createElement("DIV");
        mostUsed.id = "MostUsedRSS";
        document.body.appendChild(mostUsed)
    }
    else {
        mostUsed = document.getElementById("MostUsedRSS");
    }
    mostUsed.style.width = (elDim.w - 2) + 'px';
    mostUsed.style.top = (elDim.y + elDim.h) + 'px';
    mostUsed.style.left = elDim.x + 'px';
    mostUsed.style.display = 'block';
    document.getElementById("MostUsedRSS").innerHTML = ""
    getMostUsedRssFeed(el);
}

function hideMostUsed() {
    if (document.getElementById("MostUsedRSS") != null) {
        top.removeEvent(document, 'mousedown', hideMostUsed);
        top.removeEvent(document.getElementById("MostUsedRSS"), 'mousedown', takeRssFeed);
        setTimeout("document.getElementById('MostUsedRSS').style.display = 'none'", 100);
    }
}

function getMostUsedRssFeed(el) {
    sendRequest('/start/gaydgets/getRSS.asp?action=mostUsed&txt=' + el.value, showValExamples);
}

function showValExamples(val) {
    document.getElementById("MostUsedRSS").innerHTML = val;
    top.addEvent(document.getElementById("MostUsedRSS"), 'mousedown', takeRssFeed);
    top.addEvent(document, 'mousedown', hideMostUsed);
}

function takeRssFeed(ev) {
    ev = ev || window.event;
    var target = ev.target || ev.srcElement;
    var val = target.getAttribute('url');
    if (val != null && aktInputRSS != null) {
        aktInputRSS.value = val;
        aktInputRSS = null;
        hideMostUsed();
    } else {
        if (target.nodeName != 'A' && target.nodeName != 'DIV' && target.nodeName != 'INPUT') {
            hideMostUsed();
        }
    }
    top.stopEvent(ev);
    return false;
}

/*-------------------------------------------------------------*/
/* Userübersichten                                             */
/*-------------------------------------------------------------*/
function topUsersObj(title, action, area, prefix) {
    this.title = title;
    this.action = action;
    this.area = area;
    this.firstUser = true;
    this.getFirst = false;
    this.prefix = prefix;
    this.min = function() { var ret; try { ret = parseInt(document.getElementById(this.area).lastChild.id.substring(4), 10); } catch (e) { }; return isNaN(ret) ? 0 : ret; }
    this.max = function() { var ret; try { ret = parseInt(document.getElementById(this.area).firstChild.id.substring(4), 10); } catch (e) { }; return isNaN(ret) ? Number.MAX_VALUE : ret; }
}

var UsersToShowCounter = 0;


function moveUsersPage(dir) {
    if (topUsers[topUsersAkt].min() == topUsers[topUsersAkt].max() ||
        document.getElementById(topUsers[topUsersAkt].area).childNodes.length < CountUsersToShow) {
        return;
    }
    var CounterPage = Math.ceil(CountUsersToShow/2);
    if (timeoutUserShow != null || timeoutUserHide != null) {
        setTimeout('moveUsersPage(' + dir + ');', 10);
    } else {
        UsersToShowCounter += 1;
        if (UsersToShowCounter < CounterPage) {
            moveUsers(dir);      
            setTimeout('moveUsersPage(' + dir + ');', 5);
        } else {
            UsersToShowCounter = 0;
            top.frames['grnav'].gGRTabs.setHeadline(topUsers[topUsersAkt].title);
        }
    }
}


function changeTopUsers() {
    topUsersAkt = (topUsersAkt == (topUsers.length - 1)) ? 0 : topUsersAkt + 1;
    if (topUsers[topUsersAkt].area == 'topBanner' &&
        document.getElementById(topUsers[topUsersAkt].area).getElementsByTagName('A').length == 0) {
        changeTopUsers();
        return;
    }
    var oldVisibleArea = topVisibleArea;
    top.frames['grnav'].gGRTabs.setHeadline(topUsers[topUsersAkt].title);
    topVisibleArea = document.getElementById(topUsers[topUsersAkt].area);
    if (topVisibleArea.childNodes.length == 0) {
        topVisibleArea.innerHTML = waitImg;
        topVisibleArea.style.paddingTop = '45px';
        makePOSTRequest('/start/gaydgets/getgaydget.asp?action=' + topUsers[topUsersAkt].action + '&lang=' + userLang, '1=1', getNewUsers, 'text/xml; charset=ISO-8859-1');
    } 
    oldVisibleArea.parentNode.appendChild(topVisibleArea);
    moveTopUsersRow(oldVisibleArea.id, topUsers[topUsersAkt].area, 0);
}

function getOffsetHeight(el) {
    var h = 0;
    if (!isNaN(el.clientHeight)) {
        h = parseInt(el.clientHeight,10);
    }
    if (el.hasChildNodes()){
        for (var i = 0;i < el.childNodes.length;i++)
            h += getOffsetHeight(el.childNodes[i])
    }
    return parseInt(h/2,10);
}

function moveTopUsersRow(oldVisible, newVisible, topStyle) {
    if (!top.grnav.isAni) {
        topStyle = 136;
    }
    var oldAreaStyle = document.getElementById(oldVisible).style;
    var newAreaStyle = document.getElementById(newVisible).style;
    newAreaStyle.top = (topStyle - 288) + px;
    newAreaStyle.backgroundColor = topBGColor;
    newAreaStyle.display = 'block';
    topStyle += 4;
    if (topStyle == 140) {
        oldAreaStyle.display = 'none';
        oldAreaStyle.top = 0 + px;
        newAreaStyle.top = 0 + px;
        newAreaStyle.backgroundColor = '';
        if (newVisible == 'topBanner') {
            topStyle = parseInt((140 - getOffsetHeight(document.getElementById(newVisible)))/2,10);
            newAreaStyle.top = topStyle + px;
        }
    } else {
        setTimeout('moveTopUsersRow("' + oldVisible + '","' + newVisible + '",' + topStyle + ')', 1);
    }
}

function moveUsersShowPic() {
    var i, j, el2;
    for (i = 0; i < topVisibleArea.childNodes.length; i++) {
        if (topVisibleArea.childNodes[i].style.display != 'none')
            break;
    }
    for (j = i; (j < i + CountUsersToShow) && (j < topVisibleArea.childNodes.length); j++) {
        el2 = topVisibleArea.childNodes[j];
        if (el2.getAttribute('bg') != null) {
            picAlign(el2.id, el2.getAttribute('bg'), 1);
            el2.getElementsByTagName('SPAN')[0].style.backgroundColor = 'transparent';
            el2.getElementsByTagName('SPAN')[0].style.backgroundImage = 'url(' + el2.getAttribute('bg') + ')';
            el2.removeAttribute('bg');
        }
    }

}

function picAlign(elID, src, counter) {
    var img = document.createElement('IMG');
    img.src = src;
    if (img.complete) {
        if (img.height > 75) {
            document.getElementById(elID).getElementsByTagName('SPAN')[0].style.backgroundPosition = 'top center';
        }
    } else {
        if (counter < 10) {
            counter++;
            setTimeout('picAlign("' + elID + '","' + src + '",' + counter + ');', 100);
        }
    }
    img = null;
}

function moveUsers(dir) {
    var usersShown = 0;
    if (dir > 0) {
        for (i = topVisibleArea.childNodes.length - 1; i > -1; i--) {
            usersShown++;
            if (topVisibleArea.childNodes[i].nodeName == 'DIV') {
                if (topVisibleArea.childNodes[i].style.display == 'none') {
                    doUserShow(topVisibleArea.childNodes[i].id, -WidthUsersToShow);
                    if ((CountUsersToShow - usersShown) < 0)
                        break;
                }
            }
        }
        if (i < 0) {
            while (topVisibleArea.childNodes.length > 24) {
                topVisibleArea.removeChild(topVisibleArea.lastChild);
            }
            makePOSTRequest('/start/gaydgets/getgaydget.asp?action=' + topUsers[topUsersAkt].action + '&lang=' + userLang + '&minid=' + topUsers[topUsersAkt].max(), '1=1', getNewUsers, 'text/xml; charset=ISO-8859-1');
        } else {
            if (topUsers[topUsersAkt].getFirst) {
                if (!topUsers[topUsersAkt].firstUser || topVisibleArea.firstChild.style.display == 'none') {
                    setTimeout('moveUsers(1)', 25);
                } else {
                    topUsers[topUsersAkt].getFirst = false;
                }
            }
        }
    } else {
        for (i = 0; i < topVisibleArea.childNodes.length; i++) {
            if (topVisibleArea.childNodes[i].nodeName == 'DIV') {
                if (topVisibleArea.childNodes[i].style.display != 'none') {
                    doUserHide(topVisibleArea.childNodes[i].id, 0);
                    break;
                }
            }
        }
        if (i == topVisibleArea.childNodes.length - 10) {
            while (topVisibleArea.childNodes.length > 24) {
                topUsers[topUsersAkt].firstUser = false;
                topVisibleArea.removeChild(topVisibleArea.firstChild);
            }
            makePOSTRequest('/start/gaydgets/getgaydget.asp?action=' + topUsers[topUsersAkt].action + '&lang=' + userLang + '&maxid=' + topUsers[topUsersAkt].min(), '1=1', getNewUsers, 'text/xml; charset=ISO-8859-1');
        }
    }
    moveUsersShowPic();
    return false;
}


function cloneXMLNode(el) {
    var newEl, val, j;
    if (el.nodeType == 1) {
        newEl = document.createElement(el.nodeName);
        for (j = 0; j < el.attributes.length; j++) {
            val = el.attributes[j].nodeValue;
            if (val != null) {
                switch (el.attributes[j].nodeName.toLowerCase()) {
                    case 'id':
                        if (document.getElementById(val) == null)
                            newEl.id = val;
                        else
                            newEl.id = 'none';
                        break;
                    case 'class':
                        newEl.className = el.attributes[j].nodeValue;
                        break;
                    case 'style':
                        newEl.style.cssText = el.attributes[j].nodeValue;
                        break;
                    default:
                        newEl.setAttribute(el.attributes[j].nodeName, el.attributes[j].nodeValue);
                }
            }
        }
        if (el.hasChildNodes()) {
            for (j = 0; j < el.childNodes.length; j++) {
                newEl.appendChild(cloneXMLNode(el.childNodes[j]));
            }
        }
    } else {
        if (el.nodeType == 3 && el.nodeValue != null)
            newEl = document.createTextNode(el.nodeValue);
        else
            newEl = document.createTextNode('');
    }
    return newEl;
}

function getNewUsers(val) {
    var newUser, i, newID, doOpen;
    doOpen = false;
    var minID = topUsers[topUsersAkt].min();
    var maxID = topUsers[topUsersAkt].max();
    if (!val.documentElement.hasChildNodes()) {
        topUsers[topUsersAkt].firstUser = true;
        topUsers[topUsersAkt].getFirst = false;
        return;
    }
    for (i = 0; i < topVisibleArea.childNodes.length; i++) {
        if (topVisibleArea.childNodes[i].nodeName != 'DIV') {
            topVisibleArea.style.paddingTop = '';
            topVisibleArea.removeChild(topVisibleArea.childNodes[i]);
        }
    }
    for (i = 0; i < val.documentElement.childNodes.length; i++) {
        newUser = cloneXMLNode(val.documentElement.childNodes[i]);
        if (newUser.nodeType != 1 || newUser.id == 'none')
            continue;
        newID = parseInt(newUser.id.substring(4), 10);
        newUser.style.width = WidthUsersToShow + 'px';
        if (newID < minID || topVisibleArea.childNodes.length == 0) {
            topVisibleArea.appendChild(newUser);
            top.addEvent(newUser, 'mouseup', doBlur);
            minID = newID;
        } else {
            if (newID > maxID) {
                newUser.style.display = 'none';
                if (document.getElementById(topUsers[topUsersAkt].prefix + maxID) != null) {
                    topVisibleArea.insertBefore(newUser, document.getElementById(topUsers[topUsersAkt].prefix + maxID));
                } else {
                    topVisibleArea.insertBefore(newUser, topVisibleArea.firstChild);
                    maxID = newID;
                }
                top.addEvent(newUser, 'mouseup', doBlur);
                doOpen = true;
            }
        }
        newUser = null;
    }
    if (isIE)
        topVisibleArea.innerHTML = topVisibleArea.innerHTML;
    if (topVisibleArea.childNodes.length < CountUsersToShow && topVisibleArea.childNodes.length > 0) {
        var newWidth = parseInt((CountUsersToShow -1) * WidthUsersToShow/(topVisibleArea.childNodes.length));
        for (i = 0; i < topVisibleArea.childNodes.length; i++) {
            topVisibleArea.childNodes[i].style.width = newWidth + 'px';
        }
    }
    if (doOpen)
        moveUsers(1);
    else
        moveUsersShowPic();
}

var timeoutUserHide = null;
var timeoutUserShow = null;

function doUserHide(ID, left) {
    left -= 10;
    var elstyle = topVisibleArea.style;
    if (left > -WidthUsersToShow && (elstyle.left == "" || parseInt(elstyle.left, 10) > -WidthUsersToShow) && top.grnav.isAni) {
        elstyle.left = left + 'px';
        timeoutUserHide = setTimeout('doUserHide("' + ID + '",' + left + ')', 5);
    } else {
        document.getElementById(ID).style.display = 'none';
        elstyle.left = '0px';
        timeoutUserHide = null;
    }
}

function doUserShow(ID, left) {
    var elstyle = topVisibleArea.style;
    if (left == -WidthUsersToShow) {
        var showEl = document.getElementById(ID);
        showEl.style.display = 'block';
        elstyle.left = -WidthUsersToShow + 'px';
    }
    left += 10;
    if (parseInt(elstyle.left, 10) < -10 && top.grnav.isAni) {
        elstyle.left = left + 'px';
        timeoutUserShow = setTimeout('doUserShow("' + ID + '",' + left + ')', 5)
    } else {
        timeoutUserShow = null;
        elstyle.left = '0px';
    }
}

function bodyMove(ev) {
    top.frames['grnav'].gGRTabs.setHeadline(document.body.scrollTop < 100 ? topUsers[topUsersAkt].title : '');
}

function initMoveUsers() {
    if (top.frames['grnav'].gGRTabs) {
            top.addEvent(window, 'scroll', bodyMove);
            top.addEvent(window, 'mousewheel', bodyMove);
            top.addEvent(window.document, 'mousewheel', bodyMove);
            topVisibleArea = document.getElementById(topUsers[topUsersAkt].area);
            CountUsersToShow = (document.body.clientWidth > 608) ? 9 : 7;
            WidthUsersToShow = (document.body.clientWidth > 608) ? 94 : 81; //parseInt((topVisibleArea.offsetWidth || topVisibleArea.clientWidth)/(CountUsersToShow-1));
            WidthUsersToShow = isIE ? WidthUsersToShow + 2 : WidthUsersToShow;
            for (i = topVisibleArea.childNodes.length - 1; i > 1; i--) {
                if (topVisibleArea.childNodes[i].nodeType != 1 || topVisibleArea.childNodes[i].nodeName.toUpperCase() != 'DIV')
                    topVisibleArea.removeChild(topVisibleArea.childNodes[i]);
                else {
                    topVisibleArea.childNodes[i].style.width = WidthUsersToShow + 'px';
                }
            }
            top.frames['grnav'].gGRTabs.setHeadline(topUsers[topUsersAkt].title);
            moveUsersShowPic();
        } else {
            setTimeout('initMoveUsers()', 200);
        }
        top.addEvent(this.document, 'mouseup', doBlur);
    }

    top.addEvent(this, 'load', initMoveUsers);

    function doBlur(ev) {
        ev = ev || window.event;
        var target = ev.target || ev.srcElement;
        while (target != null && target.nodeName != 'BODY' && target.nodeName == 'DIV' && target.nodeName != null) {
            if (target.nodeName == 'A') {
                target.blur();
                break;
            }
            target = target.parentNode;
        }
    }

    var faqWin;
    
    function openFaqPic(url) {
        faqWin = window.open(url, 'FAQ', 'width=708;height=479');
        faqWin.focus();
        return false;
    }


/*-------------------------------------------------------------*/
/* Bullet Ins		                                           */
/*-------------------------------------------------------------*/

    function $(id) { return document.getElementById(id); }

    function DelBullet(ID) {
    	cid = ID.id.split('_');
    	Bullet_Mcid = cid[1];
    	Bullet_Ucid = cid[2];
    	makePOSTRequest('/user/Settings/ShoutBox.asp', 'Bullet=Del&cid=' + Bullet_Mcid + '&Ucid=' + Bullet_Ucid + '&User=' + Bullet_BulletUserID + '&Action=2', RemoveBullet, 'text/plain');
    }
    function RemoveBullet(el) {
    	MyRemove = el.split('_');
    	if ($('Bullet_' + MyRemove[1]) != null) {
    		$('Bullet_' + MyRemove[1]).parentNode.removeChild($('Bullet_' + MyRemove[1]))
    	}
    	if ($('Comment_' + MyRemove[1]) != null) {
    		if ($('Comment_' + MyRemove[1]).previousSibling.className == 'CommentLine' && $('Comment_' + MyRemove[1]).nextSibling.className == 'CommentLine') {
    			$('Comment_' + MyRemove[1]).previousSibling.parentNode.removeChild($('Comment_' + MyRemove[1]).previousSibling);
    		}
    		$('Comment_' + MyRemove[1]).parentNode.removeChild($('Comment_' + MyRemove[1]))
    	}
    	Bullet_UpDown = true;
    	Bullet_ResizeGaydget(Bullet_UpDown);
    }
    function CreateTextBox(el) {
    	ARZ = el.id.split('_');
    	if (parseInt(ARZ[3]) == 0) {
    		if (Bullet_TextExists > 0) DeleteTextBox(Bullet_foo[1] + '_' + Bullet_foo[2]);
    		Bullet_foo = el.id.split('_');
			CreateInput = document.createElement('div');
    		CreateInput.type = 'text';
    		CreateInput.className = 'small';
    		CreateInput.style.fontWeight = 'normal';
    		CreateInput.id = 'BulletComment_' + Bullet_foo[1] + '_' + Bullet_foo[2];
    		CreateInput.innerHTML = Bullet_Warn;
    		el.parentNode.appendChild(CreateInput);
    		Bullet_TextExists = 2;
    	}
    	else {
    		if (Bullet_TextExists > 0) DeleteTextBox(Bullet_foo[1] + '_' + Bullet_foo[2]);
    		Bullet_foo = el.id.split('_');
    		CreateSpan = document.createElement('span');
    		CreateSpan.style.cssText = 'float:right;';
    		CreateSpan.style.width = '100px';
    		CreateSpan.id = 'CommentChars_' + Bullet_foo[1] + '_' + Bullet_foo[2];
    		CreateSpan.style.textAlign = 'right';
    		CreateSpan.style.fontWeight = 'normal';
    		CreateSpan.style.paddingRight = '8px';
    		CreateSpan.style.marginBottom = '4px';

    	CreateSpan.innerHTML = '&nbsp;';
    		CreateInput = document.createElement('input');
    		CreateInput.type = 'text';
    		CreateInput.className = 'TextBullet';
    		top.addEvent(CreateInput, 'keyup', CheckLength);
    		top.addEvent(CreateInput, 'blur', CheckLength);
    		top.addEvent(CreateInput, 'paste', CheckLength);
    		CreateInput.id = 'BulletComment_' + Bullet_foo[1] + '_' + Bullet_foo[2];


    	CreateSub = document.createElement('input');
    		CreateSub.type = 'submit';
    		CreateSub.value = '';
    		CreateSub.className = 'SubButton';
    		CreateSub.id = 'SubButton_' + Bullet_foo[1] + '_' + Bullet_foo[2];


    	if (el.parentNode.parentNode.childNodes.length < 3) {
    		Bullet_FirstComment = true;
    		}
    		el.parentNode.insertBefore(CreateSpan, el);
    		el.parentNode.appendChild(CreateInput);
    		el.parentNode.appendChild(CreateSub);
    		$('BulletComment_' + Bullet_foo[1] + '_' + Bullet_foo[2]).focus();
    		Bullet_SendID = Bullet_foo[1] + '_' + Bullet_foo[2];
    		Bullet_TextExists = 1;
			Bullet_ResizeGaydget(false);
    	
    	}
    }


    function DeleteTextBox(Bullet_foo) {
    	if ($('CommentChars_' + Bullet_foo) != null) {
    		$('CommentChars_' + Bullet_foo).parentNode.removeChild($('CommentChars_' + Bullet_foo));
    		$('BulletComment_' + Bullet_foo).parentNode.removeChild($('BulletComment_' + Bullet_foo));
    		$('SubButton_' + Bullet_foo).parentNode.removeChild($('SubButton_' + Bullet_foo));
    		Bullet_TextExists = 0;
    		Bullet_FirstComment = false;
    	}
    	else {
    		$('BulletComment_' + Bullet_foo).parentNode.removeChild($('BulletComment_' + Bullet_foo)); 
    		Bullet_TextExists = 0;
    		Bullet_FirstComment = false;
    	}
    }

    function SubmitBulletForm() {
    	if ($('BulletComment_' + Bullet_SendID) && $('BulletComment_' + Bullet_SendID).value != '') {
    		cid = Bullet_SendID.split('_');
    		Bullet_Bullet = $('BulletComment_' + Bullet_SendID).value;
    		Bullet_Mcid = cid[1];
    		Bullet_Ucid = cid[0];
    	}
    	else {
    		if ($('BulletInsert').value != '') {
    			Bullet_Bullet = $('BulletInsert').value;
    			Bullet_Mcid = '';
    			Bullet_Ucid = '';
    		}
    		else {
    			return;
    		}
    	}
    	if (Bullet_Bullet.length > 1000) {
    		TempText = Bullet_Bullet;
    		Bullet_Bullet = TempText.substr(0, 1000);

    	}
    	makePOSTRequest('/user/Settings/ShoutBox.asp', 'Bullet=' + escape(Bullet_Bullet) + '&cid=' + Bullet_Mcid + '&Ucid=' + Bullet_Ucid + '&User=' + Bullet_BulletUserID + '&Action=1', GimmeBack, 'text/plain');
    	return false;
    }

    function GimmeBack(el) {
    	if (Bullet_Mcid == '') {
    		if ($('Bullet_Hint') != null) {
    			$('Bullet_Hint').parentNode.removeChild($('Bullet_Hint'));
    		}
    		MyEl = el.split('::lol::');
    		CreateDiv = document.createElement('div');
    		CreateDiv.className = 'Surround';
    		CreateDiv.id = 'Bullet_' + MyEl[0];

    		out = '<div class="ImageThumb" style="margin:8px;">';
    		out += Bullet_UserImg;
    		out += '</div>';
    		out += '<div class="SurroundCon" onmouseover="ShowDate(\'BulletDate_' + MyEl[0] + '\',true);" onmouseout="ShowDate(\'BulletDate_' + MyEl[0] + '\',false);">';
    		out += '<div class="NickName">';
    		out += '<b>' + Bullet_Nickname + '</b>';
    		out += '</div>';
    		out += '<div class="DatePost">';
    		out += '<span style="color:#00213A;visibility:hidden;" id="BulletDate_' + MyEl[0] + '">'
    		out += MyEl[1] + ' <img src="/images/gr2/loeschen.gif" id="Del_' + MyEl[0] + '_' + Bullet_BulletUserID + '" width="15" height="15" border="0" onclick="DelBullet(this);" style="cursor:pointer;" />';
    		out += '</span>';
    		out += '</div>';
    		out += '<div class="BulletContent">';
    		out += '<p class="BulletContent1"><table width="100%" style="margin:0px !important;padding:0px !important;"><tr><td><p style="margin:0px !important;padding:0px !important;">';
    		out += MyEl[2];
    		out += '</p></td></tr></table></p>';
    		out += '<div class="CommentLine">';
    		out += '<a href="#" style="font-weight:bold;" id="Comment_' + Bullet_BulletUserID + '_' + MyEl[0] + '_' + 1 + '" onclick="CreateTextBox(this);return false;">' + Bullet_CreateCom + '</a>';
    		out += '</div>';
    		out += '</div></div>';
    		out += Bullet_Pix;
    		out += '</div>';
    		CreateDiv.innerHTML = out;
    		$('Bullet_0').parentNode.insertBefore(CreateDiv, $('Bullet_0').nextSibling);
    		$('BulletInsert').value = '';
    	}
    	else {
    		MyEl = el.split('::lol::');
    		CreateDiv = document.createElement('div');
    		CreateDiv.className = 'CommentSurround';
    		
    		CreateDiv.id = 'Comment_' + MyEl[0];
    		out = '<div class="CommentImage">';
    		out += Bullet_UserImg;
    		out += '</div>';
    		out += '<div class="CommentConSur" onmouseover="ShowDate(\'BulletDate_' + MyEl[0] + '\',true);" onmouseout="ShowDate(\'BulletDate_' + MyEl[0] + '\',false);">';
    		out += '<div class="CommentNick">';
    		out += '<b>' + Bullet_Nickname + '</b>';
    		out += '</div><div class="CommentDate">';
    		out += '<span style="color:#00213A;visibility:hidden;" id="BulletDate_' + MyEl[0] + '">';
    		out += MyEl[1] + ' <img src="/images/gr2/loeschen.gif" id="Del_' + MyEl[0] + '_' + Bullet_BulletUserID + '" width="15" height="15" border="0" onclick="DelBullet(this);" style="cursor:pointer;" />';
    		out += '</span>';
    		out += '</div>';
    		out += '<p class="CommentConSur1"><table width="100%" style="margin:0px !important;padding:0px !important;"><tr><td><p style="margin:0px !important;padding:0px !important;">';
    		out += MyEl[2];
    		out += '</p></td></tr></table></p>'
    		out += '</div>';
    		CreateDiv.innerHTML = out;
    		if (Bullet_FirstComment) {
    			CreateCommentLine = document.createElement('div');
    			CreateCommentLine.className = 'CommentLine';
    			CreateCommentLine.id = 'CommentLine_' + MyEl[0];
    			CreateCommentLine.innerHTML = Bullet_CommentLine;
    			$('BulletComment_' + Bullet_Ucid + '_' + Bullet_Mcid).parentNode.parentNode.insertBefore(CreateCommentLine, $('BulletComment_' + Bullet_Ucid + '_' + Bullet_Mcid).parentNode);
    			Bullet_FirstComment = false;
    		}
    		$('BulletComment_' + Bullet_Ucid + '_' + Bullet_Mcid).parentNode.parentNode.insertBefore(CreateDiv, $('BulletComment_' + Bullet_Ucid + '_' + Bullet_Mcid).parentNode);
    		DeleteTextBox(Bullet_SendID);
    	}
    	EmbedVideo();
    	Bullet_UpDown = false;
    	Bullet_ResizeGaydget(Bullet_UpDown);
    }


    function ShowDate(ID, Show) {
    	$(ID).style.visibility = (Show) ? 'visible' : 'hidden';
    }

    function CheckLength(ev) {
    	ev = ev || window.event;
    	incoming = ev.target || ev.srcElement;
    	if (incoming.value.length > 1000) {
    		TempText = incoming.value;
    		incoming.value = TempText.substr(0, 1000);
    	}

    	Bullet_foo = incoming.id.split('_');
    	if (incoming.value.length >= 985) {
    		if (incoming.id == 'BulletInsert') {
    			
    			$('CharsLeft').style.color = 'gray';
    			$('CharsLeft').innerHTML = Bullet_CharsLeft + '<b>' + (1000 - incoming.value.length) + '</b>';
    		}
    		else {
    			$('CommentChars_' + Bullet_foo[1] + '_' + Bullet_foo[2]).style.color = 'gray';
    			$('CommentChars_' + Bullet_foo[1] + '_' + Bullet_foo[2]).innerHTML = Bullet_CharsLeft + '<b>' + (1000 - incoming.value.length) + '</b>';
    		}
    	}
    	else {
    		if (incoming.id == 'BulletInsert') {
    			$('CharsLeft').innerHTML = '&nbsp;';
    		}
    		else {
    			$('CommentChars_' + Bullet_foo[1] + '_' + Bullet_foo[2]).innerHTML = '&nbsp;';
    		}
    	}
    }

    function Bullet_getOwn(ad) {
    	Bullet_TextExists = 0;
    	var i;
    	for (i = 0; i < gaydgets.length; i++) {
    		if (gaydgets[i].srcUrl != null && gaydgets[i].srcUrl.indexOf('shoutbox') > -1) {
    			if (ad == 0)
    				gaydgets[i].srcUrl = '/user/shoutbox.asp?SelfOnly=0';
    			else
    				gaydgets[i].srcUrl = '/user/shoutbox.asp?SelfOnly=1';
    			gaydgets[i].loadRSS();
    			
    			break;
    		}
    	}
    }

    function Bullet_ResizeGaydget(Bullet_UpDown) {
    	for (i = 0; i < gaydgets.length; i++) {
    		if (gaydgets[i].id == $('Bullet_0').parentNode.parentNode.parentNode.parentNode.id) {
    			gaydgets[i].closed = true;
    			gaydgets[i].intoView = false;
    			if (Bullet_UpDown) {
    				gaydgets[i].visibleHeight = 0;
    				gaydgets[i].visibleContent.style.height = '';
    			}
    			gaydgets[i].maxHeight = 0;
    			gaydgets[i].slide();
    			break;
    		}
    	}

 }

 function Bullet_Init() {
     if (document.getElementById('BulletInsert') != null) {
         AddMyEv = document.getElementById('BulletInsert');
         top.addEvent(AddMyEv, 'keyup', CheckLength);
         top.addEvent(AddMyEv, 'blur', CheckLength);
         top.addEvent(AddMyEv, 'paste', CheckLength);
         EmbedVideo();
     } else {
         setTimeout('Bullet_Init()', 100);
     }
 }



    var Bullet_BulletUserID = 0;
    var Bullet_Warn = '';
    var Bullet_CanWrite = '';
    var Bullet_CharsLeft = '';
    var Bullet_CreateCom = '';
    var Bullet_CommentLine = '';
    var Bullet_TextLength = '';
    var Bullet_Nickname = '';
    var Bullet_UserImg = '';
    var Bullet_Pix = '';
    var Bullet_Del = '';
    var Bullet_TextExists = '';
    var Bullet_Bullet = '';
    var Bullet_Mcid = '';
    var Bullet_Ucid = '';
    var Bullet_foo = '';
    var Bullet_SendID = '';
    var Bullet_FirstComment = false;
    var Bullet_UpDown = false;
    var ARZ = '';

    
/*
    function changeDesign(el) {
        var val = el[el.selectedIndex].value;
        top.grnav.sendRequest('/art/change.asp?NewDesign=' + val, top.grnav.getDesign);
        top.grnav.ChangeDesign(this[this.selectedIndex].value);
       }   
 */
    var rk = false;
    var rkx = null;
    var rki = null;
    function rk_image(el, func, cfw) {
    	switch (func) {
    		case 'xv': rk_big(el, parseInt(cfw)); break;
    		case 'xu': rk_small(); break;
    		case 'ov': rk_big(el, parseInt(cfw)); if (rk) { return; } el.style.borderColor = 'gold'; break;
    		case 'ou': rk_small(); if (rk) { return; } el.style.borderColor = '#003563'; break;
    		case 'cl': if (rk) { return; } rk = el.getAttribute('val'); makePOSTRequest('/user/Settings/imagebar.asp?rk=' + rk, '', rk_result, 'text/plain');  break;
    	}
    }
    function rk_result(txt) {
    	document.getElementById('rk0').style.cursor = 'default';
    	document.getElementById('rk1').style.cursor = 'default';
    	var rkt = document.getElementById('rk_text');
   		rkt.innerHTML = (txt != rk) ? rkt.getAttribute('error') : rkt.getAttribute('thank');
   	}
   	function rk_big(el,cfw) {
   		if (rkx == null) {
   			rkx = document.createElement('DIV');
   			rki = document.createElement('IMG');
   			rkp = (document.all && !window.opera) ? 'absolute' : 'fixed';
   			rkx.style.cssText = (cfw == 864) ? 'position:' + rkp + ';z-index:1000;left:374px;top:0px;width:471px;height:616px;background-color:#003762;padding:5px;' : 'position:' + rkp + ';z-index:1000;left:262px;top:0px;width:327px;height:427px;background-color:#003762;padding:5px;';
   			rkx.appendChild(rki);
   			document.getElementsByTagName("body")[0].appendChild(rkx);
   		}
   		rki.src = el.getAttribute('osrc');
   		rki.width = (cfw == 864) ? 461 : 317;
   		rki.height = (cfw == 864) ? 606 : 417;
   		rkx.style.display = 'block';
   	}
   	function rk_small() {
   		rkx.style.display = 'none';
   	}
