$(document).ready(function()
{
	$('.tooltip').each(function()
	{
		var id= '#tip-' + $(this).attr('id');
	$(this).qtip({
	   content: {
		  text: $(id) // Add .clone() if you don't want the matched elements to be removed, but simply copied
	   },
	   style: {
				classes: 'ui-tooltip'
		},
	   position: {
				my: 'bottom center', 
				at: 'top center' 

		 }
    });
	});
	
	/*$('.toggle_footer').hover(
	function(){
		$('#footer_bottom').slideDown('slow', function() {
             // Animation complete.
        });
	},
	function(){
		$('#footer_bottom').slideUp('slow', function() {
             // Animation complete.
        });
	}
	);*/
	var $floatingbox = $('#footer');
	var bodyY = parseInt($('#footer_bottom').offset().top) + 30;
	var scrollY = $(window).scrollTop() + $(window).height();
 
	if(scrollY < bodyY){
 
	  $(window).scroll(function () { 
 
	   var scrollY = $(window).scrollTop() + $(window).height();
	   var isfixed = $floatingbox.css('position') == 'fixed';
 
	   if($floatingbox.length > 0){
 
	      /*$floatingbox.html("srollY : " + scrollY + ", bodyY : " 
                                    + bodyY + ", isfixed : " + isfixed);*/
 
	      if ( scrollY < bodyY && !isfixed ) {
			$floatingbox.stop().css({
			  position: 'fixed'
			});
		} else if ( scrollY > bodyY && isfixed ) {
		 	  $floatingbox.css({
			  position: 'relative'
		});
	     }		
	   }
       });
     } else {
		 $floatingbox.css({
			  position: 'relative'
		});
	 }

});



