$(document).ready(function() {
        $('.tmp_user_set').click(function(e) {
            tip = $('.user_tip');
            tip.appendTo("body");
            tip.fadeIn();
            var mousex = e.pageX;
            var mousey = e.pageY;
            var tipWidth = tip.width(); 
            var tipHeight = tip.height(); 
            var e_height = $('body').height() - e.pageY;
            var e_width = $('body').width() - e.pageX;
            if(e_height < tipHeight)
                mousey = $('body').height() - tipHeight;
            if(mousey < 0)
                mousey = 0;
            if(e_width < tipWidth)
                mousex = $('body').width() - tipWidth;   
            tip.css({  top: mousey, left: mousex });
        })
        $('.tmp_user_s_cycle').click(function(e) {
            tip = $('.user_tip2');
            tip.appendTo("body");
            tip.fadeIn();
            var mousex = e.pageX;
            var mousey = e.pageY;
            var tipWidth = tip.width(); 
            var tipHeight = tip.height(); 
            var e_height = $('body').height() - e.pageY;
            var e_width = $('body').width() - e.pageX;
            if(e_height < tipHeight)
                mousey = $('body').height() - tipHeight;
            if(mousey < 0)
                mousey = 0;
            if(e_width < tipWidth)
                mousex = $('body').width() - tipWidth;     
            tip.css({  top: mousey, left: mousex });
        })
        $('.tmp_user_save').click(function(e) {
            window.location = "register.php"
        })
 $(".tip_trigger").hover(function(){
        
        tip = $(this).find('.tip'); 
        if($('.tip2').css('display') == 'none')
        tip.show(); //Show tooltip
        
         
    }, function() {
        tip.hide(); //Hide tooltip
    }).mousemove(function(e) {
        tip = $(this).find('.tip'); 
        var mousex = e.clientX; //Get X coodrinates
        var mousey = e.clientY; //Get Y coordinates

        //Absolute position the tooltip according to mouse position
        tip.css({  top: mousey, left: mousex });
    }).click(function(e){
        if($(this).find('.alert_exist').attr('value') == 1)
            tip2 = $('.tip3');
        else
            tip2 = $('.tip2');
         if($('.tip2').css('display') == 'none' && $('.tip3').css('display') == 'none')
        {
        tip2.appendTo("body");
        
        
        tip.hide();
            var mousex = e.pageX;
            var mousey = e.pageY;
            var tipWidth = tip2.width() + 200; 
            var tipHeight = tip2.height() + 300; 
            var e_height = $('body').height() - e.pageY;
            var e_width = $('body').width() - e.pageX;
            if(e_height < tipHeight)
                mousey = $('body').height() - tipHeight;
            if(mousey < 0)
                mousey = 0;
            if(e_width < tipWidth)
                mousex = $('body').width() - tipWidth;   
               
        tip2.css({  top: mousey, left: mousex });
        tip2.fadeIn();
        alert_day = $(this).find('.alert_day');
        alert_month = $(this).find('.alert_month');
        alert_year = $(this).find('.alert_year');
        c_alert_day = tip2.find('.c_alert_day');
        c_alert_month = tip2.find('.c_alert_month');
        c_alert_year = tip2.find('.c_alert_year');
        c_alert_day.text(alert_day.attr('value')+"/"); 
        c_alert_month.text(alert_month.attr('value')+"/");
        c_alert_year.text(alert_year.attr('value'));
        $('.event_day').attr('value', alert_day.attr('value'));
        $('.event_month').attr('value', alert_month.attr('value'));
        $('.event_year').attr('value', alert_year.attr('value'));
        }
        
    });    
        
});
