/* Sticky Tooltip script (v1.0)
* Created: Nov 25th, 2009. This notice must stay intact for usage 
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/
var spQCTTooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    stickynotice2: "Click outside this box to hide it", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (spQCTTooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            //$tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        //$tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.tooltip-content')
            if (!spQCTTooltip.rightclickstick)
                spQCTTooltip.stickynotice1[1] = ''
            spQCTTooltip.stickynotice1 = spQCTTooltip.stickynotice1.join(' ')
            spQCTTooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                spQCTTooltip.showbox($, $tooltip, e)
            })

            $targets.bind('mouseleave', function (e) {
                spQCTTooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!spQCTTooltip.isdocked) {
                    spQCTTooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                spQCTTooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    spQCTTooltip.isdocked = false
                    spQCTTooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (spQCTTooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    spQCTTooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    spQCTTooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//spHotTooltip.init("targetElementSelector", "tooltipcontainer")
spQCTTooltip.init("*[data-tooltip]", "spQCTTooltip");

/*...............................*/

var spQCTooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    stickynotice2: "Click outside this box to hide it", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (spQCTooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            //$tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        //$tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.tooltip-content')
            if (!spQCTooltip.rightclickstick)
                spQCTooltip.stickynotice1[1] = ''
            spQCTooltip.stickynotice1 = spQCTooltip.stickynotice1.join(' ')
            spQCTooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                spQCTooltip.showbox($, $tooltip, e)
            })

            $targets.bind('mouseleave', function (e) {
                spQCTooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!spQCTooltip.isdocked) {
                    spQCTooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                spQCTooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    spQCTooltip.isdocked = false
                    spQCTooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (spQCTooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    spQCTooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    spQCTooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//spHotTooltip.init("targetElementSelector", "tooltipcontainer")
spQCTooltip.init("*[data-tooltip]", "spQCTooltip");

/*...............................*/

var spHotTooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    stickynotice2: "Click outside this box to hide it", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (spHotTooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            //$tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        //$tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.tooltip-content')
            if (!spHotTooltip.rightclickstick)
                spHotTooltip.stickynotice1[1] = ''
            spHotTooltip.stickynotice1 = spHotTooltip.stickynotice1.join(' ')
            spHotTooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                spHotTooltip.showbox($, $tooltip, e)
            })

            $targets.bind('mouseleave', function (e) {
                spHotTooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!spHotTooltip.isdocked) {
                    spHotTooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                spHotTooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    spHotTooltip.isdocked = false
                    spHotTooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (spHotTooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    spHotTooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    spHotTooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//spHotTooltip.init("targetElementSelector", "tooltipcontainer")
spHotTooltip.init("*[data-tooltip]", "myspHotTooltip");

/***********************/

var spKhuyenMaiTooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    stickynotice2: "Click outside this box to hide it", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (spKhuyenMaiTooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            $tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        $tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.tooltip-content')
            if (!spKhuyenMaiTooltip.rightclickstick)
                spKhuyenMaiTooltip.stickynotice1[1] = ''
            spKhuyenMaiTooltip.stickynotice1 = spKhuyenMaiTooltip.stickynotice1.join(' ')
            spKhuyenMaiTooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                spKhuyenMaiTooltip.showbox($, $tooltip, e)
            })

            $targets.bind('mouseleave', function (e) {
                spKhuyenMaiTooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!spKhuyenMaiTooltip.isdocked) {
                    spKhuyenMaiTooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                spKhuyenMaiTooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    spKhuyenMaiTooltip.isdocked = false
                    spKhuyenMaiTooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (spKhuyenMaiTooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    spKhuyenMaiTooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    spKhuyenMaiTooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//spKhuyenMaiTooltip.init("targetElementSelector", "tooltipcontainer")
spKhuyenMaiTooltip.init("*[data-tooltip]", "myspKhuyenMaiTooltip");

/******************************/

var spMoiTooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    stickynotice2: "Click outside this box to hide it", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (spMoiTooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            $tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        $tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.tooltip-content')
            if (!spMoiTooltip.rightclickstick)
                spMoiTooltip.stickynotice1[1] = ''
            spMoiTooltip.stickynotice1 = spMoiTooltip.stickynotice1.join(' ')
            spMoiTooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                spMoiTooltip.showbox($, $tooltip, e)
            })

            $targets.bind('mouseleave', function (e) {
                spMoiTooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!spMoiTooltip.isdocked) {
                    spMoiTooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                spMoiTooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    spMoiTooltip.isdocked = false
                    spMoiTooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (spMoiTooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    spMoiTooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    spMoiTooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//spMoiTooltip.init("targetElementSelector", "tooltipcontainer")
spMoiTooltip.init("*[data-tooltip]", "myspMoiTooltip");


/********************************/


var spNoiBatTooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    stickynotice2: "Click outside this box to hide it", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (spNoiBatTooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            $tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        $tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.tooltip-content')
            if (!spNoiBatTooltip.rightclickstick)
                spNoiBatTooltip.stickynotice1[1] = ''
            spNoiBatTooltip.stickynotice1 = spNoiBatTooltip.stickynotice1.join(' ')
            spNoiBatTooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                spNoiBatTooltip.showbox($, $tooltip, e)
            })

            $targets.bind('mouseleave', function (e) {
                spNoiBatTooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!spNoiBatTooltip.isdocked) {
                    spNoiBatTooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                spNoiBatTooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    spNoiBatTooltip.isdocked = false
                    spNoiBatTooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (spNoiBatTooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    spNoiBatTooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    spNoiBatTooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//spNoiBatTooltip.init("targetElementSelector", "tooltipcontainer")
spNoiBatTooltip.init("*[data-tooltip]", "myspNoiBatTooltip");

/***************************************/

var SanPhamTooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: false, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    stickynotice2: "Click outside this box to hide it", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (SanPhamTooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            $tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        $tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.tooltip-content')
            if (!SanPhamTooltip.rightclickstick)
                SanPhamTooltip.stickynotice1[1] = ''
            SanPhamTooltip.stickynotice1 = SanPhamTooltip.stickynotice1.join(' ')
            SanPhamTooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                SanPhamTooltip.showbox($, $tooltip, e)
            })

            $targets.bind('mouseleave', function (e) {
                SanPhamTooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!SanPhamTooltip.isdocked) {
                    SanPhamTooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                SanPhamTooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    SanPhamTooltip.isdocked = false
                    SanPhamTooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (SanPhamTooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    SanPhamTooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    SanPhamTooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//SanPhamTooltip.init("targetElementSelector", "tooltipcontainer")
SanPhamTooltip.init("*[data-tooltip]", "mySanPhamTooltip");

/***************************************/

var spTuongTuTooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to sticky box"], //customize tooltip status message
    stickynotice2: "Click outside this box to hide it", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (spTuongTuTooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            //$tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        //$tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.tooltip-content')
            if (!spTuongTuTooltip.rightclickstick)
                spTuongTuTooltip.stickynotice1[1] = ''
            spTuongTuTooltip.stickynotice1 = spTuongTuTooltip.stickynotice1.join(' ')
            spTuongTuTooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                spTuongTuTooltip.showbox($, $tooltip, e)
            })

            $targets.bind('mouseleave', function (e) {
                spTuongTuTooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!spTuongTuTooltip.isdocked) {
                    spTuongTuTooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                spTuongTuTooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    spTuongTuTooltip.isdocked = false
                    spTuongTuTooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (spTuongTuTooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    spTuongTuTooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    spTuongTuTooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//spTuongTuTooltip.init("targetElementSelector", "tooltipcontainer")
spTuongTuTooltip.init("*[data-tooltip]", "myspTuongTuTooltip");




