var menu;
var submenu;
if(!window.billy)window.billy={};
aoe.core.browser.registerRefreshFunction("menu", function(uri,params,refresh){
    var pmenu=null;
    var psubmenu=null;
    var ponload=null;
    if(uri){
        var arr=uri.split("/");
        if(arr[0]){
            pmenu=arr[0];
            switch(pmenu){
                case "newsletter":
                    pmenu="";
                    arr[1]=false;
                    aoe.core.browser.setAnchorUri('home');
                    break;
            }
            if(pmenu && arr[1]){
                psubmenu=decodeURIComponent(arr[1]);
                if(psubmenu || arr[2]){
                    var reg=new RegExp("(\\d+)( - (.*))?");
                    var str=psubmenu;
                    if(/^[A-Za-z0-9_]+$/.test(str)&&arr[2]){
                        str=decodeURIComponent(arr[2]);
                    }
                    if(reg.test(str)||Number(str)==str){
                        var id=null;
                        if(reg.test(str)){
                            var r=reg.exec(str);
                            if(r[1]){
                                id=r[1];
                            }
                        }else {
                            id=str;
                        }
                        if(id!=null){
                            switch(pmenu){
                                case "fotostory":
                                    psubmenu="read";
                                    if(!params){params={};}
                                    params[BILLY_PATH+":fotostory:story_id"]=id;
                                    params["action:"+BILLY_PATH+":fotostory:show_story"]=1;
                                    break;
                            }
                        }
                    }
                    if(id==psubmenu)psubmenu="";
                }
            }
            if(pmenu){
                switch(pmenu){
                    case "news":
                        if(psubmenu=="older"){
                            if(!params){params={};}
                            params["action:billy:news:show_older"]=1;
                            psubmenu="";
                        }
                        break;
                }
            }
        }
    }
    if(pmenu && !psubmenu){
        switch(pmenu){
            case "fotostory":
                psubmenu="read";
                break;
            case "band":
                psubmenu="band";
                break;
            case "events":
                psubmenu="future";
                break;
        }
    }
    if(refresh){
        aoe.core.browser.setCookie("js_refresh", 1,false,'/');
        openContent(uri,params,pmenu,psubmenu,ponload);
        if(pmenu){
            var sub=aoe.util.getTN("ul",aoe.util.getID("billy_menu_"+pmenu+"_selected").parentNode,0);
            if(sub && sub.clientHeight==0){sub.style.height="20px";}
        }
    }else {
        if(pmenu){
            menu=pmenu;
            if(psubmenu){
                submenu=psubmenu;
            }
        }
    }
},aoe.core.browser.REFRESH_PRIORITY_HIGH);

function closeMenu(){
    if(menu){
        aoe.util.getID("billy_menu_"+menu+"_selected").id="billy_menu_"+menu;
        aoe.util.getID("billy_content_menu_"+menu).style.display="none";
    }
    if(menu && submenu){
        aoe.util.getID("billy_submenu_"+menu+"_"+submenu+"_selected").id="billy_submenu_"+menu+"_"+submenu;
        aoe.util.getID("billy_submenu_"+menu+"_"+submenu).parentNode.className="billy_submenu_item";
       aoe.util.getID("billy_content_submenu_"+menu+"_"+submenu).style.display="none";
    }
    menu="";
    submenu="";
}
function openLink(link){
    window.open(link.href, ((link.title!="")?link.title:link.href).replace(/(\W)/g,'_')).focus();
    return false;
}
var billy_titles={};
function openContent(uri,params,pmenu,psubmenu,ponload,pcache){
    aoe.util.getID("billy_content_other").style.display="none";
    if(menu){
        aoe.util.getID("billy_menu_"+menu+"_selected").id="billy_menu_"+menu;
        if(aoe.core.browser.isIE()){
            aoe.util.getID("billy_content_menu_"+menu).style.display="none";
        }else {
            aoe.util.getID("billy_content_menu_"+menu).style.visibility="hidden";
            aoe.util.getID("billy_content_menu_"+menu).style.height="0";
            aoe.util.getID("billy_content_menu_"+menu).style.width="0";
            aoe.util.getID("billy_content_menu_"+menu).style.overflow="hidden";
        }
    }
    if(menu && submenu){
        aoe.util.getID("billy_submenu_"+menu+"_"+submenu+"_selected").id="billy_submenu_"+menu+"_"+submenu;
        aoe.util.getID("billy_submenu_"+menu+"_"+submenu).parentNode.className="billy_submenu_item";
       if(aoe.core.browser.isIE()){
           aoe.util.getID("billy_content_submenu_"+menu+"_"+submenu).style.display="none";
       }else {
        aoe.util.getID("billy_content_submenu_"+menu+"_"+submenu).style.visibility="hidden";
        aoe.util.getID("billy_content_submenu_"+menu+"_"+submenu).style.height="0";
        aoe.util.getID("billy_content_submenu_"+menu+"_"+submenu).style.width="0";
        aoe.util.getID("billy_content_submenu_"+menu+"_"+submenu).style.overflow="hidden";
       }
       if(aoe.util.getID("billy_menu_"+menu).parentNode.onmouseout){
           aoe.util.getID("billy_menu_"+menu).parentNode.onmouseout(-1);
       }
    }
    if(menu){
        if(submenu){
            if(!billy_titles[menu]){
                billy_titles[menu]={};
            }
            billy_titles[menu][submenu]=document.title;
        }else {
            billy_titles[menu]=document.title;
        }
    }
    if(pmenu){
        aoe.util.getID("billy_menu_"+pmenu).id="billy_menu_"+pmenu+"_selected";
        if(aoe.util.getID("billy_content_menu_"+pmenu).style.display!="block")aoe.util.getID("billy_content_menu_"+pmenu).style.display="block";
        aoe.util.getID("billy_content_menu_"+pmenu).style.visibility="visible";
        aoe.util.getID("billy_content_menu_"+pmenu).style.height="";
        aoe.util.getID("billy_content_menu_"+pmenu).style.width="";
        menu=pmenu;
    }else {
        menu="";
    }
    if(pmenu && psubmenu){
        if(aoe.util.getID("billy_submenu_"+pmenu+"_"+psubmenu))aoe.util.getID("billy_submenu_"+pmenu+"_"+psubmenu).id="billy_submenu_"+pmenu+"_"+psubmenu+"_selected";
        aoe.util.getID("billy_submenu_"+pmenu+"_"+psubmenu+"_selected").parentNode.className="billy_submenu_item_selected";
        if(aoe.util.getID("billy_content_submenu_"+pmenu+"_"+psubmenu).style.display!="block")aoe.util.getID("billy_content_submenu_"+pmenu+"_"+psubmenu).style.display="block";
        aoe.util.getID("billy_content_submenu_"+pmenu+"_"+psubmenu).style.visibility="visible";
        aoe.util.getID("billy_content_submenu_"+pmenu+"_"+psubmenu).style.height="";
        aoe.util.getID("billy_content_submenu_"+pmenu+"_"+psubmenu).style.width="";
        submenu=psubmenu;
        if(aoe.util.getID("billy_menu_"+menu+"_selected").parentNode.onmouseover){
            var x=aoe.util.getID("billy_menu_"+menu+"_selected").parentNode;
            x.onmouseover();
            window.setTimeout(function(){x.onmouseout();},1000);
        }
    }else {
        submenu="";
    }
    if(uri){
        uri=aoe.util.removeDomain(uri);
    }else if(pmenu){
        uri=pmenu;
        if(psubmenu){
            uri+="/"+psubmenu;
        }
    }
    if(uri){
        aoe.core.browser.setAnchorUri(uri);
    }
    var cn="standard";
    var scn="";
    switch(menu){
        case "home":
            cn="extended";
            break;
         case "fotostory":
             if(submenu=="create"){cn="extended";scn="extended";}
             break;
    }
    aoe.util.getID("billy_content").className="billy_content_"+cn;
    if(scn=="extended"){
        if(aoe.util.getID("billy_sidebar")){
            aoe.util.getID("billy_sidebar").id="billy_sidebar_extended";
        }
    }else {
        if(aoe.util.getID("billy_sidebar_extended")){
            aoe.util.getID("billy_sidebar_extended").id="billy_sidebar";
        }
    }
    if(menu){
        var id="billy_content_"+((menu&&submenu)?'submenu':'menu')+"_"+menu+((submenu)?"_"+submenu:"");
    }else {
        id="billy_content_other";
        pcache=false;
    }
    if(!pcache || aoe.util.getID(id).innerHTML.trim()==""){
        var cl=new ContentLoader(ContentLoader.REPLACE,aoe.util.getID(id));
        var pl=(ponload)?ponload:function(){};
        cl.load(params,pl,uri);
    }else {
        aoe.core.browser.locationHashListener.changed=true;
        if(menu){
            if(submenu && billy_titles[menu][submenu]){
                document.title=billy_titles[menu][submenu];
            }else if(!submenu&&billy_titles[menu]){
                document.title=billy_titles[menu];
            }
        }
    }
    return false;
}
function checkFotostoryJS(){
    aoe.util.getID("story_obj").SetVariable("_root.jsEnabled",1);
}
function getBillyPath(){
    return aoe.getFE("billy_path").value;
}
function openTab(id){
    if(aoe.util.getID('billy_songbook_tab_'+id).innerHTML==""&&aoe.util.getID('billy_songbook_tab_'+id).style.display=='none'){
    var uri="/songbook/"+id;
    aoe.util.getID('billy_songbook_tab_'+id).style.display='block';
        aoe.util.getID('billy_songbook_song_'+id).className="billy_songbook_song_open_selected";
    var cl=new ContentLoader(ContentLoader.REPLACE,aoe.util.getID('billy_songbook_tab_'+id));
    cl.load(null,function(){},uri);
    }else if(aoe.util.getID('billy_songbook_tab_'+id).style.display=='none'){
        aoe.util.getID('billy_songbook_tab_'+id).style.display='block';
        aoe.util.getID('billy_songbook_song_'+id).className="billy_songbook_song_open_selected";
    }else {
        aoe.util.getID('billy_songbook_tab_'+id).style.display='none';
        aoe.util.getID('billy_songbook_song_'+id).className="billy_songbook_song_open";
    }
    return false;
}
function showOlderNews(){
    var params=new Object();
    params["action:"+BILLY_PATH+":menu"]=1;
    params[BILLY_PATH+":menu"]="news";
    params["action:"+BILLY_PATH+":news:show_older"]=1;
    var cl=new ContentLoader(ContentLoader.REPLACE,aoe.util.getID("older_news"));
    cl.load(params);
    return false;
}
function showEventsDescription(id){
    var el1=aoe.util.getID("billy_events_entry_description_"+id);
    if(el1.style.display=='none'){
        el1.style.display='block';
        aoe.util.getID("billy_events_entry_link_"+id).innerHTML='weniger...';
    }else{
        el1.style.display='none';
        aoe.util.getID("billy_events_entry_link_"+id).innerHTML='mehr...';
    }
    return false;
}

function registerNewsletter(){
    var p={};
    p['action:'+BILLY_PATH+":newsletter:register"]=1;
    p["action:"+BILLY_PATH+":menu"]=1;
    p[BILLY_PATH+":menu"]="newsletter";
    p[BILLY_PATH+":newsletter:mail"]=encodeURIComponent(aoe.util.getFE(BILLY_PATH+':newsletter:mail').value.trim());
    p[BILLY_PATH+":newsletter:name"]=encodeURIComponent(aoe.util.getFE(BILLY_PATH+':newsletter:name').value.trim());
    p[BILLY_PATH+":newsletter:captcha[value]"]=aoe.util.getFE(BILLY_PATH+":newsletter:captcha[value]").value;
    p[BILLY_PATH+":newsletter:captcha[id]"]=aoe.util.getFE(BILLY_PATH+":newsletter:captcha[id]").value;
    var err=false;
    if(p[BILLY_PATH+":newsletter:name"]==''||p[BILLY_PATH+":newsletter:name"]=='Name'){
        err=true;
        aoe.util.getFE(BILLY_PATH+':newsletter:name').className='input input_text input_text_error';
    }
    if(p[BILLY_PATH+":newsletter:mail"]==""||p[BILLY_PATH+":newsletter:mail"]=="Emailadresse"||!aoe.util.checkMail(p[BILLY_PATH+":newsletter:mail"])){
        err=true;
        aoe.util.getFE(BILLY_PATH+':newsletter:mail').className='input input_text input_text_error';
    }
    if(!err){
        //var cl=new ContentLoader(ContentLoader.REPLACE,aoe.util.getID('billy_newsletter_abo'));
        aoe.util.getID('billy_newsletter_abo').innerHTML='';
        aoe.util.getID('billy_newsletter_abo_loader').className='billy_newsletter_abo_loader_visible';
        Request.get(p, function(c){
            aoe.util.getID('billy_newsletter_abo').innerHTML=c;
            aoe.util.getID('billy_newsletter_abo_loader').className="billy_newsletter_abo_loader_hidden";
        }, '/newsletter/register');
        
    }
    return false;
}

function confirmNewsletter(){
    var p={};
    p['action:'+BILLY_PATH+":newsletter:confirm"]=1;
    p["action:"+BILLY_PATH+":menu"]=1;
    p[BILLY_PATH+":menu"]="newsletter";
    p[BILLY_PATH+":newsletter:mail"]=encodeURIComponent(aoe.util.getFE(BILLY_PATH+':newsletter:mail').value.trim());
    p[BILLY_PATH+":newsletter:confirm_key"]=encodeURIComponent(aoe.util.getFE(BILLY_PATH+':newsletter:confirm_key').value.trim());
    p[BILLY_PATH+":newsletter:captcha[value]"]=aoe.util.getFE(BILLY_PATH+":newsletter:captcha[value]").value;
    p[BILLY_PATH+":newsletter:captcha[id]"]=aoe.util.getFE(BILLY_PATH+":newsletter:captcha[id]").value;
    var err=false;
    if(p[BILLY_PATH+":newsletter:confirm_key"]==''||p[BILLY_PATH+":newsletter:confirm_key"]==encodeURIComponent('Bestätigungscode')){
        err=true;
        aoe.util.getFE(BILLY_PATH+':newsletter:confirm_key').className='input input_text input_text_error';
    }
    if(p[BILLY_PATH+":newsletter:mail"]==""||p[BILLY_PATH+":newsletter:mail"]=="Emailadresse"||!aoe.util.checkMail(p[BILLY_PATH+":newsletter:mail"])){
        err=true;
        aoe.util.getFE(BILLY_PATH+':newsletter:mail').className='input input_text input_text_error';
    }
    if(!err){
        var cl=new ContentLoader(ContentLoader.REPLACE,aoe.util.getID('billy_newsletter_abo'));
        cl.load(p,function(){});
    }
    return false;
}

function openNewsletterConfirm(){
    var p={};
    p['action:'+BILLY_PATH+":newsletter:confirm"]=1;
    p["action:"+BILLY_PATH+":menu"]=1;
    p[BILLY_PATH+":menu"]="newsletter";
   var cl=new ContentLoader(ContentLoader.REPLACE,aoe.util.getID('billy_newsletter_abo'));
   cl.load(p,function(){});
   return false;
}
function cancelNewsletterConfirm(){
    var p={};
    p["action:"+BILLY_PATH+":menu"]=1;
    p[BILLY_PATH+":menu"]="newsletter";
   var cl=new ContentLoader(ContentLoader.REPLACE,aoe.util.getID('billy_newsletter_abo'));
   cl.load(p,function(){});
   return false;
}
var gallery_album=null;
function getGalleryPicSize(){
   var mw=800;
   var mh=600;
   var s={w:mw,h:mh}
   var w=gallery_album.pics[gallery_album.current][2];
   var h=gallery_album.pics[gallery_album.current][3];
   if(w>h){
       s.h=h*(mw/w);
   }else if(w<h){
       s.w=w*(mh/h);
   }else {
       s.w=mh;
   }
   return s;
}
function openGalleryPic(i){
   gallery_album.current=i;
   var album=gallery_album.id;
   var ext=gallery_album.pics[i][1];
   var pic=gallery_album.pics[i][0];
   var div =aoe.util.cE('div');
   var s=getGalleryPicSize();
   div.className="billy_overlay_1";
   var h = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
   var w = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
   var p=aoe.util.getPos(aoe.util.getID("billy_content"));
   if(h<p.h+117+70+113){
       div.style.height=(p.h+117+70+113)+"px";
   }
   var spos="";
   if(aoe.core.browser.isIE(6,"<=")){
       spos="position:absolute;";
   }
   div.id="billy_gallery_pic";
   div.innerHTML="<div style=\""+spos+"top:0;left:"+((w/2)-(s.w/2))+"px;\" id=\"billy_gallery_pic_content\">"+
    "<table id=\"billy_gallery_pic_content_table\" style=\"empty-cells: show; border-spacing:0;border-collapse:collapse\"><tr><td colspan=\"3\" style=\"border-radius: 10px 0 0 0;height:18px;background-image:url('/icon/gallery_pic_border_t.png');background-repeat:repeat-x;\">&#32;</td></tr><tr><td style=\"width:18px;background-image:url('/icon/gallery_pic_border_l.png');background-repeat:repeat-y;\">&#32;</td><td style=\"width:"+s.w+"px;height:"+s.h+"px;\">"+
    "<a onfocus=\"if(this.blur)this.blur()\" onmouseover=\"aoe.util.getID('billy_gallery_pic_left_img').src='/icon/pfeil_links2.png'\" onmouseout=\"aoe.util.getID('billy_gallery_pic_left_img').src='/icon/pfeil_links.png'\" title=\"Zurück\" style=\"top:"+s.h+"px\" id=\"billy_gallery_pic_link_left\" class=\"billy_gallery_pic_link billy_gallery_pic_link_left\" href=\"javascript:prevGalleryPic();\">"+
    "<img id=\"billy_gallery_pic_left_img\" style=\"\" src=\"/icon/pfeil_links.png\" alt=\"Zurück\" />"+
    "</a>"+
    "<img onload=\"if(!this.__loaded)showGalleryPic();this.__loaded=true;\" style=\"visibility:hidden;width:"+s.w+"px;height:"+s.h+"px\" id=\"billy_gallery_pic_img\" src=\"/fotos/"+album+"/"+pic+"."+ext+"\" alt=\"\" />"+
    "<a onfocus=\"if(this.blur)this.blur()\" onmouseover=\"aoe.util.getID('billy_gallery_pic_right_img').src='/icon/pfeil_rechts2.png'\" onmouseout=\"aoe.util.getID('billy_gallery_pic_right_img').src='/icon/pfeil_rechts.png'\" title=\"Vor\" style=\"\" id=\"billy_gallery_pic_link_right\" class=\"billy_gallery_pic_link billy_gallery_pic_link_right\" href=\"javascript:nextGalleryPic();\">"+
    "<img id=\"billy_gallery_pic_right_img\" style=\"\" src=\"/icon/pfeil_rechts.png\" alt=\"Vor\" />"+
    "</a><div id=\"billy_gallery_close\" class=\"billy_gallery_close\" style=\"top:-"+(s.h+17)+"px;left:"+(s.w-18)+"px;height:34px;width:36px;\">"+
    "<a href=\"javascript:closeGalleryPic();\" id=\"billy_galley_close\" title=\"Schließen\"><img src=\"/icon/kreuz.png\" alt=\"Schließen\" /></a>"+
    "<img id=\"billy_gallery_loader\" src=\"/icon/loader_cicle.gif\" alt=\"\" style=\"position:relative;top:"+((s.h/2)-22)+"px;left:-"+((s.w/2)+32)+"px;\"/></div>"+
    "</td><td style=\"width:16px;background-image:url('/icon/gallery_pic_border_r.png');background-repeat:repeat-y;\">&#32;</td></tr><tr><td colspan=\"3\" style=\"border-radius: 0 0 10px 10px;height:16px;background-image:url('/icon/gallery_pic_border_b.png');background-repeat:repeat-x;\">&#32;</td></tr></table>"+
    "</div>";
   aoe.util.getID("billy_root").appendChild(div);
   return false;
}
function showGalleryPic(){
    if(aoe.util.getID("billy_gallery_pic_img_old")){
        aoe.util.getID("billy_gallery_pic_img_old").parentNode.removeChild(aoe.util.getID("billy_gallery_pic_img_old"));
    }
    updateGalleryPicSizes();
    var img=aoe.util.getID("billy_gallery_pic_img");
    img.style.visibility="visible";
    img.style.display="inline";
    aoe.util.getID("billy_gallery_loader").style.display="none";
}
function updateGalleryPicSizes(){
    var s=getGalleryPicSize();
    var content=aoe.util.getID("billy_gallery_pic_content");
    var t=aoe.util.getID("billy_gallery_pic_content_table");
    var close=aoe.util.getID("billy_gallery_close");
    var loader=aoe.util.getID("billy_gallery_loader");
    var left=aoe.util.getID("billy_gallery_pic_link_left");
    var right=aoe.util.getID("billy_gallery_pic_link_right");
    var w = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
    content.style.left=((w/2)-(s.w/2))+"px";
    close.style.left=(s.w-18)+"px";
    close.style.top="-"+(s.h+17)+"px";
    loader.style.top=((s.h/2)-22)+"px";
    loader.style.left="-"+((s.w/2)+32)+"px";
    left.style.top=s.h+"px";
    //right.style.top=s.h+"px";
    t.rows[1].childNodes[1].style.width=s.w+"px";
    t.rows[1].childNodes[1].style.height=s.h+"px";
    var p=aoe.util.getID("billy_gallery_pic_img");
     p.style.width=s.w+"px";
     p.style.height=s.h+"px";
}
function closeGalleryPic(){
    var d=aoe.util.getID("billy_gallery_pic");
    d.parentNode.removeChild(d);
}
function nextGalleryPic(){
 aoe.util.getID("billy_gallery_loader").style.display="inline";
 var p=aoe.util.getID("billy_gallery_pic_img");
 var p2=p.cloneNode(true);
 p2.__loaded=false;
 p.id+="_old";
 //p2.style.visibility="hidden";
 p2.style.display="none";
 p2.style.width="0";
 p2.style.height="0";
 if(gallery_album.current<gallery_album.pics.length-1){
    gallery_album.current++;
 }else {
    gallery_album.current=0;
 }
 p2.src="/fotos/"+gallery_album.id+"/"+gallery_album.pics[gallery_album.current][0]+"."+gallery_album.pics[gallery_album.current][1];
 p.parentNode.insertBefore(p2, p);
}
function prevGalleryPic(){
    aoe.util.getID("billy_gallery_loader").style.display="inline";
 var p=aoe.util.getID("billy_gallery_pic_img");
 var p2=p.cloneNode(true);
 p2.__loaded=false;
 p.id+="_old";
 //p2.style.visibility="hidden";
 p2.style.display="none";
 p2.style.width="0";
 p2.style.height="0";
    if(gallery_album.current>0){
         gallery_album.current--;
    }else {
        gallery_album.current=gallery_album.pics.length-1;
    }
         p2.src="/fotos/"+gallery_album.id+"/"+gallery_album.pics[gallery_album.current][0]+"."+gallery_album.pics[gallery_album.current][1];
 p.parentNode.insertBefore(p2, p);
}
function openLoveStoryCollection(y){
    if(aoe.util.getID('billy_fotostory_story_'+y).style.display!="block"){
        aoe.util.getID('billy_fotostory_story_'+y).style.display="block";
        aoe.util.getTN("span", aoe.util.getID('billy_fotostory_list_story_'+y), 0).className="billy_fotostory_list_open_span_selected";
    }else {
        aoe.util.getID('billy_fotostory_story_'+y).style.display="none";
        aoe.util.getTN("span", aoe.util.getID('billy_fotostory_list_story_'+y), 0).className="billy_fotostory_list_open_span";
    }
    return false;
}
var fotostory_story={};
function openLoveStory(id,p,title,col){
    if(!title)title="";
    if(!p){
        p=new Object();
    }
    p['billy:fotostory:collection_id']=col;
    p['action:billy:fotostory:show_story']=1;
    p[BILLY_PATH+':fotostory:story_id']=id;
    openContent('/fotostory/read/'+id+((title)?"%20-%20"+title:""),p,"fotostory","read");
   return false;
}
function nextStoryPic(id){
    var c=fotostory_story[id].count;
    var nr=fotostory_story[id].current;
    if(c>(nr+1)){
        nr++;
        fotostory_story[id].current=nr;
        aoe.util.getID('story_img_'+id).src='/dpu/fotostory/'+id+'/'+(nr+1)+'.png';
        aoe.util.getID('story_img_prev_link_'+id).href='/fotostory/'+id+'/'+(nr);
        aoe.util.getID('story_img_next_link_'+id).href='/fotostory/'+id+'/'+(nr+2);
        if(c<=(nr+1)){
            aoe.util.getID('story_img_next_'+id).src='/icon/rechts_deakt.png';
            aoe.util.getID('story_img_next_link_'+id).href='/fotostory/'+id+'/'+c;
        }
        if(nr>0){
            aoe.util.getID('story_img_prev_'+id).src='/icon/links.png';
        }
    }
}
function prevStoryPic(id){
    var c=fotostory_story[id].count;
    var nr=fotostory_story[id].current;
    if(nr>0){
        nr--;
        fotostory_story[id].current=nr;
        aoe.util.getID('story_img_'+id).src='/dpu/fotostory/'+id+'/'+(nr+1)+'.png';
        aoe.util.getID('story_img_prev_link_'+id).href='/fotostory/'+id+'/'+(nr);
        aoe.util.getID('story_img_next_link_'+id).href='/fotostory/'+id+'/'+(nr+2);
        if(nr<=0){
            aoe.util.getID('story_img_prev_'+id).src='/icon/links_deakt.png';
            aoe.util.getID('story_img_prev_link_'+id).href='/fotostory/'+id+'/1';
        }
        if(c>(nr+1)){
            aoe.util.getID('story_img_next_'+id).src='/icon/rechts.png';
        }
    }
}
function closeFotostory(){
    openContent(null,null,'fotostory','read');
    var p=aoe.util.getID("story_obj").parentNode;
    var swf=aoe.util.getID("story_obj").cloneNode(true);
    p.removeChild(aoe.util.getID("story_obj"));
    p.appendChild(swf);
}
function addFotostoryComment(id){
    var success=false;
    if(aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]") && aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").value!=""){
        if(aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").value.trim()!=""&&aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").value.trim()!="Kommentar"){

        success=true;
       var params=new Object();
    params["action:"+BILLY_PATH+":menu"]=1;
    params[BILLY_PATH+":menu"]="fotostory";
       params[BILLY_PATH+':fotostory:story_id']=id;
       params[BILLY_PATH+":fotostory:comment["+id+"]"]=encodeURIComponent(aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").value.trim());
       params[BILLY_PATH+":fotostory:comment_author["+id+"]"]=encodeURIComponent(aoe.util.getFE(BILLY_PATH+":fotostory:comment_author["+id+"]").value.trim());
       params[BILLY_PATH+":fotostory:captcha["+id+"][value]"]=encodeURIComponent(aoe.util.getFE(BILLY_PATH+":fotostory:captcha["+id+"][value]").value);
       params[BILLY_PATH+":fotostory:captcha["+id+"][id]"]=encodeURIComponent(aoe.util.getFE(BILLY_PATH+":fotostory:captcha["+id+"][id]").value);
       params['action:'+BILLY_PATH+':fotostory:show_story']=1;
       params['action:'+BILLY_PATH+':fotostory:add_comment']=1;
       if(!params[BILLY_PATH+":fotostory:comment_author["+id+"]"]||params[BILLY_PATH+":fotostory:comment_author["+id+"]"]=='Name'){
           params[BILLY_PATH+":fotostory:comment_author["+id+"]"]="";
       }
       var cl=new ContentLoader(ContentLoader.REPLACE,aoe.util.getID('billy_fotostory_story_'+id));
   cl.load(params,function(){});
        }
    }
    if(aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]")&&!success){
        var b=(aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").currentStyle)?aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").currentStyle.border:aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").style.border;
        aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").sbf=(b!="")?b:"auto";
        aoe.util.getFE(BILLY_PATH+":fotostory:comment["+id+"]").style.border="0.5px solid red";
    }
    return false;
}

function logout(){
    Request.get({logout:1}, function(){
        window.location.reload();
    }, null);
    return false;
}
function getYoutubeId(str){
    var r=new RegExp("(\\?|&)v=([A-Za-z0-9\\-_]+)(&|$)");
    var r2=new RegExp("[^A-Za-z0-9\\-_]");
    if(r.test(str)){
        var a=r.exec(str);
        if(a[2])return a[2];
    }
    return str;
}

function showVideos(id){
    var l=aoe.util.getID("billy_videos_list_videos_"+id);
    if(l.style.display=="block"){
       l.style.display="none";
       aoe.util.getID("billy_videos_list_title_"+id).className="billy_videos_list";
    }else {
        l.style.display="block";
        aoe.util.getID("billy_videos_list_title_"+id).className="billy_videos_list_selected";
    }
}

function createFotostory(){
    var t=aoe.util.cE("canvas");
    if(t.getContext){
        aoe.util.getID("billy_fotostory_container").innerHTML="";
        new billy.ft.Fotostory("billy_fotostory_container");
    }else {
        aoe.util.getID("billy_fotostory_container").innerHTML="<object id=\"story_obj\" data=\"/f/fotostory/fotostory.swf\" type=\"application/x-shockwave-flash\" style=\"width:788px;height:442px;\">"+
                        "<param name=\"movie\" value=\"/f/fotostory/fotostory.swf\" />"+
                        "<param name=\"quality\" value=\"high\" />"+
                        "<param name=\"scale\" value=\"exactfit\" />"+
                        "<param name=\"menu\" value=\"false\" />"+
                        "<param name=\"wmode\" value=\"transparent\" />"+
                        "<param name=\"flashVars\" value=\"sid=' . \aoe\AOEClass::Aphrodite__getSID() . '&amp;lang=' . \aoe\AOEClass::Aphrodite__getLang() . '&amp;billy_path=' . $this->getParent()->getFullName() . '\" />"+
                      "</object>";
    }
}
