jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);

}; 

$(document).ready(function(){
	$('a.more_info').parents('p').nextAll('ul').hide();
	$('a.more_info').click(function(){
		//$(this).parents('p').nextAll('ul').slideToggle();
		$(this).parents('p').nextAll('ul').fadeToggle(800);
	});
	
	$('p#et_image').next('a').hide();

	$('a.show_info').parents('p').nextAll('.csc-textpic').hide();
	/* $('h3').hide(); */
	$('a.show_info').click(function(){

		$(this).parents('p').nextUntil('p').fadeToggle(800, function(){
			if($('.csc-textpic:visible').length == 0)
			{
				$('.karte_ausschnitt').show();
			}
		});
		
		if($('.csc-textpic:visible').length > 0)
		{
			$('.karte_ausschnitt').hide();
		}
		
		
/*		if ($('.csc-textpic').css('display')=='none')
		{
		}
		else if ($('.csc-textpic').css('display')=='block')
		{
			$('.karte_ausschnitt').hide();
		}*/
		
	
	});
  	  
	if($('.area').length > 0)
	{
		$('.area').hover(function(){
			var item = $(this).attr("class");
			var pos = item.indexOf(" ")+1;
			var getit = item.substring(pos);
			show_contact(getit);
		}, function(){
		        var item = $(this).attr("class");
			var pos = item.indexOf(" ")+1;
			var getit = item.substring(pos);
			hide_contact(getit);
		});
	}
	
	if($('.special_euro').length > 0)
	{
		$('.special_euro').hover(function(){
		        var item = $(this).attr("class");
			var pos = item.indexOf(" ")+1;
			var getit = item.substring(pos);
			showInfo(getit);
		}, function(){
		        var item = $(this).attr("class");
			var pos = item.indexOf(" ")+1;
			var getit = item.substring(pos);
			clearInfo(getit);
		});
	}
	if($('.special_regional').length > 0)
	{
		$('.special_regional').hover(function(){
		        var item = $(this).attr("class");
			var pos = item.indexOf(" ")+1;
			var getit = item.substring(pos);
			showInfo(getit);
		}, function(){
		        var item = $(this).attr("class");
			var pos = item.indexOf(" ")+1;
			var getit = item.substring(pos);
			clearInfo(getit);
		});
	}
	

	if($('#goback').length > 0)
	{
		if (document.documentElement.scrollTop == 0)
			$('#goback').css('top', 490 + "px");	
		else
			$('#goback').css('top', document.documentElement.scrollTop + "px");	
	}
	

	
	
});


$(window).scroll(function() {

	if($('#goback').length > 0)
	{
		var offset = $('#goback').offset();
	
		if(offset.top < document.documentElement.scrollTop)
		{
        		$('#goback').css('top', $(this).scrollTop() + "px");
     		}
        	else if (document.documentElement.scrollTop == 0 || document.documentElement.scrollTop < 489)
     		{
     			$('#goback').css('top', 490 + "px");
     		}
     		 else if (document.documentElement.scrollTop > 490)
     		{
     			$('#goback').css('top', $(this).scrollTop() + "px");
     		}
     	}
});


function showInfo(the_id)
{
  $('#'+the_id).show();
  document.onmousemove=mouseposition;
}

var IE = document.all?true:false;

function mouseposition(e)
{

if (IE) {

  var de = document.documentElement;
  var b = document.body;
  var x = event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
  var y = event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);

  }
  else
  {
  var x = e.pageX;
  var y = e.pageY;
  }
  //var x = e? e.pageX : event.clientX + document.body.scrollLeft;
  //var y = e? e.pageY : event.clientY + document.body.scrollTop;
  if($('#special').length > 0)
  {
  	//document.getElementById('special').style.top = y + 10 + "px";
  	//document.getElementById('special').style.left = x + 10 + "px";
  }
}

function clearInfo(the_id)
{
  document.onmousemove=null;
  $('#'+the_id).hide();
}

function show_contact(area)
{
	$('#'+area).show();	
}

function hide_contact(area)
{
 	$('#'+area).hide();
}
