function showBlock(vid) {
    var b = document.getElementById("block_" + vid);
    hideBlock(b);
    if (b) {
        b.style.display = "block";
    }
    return false;
}

function hideBlock(block) {
    var blocks = block.parentNode.getElementsByTagName("div");
    if (blocks.length > 0) {
        for (i = 0; i < blocks.length; i++) {
            blocks[i].style.display = "none";
        }
    }
}



/******************************************/
/* Textgroesse aendern                    */
/******************************************/
function getCookie (cookieName) {
    var cookie = cookieManager.getCookie(cookieName);
    return (cookie)?cookie:false;
}

function setCookie (cookieName,cookieValue) {
    return cookieManager.setCookie(cookieName,cookieValue);
}

// Funktion zum vergroessern bzw. verkleinern der Textgroesse
function schrift(plus){
    if(plus) {
        nr++;
    } else {
        nr--;
    }
    
    if(nr < 0) {
        nr = 0;
    }
    
    if(nr >= Sizes.length) {
        nr = Sizes.length-1;
    }

    setCookie("textgroesse",nr);
    document.getElementsByTagName('body')[0].style.fontSize=Sizes[nr]+'%';
}



/******************************************/
/* DIV aufklappen                         */
/******************************************/
var id;
function fctShowBlock(intBlockID, maxid) {
    if(id == intBlockID) {
        Effect.BlindUp('block' + intBlockID, {});
        id=-1;
        document.getElementById('blockliste' + id).style.background = "#ffffff";
        document.getElementById('blockbutton' + id).style.display = "block";
        return false;
    }

    id = intBlockID;
    for(i=0; i<maxid; i++) {
        if(intBlockID != i) {
            Effect.BlindUp('block' + i, {});
            document.getElementById('blockliste' + i).style.background = "#ffffff";
            document.getElementById('blockbutton' + i).style.display = "block";
        }
    }

    Effect.BlindDown('block' + intBlockID, {});
    document.getElementById('blockliste' + intBlockID).style.background = "#e6e6e6";
    document.getElementById('blockbutton' + intBlockID).style.display = "block";
    return false;
}



/******************************************/
/* Suche                                  */
/******************************************/
var sI=null;
var ss;
var la;
var pa;

function suche(begriff, lang, page) {
    if(begriff.length > 2 && begriff != "Suchbegriff eingeben") {
        ss = escape(begriff);
        la = lang;
        pa = page
        if(sI) window.clearInterval(sI);
        sI = window.setInterval("requestSuche();window.clearInterval(sI);", 300);
    }
}

function requestSuche() {
    var URI = "/administration/scripte/suche.php";
    var pars = "search=" + ss + "&lang=" + la + "&page=" + pa;
    new Ajax.Request(URI, {method:"post", postBody:pars, onComplete:showSearchResult});
}

function showSearchResult(request) {
    $('searchcontent').innerHTML = request.responseText;
    new Effect.Fade($('contenttext'), {afterFinish: function() {new Effect.Appear($('searchcontent'))}});
}

function createPageNav(s,e,m) {
    var pages = Math.ceil(m/10);
    var akt = Math.ceil(s/10);
    var d = document.createElement('div');
    d.style.marginTop = "10px";
    d.style.marginBottom = "10px";
    if(akt>0) {
        var l = document.createElement('a');
        l.href = "javascript:;";
        l.onclick = showPage;
        l.title = akt;
        var l_t = document.createTextNode("<<");
        l.appendChild(l_t);
        d.appendChild(l);
    }
    for(var i=1; i<=pages; i++) {
        if(i != (akt+1)) {
            var l = document.createElement('a');
            l.href = "javascript:;";
            l.onclick = showPage;
            l.title = i;
            var l_t = document.createTextNode(i);
        } else {
            var l = document.createElement('a');
            l.href = "javascript:;";
            l.onclick = showPage;
            l.title = i;
            var l_t = document.createTextNode("["+i+"]");
        }
        l.appendChild(l_t);
        l.style.marginLeft = "5px";
        d.appendChild(l); 
    }
    if(akt+1<pages) {
        var l = document.createElement('a');
        l.href = "javascript:;";
        l.onclick = showPage;
        l.title = akt + 2;
        var l_t = document.createTextNode(">>");
        l.appendChild(l_t);
        l.style.marginLeft = "5px";
        d.appendChild(l);
    }
    return d;
}
function showPage() {
    p = parseInt(this.title);
    cs.setOpts('p', p);
    cs.sendRequest();
    return false;
}
