/**
Based on Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/
this.vtip = function () {
    this.xOffset = -10;
    this.yOffset = 10;
    $(".vtip").each(function(i) {
        if (this.title) {
            this.t = $('<div class="wrapper">'+this.title+'</div>');
            this.title = "";
        } else {
            this.t = $('#'+$(this).attr('content')).remove();
        }
        if ($(this).attr('vtip_width')) {
            this.t.css('width', parseInt($(this).attr('vtip_width')));
        }
        if ($(this).attr('vtip_font_size')) {
            this.t.css('font-size', parseInt($(this).attr('vtip_font_size'))).css('line-height', (parseInt($(this).attr('vtip_font_size'))+6)+'px');
        }
        this.align = $(this).attr('tipAlign')=='right'?'right':'left';
        this.i=i;
        $(this).unbind()
        .bind($(this).attr('startEvent')?$(this).attr('startEvent'):'mouseenter', function(a) {
            this.static = $(this).attr('static');
            this.offset = $(this).offset();
            this.top = this.static ? this.offset.top + parseInt($(this).attr('vtop')) : (a.pageY + yOffset);
            this.left = this.static ? this.offset.left + parseInt($(this).attr('vleft')) : (a.pageX + xOffset);
            if ($('#vtip_'+this.i).length==0) {
                $("body").append('<p class="_vtip" id="vtip_'+this.i+'"><img id="vtipArrow" /><span id="vtipbody"></span></p>');
            }
            $('#vtip_'+this.i+' #vtipbody').html(this.t);
            if (this.align=='right') {
                this.left = this.left-$("#vtip_"+this.i).width();
                $('#vtip_'+this.i+' #vtipArrow').css({'left':'auto','right':'12px'});
            }
            $("#vtip_"+this.i+" #vtipArrow").attr("src", "/assets/images/vtip_arrow.png");
            $("#vtip_"+this.i).css("top", this.top + "px").css("left", this.left + "px").fadeIn("fast")
        })
        .bind($(this).attr('stopEvent')?$(this).attr('stopEvent'):'mouseleave', function(a) {
            $("#vtip_"+this.i).fadeOut("fast", function() {$(this).remove()});
        })
        .mousemove(function (a) {
            if ($(this).attr('static') == 'true') return;
            this.top = (a.pageY + yOffset);
            this.left = (a.pageX + xOffset);
            this.left = $(this).attr('tipAlign')=='right'?this.left-$("#vtip_"+this.i).width():this.left;
            $("#vtip_"+this.i).css("top", this.top + "px").css("left", this.left + "px")
        });
    });
};
jQuery(document).ready(function (a) {
    vtip()
});
