var frontscrollaction = "change";
var lastfrontscrollaction = "fadeout";
var frontscrolltexteid = -1;
var frontscrollidleft = 0;
var frontscrollmouseover = false;

function frontscrollen(){
opacitynow = Math.floor(frontscrollid.style.opacity * 100);
tempfrontscrollaction = frontscrollaction;
if(frontscrollmouseover == false){
switch(tempfrontscrollaction){
    case "change":
    frontscrolltexteid = frontscrolltexteid+1;
    if(frontscrolltexteid>=frontscrolltexte.length) frontscrolltexteid=1;
    frontscrollidleft = 0;
    frontscrollid.style.left = frontscrollidleft+"px";
    frontscrollid.innerHTML = "<nobr>"+frontscrolltexte[frontscrolltexteid]+"</nobr>";
    frontscrollaction = "fadein";
    window.setTimeout("frontscrollen()", 20);
    break;

    case "fadein":
    if(opacitynow == 100){
        frontscrollaction = "move";
        window.setTimeout("frontscrollen()", 5000);
    }
    else{
    //    frontscrollid.style.top = Math.floor((-100+(opacitynow+4))/5)+"px";
        setOpacity(frontscrollid, opacitynow+4);
        window.setTimeout("frontscrollen()", 20);
    }
    break;
    
    case "fadeout":
    if(opacitynow == 0){
        frontscrollaction = "change";
        window.setTimeout("frontscrollen()", 20);
    }
    else{
    //    frontscrollid.style.top = Math.floor((100-(opacitynow+4))/5)+"px";
        setOpacity(frontscrollid, opacitynow-4);
        window.setTimeout("frontscrollen()", 20);
    }
    break;
    
    case "move":
    shouldMove = false;
    helptext = "0";
    if(frontscrollid.offsetWidth && frontscrollaussen.offsetWidth){
        if(frontscrollid.offsetWidth>frontscrollaussen.offsetWidth){
            if(frontscrollidleft>(frontscrollaussen.offsetWidth-frontscrollid.offsetWidth)){
                shouldMove = true;
            }
        }
    }
    if(shouldMove == true){
        frontscrollidleft -= 1;
        frontscrollid.style.left = frontscrollidleft+"px";
        window.setTimeout("frontscrollen()", 20); 
    }
    else{
        frontscrollaction = "fadeout";
        window.setTimeout("frontscrollen()", 1000);
    }
    break;
}
}
else{
window.setTimeout("frontscrollen()", 200);
}
}

function selectBilder(objname){
if(objname!=bilderOpen){
new Effect.SlideUp('userbilder_'+bilderOpen, {queue: 'front'});
new Effect.SlideDown('userbilder_'+objname, {queue: 'end'});
bilderOpen=objname;
}
}

var rechtsOpen = 'forenb';
function selectRechts(objname){
if(objname!=rechtsOpen){
new Effect.BlindUp('cont_'+rechtsOpen, {queue: 'front'});
new Effect.BlindDown('cont_'+objname, {queue: 'end'});
rechtsOpen=objname;
}
}

function grabNIcontent(what, options){
grabTime = new Date();
var optional = "";
var cacheWhat = what;
if(what.substr(0,4)!="user"||(blocksLoaded[cacheWhat] < ((grabTime.getSeconds()+60*grabTime.getMinutes())-60))||!blocksLoaded[cacheWhat]){
    document.getElementById(what).innerHTML=document.getElementById(what).innerHTML+'<div style="position:absolute; top:20px; right:20px; z-index:50;"><img src="images/loading_snake.gif"></div>';
//    for(var index in options){
//        optional += "&"+index+"="+escape(options[index]);
//        }
    http.open("GET", "http://besserhausen.de/neuesteInhalteXML.php?block=" + what + optional, true);
    http.onreadystatechange = function(){
        if (http.readyState == 4) {
        if (http.responseText.indexOf('invalid') == -1) {
            document.getElementById(what).innerHTML=http.responseText;
            loadTime = new Date();
            blocksLoaded[cacheWhat] = loadTime.getSeconds() + 60 * loadTime.getMinutes();
        }
        isWorking = false;
    }};
    isWorking = true;
    http.send(null);
    }
}

