var src_obj=0;
var ret_val=2;

function print_window() {
    var ifs=window.frames;
    var cw=window;
    for(var i=0;i<ifs.length;i++) {
        if( (ifs[i].location.href.indexOf("forum/")>-1) ||(ifs[i].location.href.indexOf("beitrag/")>-1) ) {
            cw=ifs[i];
            break;
        }
    }
    cw.focus();
    cw.print();
    window.focus();
}

var spis=new Array();

function init() {
    aktmenu=0;
    var i;
    var j=0;
    if(li1) {
        if(document.images["l_head"])
            document.images["l_head"].src=li1.src;
        if(document.images["l_right1"] && li2) {
            document.images["l_right1"].src=li2.src;
        }
        if(document.images["l_right2"]&&li3) {
            document.images["l_right2"].src=li3.src;
            if(li3.src.indexOf("/partner.gif")>-1) {
                document.images["l_right2"].useMap="#partner";
            }
        }
    }else
        setTimeout("init_l()",400);
    initmenu("navi",".");
    initpos(m1[aktmenu]);
    if(document.getElementById(unescape(akt_menu).split(".")[0]) && document.getElementById(unescape(akt_menu).split(".")[0]).active) {
        document.getElementById(unescape(akt_menu).split(".")[0]).active();
    }
    document.getElementById("navigation_pos").style.visibility="visible";
    try{
        if( (window.location.href.indexOf("preview")>-1) || (window.location.href.indexOf("portal/portal")>-1) )
            init_vdr();
    }catch(e) {
        if(window.location.href.indexOf("preview")>-1)
            if(e.message)
                alert(e.message);
            else
                alert(e);
    }
    var sps=document.getElementsByTagName("span");
    for(i=0,j=0;i<sps.length;i++)
    {
        if(sps[i].id && sps[i].id.indexOf("span_")==0)
        {
            var ci=document.getElementById(sps[i].id.replace("span_",""));
            if(ci)
            {
                spis[j]=new Array(sps[i],ci);
                sps[i].innerHTML=ci.value;
                j++;
            }
        }
    }
    if(spis.length>0)
    {
        window.setTimeout("spsi_f()",50);
    }
}

function spsi_f()
{
    var i;
    for(i=0;i<spis.length;i++)
    {
        spis[i][1].value=getInnerText(spis[i][0]).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
    }
    window.setTimeout("spsi_f()",50);
}

function getInnerText(node)
{
//    if(node.innerText)
//        return node.innerText;
    var res="";
    var j;
    var cns=node.childNodes;
    for(j=0;j<cns.length;j++)
    {
        if(cns[j].nodeName=="#text")
        {
            res+=cns[j].nodeValue;
        }else
        {
            res+=getInnerText(cns[j]);
        }
    }
    return res;
}

function init_l() {
    if(document.images["l_head"]&&li1)
        document.images["l_head"].src=li1.src;
    if(document.images["l_right1"]&&li2) {
        document.images["l_right1"].src=li2.src;
    }
    if(document.images["l_right2"] && li3) {
        document.images["l_right2"].src=li3.src;
        if(li3.src.indexOf("/partner.gif")>-1)
            document.images["l_right2"].useMap="#partner";
    }
}

function init_n() {
    var i;
    var n=document.getElementById("menu");
    var divs=n.getElementsByTagName("div");
    for(i=0;i<divs.length-1;i++) {
        var l1=parseInt(divs[i].className.replace(/l/,""));
        var l2=parseInt(divs[i+1].className.replace(/l/,""));
        if(l1>=l2) {
            divs[i].getElementsByTagName("img")[0].src=divs[i].getElementsByTagName("img")[0].src.replace(/_c/,"");
        }
        if(divs[0].className!="l1" && divs[i].className==divs[0].className) {
            divs[i].style.display="block";
        }
    }
    if(divs.length!=0) {
        divs[i].getElementsByTagName("img")[0].src=divs[i].getElementsByTagName("img")[0].src.replace(/_c/,"");
    }
}

function go_l(hr,target) {
    try{
        if(timer) {
            window.clearInterval(timer);
            timer=0;
        }
    }catch(e){}
    if(src_obj!=0)
        target=src_obj.target;
    if(!target)
        target="";
    switch(target) {
        case "":
            window.location.href=hr;
            break;
        case "_self":
            window.location.href=hr;
            break;
        case "_top":
            top.location.href=hr;
            break;
        case "_parent":
            parent.location.href=hr;
            break;
        default:
            window.open(hr,src_obj.target);
            break;
    }
}

function go(cid,nid,lang,pl,target) {
    try{
        if(timer) {
            window.clearInterval(timer);
            timer=0;
        }
    }catch(e){}
    
    if(src_obj!=0)
        target=src_obj.target;
    if(!target)
        target="";
    try{
        if(!akt_menu)
            akt_menu="";
    }catch(e){
        window.akt_menu="";
    }
    if(!pl || pl=="") {
        pl=akt_menu;
    }
    //	else
    //		pl=escape(pl).replace(/%C3%83%C2%BC/g,"&uuml;").replace(/%C3%83%C2%9C/g,"&Uuml;").replace(/%C3%83%C2%A4/g,"&auml;");
    
    pl=pl.replace(/[&]/g,"%26");
    pl=escape(unescape(pl));
    if(window.location.href.indexOf("content_popup")>-1) {
        //	pl=escape(unescape(pl));
        switch(target) {
            case "":
            case "_self":
                hr=window.location.pathname.replace(/\/cms.*/,"/portal");
                hr=hr.replace(/\/forum.*/,"/portal").replace(/\/user.*/,"/portal").replace(/\/tools.*/,"/portal");
                window.location.href=hr+"?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+pl;
                break;
            case "_top":
            case "_parent":
                hr=top.location.pathname.replace(/\/cms.*/,"/portal");
                hr=hr.replace(/\/forum.*/,"/portal").replace(/\/user.*/,"/portal").replace(/\/tools.*/,"/portal");
                top.location.href=hr+"?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+pl;
                break;
            default:
                if(pl!="")
                    window.open(cpath+"/portal/portal?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+pl,src_obj.target);
                else
                    window.open(cpath+"/portal/portal?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+akt_menu,src_obj.target);
                break;
        }
    }else {
        if(window.location.href.indexOf("prev")>-1) {
            window.location.href=window.location.pathname+"?cid="+cid+"&nid="+nid+"&lang="+lang;
        }else {
            //				if(window.location.href.indexOf("forum")>-1)
            //				{
            //					window.location.href="../portal?cid="+cid+"&nid="+nid+"&lang="+lang+(pl && pl!=""?("&am="+pl):"");
            //				}else
            {
                var hr;
                //				pl=pl.replace(/%C3%B6/g,"ö").replace(/%C3%A4/g,"ä").replace(/%C3%BC/g,"ü").replace(/%C3%9C/g,"Ü").replace(/%C3%96/,"Ö").replace(/%C3%84/,"Ä").replace(/%C3%9F/g,"ß");
                switch(target) {
                    case "":
                    case "_self":
                        hr=window.location.pathname.replace(/\/cms.*/,"/portal");
                        hr=hr.replace(/\/forum.*/,"/portal").replace(/\/user.*/,"/portal").replace(/\/tools.*/,"/portal");
                        //						if(hr.indexOf("/portal")>-1 || hr.indexOf("/p_")>-1)
                        //							hr=hr+"/../p_"+unescape(pl).replace(/ü/g,"ue").replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/Ü/g,"Ue").replace(/Ä/g,"Ae").replace(/Ö/g,"Oe").replace(/€/g,"EURO").replace(/ß/g,"ss").replace(/%/g,"_PROZENT_").replace(/\W/g,"_");
                        hr=hr+"?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+pl;
                        window.location.href=hr;
                        break;
                    case "_top":
                    case "_parent":
                        hr=window.location.pathname.replace(/\/cms.*/,"/portal").replace(/\/forum.*/,"/portal").replace(/\/user.*/,"/portal").replace(/\/tools.*/,"/portal");
                        //						if(hr.indexOf("/portal")>-1 || hr.indexOf("/p_")>-1)
                        //							hr=hr+"/../p_"+unescape(pl).replace(/ü/g,"ue").replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/Ü/g,"Ue").replace(/Ä/g,"Ae").replace(/Ö/g,"Oe").replace(/€/g,"EURO").replace(/ß/g,"ss").replace(/%/g,"_PROZENT_").replace(/\W/g,"_");
                        top.location.href=hr+"?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+pl;
                        break;
                        //					case "_parent":
                        //						if(pl!="")
                        //								parent.location.href=window.location.pathname.replace(/\/cms.*/,"/portal").replace(/\/forum.*/,"/portal").replace(/\/user.*/,"/portal").replace(/\/tools.*/,"/portal")+"?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+pl;
                        //						else
                        //								parent.location.href=window.location.pathname.replace(/\/cms.*/,"/portal").replace(/\/forum.*/,"/portal").replace(/\/user.*/,"/portal").replace(/\/tools.*/,"/portal")+"?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+akt_menu;
                        //						break;
                    default:
                        if(pl!="")
                            window.open(cpath+"/portal/portal?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+pl,src_obj.target);
                        else
                            window.open(cpath+"/portal/portal?cid="+cid+"&nid="+nid+"&lang="+lang+"&am="+akt_menu,src_obj.target);
                        break;
                }
            }
        }
    }
    src_obj=0;
    switch(ret_val) {
        case 0:
            ret_val=2;
            return false;
        case 1:
            ret_val=2;
            return true;
    }
}

function showcontent(o,n,cp) {
    if(n=="")
        popup(cp+"/portal/cms/contentbynamepopup?pl="+o.name,500,500,"content");
    else
        popup(cp+"/portal/cms/contentbynamepopup?pl="+n,500,500,"content");
    return false;
}

function search(field) {
    var q;
    if(field)
        q=document.getElementById(field);
    if(!q)
        q=document.getElementById("search");
    if(q) {
        q=q.value;
        if(q!="")
            window.location.href=window.location.pathname.replace(/\/cms/,"/portal").replace(/\/obj.*/,"")+"?query=\""+(q)+"\"";
        //            window.location.href=window.location.pathname.replace(/\/cms/,"/portal").replace(/\/obj.*/,"")+"?pageLabel=" + akt_menu + "&query="+q;
    }
}

function search_adv() {
    var q="";
    var qf=document.getElementById("all_search");
    if(qf && qf.value!="") {
        q=" AND "+qf.value.replace(/[' ']+/g," AND ");
        //        q="&all_search="+qf.value;
    }
    qf=document.getElementById("or_search");
    if(qf && qf.value!="") {
        q=q+" AND ("+qf.value + ")";
        //			q=q+"&or_search="+qf.value;
    }
    qf=document.getElementById("exact_search");
    if(qf && qf.value!="") {
        q=q+" AND \""+qf.value+"\"";
        //		q=q+"&exact_search="+qf.value;
    }
    qf=document.getElementById("not_search");
    if(qf && qf.value!="") {
        if(q=="")
            alert("Bitte geben Sie auch einen Begriff ein, der in der Suche enthalten sein soll!")
        else
            q=q+" NOT "+qf.value.replace(/[' ']+/g," NOT ");
        //			q=q+"&not_search="+qf.value;
    }
    if(q!="")
        window.location.href=window.location.pathname.replace(/\/cms/,"/portal").replace(/\/obj.*/,"").replace(/\/forum.*/,"").replace(/\/user.*/,"").replace(/\/tools.*/,"")+"?query="+q;
    //		window.location.href=window.location.pathname.replace(/\/cms/,"/portal").replace(/\/obj.*/,"").replace(/\/forum.*/,"").replace(/\/user.*/,"").replace(/\/tools.*/,"")+"?query="+escape(q);
}

function reg(cid,fid) {
}

function contact() {
}

function help() {
}

function imprint() {
}

function faq() {
}

function sitemap(p) {
    popup(p,800,600,"Sitemap");
    return false;
}

function forms_onsubmit() {
    if(!document.forms[0].nid)
        return true;
    return true;
}

function preload(image_src) {
    var temp=new Image();
    temp.src=image_src;
    return temp;
}

function makePageCoords(win,fr) {
    if(!win) win=window
    this.x=win.innerWidth?win.innerWidth:win.document.body.offsetWidth;
    this.y=win.innerHeight?win.innerHeight:win.document.body.offsetHeight;
    return this;
}

function popup(PopURL,x,y,wname) {
    var pg=new makePageCoords();
    var fens=window.open(PopURL,wname,'directories=no,location=no,menubar=no,resizable=no,status=no,scrollbars=yes,toolbar=no,width='+x+',height='+y);
    fens.focus();
}

function popup2(PopURL,x,y,wname) {
    var fens=window.open(PopURL,wname,'directories=no,location=no,menubar=no,resizable=yes,status=no,scrollbars=yes,toolbar=no,width='+x+',height='+y);
    fens.focus();
}

function popup_return(PopURL,x,y,wname) {
    var fens=window.open(PopURL,wname,'directories=no,location=no,menubar=no,resizable=yes,status=no,scrollbars=yes,toolbar=no,width='+x+',height='+y);
    fens.focus();
    return fens;
}

function gosb(o,targets) {
    if(o.options.selectedIndex==0)
        return;
    var t=targets.split(",");
    var target="";
    if(o.options.selectedIndex>t.length)
        target=t[0];
    else
        target=t[o.options.selectedIndex-1];
    if(target=="_blank") {
        window.open(o.options[o.options.selectedIndex].value,"_blank","location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes");
        return;
    }
    window.location.href=o.options[o.options.selectedIndex].value;
}

function switch_l(nl) {
    var c="language="+nl+"; path=/;";
    document.cookie=c;
    // window.location.href="";
}

function golink(o,t,link) {
    window.open(link+"?open&lb="+o.options[o.options.selectedIndex].value,"_blank",'directories=no,location=no,menubar=no,resizable=no,status=no,scrollbars=yes,toolbar=no,width=800,height=600');
}
function sort(o) {
    if(o.options.selectedIndex>0) {
        var h=window.location.href;
        if(h.indexOf('sort')>-1) {
            h=h.replace(/sort=[^&]+/,'sort='+o.options[o.options.selectedIndex].value);
            window.location.href=h;
        }else {
            window.location.href+=('&sort='+o.options[o.options.selectedIndex].value)
        }
    }
}
function checkdelete(url,target) {
    ok=confirm("Sind Sie sicher, dass Sie LOESCHEN moechten?");
    if(ok){
        if(!target)
            popup(url,300,300,'cd');
        else
            window.location.href=url;
    }
}

function navi_select(nid,cid,lang,ntitle,ctitle,pl) {
    if(top.opener.select) {
        top.opener.select("cms/content_popup?cid="+cid);
        top.close();
    }
    else {
        if(top.opener.nid)
            top.opener.nid.value=nid;
        if(top.opener.cid)
            top.opener.cid.value=cid;
        if(top.opener.lang)
            top.opener.lang.value=lang;
        if(top.opener.ntitle)
            top.opener.ntitle.value=ntitle;
        if(top.opener.ctitle)
            top.opener.ctitle.value=ctitle;
        if(top.opener.select_page)
            top.opener.select_page(nid,cid,lang,ntitle,ctitle,pl,window);
    }
}
function overtab(o) {
    o.firstChild.style.visibility="visible";
    o.style.borderBottomWidth="3px";
    o.style.paddingBottom="2px";
}

function outtab(o) {
    o.firstChild.style.visibility="hidden";
    o.style.borderBottomWidth="1px";
    o.style.paddingBottom="4px";
}

function init_iframe(){
    var i;
    var ifs=parent.frames;
    var ifo=parent.document.getElementsByTagName("iframe");
    if(ifs&&ifo.length>0) {
        for(i=0;i<ifs.length;i++) {
            try{
                if(window.location.href==ifs[i].location.href)
                    //   if(ifs[i].name==window.name)
                {
                    if(document.getElementById("mainif"))
                        ifo[i].style.height=(document.getElementById("mainif").offsetHeight)+"px";
                }
            }catch(e){}
        }
    }
}
