$(window).resize(function(){
	$("#links").css({ height: $(document).height() - 75 + "px" });
});

$(document).ready(function(){
		$("#links").css({ height: $(document).height() - 75 + "px" });

		/* Navigation */
    $("a img.hover").hover(function(){
    	if ($(this).hasClass("aktuelles") === false){ 	
	  	  var elem = $(this).attr("src").replace(/\.(.+)$/i, "-on.$1");
  	  	  $(this).attr("src", elem);
  		}
    }, function(){
    	if ($(this).hasClass("aktuelles") === false){
  	    var elem = $(this).attr("src").replace(/-on\.(.+)$/i, ".$1");
            $(this).attr("src", elem);
			}
		});

		$("#navigation a").click(function(){
			if ($(this).find("img").attr("alt") == "blog"){
				window.open(this.href);
				return false;
			}
		});

		/* Teaser Bilder */
    $("#teaser-breit a, .teaser-klein a")
    	.mouseout(function(){
				$("img:first", this)
					.stop()
					.animate({opacity: '1'}, 1);
    	})
    	.mouseover(function(){
				$("img:first", this)
					.stop()
					.animate({opacity: '.70'}, 1);
    	});

		/* Bilder Navigation */
    $(".bilder-navigation")
    	.mouseout(function(){
				$(this)
					.stop()
					.animate({opacity: ".0"}, 100);
  	  })
  	  .mouseover(function(){
				$(this)
					.stop()
					.animate({opacity: ".30"}, 100);
	    });

		// entferne Galerie-Navigation über dem Bild, wenn nur ein Bild vorhanden ist
		if ($("#breiter").children().length == 1)
		{
			$("#bilder-navigation-zurueck").remove();
			$("#bilder-navigation-vor").remove();
		}

		$("#breiter")
			.cycle({ 
  	  	fx: "scrollHorz", 
	  	  speed: 400,
		    speedOut: 405,
  	  	timeout: 0,
				pager: "#pager",
    		prev:   "#bilder-navigation-zurueck", 
	    	next:   "#bilder-navigation-vor",
    		pager:  "#bilder-zaehler",
				pagerAnchorBuilder: function(idx, slide){
					return '<li><a href="#" title="' + slide.alt + '">/</a></li>';
				}
		});

		// enferne in der Unternavigation den Link von allen Einträgen mit dem Namen: ---
		$("#inhalt-navigation li a").each(
	   	function(intIndex)
  	  {
				if ($(this).attr("innerHTML") == "---")
				{
					$(this).parent().attr("innerHTML", "---");
					$(this).remove();
				}
     	}
  	);

		$("#navigation li:last-child").css({
			background: "none"
		});

		$("#navigation-unter li:last-child").css({
			background: "none"
		});

  });
  
  function UnCryptMailto(s) {
		var n = 0;
    var r = "";
  
    for (var i=0; i<s.length; i++)
    {
	    n = s.charCodeAt(i);

      if (n >= 8364)
       n = 128;

      r += String.fromCharCode(n-1);
    }

    return r;
  }

  function linkTo_UnCryptMailto(s) {
	  location.href = UnCryptMailto(s);
  }  
  
  function strpos (haystack, needle, offset) {
	// http://kevin.vanzonneveld.net
  // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  // +   improved by: Onno Marsman    
  // +   bugfixed by: Daniel Esteban
  // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
  // *     returns 1: 14
 
	var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
  return i === -1 ? false : i;
}
