(function(jQuery){
        jQuery.fn.tooltips = function( ) {
            this.each(function(){
                var img = jQuery(this).find( 'img' );
                var text = jQuery(img).attr("alt") ;
                var theme = jQuery(img).attr("rel") ;
                jQuery(this).mouseenter( function(){
                    jQuery('#tooltip').hide();
                    jQuery('#tooltip-text').html( text );
                    var position = img.position();
                    if(theme=="small"){
                        $("#tooltip").css("width", "150px");
                        
                        $("#tooltip .header").css("width", "120px");
                        $("#tooltip .content").css("width", "120px");
                        $("#tooltip .content div").css("width", "105px");
                        $("#tooltip .footer").css("width", "120px");
                        $("#tooltip .header").css("background-image", "url(css/tooltip/header_small.png)");
                        $("#tooltip .content").css("background-image", "url(css/tooltip/body_small.png)");
                        $("#tooltip .footer").css("background-image", "url(css/tooltip/footer_small.png)");
                        jQuery('#tooltip').css({
                            top: (parseInt(position.top )  + 36 ),
                            left: (parseInt(position.left) - 38)
                        }).show();
                        
                    } else {
                        $("#tooltip").css("width", "160px");
                        $("#tooltip .header").css("width", "160px");
                        $("#tooltip .content").css("width", "160px");
                        $("#tooltip .content div").css("width", "150px");
                        $("#tooltip .footer").css("width", "160px");
                        $("#tooltip .header").css("background-image", "url(css/tooltip/header.png)");
                        $("#tooltip .content").css("background-image", "url(css/tooltip/body.png)");
                        $("#tooltip .footer").css("background-image", "url(css/tooltip/footer.png)");
                        jQuery('#tooltip').css({
                            top: (parseInt(position.top )  + 36 ),
                            left: (parseInt(position.left) - 58)
                        }).show();
                    }
                    
                    
                });
                jQuery(this).mouseout( function(){
                    jQuery('#tooltip').hide();
                    if(theme=="small"){
                        $("#tooltip").css("width", "160px");
                        $("#tooltip .header").css("width", "160px");
                        $("#tooltip .content").css("width", "160px");
                        $("#tooltip .content div").css("width", "160px");
                        $("#tooltip .footer").css("width", "160px");
                        $("#tooltip .header").css("background-image", "url(css/tooltip/header.png)");
                        $("#tooltip .content").css("background-image", "url(css/tooltip/body.png)");
                        $("#tooltip .footer").css("background-image", "url(css/tooltip/footer.png)");
                    }
                });
            });
        };
})(jQuery);




