(function ($) {
    $.fn.mailto = function (options) {
        var opts = $.extend({},$.fn.mailto.defaults, options);
        // iterate and reformat each matched element
        return this.each(function () {
            $this = $(this);
            // build element specific options
            var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
            var address = $this.html();
            // call our format function
            link = $.fn.mailto.format(address, opts);
            $this.html(link);
        });
    };
    // plugin defaults
    $.fn.mailto.defaults = {
        at: '@',
        domain: 'rubi',
        extension: 'pl',
        country : '' /* like br, au, uk... */,
        dot : '.',
        nazwa : 'rubi'
    };
    // Format and returns the mailto link
    $.fn.mailto.format = function (txt, opts) {
    	//var mail = $.trim(txt) + opts.nazwa + opts.at + opts.domain + opts.dot + opts.extension + ((opts.country!='') ? opts.dot + opts.country : '');
		if ($.trim(txt)=='astalavista')
		{
		    	var mail = opts.nazwa + opts.at + opts.domain + opts.dot + opts.extension + ((opts.country!='') ? opts.dot + opts.country : '');
		}
    	var ahref = $('<a></a>');
    	ahref
    		.attr('href','mailto:' + mail)
    		.attr('class','mail')
    		.html(mail);
    	return ahref;
    };
})(jQuery);

$(document).ready(function(){
		$('span.mail').mailto({});
});
