var sagscroller1=new sagscroller({
	id:'mysagscroller1',
	mode: 'auto',
	rssdata:{
		feeds: [
			['Verkehrsinfo','http://www.vmz-niedersachsen.de/vwd/InfoRss.xml']
		],
		linktarget: '_new',
		displayoptions: 'datetime label description',		
		entries: 8 
	},
	pause: 2500,
	animatespeed: 200 
	})

var sagscroller1=new sagscroller({
	id:'mysagscroller2',
	mode: 'manual',
	rssdata:{
		feeds: [
			['Verkehrsinfo','http://www.vmz-niedersachsen.de/vwd/InfoRss.xml']
		],
		linktarget: '_new',
		displayoptions: 'datetime label description',		
		entries: 8 
	},
	pause: 2500,
	refreshsecs: 60,
	animatespeed: 400 
	})
	

$(document).ready(function() {			
	//Hide the toggle containers on load
	$("ul.toggle_container").hide(); 	
	// Menues aufklappen
	$("ul#first.toggle_container").show();
	$("ul#second.toggle_container").show();
        //Switch the "Open" and "Close" state per click
	$("h2.trigger").toggle(function(){
        $(this).addClass("active");
        }, function () {
         $(this).removeClass("active");
	});

        //Slide up and down on click
	$("h2.trigger").click(function(){
	       $(this).next("ul.toggle_container").slideToggle("slow");
	       return false;
        }, function () {
         $(this).next("ul.toggle_container").slideToggle("slow");
          return false;
         //$(this).next("ul.toggle_container").slideToggle("slow");
        //return false;
	});


 if ( $.browser.msie ) {  
 
 // Funktion z.Z. off
 //  $(".popup").colorbox({transition:"fade", width:"480", height:"400", iframe:true});
   
   // Script by Thomas Stich
// http://www.stichpunkt.de/beitrag/popup.html
// use it if you like it
// 
// <a href="html-or.jpg" onclick="return popup(this,123,456)" title="..."
// or
// <a href="html-or.jpg" onclick="return popup(this)" title="..."


var pop = null;

function popdown() {
  if (pop && !pop.closed) pop.close();
}

function popup(obj,w,h) {
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
  w = (w) ? w += 20 : 150;  // 150px*150px is the default size
  h = (h) ? h += 25 : 150;
  var args = 'width='+w+',height='+h+',resizable';
  popdown();
  pop = window.open(url,'',args);
  return (pop) ? false : true;
}

window.onunload = popdown;
window.onfocus = popdown;
       
 
 } else {
  
	// Popup Flashstream
	$(".popup").popup({
        width: 480,
        height: 370,
        titlebar: false,
        status: false,
        resizable: false,
        toolbar: false,
        scrollbars: true,
        menubar: false
        });
        
   // Popup Druck


	$(".popup-druck").popup({
        width: 700,
        height: 600,
        titlebar: false,
        status: false,
        resizable: false,
        toolbar: false,
        scrollbars: true,
        menubar: false
        });
        
 
 }        
             
/* 
 var siteurl = document.URL;
 var printurl= siteurl+'&type=98&print=1&no_cache=1'

 $('.popup').live('click', function(event) {
          event.preventDefault();
          $.popupWindow('http://www.leinehertz.net/player2/', {
        width: 480,
        height: 370
          });
        });
        
        $('.popup-druck').live('click', function(event) {
          event.preventDefault();
          $.popupWindow(''+printurl, {
            width: 700,
            height: 600
          });
        });
        
*/       
         

//innerfade

$('.bilderSlider ul').innerfade({ 
//speed: 'slow', 
timeout: 10000,
speed: 1000,
 type: 'sequence', 
containerheight: '198px' 
}); 

// E-Mail Verschluesselung hardcodierte EMail-Adressen
$("body").emailSpamProtection("email");
// Wettervorschau Medienspalte rechts
$('div.vorschau ul').hide(); 
$('div.vorschau h3.handle')
.mouseover(function(){
  $('div.vorschau ul').slideToggle("medium")
  })
.mouseout(function(){
	$('div.vorschau ul').slideUp()
  })

// Top Scroll Buttons Content/Content Footer
$('#seite').scrollTo(0);
//------ Reset the screen to (0,0)
//$.scrollTo(0);
$('p.csc-linkToTop a').click(function(){ 
  $.scrollTo('#content-innen', {duration: 1000});
  return false;
});

var scrollDiv = document.createElement('div');
$(scrollDiv).attr('id', 'toTop').html('&uarr; Nach oben').appendTo('body');    
$('div#toTop').attr('title', 'zum Seitenanfang scrollen');
$(window).scroll(function () {
            if ($(this).scrollTop() != 0) {
                $('#toTop').fadeIn();
            } else {
                $('#toTop').fadeOut();
            }
        });
        $('#toTop').click(function () {
            $('body,html').animate({
                scrollTop: 0
            },
            800);
        });



// Playlist ------------------------

$('#playlist').load('playlist_convert.php').fadeIn("slow"); 
var refreshId = setInterval(function(){
 $('#playlist').load('playlist_convert.php'); }, 15000);

// Slider Aktuelle Beitraege Starseite ------------------------
$('#slides1').bxSlider({
		//prev_text: 'prev',
    prev_image: 'fileadmin/templates/leinehertz/images/icons/btn_arrow_left.png',
		//next_text: 'next',
    next_image: 'fileadmin/templates/leinehertz/images/icons/btn_arrow_right.png',
		wrapper_class: 'slides1_wrap',
		margin: 40,
		auto: true,
		auto_controls: true,
		
		controls: true,                 // determines if default 'next'/'prev' controls are displayed
    speed: 800,                     // amount of time slide transition lasts (in milliseconds)
    pager: true,                    // determines if a numeric pager is displayed (1 2 3 4...)
	  //pager_short: false,             // determines if a 'short' numeric pager is displayed (1/4)
	  //pager_short_separator: ' / ',   // text to be used to separate the short pager
	  pause: 5000,                    // time between each slide transition (auto mode only)
	  auto_direction: 'next',         // order in which slides will transition (auto mode only)
	  auto_hover: true,               // determines if slideshow will pause while mouse is hovering over slideshow
	  //ticker: false,                  // determines if slideshow will behave as a constant ticker
	  //  ticker_controls: false,         // determines if 'start'/'stop' ticker controls are displayed (ticker mode only)
	  //ticker_direction: 'next',       // order in which slides will transition (ticker mode only)
    ticker_hover: true,             // determines if slideshow will pause while mouse is hovering over slideshow
	  stop_text: 'Stop',              // text to be displayed for the 'stop' control
	  start_text: 'Start'       
	
	});


// Colorbox - Lightbox Bilder Content /tt_news ------------------------	
 $("a[rel='groupe']").colorbox();
  $("a[rel='colorbox']").colorbox({transition:"fade"});
  $(".single").colorbox({}, function(){});
  $(".colorbox").colorbox({maxWidth:"600px", maxheight:"400px"});
  $(".colorbox img").attr({title: 'zum Vergrößern bitte klicken'});
  $(".iframe").colorbox({width:"80%", height:"80%", iframe:true}); 
  
  
   
  
  var $singleNewsItem = $('div#slider-single div.news-single-item');  
  if ($singleNewsItem.find('img').length > 1) {
   $("div#slider-single div.news-single-item div.csc-textpic-imagerow img").css({height:'80px',width:'120px',padding:'0 5px 0 0',float:'left'});
   $("div#slider-single div.news-single-item div.csc-textpic-imagerow").css({width:'auto',background:'red'});
   $("div#slider-single div.news-single-item .csc-textpic-text").css({width:'auto'});                     
   }    
/*  
   setTimeout(function(){
            var $imageItems = $('div#slider-single div.news-single-item img');
            if($imageItems.size()==4) {
                $imageItems.css("width", "210px");
            } else if ($imageItems.size()==3) {
                $imageItems.css("width", "294px");
            }
        }, 100);
   
   
   
  //$("div.block-menu li.first").next("li").addClass("seccond");
    $("div.block-menu li.second").toggle(
      function(){
        $this = $(this);
        $this.find('a').addClass('active');
        $this.prev().addClass("no-bg-3");
        $this.addClass('opened').removeClass('closed');
        $('div.block-menu-submenu').slideDown();
      },

      function(){
        $this = $(this);
        $this.addClass('closed').removeClass('opened');
        $('div.block-menu-submenu').slideUp('normal', function(){
          if ($this.parent().find('a.active').length > 1) {
            $this.find('a').removeClass('active');
            $this.prev().removeClass("no-bg-3");
          }
        });
    }
   );
*/  
    /*block-submenu
        var $submenu = $('div.block-menu-submenu');
        $('ul.level1 > li > a', $submenu).click(function(event){
            var $this = $(this);
            var $li = $this.parent();
            if (!$li.hasClass('active')) {
                $li.parent().find('li.active').removeClass('active');
                $li.addClass('active');
            }
        });
        var ul1li_left = 0;
        $('ul.level1 > li', $submenu).each(function(){
            var $this = $(this);
            var left = parseInt($this.offset().left, 10);
            if (left < ul1li_left) {
                $this.prev().addClass('last-p');
            }
            ul1li_left = left;
        });

        $('ul.level2').each(function(){
            var ul2li_left = 0;
            $(this).find('li').each(function(){
                var $this = $(this);
                var left = parseInt($this.offset().left, 10);
                if (left < ul2li_left) {
                    $this.prev().addClass('last-p');
                }
                ul2li_left = left;
            });
        });

        var ul1_height = $('ul.level1 > li:last').offset().top - $('ul.level1 > li:first').offset().top
        + $('ul.level1 > li:first').height();
        var ul2_height = $('ul.level2:first > li:last').offset().top - $('ul.level2:first > li:first').offset().top
        + $('ul.level2:first > li:first').height();
        var wDelimiterTop = parseInt(
            ul1_height + parseInt($('ul.level1').css('paddingTop'), 10) + 17
            ,10);

        $('div.block-menu-submenu-dl', $submenu).css('top', wDelimiterTop);

        $('ul.level2', $submenu).css('top', wDelimiterTop + 10);

        var subMenuHeight = parseInt(
            wDelimiterTop + ul2_height
            + parseInt($('ul.level1').css('paddingTop'), 10)
            , 10);

        $submenu.height(subMenuHeight);
        $submenu.css({
            position: 'relative',
            top: 0,
            display: 'none'
        });
       */

});

