(function ($) {

    $.fundsPopup = function (el, options) {
        var self = this,
			node = $(el),
			popup = $('#fundsPopup'),
			popupClose = $('.f-popup-close', popup),
			links = $('.p-link', node);

		node.data('fundsPopup', this);

		/**
		 *	Initializing
		 */
        this.init = function () {
            this.options = $.extend({}, $.fundsPopup.defaultOptions, options);
			this.active = -1;

			links.click(this._show);
			popupClose.click(this._hide);
        };

		/**
		 *  Event for "show/hide" popup
		 */
		this._show = function () {
			popup.hide();
			popup.css({
				'left': $(this).offset().left + $(this).width(),
				'top': $(this).offset().top
			});

			var text = $(this).next().html();

			popup.find('.f-popup-content').html(text);
			popup.show();

			return false;
		};

		/**
		 *  Event for "close" popup
		 */
		this._hide = function () {
			popup.hide();
			return false;
		};

        this.init();
    };

    $.fundsPopup.defaultOptions = {
		
    };

    $.fn.fundsPopup = function (options) {
        return this.each(function () {
            (new $.fundsPopup(this, options));
        });
    };

})(jQuery);
