/**
 *  jQuery Tooltip Plugin
 *  @requires jQuery v1.3 or 1.4
 *  http://intekhabrizvi.wordpress.com/
 *
 *  Copyright (c)  Intekhab A Rizvi (intekhabrizvi.wordpress.com)
 *  Licensed under GPL licenses:
 *  http://www.gnu.org/licenses/gpl.html
 *
 *  Version: 1.0
 *  Dated : 21-Jan-2010
 */
(function($) {
        jQuery.fn.tooltip = function(text,options){
                 var defaults = {
                    offsetX: 10,  //X Offset value
                    offsetY: -30,  //Y Offset value
                    bordercolor: '#000000', // tooltip border color
                    bgcolor: '#F7F6F0', //Tooltip background color
                    fontcolor : '#000000', //Tooltip Font color
                    fontsize : '15px', // Tooltip font size
                    folderurl : 'NULL', // Folder url, where the tooltip's content file is placed, needed with forward slash in the last (/), or can be use as http://www.youwebsitename.com/foldername/ also.
                    filetype: 'txt' // tooltip's content files type, can be use html, txt
                   };
        var options = $.extend(defaults, options);
        return this.each(function(){
        //Runtime div building to hold tooltip data, and make it hidden
                        $tooltip = $('<div id="divToolTip"></div>');
                        $('body').append($tooltip);
                        $tooltip.hide();
        //Runtime variable definations
                var element = this;
                var id = $(element).attr('id');
                var dialog_id = '#divToolTip';
        //Tooltips main function
                $(this).hover(function(e){
                                //edited 23.1.2010
                                $(dialog_id).html(text);
                                //enable div block
                                $(dialog_id).attr('style', 'display:block');
                                //assign css value to div
                                $(dialog_id).css({
                                        'position' : 'absolute',
                                        'border' : '1px solid ' + options.bordercolor,
                                        'background-color' : options.bgcolor,
                                        'padding' : '5px 5px 5px 5px',
                                        '-moz-border-radius' : '5px 5px 5px 5px',
                                        'top' : e.pageY + options.offsetY,
                                        'left' : e.pageX + options.offsetX,
                                        'color' : options.fontcolor,
                                        'font-size' : options.fontsize,
										'z-index' : '100'
                                });
                                        },function(){
                                // when mouse out remove all data from div and make it hidden
                                $(dialog_id).html("");
                                $(dialog_id).attr('style', 'display:none');

                                        }).mousemove(function(e){
                                // to make tooltip moveable with mouse
                                $(dialog_id).css({
                                        'position' : 'absolute',
                                        'border' : '1px solid ' + options.bordercolor,
                                        'background-color' : options.bgcolor,
                                        'padding' : '5px 5px 5px 5px',
                                        '-moz-border-radius' : '5px 5px 5px 5px',
                                        'top' : e.pageY + options.offsetY,
                                        'left' : e.pageX + options.offsetX,
                                        'color' : options.fontcolor
                                });
                                        });
                });
        };
 })(jQuery);
