//---------------------------------------------------------
jQuery(document).ready(function()
{
  jQuery('#headerslideshow .slide').removeClass('hidden');

  //this next line is needed by IE to make info text ledgible
  jQuery('#headerslideshow .slide .info .info_text').css({opacity:1.0});
  
  var headerslideshowinterval = setInterval("nextHeaderSlide(1000)", 10000);
  
  var timeout;
  jQuery('#headerslideshow .slide, #headerslidecontrol img').hover(
    function() {  // on enter 
      clearTimeout(timeout);
      clearInterval(headerslideshowinterval);
    },
    function() {  // on exit
      timeout = setTimeout( 
        function() {
          clearTimeout(timeout);
          nextHeaderSlide(1000);
          headerslideshowinterval = setInterval("nextHeaderSlide(1000)", 10000);
        },
        2000 // wait 2 seconds before resuming slideshow
        );
    }
  );
  
//  $(".mainnav li").click(function() {
//    switchContent($(this).text());
//    return false; 
//  });
  
//  DD_belatedPNG.fix('div.panelbg, .info img.logo');
  DD_belatedPNG.fix('div.panelbg');
      
  jQuery.localScroll.hash({
    constant: false,
    queue: true,
    speed: 1500
  }); 
  
  jQuery.localScroll({
    lazy: true,
    constant: false,
    queue:true,
    speed: 1500,
    hash:true,
    onBefore:function( e, anchor, $target ){
      // The 'this' is the settings object, can be modified
    },
    onAfter:function( anchor, settings ){
      // The 'this' contains the scrolled element (#content)
    }
  });
  
});
//---------------------------------------------------------
function nextHeaderSlide(speed) 
{
	var active = jQuery('#headerslideshow .slide.active');
	if ( active.length == 0 )
    active = jQuery('#headerslideshow .slide:last');

  var next = active.next().length ? active.next() : jQuery('#headerslideshow .slide:first');

  active.addClass('last-active');

  next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, speed, function() {
      active.removeClass('active last-active');
//      next.children('.info p').css({opacity: 1.0});     
      });
      
}
//---------------------------------------------------------
function prevHeaderSlide(speed) 
{
  var active = jQuery('#headerslideshow .slide.active');
  if ( active.length == 0 )
    active = jQuery('#headerslideshow .slide:last');

  var prev = active.prev().length ? active.prev() : jQuery('#headerslideshow .slide:last');

  active.addClass('last-active');

  prev.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, speed, function() {
      active.removeClass('active last-active');
//      prev.children('.info p').css({opacity: 1.0});     
    });
}

////---------------------------------------------------------
//function switchContent(newContentName)
//{
//  
//  var contentName = $("#variablecontent").attr("title");
//  
//  if (newContentName != contentName)
//  {
//    $("#variablecontent")
//      .load("library/scripts/mchozer_ajax.php", {contentname: newContentName})
//      .attr("title", newContentName);
//   
//    document.location = 
//      
//  }
//}
//---------------------------------------------------------
