var JSP_API = null;

var CycleImage = {
  max : new Array(),
  idx : new Array(),
  cycle : function (i) {
    $('div.cycle').eq(i).children('img').eq(CycleImage.idx[i]).fadeOut(2000);
    CycleImage.idx[i]++
    if (CycleImage.idx[i] == CycleImage.max[i]) CycleImage.idx[i] = 0;
    $('div.cycle').eq(i).children('img').eq(CycleImage.idx[i]).fadeIn(2000);
    setTimeout("CycleImage.cycle(" + i + ")", 5000);
  }  
}


$(function() {

  $('#footsample a').click(function () {
    var i = $('#footsample a').index(this);
    var j = $('#footsample a').index($('#footsample a.blackquad'));
    if (i != j) {
      $('#footsample a').eq(i).removeClass('whitequad').addClass('blackquad');
      $('#footsample a').eq(j).removeClass('blackquad').addClass('whitequad');
      $('#contpict img').eq(i).fadeIn(1000);
      $('#contpict img').eq(j).fadeOut(1000);
      $('#foottext div').eq(j).hide();
      if ($('#foottext div').eq(i).html() == '&nbsp;') {
        $('#foottoggle').hide();
      } else {
        $('#foottoggle').css('backgroundImage', 'url(/images/dreieck-schwarz.gif)').show();
        $('#foottext div').eq(i).show();
      }
      return false;
    }
  }); 

  $('#foottoggle').click(function () {
    var j = $('#footsample a').index($('#footsample a.blackquad'));
    if ($(this).css('backgroundImage').indexOf('dreieck-schwarz.gif') != -1) {
      $(this).css('backgroundImage', 'url(/images/dreieck-weiss.gif)');
      $('#foottext div').eq(j).hide();
    } else {
      $(this).css('backgroundImage', 'url(/images/dreieck-schwarz.gif)');
      $('#foottext div').eq(j).show();
    }
  });

  if ($('#navsubsub_scroller').length) JSP_API = $('#navsubsub_scroller').jScrollPane({showArrows: true}).data('jsp');
  $('#cont2textcols1').jScrollPane({showArrows: true});

  if (JSP_API) {
    $('#navsubsub_scroller a').click(function() { 
      if(JSP_API.getContentPositionY() > 0) {
        var y = JSP_API.getContentPositionY() + '';
        y = y.replace(/(\.\d\d)(\d*)/g, '$1');
        this.href = this.href+'?pos='+ y; 
      }
    });
    var pattern = /\?pos=((\d+)(\.(\d\d?))?)/;
    pattern.exec(location.href);
    if (RegExp.$1) JSP_API.scrollToY(RegExp.$1);
  }

  /*
  $('#navsubsub a img.down').hover(
    function () { $(this).attr('src', '/images/dreieck-runter_s.gif') },
    function () { $(this).attr('src', '/images/dreieck-runter.gif') }
  );

  $('#navsubsub a img.up').hover(
    function () { $(this).attr('src', '/images/dreieck-hoch_s.gif') },
    function () { $(this).attr('src', '/images/dreieck-hoch.gif') }
  );
  */

  $('div.cycle').each(function(i) {
    CycleImage.idx[i] = 0;
    CycleImage.max[i] = $('div.cycle').eq(i).children('img').length;
    if (CycleImage.max[i] > 1) setTimeout("CycleImage.cycle(" + i + ")", 2000);
  });

  Newsticker = new minScroller({instance : 'Newsticker', id : 'newsticker', auto : 'w', ms : 30, sh : 2, mode : 'horizontal'});

});


