//wiammeer.js
//2010-03-19
//v1.0
$(document).ready(function(){
	$(
	function()
	{
		$("img.rollover").css({'opacity':'1'}).hover(
			function()
			{
				$(this).attr('src', $(this).attr('src').replace("_low", "_high"));
			},
			function()
			{
				$(this).attr('src', $(this).attr('src').replace("_high", "_low"));
			}
		);
	}
	);

//crossfader
	$(".picon").css("opacity",0).fadeTo(500, 0);
		$(".picon").mouseover(function () {
			$(this).fadeTo(300, 1);
		});
		$(".picon").mouseout(function () {
			$(this).fadeTo(300, 0);
	});

//start fancybox	
	$("a.akbild").fancybox({
				'titleShow'     : false
	});
	
//change image by subnavi
	$('.subnavi').click(function() {
		var mainImage = $(this).attr("href");
		$("#meinbild").attr({ src: mainImage });
		return false;
	});
	
//replace image name to _large for fancy effect
	$('a.subnavi').click(function() {
		var mainImage = $('#meinbild').attr('src');
		var index = mainImage.indexOf('.');
		var before = mainImage.substr(0, index);
		var after = mainImage.substr(index);
		var largeimage =  before + "_large" + after;
		$('a.akbild').attr('href', largeimage);
		return;
		
	});
	
});

//remove all class an on subnavi
function allelow() {
	$("div.visual").find(".an").removeClass("an");
	$("div.visual").find(".subnavi").addClass("aus");
	return false;
}

function allelow2() {
	$("div.visualnews").find(".an").removeClass("an");
	$("div.visualnews").find(".subnavi").addClass("aus");
	return false;
}

//add class an on subnavi		
$(
	function()
	{
		$("a.subnavi").click(
			function()
			{
				allelow();
				$(this).removeClass("aus");
				$(this).addClass("an");
			}
		);
	}
)

$(
	function()
	{
		$("a.subnavi").click(
			function()
			{
				allelow2();
				$(this).removeClass("aus");
				$(this).addClass("an");
			}
		);
	}
)

//Images rollover Function
$(
	function()
	{
		$("#footernavi img").toggle(
			function()
			{
				this.src = this.src.replace("_high","_low");
				$(this).next('div').animate({
					height: 'toggle'
				  }, 500, function() {
					// Animation complete.
				  });
			},
			function()
			{
				this.src = this.src.replace("_low","_high");
				$(this).next('div').animate({
					height: 'toggle'
				  }, 500, function() {
					$('html,body').animate({
					scrollTop: $("#ankerende").offset().top
					}, 2000 , function (){location.hash = "#ankerende";});
				  });
			}
		);
	}
)
//Images rollover duplicate off Function, ev. change it
$(
	function()
	{
		$("#footernaviaus img").toggle(
			function()
			{
				this.src = this.src.replace("_high","_low");
				$(this).next('div').animate({
					height: 'toggle'
				  }, 500, function() {
					$('html,body').animate({
					scrollTop: $("#ankerende").offset().top
					}, 2000 , function (){location.hash = "#ankerende";});
				  });
			},
			function()
			{
				this.src = this.src.replace("_low","_high");
				$(this).next('div').animate({
					height: 'toggle'
				  }, 500, function() {
					// Animation complete.
				  });
			}
		);
	}
)


	
