/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var i= 0

window.addEvent('domready', function() {
        

        /*Formatierung Box*/
        if($$('.box.list ul li').length>0){
            $$('.box.list ul li')[$$('.box.list ul li').length-1].setStyle('border-bottom','none');
        }
        if($$('.box.liste ul li').length>0){
            $$('.box.liste ul li')[$$('.box.liste ul li').length-1].setStyle('border-bottom','none');
        }

        /*Formatierung Rand*/
        writerRand('.container-header');
        writerRand('.container-content');
        $$('.container-footer')[0].setStyles({
                    'width':'62.4963em',
                    'height':'2.75em',
                    'padding-left':'6px',
                    'padding-right':'6px',
                    'background':'url(fileadmin/templates/img/bg_verlauf_footer.png) repeat-y '
            })

        /*Schritgröße*/
        fontsizer();
        
        /*Sitemap*/
        if($$('.csc-sitemap').length>0){
            /*Listen schließen*/
            $$('.csc-sitemap .withsub_l0 .sub1').setStyles({'height':'0','display':'block','overflow':'hidden'})
            $$('.csc-sitemap .withsub_l0 .sub1')[0].setStyles({'height':'auto','display':'block','overflow':'hidden'})
            /*Button einfügen*/
            $each($$('.csc-sitemap .withsub_l0 .openclose'),function(item){
                item.innerHTML='<img src="fileadmin/templates/img/button_sitemap_closed.jpg" />';
                item.i = i
                item.status = 0
                item.addEvent(
                'click', function(){
                    if(this.status == 0){
                        $$('.csc-sitemap .withsub_l0 .sub1')[this.i].setStyles({'height':'auto'})
                        newheight = 'auto';
                        this.innerHTML='<img src="fileadmin/templates/img/button_sitemap.jpg" />';
                        this.status=1
                    }else{
                        $$('.csc-sitemap .withsub_l0 .sub1')[this.i].setStyles({'height':'0'})
                        newheight = '0';
                        this.innerHTML='<img src="fileadmin/templates/img/button_sitemap_closed.jpg" />';
                        this.status=0
                    }
                });
                i++

            })
            $$('.csc-sitemap .withsub_l0 .openclose')[0].innerHTML='<img src="fileadmin/templates/img/button_sitemap.jpg" />';
            $$('.csc-sitemap .withsub_l0 .openclose')[0].status = 1
        }

        /*Schrift anpassen*/
        if(fontsizechosed!=""){
            document.getElementsByTagName("html")[0].style.fontSize =  fontsizechosed;
            if(fontsizechosed=='18px'){
                var bg = 'url(fileadmin/templates/img/bg_verlauf_size_m.png) repeat-y';
                $$('.container-header')[0].setStyle('background',bg);
                $$('.container-footer')[0].setStyle('background',bg);
                $$('.container-content')[0].setStyle('background',bg);
            }else if(fontsizechosed=='20px'){
                var bg = 'url(fileadmin/templates/img/bg_verlauf_size_l.png) repeat-y';
                $$('.container-header')[0].setStyle('background',bg);
                $$('.container-footer')[0].setStyle('background',bg);
                $$('.container-content')[0].setStyle('background',bg);
            }
        }
});


function writerRand($class,$bg){
        $$($class)[0].setStyles({
            'width':'62.4963em',
            'padding-left':'6px',
            'padding-right':'6px',
            'background':'url(fileadmin/templates/img/bg_verlauf.png) repeat-y '
    })    
}
function fontsizer(){
    $('fsizenormal').addEvents({
    'click': function(){
            $$('html').setStyle("font-size","16px");
            setCookie("16px");
            var bg = 'url(fileadmin/templates/img/bg_verlauf.png) repeat-y';
            $$('.container-header')[0].setStyle('background',bg);
            $$('.container-footer')[0].setStyle('background',bg);
            $$('.container-content')[0].setStyle('background',bg);
    }
    });
    $('fsizemitte').addEvents({
    'click': function(){
            $$('html').setStyle("font-size","18px")
            setCookie("18px")
            var bg = 'url(fileadmin/templates/img/bg_verlauf_size_m.png) repeat-y';
            $$('.container-header')[0].setStyle('background',bg);
            $$('.container-footer')[0].setStyle('background',bg);
            $$('.container-content')[0].setStyle('background',bg);

    }
    });
    $('fsizegross').addEvents({
    'click': function(){
            $$('html').setStyle("font-size","20px")
            setCookie("20px")
            var bg = 'url(fileadmin/templates/img/bg_verlauf_size_l.png) repeat-y';
            $$('.container-header')[0].setStyle('background',bg);
            $$('.container-footer')[0].setStyle('background',bg);
            $$('.container-content')[0].setStyle('background',bg);
    }
    });
}  
function setCookie(fontsize){
    document.cookie = "fsize="+fontsize+"#";
}


function listeAnzeigen(){
    if($('flashbox_big')!=null){
        var listeAufFx = new Fx.Morph($('flashbox_big'), {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
        listeAufFx.start({'height': '540'});
    }else{
        var listeAufFx = new Fx.Morph($('flashbox_small'), {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
        listeAufFx.start({'height': '470px'});
    }
}
function closeList(){
    if($('flashbox_big')!=null){
     var listeZufFx = new Fx.Morph($('flashbox_big'), {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
    listeZufFx.start({'height': '400'});
    }else{
     var listeZufFx = new Fx.Morph($('flashbox_small'), {duration: '1000', transition: Fx.Transitions.Sine.easeOut});
    listeZufFx.start({'height': '330'});
    }
}



cookie = document.cookie;
fontsizechosed = cookie.substr(cookie.search('fsize=')+6,4);

function bookmarkMe()
{
	if ((navigator.appName == 'Microsoft Internet Explorer') && (parseInt(navigator.appVersion) >= 4))
	{
		window.external.AddFavorite(window.location,document.title);
	}
	else
	{
		window.sidebar.addPanel('Fördern und Wohnen', window.location,'')
	}
}

