﻿function gotoLink(obj) {
    if (obj.href.indexOf("#") == obj.href.length - 1)
        return false;
    top.location.href = obj.href;
}
// ausgaben wechseln
function changeI(obj) {
    if (obj.id == "anavnext") {
        $jq("#op1").css("height", $jq("div.page").height() + 23);    
        $jq("#op1").fadeTo(2000, 0.9, function() { top.location.href = document.getElementById(obj.id).href; });
    } else {
        $jq("#op1").css("height", $jq("div.page").height() + 23);
//        $jq("#op1").css("overflow", "hidden");
//        $jq("#op1").html("<img src=\"" + previmage + "\" width=\"100%\" style=\"position: absolute; top: 0px; left: 0px;\"/><div style=\"position:absolute;opacity:0.01;background-color:#000000;width:100%;height:100%;\">&nbsp;</div>");
//        window.setTimeout("top.location.href=document.getElementById(\"" + obj.id + "\").href", 2000000);
        $jq("#op1").fadeTo(2000, 0.9, function() { top.location.href = document.getElementById(obj.id).href; });
//        $jq("#op1 div").fadeTo(1000,0.8);
    }
    return false;
}
function showN1(obj) {
    if(ivsh)
        $jq("#sbcat").slideUp("normal");
    else
        $jq("#sbcat").slideDown("normal");
    ivsh = !ivsh;
    return false;
}
var counter = 0;
function timeout() {
    if (minsh1 == false && minsh2 == false && minsh3 == false) {
        counter--;
        if (counter == 0) {
            $jq("#sbcat").slideUp("normal");
            ivsh = false;
        }
        counter = Math.max(counter, -1);
    }
}
function rss() {
    return false;
}
// read more
function rmore(obj) {
    var tmp = $jq(obj).parent();
    tmp.next("div").slideToggle("normal");
}
// filter object type
function selectOT(type) {
    //if (top.location.href.indexOf("onloadfilter") > -1)
// else

    return false;
}
function read() {
    return false;
}
var currfsize = 11;
var currfsizeh3 = 13;

function fsize(dy) {
    if (currfsize < 6)
        currfsize=6
    currfsize += dy;
    currfsizeh3 += dy;
    var tmp = $jq("div.middle div.text");
    tmp.css("font-size", currfsize + "px");
    tmp = $jq("div.middle div.text *");
    tmp.css("font-size", currfsize + "px");
    tmp = $jq("div.sitemap li *");
    tmp.css("font-size", currfsize + "px");
    tmp = $jq("div.comment *");
    tmp.css("font-size", currfsize + "px");
    tmp = $jq("div.comments h3");
    tmp.css("font-size", currfsizeh3 + "px");
    return false;
}
// search has focus?
var isa = false;
// category expanded?
var ivsh = false;
var sindex;
var minsh1 = false;
var minsh2 = false;
var minsh3 = false;
// li navigation left active
var currli = null;

function initall() {
    $jq("p.choice input").click(function() { this.checked = true; $jq("#rsubmit input").click(); });
    // replace read button:
    $jq("img.vrweb_img").attr("src", "portaldata/2/resources/_layout/read_" + lang + "_i.gif").attr("alt", lang == "1" ? "Vorlesen" : "Read").attr("title", lang == "1" ? "Vorlesen" : "Read");
    $jq("div.text p.rmore").each(function(i) { $jq(this).nextAll().wrapAll("<div></div>") }); 
    $jq("div.text p.rmore").next("div").toggle();
    $jq("#op1").css("height", $jq("div.page").height() + 23);
if(navigator.appVersion.indexOf("MSIE 6")==-1)
    $jq("#op2").css("height", "100%");
    // home+ mm Button
    tmp = $jq("div.head div.search img");
    if ((typeof (ismmsitemap) != "undefined") && ismmsitemap) {
        tmp.get(2).src = tmp.get(2).src.replace("_i", "_a");
        var tmp2 = $jq("div.desc");
        $jq("div.data").click(function() {location.href=$jq(this).parent().find("a").attr("href") });
        tmp2.mouseenter(function() { $jq("div.data", this).show(); $jq("div.tn img", this).eq(0).fadeOut(); $jq("div.tn img", this).eq(1).fadeIn(); });
        tmp2.mouseleave(function() { $jq("div.data", this).hide(); $jq("div.tn img", this).eq(1).fadeOut(); $jq("div.tn img", this).eq(0).fadeIn(); });
    } else {
        tmp.eq(2).mouseenter(function() { this.src = this.src.replace("_i", "_a") });
        tmp.eq(2).mouseleave(function() { this.src = this.src.replace("_a", "_i") });
    }

    if ((typeof (isarchive) != "undefined") && isarchive) {
        tmp.get(1).src = tmp.get(1).src.replace("_i", "_a");
    } else {
        tmp.eq(1).mouseenter(function() { this.src = this.src.replace("_i", "_a") });
        tmp.eq(1).mouseleave(function() { this.src = this.src.replace("_a", "_i") });
    }
    
    
    tmp.eq(tmp.size() - 1).mouseenter(function() { this.src = this.src.replace("_i", "_a") });
    tmp.eq(tmp.size() - 1).mouseleave(function() { this.src = this.src.replace("_a", "_i") });
    if ((typeof (ishome) != "undefined") && ishome) {
        tmp.get(0).src = tmp.get(0).src.replace("_i", "_a");
        tmp = $jq("div.box div.tn");
        tmp.mouseenter(function() { $jq("img", this).eq(0).fadeOut(); $jq("img", this).eq(1).fadeIn(); });
        tmp.mouseleave(function() { $jq("img", this).eq(1).fadeOut(); $jq("img", this).eq(0).fadeIn(); });
    }
    else {
        tmp.eq(0).mouseenter(function() { this.src = this.src.replace("_i", "_a") });
        tmp.eq(0).mouseleave(function() { this.src = this.src.replace("_a", "_i") });
    }
    tmp = $jq("#sbcat a")
    sindex = tmp.size();
    tmp.each(function(i) {        
        if (location.href.indexOf(this.href) > -1) {
            sindex = i;
        }
    }
    );

    window.setInterval("timeout()", 50);
    if (sindex < tmp.size()) {
        $jq("#sbcat_txt").html(tmp.eq(sindex).html());
        tmp = $jq("a.sbhead img");
        tmp.attr("src", tmp.attr("src").replace("_i", "_a"));
        $jq("a.sbhead img").mouseenter(function() {
            minsh1 = true;
            this.src = this.src.replace("_i", "_a");
        });
        $jq("a.sbhead img").mouseleave(function() {
            minsh1 = false;
            counter = 10;
        });
        $jq("#sbcat_txt").mouseenter(function() {
            minsh2 = true;
        });
        $jq("#sbcat_txt").mouseleave(function() {
            minsh2 = false;
            counter = 10;
        });
    } else {
        $jq("a.sbhead img").mouseenter(function() {
            minsh1 = true;
            this.src = this.src.replace("_i", "_a");
        });
        $jq("a.sbhead img").mouseleave(function() {
            minsh1 = false;
            counter = 10;
            if (!ivsh) {
                this.src = this.src.replace("_a", "_i");
            }
        });
        $jq("#sbcat_txt").mouseenter(function() {
            minsh2 = true;
            tmp = $jq("a.sbhead img");
            tmp.attr("src", tmp.attr("src").replace("_i", "_a"));
        });
        $jq("#sbcat_txt").mouseleave(function() {
            counter = 10;
            minsh2 = false;
        });
    }
    $jq("#sbcat").mouseenter(function() {
        minsh3 = true;
    });
    $jq("#sbcat").mouseleave(function() {
        minsh3 = false;
    });
    $jq("div.left img").each(
    function(i) {
        if (this.src.indexOf("_i.gif") > -1) {
            $jq(this).mouseenter(function() {
                this.src = this.src.replace("_i", "_a");
            });
            $jq(this).mouseleave(function() {
                this.src = this.src.replace("_a", "_i");
            });
        }
    }
    );
    $jq("div.middle img").each(
    function(i) {
        if (this.src.indexOf("_i.gif") > -1) {
            $jq(this).mouseenter(function() {
                this.src = this.src.replace("_i", "_a");
            });
            $jq(this).mouseleave(function() {
                this.src = this.src.replace("_a", "_i");
            });
        }
    }
    );
    $jq("div.hiresimage img").each(
    function(i) {
        if (this.src.indexOf("_i.gif") > -1) {
            $jq(this).mouseenter(function() {
                this.src = this.src.replace("_i", "_a");
            });
            $jq(this).mouseleave(function() {
                this.src = this.src.replace("_a", "_i");
            });
        }
    }
    );
    $jq("div.right img").each(
    function(i) {
        if (this.src.indexOf("_i.gif") > -1) {
            $jq(this).mouseenter(function() {
                this.src = this.src.replace("_i", "_a");
            });
            $jq(this).mouseleave(function() {
                this.src = this.src.replace("_a", "_i");
            });
        }
    }
    );
    $jq("div.main input").each(
    function(i) {
        if (this.src.indexOf("_i.gif") > -1) {
            $jq(this).mouseenter(function() {
                this.src = this.src.replace("_i", "_a");
            });
            $jq(this).mouseleave(function() {
                this.src = this.src.replace("_a", "_i");
            });
        }
    }
    );
// filter buttons
    $jq("div.multimedia .ot img").each(
    function(i) {
        var tmp2 = $jq(this);
        if (location.href.indexOf(this.className) == -1) {
            tmp2.mouseenter(function() {
                this.src = this.src.replace("4.gif", ".gif");
            });
            tmp2.mouseleave(function() {
                this.src = this.src.replace(".gif", "4.gif");
            });
        } else {
            this.src = this.src.replace("4.gif", ".gif");
        }
    }
    );
    // search    
    tmp = $jq("#squery").parent();
    tmp.mouseenter(function() {
        var tmp2 = $jq("input", this);
        tmp2.eq(0).css("background-color", "#ffffff");
        tmp2.eq(1).attr("src", tmp2.eq(1).attr("src").replace("_i", "_a"));
        $jq("#squery").css("background-color", "#ffffff");
    });
    tmp.mouseleave(function() {
        if (isa == false) {
            var tmp2 = $jq("input", this);
            tmp2.eq(0).css("background-color", "#a7a9ac");
            tmp2.eq(1).attr("src", tmp2.eq(1).attr("src").replace("_a", "_i"));
            $jq("#squery").css("background-color", "#a7a9ac");
        }
    });
    tmp = $jq("#squery input").eq(0);
    tmp.blur(function() {
        isa = false;
        var tmp2 = $jq("#squery").parent().find("input");
        tmp2.eq(0).css("background-color", "#a7a9ac");
        tmp2.eq(1).attr("src", tmp2.eq(1).attr("src").replace("_a", "_i"));
        $jq("#squery").css("background-color", "#a7a9ac");
    });
    tmp.focus(function() { isa = true; });
    
    tmp = $jq("div.box div.desc");
    tmp.css("cursor", "pointer");
    tmp.click(function() {
        var tmp = $jq(this).find("a");
        if (tmp.length > 0)
            window.location.href = tmp.get(0).href;
    });
    tmp = $jq("div.archive div.desc");
    tmp.css("cursor", "pointer");
    tmp.click(function() {
        var tmp = $jq(this).find("a");
        if (tmp.length > 0)
            window.location.href = tmp.get(0).href;
    });
    tmp = $jq("div.searchresult div.desc");
    tmp.css("cursor", "pointer");
    tmp.click(function() {
        var tmp = $jq(this).find("a");
        if (tmp.length > 0)
            window.location.href = tmp.get(0).href;
    });
    tmp = $jq("div.navigationleft li");
    tmp.css("cursor", "pointer");
    tmp.click(function() {
        var tmp2 = $jq(this).find("a").get(0);
        if (tmp2.target != "") {
            window.open(tmp2.href, tmp2.target);
            return false;
        } else
            window.location.href = tmp2.href;
    });
    
    tmp = $jq("div.navigationleft ul");
    tmp.mouseleave(function() {
        var tmp2 = $jq("li div.tn", this);
        tmp2.stop(true);
        tmp2.animate({ height: "0" }, "slow");
        $jq("li", this).each(function() {
            if(this.id=="currli")
                this.className="active";
            else
                this.className= "inactive";
        });
        currli = null;
    });
    $jq("img", this).height()
    tmp = $jq("div.navigationleft ul li div.data")
    tmp.each(function() { try{this.ih = $jq("img", this).get(0).offsetHeight+"px";}catch(e){this.ih=0;} });
    tmp.mouseenter(function() {
        var tmp2 = $jq("div.tn", this.parentNode);
        tmp2.stop(true);
        tmp2 = $jq("div.tn", this);
        //        tmp2.slideDown("slow");
        tmp2.animate({ height: this.ih }, "slow");
        if (currli) {
            tmp2 = $jq("div.tn", currli);
            tmp2.animate({ height: "0" }, "slow");
            currli.className="inactive";
        } else
            if(this.parentNode.id!="currli")
                document.getElementById("currli").className = "inactive";
        currli = this.parentNode;
        currli.className= "active" ;
    });
    /*
    tmp.mouseleave(function() {
        
    });
    */
    
    $jq("div.sitemap ul.l2").each(function(){ $jq(this).find("li:last").css("border", "0px")});
    
}
// Gallerlist 
function initGList(){
            $jq("div.gallerylist").each(
                function(i) {
                   $jq(this).find("div.item:gt(3)").hide();
                   var tmp=$jq(this).find("div.item");
                   var numpages=Math.floor((tmp.size() +3) / 4);
                   if(numpages>1){
                       erg="<a href=\"#\" onclick=\"return navigateGL(this,\'prev\')\" id=\"gln-"+String(i)+"-0-"+String(numpages)+"\">&lt;</a> ";
                       var j;
                       for(j=1;j<=numpages;j++) {
                           if(j>1)
                               erg+="<span>|</span>";
                           erg+=" <a href=\"#\" onclick=\"return navigateGL(this,"+String(j)+")\" id=\"gln-"+String(i)+"-"+String(j)+"-"+String(numpages)+"\""+(j==1?"class=\"active\"":"")+">"+String(j)+"</a> ";
                       }
                       erg+="<a href=\"#\" onclick=\"return navigateGL(this,\'next\')\" id=\"gln-"+String(i)+"-"+String(j)+"-"+String(numpages)+"\">&gt;</a> ";
                       $jq(this).find("div.nav").html(erg);
                       if(typeof(currvideo)!="undefined") {
                            tmp.each(function(k) {
                                if (this.id == ("videos-" + currvideo)) {
                                    navigateGL($jq(this.parentNode).find("div.nav a").get(Math.floor(k / 4) + 1), String(Math.floor(k / 4) + 1));
                                    return;
                                }
                            });
                       }
                       if(typeof(currimagegallery)!="undefined") {
                           tmp.each(function(k) {
                               if (this.id == ("imagegalleries-" + currimagegallery)) {
                                   navigateGL($jq(this.parentNode).find("div.nav a").get(Math.floor(k / 4) + 1), String(Math.floor(k / 4) + 1));
                                   return;
                               }
                           });
                        }
                   }
                }
            );
            if (typeof (currimagegallery) != "undefined") {
                initIG();
            }
}
// Image Gallery
var tnwidth = 0;
var tndx = 0;

function initIG() {
    $jq().keypress(function(e) {
        if (e.which == 27) { //esc
            closeLImage();
        }
    });


    tmp = $jq("#ig_mainimage");
    var tmp2 = $jq("#img_container div.middle:first;")
    tmp.attr("src", tmp2.attr("ol_imgsrc"));
    tmp.attr("alt", tmp2.attr("title"));
    tmp.attr("hid", tmp2.attr("hid"));
    tmp.attr("mid", tmp2.attr("id"));
    tmp.attr("lid", tmp2.attr("lid"));
    tnwidth = $jq("#igmc").find("div.low").size() * 100;
//    $jq("#igmc").css("width", String(tnwidth)+"px");
    $jq("div.mainimage").mouseenter(mover_mi);
    $jq("div.mainimage").mouseleave(mout_mi);
    $jq("div.imagegallery div.navleft img,div.imagegallery div.navright img").mouseover(function() {
       this.src = this.src.replace("_i", "_a");
    });
    $jq("div.imagegallery div.navleft img,div.imagegallery div.navright img").mouseout(function() {
        this.src = this.src.replace("_a", "_i");
    });
    $jq("#op1").fadeTo(0, 0.01);
}
function mover_mi(obj) {
    $jq("div.mainimage div.navleft").fadeIn();
    $jq("div.mainimage div.navright").fadeIn();
    $jq("div.mainimage div.zoom").fadeIn();
}

function mout_mi(obj) {
        $jq("div.mainimage div.navleft").fadeOut();
        $jq("div.mainimage div.navright").fadeOut();
        $jq("div.mainimage div.zoom").fadeOut();
}
function nextImg(obj) {
    var tmp = $jq("#ig_mainimage");
    var tmp2 = $jq("#" + tmp.attr("lid")).next().find("div.middle");
    if (tmp2.size() > 0) {
        tmp.attr("src", tmp2.attr("ol_imgsrc"));
        tmp.attr("alt", tmp2.attr("title"));
        tmp.attr("hid", tmp2.attr("hid"));
        tmp.attr("mid", tmp2.attr("id"));
        tmp.attr("lid", tmp2.attr("lid"));
    }
    return false;
}
function prevImg(obj) {
    var tmp = $jq("#ig_mainimage");
    var tmp2 = $jq("#" + tmp.attr("lid")).prev().find("div.middle");
    if (tmp2.size() > 0) {
        tmp.attr("src", tmp2.attr("ol_imgsrc"));
        tmp.attr("alt", tmp2.attr("title"));
        tmp.attr("hid", tmp2.attr("hid"));
        tmp.attr("mid", tmp2.attr("id"));
        tmp.attr("lid", tmp2.attr("lid"));
    }
    return false;
}
function nextLImg(obj) {
    var tmp = $jq("#ig_mainimage");
    var tmp2 = $jq("#" + tmp.attr("lid")).next().find("div.middle");
    if (tmp2.size() > 0) {
        tmp.attr("src", tmp2.attr("ol_imgsrc"));
        tmp.attr("alt", tmp2.attr("title"));
        tmp.attr("hid", tmp2.attr("hid"));
        tmp.attr("mid", tmp2.attr("id"));
        tmp.attr("lid", tmp2.attr("lid"));
        var tmp3 = $jq("#" + tmp.attr("hid")).attr("ol_imgsrc");
        tmp2 = $jq("#ig_hiresimage");
        tmp2.attr("src", tmp3);
    }
    return false;
}
function prevLImg(obj) {
    var tmp = $jq("#ig_mainimage");
    var tmp2 = $jq("#" + tmp.attr("lid")).prev().find("div.middle");
    if (tmp2.size() > 0) {
        tmp.attr("src", tmp2.attr("ol_imgsrc"));
        tmp.attr("alt", tmp2.attr("title"));
        tmp.attr("hid", tmp2.attr("hid"));
        tmp.attr("mid", tmp2.attr("id"));
        tmp.attr("lid", tmp2.attr("lid"));
        var tmp3 = $jq("#" + tmp.attr("hid")).attr("ol_imgsrc");
        tmp2 = $jq("#ig_hiresimage");
        tmp2.attr("src", tmp3);
    }
    return false;
}/*
function movingIGTN() {
    if (tndx != 0) {
        window.setTimeout("movingIGTN()", 20);
        var dx = Math.max(Math.min($jq("#igmc").position().left + 2 * tndx,0),(-tnwidth+5*94));
        $jq("#igmc").css("left",dx);
    }
}
*/
function moveIGTN(obj, dx) {
    tndx += dx;
    if (tndx >= 0) {
        var nitem = $jq("#igmc div.low").eq(tndx * 5);
        if (nitem.size() > 0) {
            $jq("#igmc").animate({ left: String(-nitem.position().left) + "px" }, "normal");
        } else
            tndx -= dx;
    } else
        tndx = 0;
    return false;
//    window.setTimeout("movingIGTN()", 20);
}

function stopMoveIGTN(obj) {
    tndx = 0;
}
function showLImage(obj) {
    var tmp = $jq("#ig_hiresimage");
    var tmp2 = $jq("#ig_mainimage");
    tmp2 = $jq("#" + tmp2.attr("hid")).attr("ol_imgsrc");
    tmp.attr("src", tmp2);
    $jq("div.hiresimage").fadeIn("slow");
//    $jq("#op2").css("z-index", "10000");
    $jq("#op1").fadeTo("slow", 0.9, function() { $jq("#op2").css("z-index", "10000") });
    return false;
}
function closeLImage(obj) {
    $jq("#op1").fadeTo("slow", 0.01, function() { $jq("#op2").css("z-index", "-1") });
    $jq("div.hiresimage").fadeOut("slow");
    return false;
}
function showMImage(obj, mid, hid,lid) {
    tmp = $jq("#ig_mainimage");
    tmp.attr("src", $jq("#"+mid).attr("ol_imgsrc"));
    tmp.attr("alt", $jq("#"+mid).attr("title"));
    tmp.attr("hid", hid);
    tmp.attr("mid", mid);
    tmp.attr("lid", lid);
    return false;
}
// Image Gallery End
// MM List
function navigateGL(obj, p) {
    var d = obj.id.split("-");
    var aobj = obj;
    obj = obj.parentNode.parentNode.parentNode; //div.gallerylist
    var currp;
    if (typeof (obj.currp) == "undefined") {
        currp = 1;
        obj.currp = 1;
    } else
        currp = obj.currp;
    if (p == "prev") {
        if (currp > 1) {
            currp--;
        }
    } else if (p == "next") {
        if (currp < parseInt(d[3])) {
            currp++;
        }
    } else {
        currp = parseInt(parseInt(d[2]));
    }
    if (obj.currp != currp) {
        activateListGroup(obj, currp);
        $jq(aobj).siblings().attr("class", "");
        aobj.className = "active"
    }
    obj.currp = currp;
    return false;
}
function activateListGroup(obj, currp) {
    $jq(obj).find("div.item").each(function(i) {
        if ((i < (currp - 1) * 4) || (i >= currp * 4))
            $jq(this).hide();
        else
            $jq(this).show();
    })
}
// End MM List