$(document).ready(function() {

    //Tooltips (http://www.sohtanaka.com/web-design/examples/element-tooltip/)
    $(".tip_trigger").hover(function(){
        tip = $(this).find('.tip');
        tip.show(); 
    }, function() {
        tip.hide();
    }).mousemove(function(e) {
        var mousex = e.pageX + 20;
        var mousey = e.pageY + 20;
        var tipWidth = tip.width(); 
        var tipHeight = tip.height(); 

        var tipVisX = $(window).width() - (mousex + tipWidth);
        var tipVisY = $(window).height() - (mousey + tipHeight);

        if ( tipVisX < 20 ) { 
            mousex = e.pageX - tipWidth - 20;
        } if ( tipVisY < 20 ) { 
            mousey = e.pageY - tipHeight - 20;
        }
        
        tip.css({  top: mousey, left: mousex });
    });

	//jCarousel lite (http://www.gmarwaha.com/jquery/jcarousellite/)
	$(function() {
	    $(".portfolio").jCarouselLite({
	        btnNext: ".next",
	        btnPrev: ".prev",
	        circular: false
	    });
	});
 
    //Portfolio Caption Overlay
    $('.item').hover(function() {             
        $(this).find('div.caption').stop(false,true).fadeIn(200);
    },
    function() { 
        $(this).find('div.caption').stop(false,true).fadeOut(500);
    });
    
});
