Guide for created a tooltip simple?

Why in following code(example) tooltip box come out from page, how can it fix as automatic(dynamic) with page that not come out from page?

Demo: (i mane is about how that mouse over on it display toltip box out page) SEE image:

$('li a').hover(function() {

    var title = $(this).next('.tooltip').html();
    var offset = $(this).offset();

    $tooltip = $('<div />').addClass('show_tooltip').html(title);

    var delay = setTimeout(function() {

        var width = $tooltip.outerWidth();

        var p_top =;
        var p_left = offset.left - width; 
        $tooltip.css({top: p_top, left: p_left}).fadeIn(180);


    $(this).data('delay', delay);
    $(this).data('tooltip', $tooltip);

},function() {

    delay = $(this).data('delay');
    $tooltip = $(this).data('tooltip');