$(document).ready(function() {

	active = true;
	
	function randLeft(obj){
		
		var aktuell = obj.css("left");
		neu = $.randomBetween(25, 75)+"%";
		if(neu<=aktuell){
			obj.addClass("fischLinks");
		}else{
			obj.removeClass("fischLinks");		
		};
		return neu;
	};
	function randTop(obj){
		oben = $.randomBetween(20, 80)+"%";
		return oben;
	};
	
	function done(){
		active = true;
	};
		
	$("#fish").hover(
      function () {
      		if(active){
	         	$(this).animate(
	         		{ "left": randLeft($(this)),"top": randTop($(this)) },
	         		{ "duration": 1500, "easing": "swing",  "complete": done }
	         	);
	        };
         	active = false;   	
        }, 
      function () {
        
      }
    );
	



	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		
		
});