/* 
 * moreless animation
 */
var aktiv
sub_desc_show = function(){
    if(zustand==1){
        $('content_moreless').innerHTML=conent_desc_2;
        $('moreless').innerHTML="zur&uuml;ck"
        zustand=2;
    }else{
        $('content_moreless').innerHTML=conent_desc_1;
        $('moreless').innerHTML="weiter lesen";
        zustand=1;
    }
    morph_element($('content-desc'),'300',{ 'color': '#ffffff'})
    morph_element($('moreless'),'300',{'color': '#e32118'})
}
var conent_desc_1="";
var conent_desc_2="";
var zustand = 1;

/*
 *List Beschreibung
 */
var conent_desc_1;
var conent_desc_2;
js_init_ttnews_desc = function(){
    if($('content-desc-2')!= null){
        if($('content-desc-2').innerHTML != ''){
             $('content-desc').setStyle('overflow',"hidden")
            
             conent_desc_1= ''+$('content-desc-1').innerHTML+'<a id="moreless">...mehr lesen</a>';
             conent_desc_2= ''+$('content-desc-1').innerHTML+'<span id="readmore">'+$('content-desc-2').innerHTML+'</span><a id="moreless">schlie&szlig;en</a>';

            $('content-desc').innerHTML = conent_desc_1;

            $('moreless').addEvent(
                'click', function(){
                show_content_desc()
            });
        }
    }
 }
 var $start_desc_height ='';
 var content_desc_aktiv;
 var zustand = 'small';
 function show_content_desc(){
     $h=$('content-desc').getScrollSize()
     if(zustand == 'big'){
       $('content-desc').setStyle('height',$h.y)
       $('content-desc').innerHTML = conent_desc_2;
       morph_element($('content-desc'),1000, {'height':$start_desc_height.y});
       sb=$('content-gallery-scrollbox');
       if($('content-gallery-scrollbox')==null){
           sb=$('news-singel-img');
       }

       if(sb!=null){
            morph_element(sb,1000, {'margin-top':'0'});
       }
            morph_element($('readmore'),1200, {'color':'#1B2830'});
        content_desc_aktiv = window.setInterval("change_desc()", 1200);

       zustand = 'small';
    }else{
       zustand = 'big';
       $start_desc_height = $('content-desc').getScrollSize()
       $('content-desc').setStyle('height',$h.y)
       $('content-desc').innerHTML = conent_desc_2;
       $('readmore').setStyle('color','#1B2830');
       morph_element($('content-desc'),1200, {'height':'415'});
       sb=$('content-gallery-scrollbox');
       if($('content-gallery-scrollbox')==null){
           sb=$('news-singel-img');
       }
       if(sb!=null){
           morph_element(sb,800, {'margin-top':'415'});
       }
           morph_element($('readmore'),1200, {'color':'#fff'});
        $('moreless').addEvent(
            'click', function(){
            show_content_desc()
        });
     }
 }
 function change_desc(){
     $('content-desc').innerHTML = conent_desc_1;
     window.clearInterval(content_desc_aktiv);
     $('moreless').setStyle('color','#1B2830');
     morph_element($('moreless'),500, {'color':'#e32118'});
    $('moreless').addEvent(
        'click', function(){
        show_content_desc()
    });
 };
 /*
  *tt_news gallery list

var temp_y = 0;
var down;
var up;
  */
var scrollGallerycount = 0
 function scrollGallery(class_id){
     if( scrollGallerycount+class_id>=0&& $$('.box').length > scrollGallerycount+class_id)
    scrollGallerycount+=class_id;
    $('content-gallery-scrollbox').$hide_sub_desc_txt = new Fx.Morph($('content-gallery-scrollbox'), {duration: '800', transition: Fx.Transitions.Quad.easeInOut});

    $('content-gallery-scrollbox').$hide_sub_desc_txt.cancel();
    $('content-gallery-scrollbox').$hide_sub_desc_txt.start({'margin-left':302*scrollGallerycount*-1});
}

js_init_ttnews_gal = function(){
// scoll Gallery
    if($('content-gallery')!=null){
   
        $('content-gallery').setStyle('overflow', 'hidden');
        tempHTML =$('content-gallery').innerHTML
        elements = $$('.content-gallery-item');
        last_in_box  ='<div class="content-gallery-item last"><img src="fileadmin/templates/img/arrow_right.jpg" class="box-scroll-button-r" /></div></div>'
        first_box='<div class="box"> <div class="content-gallery-item"><img src="fileadmin/templates/img/arrow_left.jpg" class="box-scroll-button-l" /></div>'
        $content = '<div id="content-gallery-scrollbox"><div class="box" id="boxid0">';
        $k=1
        $gallery_page = 1;
        for($j=0;$j<elements.length;$j++){
            if(($k)%4==0){
               $content +='<div class="content-gallery-item last">'+  elements[$j].innerHTML+'</div>';
            }else{
               $content +='<div class="content-gallery-item">'+  elements[$j].innerHTML+'</div>';
            }
            if(($j%10==0&&($j+1)>10&&($j+1)>11)||$k+1==12){
                $content +=last_in_box;
                if($j+1!==elements.length) {
                    $content +='<div class="box" id="boxid'+$gallery_page+'"> <div class="content-gallery-item"><img src="fileadmin/templates/img/arrow_left.jpg" class="box-scroll-button-l" /></div>'
                    $gallery_page++
                    $k++;
                }
                $k++;
            }
            $k++;
        }
        if(elements.length%10!=0){
            $content +='<div>';
        }
        $content +='<div>';
        //debug('elements[]->'+$content);
        $('content-gallery').innerHTML = $content

        $('content-gallery-scrollbox').setStyle('width', '2000');
        $('content-gallery-scrollbox').$hide_sub_desc_txt = new Fx.Morph($('content-gallery-scrollbox'), {duration: '800', transition: Fx.Transitions.Quad.easeInOut});

        $$('.box').setStyles({'float': 'left','width':'302'});
        $$('.box').each(function(el){
            el.addEvent('mousewheel', function(e){
                e.stop();
                e.wheel < 0 ?  scrollGallery(1) :  scrollGallery(-1);
            })
        });
        coFx = new Fx.Scroll($('content-gallery-scrollbox'),{duration: 1500,transition: Fx.Transitions.Quad.easeInOut});
       

        $i = 1

        $$('.content-gallery-item a img').each(function(el){
            el.$show_border = new Fx.Morph(this, {duration: '1300', transition: Fx.Transitions.Sine.easeOut});
            el.addEvents({
                'mouseover': function(){
                       this.$show_border.cancel();
                       this.$show_border = new Fx.Morph(this, {duration: '1300', transition: Fx.Transitions.Sine.easeOut});
                       this.$show_border.start({
                            'border-color' : '#e32118',
                            'border-width' : '1px',
                            'border-style' : 'solid'
                        });
                },
                'mouseleave': function(){
                       this.$show_border.cancel();
                       this.$show_border = new Fx.Morph(this, {duration: '1300', transition: Fx.Transitions.Sine.easeOut});
                       this.$show_border.start({
                            'border-color' : '#1B2830',
                            'border-width' : '1px',
                            'border-style' : 'solid'
                        });
                }
            });
        });
        $$('.box-scroll-button-r').each(function(el){
            el.id = $i;

            el.addEvents({
           'click': function(){
                    scrollGallery(+1);
           }})
           $i++;
        });
        $i = $$('#content-gallery-scrollbox .box').length;

        $$('.box-scroll-button-l').each(function(el){
            $i--;
            el.id = $i;
            el.addEvents({
           'click': function(){
                  scrollGallery(-1);
           } })
       });
    }
}

/*
 * Singel Gallery
 */
var imageSetSingel ;
var imageObj = new Array() ;
function imgloader(i){
    imageObj[i].imgLoaded=true
}

function setimageSet(){
    if(typeof(imageSet1)=='object'){
        for(i=0;i<imageSet1.length;i++){
            imageObj[i] = new Image()
            imageObj[i].src = imageSet1[i];
            imageObj[i].imgId = i
            imageObj[i].imgLoaded= false;
            imageObj[i].onLoad= imgloader(i);
        }
    }
}
var act_id_singleimg = "";
var fadeNr = new Number(0);
var hide = new Fx.Morph($('content-img'), {duration: effectspeed, transition:  Fx.Transitions.Quad.easeInOut});
function init_tt_news_SingelGallery(){
$i = 0;
    $$('.tt_news-single-imglist').each(function(el){
       el.$show_border = new Fx.Morph(this, {duration: '1300', transition: Fx.Transitions.Sine.easeOut});
       el.$id=$i;
       $i++;
       el.addEvents({
            'mouseover': function(){
                   this.$show_border.cancel();
                   this.$show_border = new Fx.Morph(this, {duration: '1300', transition: Fx.Transitions.Sine.easeOut});
                   this.$show_border.start({
                       'width' : '65',
                       'height' : '56',
                        'border-color' : '#e32118',
                        'border-width' : '1px',
                        'border-style' : 'solid'
                    });
            },
            'mouseleave': function(){
                   this.$show_border.cancel();
                   this.$show_border = new Fx.Morph(this, {duration: '1300', transition: Fx.Transitions.Sine.easeOut});
                   this.$show_border.start({
                        'border-color' : '#1B2830',
                        'border-width' : '1px',
                        'border-style' : 'solid'
                    });
            },
            'click': function(){
                window.clearTimeout(aktiv);
                $('tt_news-single-imgbig').setStyles({
                    'filter':'alpha(opacity=100)',
                    '-moz-opacity': '1',
                    'opacity': '1'
                });
                $('tt_news-single-imgbig').src= imageObj[fadeNr].src;
                $('tt_news-single-imgbig').title=this.title
                
                hide.cancel();
                hide = new Fx.Morph($('tt_news-single-imgbig'), {duration: effectspeed, transition:  Fx.Transitions.Quad.easeInOut});
                hide.addEvent('onComplete', function() {
showNewsImg()
});
                hide.start({
                    'filter':'alpha(opacity=0)',
                    '-moz-opacity': '0',
                    'opacity': '0'
                });
                //alert(imageObj[this.$id].src);
                $('content-img').setStyles({"background-image": 'url('+imageObj[this.$id].src+')','background-repeat':'no-repeat'});
                fadeNr = this.$id;
                act_id_singleimg = this;
            }
        });
    });
}
showNewsImg = function(){
    $('tt_news-single-imgbig').setStyles({
        'filter':'alpha(opacity=100)',
        '-moz-opacity': '1',
        'opacity': '1',
        'visibility':'visible'
    });
    $('tt_news-single-imgbig').src= imageObj[fadeNr].src;

}












 /*  var $i = 0;
    $$('.content-gallery-row').each(function(el){
        if($i==0){
            $('content-gallery').innerHTML = '|<div class="content-gallery-area"> <div class="content-gallery-row">'+el.innerHTML+"</div>|";
            $i++;
        }else if($i%3==0){
            $('content-gallery').innerHTML +='</div><div class="content-gallery-area"><div class="content-gallery-row">'+el.innerHTML+"</div>";
             $i=1;
        }else{
            $('content-gallery').innerHTML +='<div class="content-gallery-row">'+el.innerHTML+"</div>";

            $i++;
        }
    })
    if($$('.content-gallery-row').length%3!=0){
        $('content-gallery').innerHTML +='</div>';
    }*/
