$(document).ready(function() {

    //Select all anchor tag with rel set to tooltip
    $('.have_tooltip').mouseover(function(e) {

        //Grab the title attribute's value and assign it to a variable
        var tip = $(this).children('.tooltip_content').html();

        //Remove the title attribute's to avoid the native tooltip from the browser
        var title = $(this).attr('title');
        $(this).attr('title','');
        $(this).attr('alt','');
        $(this).children('.tooltip_content').html(title);

        //Append the tooltip template and its value
        $('body').append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');

        var x = e.pageX;
        var y = e.pageY;
        //Set the X and Y axis of the tooltip
        $('#tooltip').css('top', y + 100 );
        $('#tooltip').css('left', x + 100 );


        //Show the tooltip with faceIn effect
        $('#tooltip').fadeIn('500');
        $('#tooltip').fadeTo('10',0.98);

    }).mousemove(function(e) {

        //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
        var x = e.pageX;
        var y = e.pageY;
        $('#tooltip').css('top', y + -30 );
        $('#tooltip').css('left', x + 30);

    }).mouseleave(function() {

        //Put back the title attribute's value
        $(this).attr('title',$(this).children('.tooltip_content').html());
        $(this).attr('alt',$(this).children('.tooltip_content').html());
        $(this).children('.tooltip_content').html($('.tipBody').html());

        //Remove the appended tooltip template
        $('body').children('div#tooltip').remove();

    });

});

$(document).ready(function() {

    //Select all anchor tag with rel set to tooltip
    $('.have_tooltip_parent').mouseover(function(e) {


        //Grab the title attribute's value and assign it to a variable
        var tip = $(this).parent().children('.tooltip_content').html();

        //Remove the title attribute's to avoid the native tooltip from the browser
        var title = $(this).attr('title');
        $(this).attr('title','');
        $(this).attr('alt','');
        $(this).parent().children('.tooltip_content').html(title);

        //Append the tooltip template and its value
        $('body').append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');

        var x = e.pageX;
        var y = e.pageY;
        //Set the X and Y axis of the tooltip
        $('#tooltip').css('top', y + 100 );
        $('#tooltip').css('left', x + 100 );


        //Show the tooltip with faceIn effect
        $('#tooltip').fadeIn('500');
        $('#tooltip').fadeTo('10',0.98);

    }).mousemove(function(e) {

        //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
        var x = e.pageX;
        var y = e.pageY;
        $('#tooltip').css('top', y + -30 );
        $('#tooltip').css('left', x + 30);

    }).mouseleave(function() {

        //Put back the title attribute's value
        $(this).attr('title',$(this).children('.tooltip_content').html());
        $(this).attr('alt',$(this).children('.tooltip_content').html());
        $(this).parent().children('.tooltip_content').html($('.tipBody').html());

        //Remove the appended tooltip template
        $('body').children('div#tooltip').remove();

    });

});

var inter = true;
var ckmenu;
function show_submenu(tip)
{
    //inter = false;
    $('#submenu').html(tip);
    //Show the tooltip with faceIn effect
    $('#submenu').fadeIn('500');
    //ckmenu = self.setInterval("clock_menu()",1500);
}

function clock_menu()
{
    clearInterval(ckmenu);
    inter = true;
}

$(document).ready(function() {

    //Select all anchor tag with rel set to tooltip
    $('.menu').mouseover(function(e) {

        //Grab the title attribute's value and assign it to a variable
        var tip = $(this).children('.submenu_content').html();
        //console.debug(inter);
        var menu = $('#menu1')
        if(menu)
        {
            menu.remove();
        }
        if(tip)
        {
            //console.debug(tip);
            //show_submenu(tip);
            $(this).parent().append('<div id="menu1">' + tip + '</div>');

            //Set the X and Y axis of the tooltip
            var x = $(this).position().left ;
            var y = $(this).position().top;
            $('#menu1').css('top', y + 59 );
            $('#menu1').css('left', x + 0);

            //Show the tooltip with faceIn effect
            $('#menu1').fadeIn('500');
            $('#menu1').fadeTo('10',1);
            $('#menu1 ul').mouseleave(function() {
                $('#menu1').remove();
            });
        }

    }).mousemove(function(e) {



    }).mouseout(function() {
        //$("#submenu").hide();
    });

});

$(document).ready(function() {

    //Select all anchor tag with rel set to tooltip
    var sel = $('.submenu_content ._active');
    if (sel)
    {
        sel.mouseover();
    }

});
