/******************************************/
/* DIV aufklappen                         */
/******************************************/

var id;
function fctShowBlock(intBlockID, maxid) {
//    cont=document.getElementById('refContainer');
//    lastNode=cont.lastChild;
//console.log(lastNode);
//    prev=lastNode.previousSibling;
//    prev=prev.previousSibling;
//    prev=prev.previousSibling;
//console.log(prev.attributes);
    if(id == intBlockID) {
        Effect.BlindUp('block' + intBlockID, {});
        id=-1;
        document.getElementById('blockbutton' + intBlockID).style.backgroundImage = "url('/bilder/layout/pfeil_block_inakt.gif')";
        return false;
    }
    id = intBlockID;
    for(z=0; z<maxid; z++) {
        if(intBlockID != z) {
            Effect.BlindUp('block' + z, {});
            document.getElementById('blockbutton' + z).style.backgroundImage = "url('/bilder/layout/pfeil_block_inakt.gif')";
        }
    }
    Effect.BlindDown('block' + intBlockID, {});
    document.getElementById('blockbutton' + intBlockID).style.backgroundImage = "url('/bilder/layout/pfeil_block_akt.gif')";
    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($('maincontent'), {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;
}
/***************************************************************
 *   Suche Ende
 ***************************************************************/                                                  