function Blotter()
{
    this.blotterTab = [];
    this.blotterRegister = [];
    this.startTab = "";
    this.startRegister = "";
    this.setStartTab = function(tab, register) {
        this.startTab = tab;
        this.startRegister = register;
    }
    this.showStartTab = function(tab, register) {
    // Damit die Tabs in der Printversion alle ausklappen
    if (window.name!="printversion"){  
                this.closeAllTabs();
                this.setStartTab(tab, register);
                $("#"+tab).addClass("cboxtab_active");
                startReg = this.startRegister;
                $("#"+startReg).show();
                                      }
    }
    this.addTab = function(tab, register) {
        this.blotterTab.push(tab);
        this.blotterRegister.push(register);
    }
    this.showTab = function(tab, register) {
        this.closeAllTabs();
        $("#"+tab).addClass("cboxtab_active");
        $("#"+register).show();
        this.saveTab(tab, register);
    }
    this.closeAllTabs = function() {
        var temp = this.blotterRegister;
        var tabs = this.blotterTab;
        $.each(temp, function(i) {
               $("#"+this).removeClass("cboxtab_active");
        });

 this.saveTab = function(tab, register) {

        document.cookie = 'actualTab='+tab+';';
        document.cookie = 'actualRegister='+register+';';

    }
    this.showSavedTab = function() {
        a = document.cookie;
        indexTab = a.indexOf("actualTab=");
        indexRegister = a.indexOf("actualRegister=");
        if(indexTab>-1&&indexRegister>-1){
            actualTab = a.substring((indexTab+"actualTab=".length),a.indexOf(';',indexTab));
            if(a.indexOf(';',indexRegister)>-1){endIndexRegister=a.indexOf(';',indexRegister)}
            else{endIndexRegister=a.length}
            actualRegister = a.substring((indexRegister+"actualRegister=".length),endIndexRegister);
            if($("#"+actualTab).length > 0){
                this.showTab(actualTab, actualRegister);
            }
        }
    }





    $.each(tabs, function(i) {
        $("#"+this).hide();
    });
    }
}
function switchLayers(image,name) {
                                 var elem = document.getElementById(name);
                                 //alert(name + ": " + elem);                            
                                 if( elem.style.display == "none" || elem.style.display == "") {
                                     elem.style.display = "block";
                                     image.src = "/static/img/admin/btn_close_12x12.gif"; 
                                                                 
                                 } else {
                                     elem.style.display = "none";
                                     image.src = '/static/img/admin/btn_open_12x12.gif';
                                 }
}
function openAllLayers() {
                                var uls = document.getElementsByTagName("ul");                                  
                                var lis = document.getElementsByTagName("li");
                                var imgs = document.getElementById("sitemap").getElementsByTagName("img");    
                                
                                for( i = 0; i < imgs.length; i++ ) {                                     
                                         var image =imgs[i];                                                                    
                                        image.src='/static/img/admin/btn_close_12x12.gif'; 
                                                                                     
                                 }                                    
                                for( y = 0; y < lis.length; y++ ) {                                     
                                         var li =lis[y];                                                                    
                                        if(li.className == "firstlevel"){
                                            li.style.display = "block";                                                
                                        }                                                    
                                 }                             
                                 for( z = 0; z < uls.length; z++ ) {                                     
                                         var ul =uls[z];                                        
                                        //alert(ul.className);                                        
                                        if(ul.className == "secondlevel" || ul.className == "thirdlevel"){
                                            ul.style.display = "block";
                                        }                                    
                }                                
} 
/* Timer Function from http://www.codingforums.com/showthread.php?t=10531 */
// The constructor should be called with
// the parent object (optional, defaults to window).
function Timer(){
    this.obj = (arguments.length)?arguments[0]:window;
    return this;
}
// The set functions should be called with:
// - The name of the object method (as a string) (required)
// - The millisecond delay (required)
// - Any number of extra arguments, which will all be
//   passed to the method when it is evaluated.
Timer.prototype.setInterval = function(func, msec){
    var i = Timer.getNew();
    var t = Timer.buildCall(this.obj, i, arguments);
    Timer.set[i].timer = window.setInterval(t,msec);
    return i;
}
Timer.prototype.setTimeout = function(func, msec){
    var i = Timer.getNew();
    Timer.buildCall(this.obj, i, arguments);
    Timer.set[i].timer = window.setTimeout("Timer.callOnce("+i+");",msec);
    return i;
}
// The clear functions should be called with
// the return value from the equivalent set function.
Timer.prototype.clearInterval = function(i){
    if(!Timer.set[i]) return;
    window.clearInterval(Timer.set[i].timer);
    Timer.set[i] = null;
}
Timer.prototype.clearTimeout = function(i){
    if(!Timer.set[i]) return;
    window.clearTimeout(Timer.set[i].timer);
    Timer.set[i] = null;
}
// Private data
Timer.set = new Array();
Timer.buildCall = function(obj, i, args){
    var t = "";
    Timer.set[i] = new Array();
    if(obj != window){
        Timer.set[i].obj = obj;
        t = "Timer.set["+i+"].obj.";
    }
    t += args[0]+"(";
    if(args.length > 2){
        Timer.set[i][0] = args[2];
        t += "Timer.set["+i+"][0]";
        for(var j=1; (j+2)<args.length; j++){
            Timer.set[i][j] = args[j+2];
            t += ", Timer.set["+i+"]["+j+"]";
    }}
    t += ");";
    Timer.set[i].call = t;
    return t;
}
Timer.callOnce = function(i){
    if(!Timer.set[i]) return;
    eval(Timer.set[i].call);
    Timer.set[i] = null;
}
Timer.getNew = function(){
    var i = 0;
    while(Timer.set[i]) i++;
    return i;
}
/* suckerfish css dropdown js helper with timer for IE */
sfHover = function() {
        var sfEls = document.getElementById("hnavmenu").getElementsByTagName("LI");
        for (var i=0; i<sfEls.length; i++) {
            sfEls[i].onmouseover=function() {
                this.className+=" sfhover";
            }
            sfEls[i].onmouseout=function() {
                this.timer = new Timer(this);
                this.timer.setTimeout("out",200); /* DEFAULT: this.timer.setTimeout("out",500); */
            }
            sfEls[i].out=function() {
            this.className=this.className.replace(new RegExp("\\bsfhover\\b"), "");
            }
        }
    }
    if (window.attachEvent) window.attachEvent("onload", sfHover);
    if (window.addEventListener) window.addEventListener( "load", sfHover, false );
// -- Bereiche durch Mausklick ein/ausblenden --
// Anweisung, die Bereiche sichtbar/unsichtbar macht
 function ausblenden (uDiv) {
    if(uDiv.style.display=='none') {
         uDiv.style.display='block';
    }
    else {
        uDiv.style.display='none';
    }
 }