///////////////////////////////////////////
//                                       //
//  © 2010 www.ARTCORE-ILLUSTRATIONS.de  //
//                                       //
///////////////////////////////////////////

// Comment Number Fly in
              
CommentFly = function(){	


	$("h1").hover(function() {
		$(this).find("span").stop().animate({right:-65, opacity:1}, 100);
	}, function () {
		$(this).find("span").stop().animate({right:-100, opacity:0}, 100);		
	});

};

// Tooltip
              
toolTip = function(){		

	$("a.tooltip").hover(function(e){											  
		content = $(this).attr("title");
		offset  = $(this).offset();
		
		$(this).removeAttr("title");
		  
		$("body").append("<p id='tooltip'>"+ content +"</p>");

		widthTip   = $('#tooltip').outerWidth();
		heightLink = $(this).innerHeight();
		widthLink  = $(this).width();
		
		$("#tooltip").css("top", (offset.top + heightLink) + 3 + "px").css("left", (offset.left + widthLink/2 - widthTip/2) + "px").fadeIn("fast");
		
		$(document).scroll(function() {
  			$('#tooltip').fadeOut('slow');
		});
    }, 
	function(){ 
		$(this).attr("title", content);
		$("#tooltip").remove(); });
};    


// Menu Animation

menuAnimation = function() {

	var menuItems = $("ul.categories").find("a");
	
	menuItems.attr("title", "");

	menuItems.hover(function () {

			$(this).stop().animate({
	    		paddingLeft: '6',
	    		textAlign:'right',
	    		width: '84'
		  	}, 100);
	
	  	}, function () {
	  	
	  		$(this).stop().animate({
	    		paddingLeft: '0',
	    		width: '90'
	  		}, 100);
	});
}


// Scroll To Top

jQuery.fn.topLink = function(settings) {
  settings = jQuery.extend({
    min: 1,
    fadeSpeed: 200
  }, settings);
  return this.each(function() {
    //listen for scroll
    var el = $(this);
    el.hide(); //in case the user forgot
    $(window).scroll(function() {
      if($(window).scrollTop() >= settings.min)
      {
        el.fadeIn(settings.fadeSpeed);
      }
      else
      {
        el.fadeOut(settings.fadeSpeed);
      }
    });
  });
};

// DOM Ready

$(function() {

	// Comment Number Fly In
	CommentFly();

	// Menu Init	
	menuAnimation();	
	
	// Tooltip Init
	toolTip();
	
	// Set The Link For Scroll To Top
  	$('#top-link').topLink({
    	min: 400,
    	fadeSpeed: 500
  	});
  	$('#top-link').click(function(e) {
    	e.preventDefault();
    	$.scrollTo(0,300);
  	});
});
