// Newsticker
(function () {
    var nt = jQuery ('#newsticker');
    if (false && nt.length > 0) {
	nt.show ();
	jQuery ('marquee').marquee ().fadeIn ().mouseover (function () {
	 jQuery (this).trigger ('stop');
	 }).mouseout (function () {
	  jQuery (this).trigger ('start');
	  }).mousemove (function (event) {
	   if (jQuery (this).data ('drag') == true)
	      this.scrollLeft = jQuery (this).data ('scrollX') + (jQuery (this).data ('x') - event.clientX);
	      }).mousedown (function (event) {
	       jQuery (this).data ('drag', true).data ('x', event.clientX).data ('scrollX', this.scrollLeft);
	       }).mouseup (function () {
		jQuery (this).data ('drag', false);
		});
        }
 }) ();


    var html = $('#gallery-images').eq (0).html ();
    var regexp = /<p>(([^\|]+)\|([^<]+?))<\/p>/gi;
    var images = [];
    while (match = regexp.exec (html))
 	  images.push ({ src: match[2], text: match[3] });

try {
    var infoboxItems = $('#infobox-items');
    if (infoboxItems.length != 0) {
       var html = '<table cellspacing="0" cellpadding="0" border="0"><tr><td id="infobox1" class="pngtrans">&nbsp;</td></tr>';
       var itemHTML = infoboxItems.eq (0).html ();
       jQuery ('.infobox-addition').each (function (index, item) {
	   html += '<tr><td class="infobox-nonitem pngtrans">'+jQuery (item).html ()+'</td></tr>';
	   jQuery (item).remove ();
	   });
       var found = false;
	   while (match = regexp.exec (itemHTML)) {
	       found = true;
             html += '<tr><td class="infobox-item pngtrans"><a href="'+match[2]+'" target="_blank">'+match[3]+'</td></tr>';
	     }
        if (!found) html += '<tr><td class="infobox-nonitem pngtrans">'+itemHTML+'</td></tr>'; 
        html += '<tr><tr><td id="infobox3" class="pngtrans"><img src="/images/empty.gif" width="1" height="1"></td></tr></table>';
       jQuery ('#infobox-table').html (html);
       //infobox.eq (0).css ('visibility', 'visible');
       }
} catch (ex) { console.log (ex); }
 function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
       break;
    containee = containee.parentNode;
    } while (containee != null);
  return isParent;
  }

var mainMenuTimes = {};
function mainMenuIn (id) {
  mainMenuTimes[id] = new Date ().getMilliseconds ();
  document.getElementById (id).style.visibility = 'visible';
  } 
function mainMenuOut (id, event) {
  if (checkMouseLeave(document.getElementById (id),event))
     document.getElementById (id).style.visibility = 'hidden';
  }

 function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement)
    return !element.contains (evt.toElement);
    else if (evt.relatedTarget) 
            return !containsDOM (element, evt.relatedTarget);
  }

     var image1 = $('#gallery-image1');
     var image2 = $('#gallery-image2');
     var label = $('#gallery-text');
     var index = images.length-1;
     var aniTimer;    
     
     function showNext () {
       index = index < images.length-1 ? index+1 : 0;
       image2.attr ('src', image1.attr ('src'));
       image1.hide();
       image1.attr ('src', images[index].src);
       label.fadeOut (100, function () { 
          label.html (images[index].text);
          label.fadeIn (1000); 
          });
       image1.fadeIn (2000, function () {
            aniTimer = setTimeout (showNext, 5000);
            });
       }
 
     if (images.length > 0) showNext ();
     

     function galleryLeft () {
       clearTimeout (aniTimer);
       image1.stop ();
       index = index > 0 ? index-1 : images.length-1;
       image1.css ('opacity', 1.0);
       image1.attr ('src', images[index].src);
       label.fadeOut (100, function () { 
          label.html (images[index].text);
          label.fadeIn (100); 
          });
       aniTimer = setTimeout (showNext, 5000);
       }  
     function galleryRight () {
       clearTimeout (aniTimer);
       image1.stop ();
       index = index < images.length-1 ? index+1 : 0;
       image1.css ('opacity', 1.0);
       image1.attr ('src', images[index].src);
       label.fadeOut (100, function () { 
          label.html (images[index].text);
          label.fadeIn (100); 
          });
       aniTimer = setTimeout (showNext, 5000);
       }  

   var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
   document.write (unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

    var pageTracker = _gat._getTracker ("UA-2496887-4");
    pageTracker._initData ();
    pageTracker._trackPageview ();
    // Aktivierung des Loggings von externen Links
    $('a[href$=pdf],a[href$=doc]').click (function () {
      try {
          var href = $(this).attr ('href');
          if (href.indexOf ('http:') != 0 && href.indexOf ('/') != 0 && href.indexOf ('/') != -1)
	     href = (''+window.location).substring ((''+window.location).indexOf ('/', 8), (''+window.location).lastIndexOf ('/')+1)+href; 
          pageTracker._trackPageview (href);
	  } catch (ex) { }
      });

$ ('#documents tr').each (function () {
  $(this).mouseover (function () {
      $(this).addClass ('highlight');
      });
  $(this).mouseout (function () {
      $(this).removeClass ('highlight');
      });
  });