$(document).ready(function(){
	$('a[title],span[title]').each(function(){
		var title = $(this).attr('title');
		$(this).removeAttr('title');
		var sup = $('<sup class="wtf">Что это?</sup>');
		sup.attr('title', title);
		sup.attr('rel', $(this).attr('rel'));
		sup.data('title', $(this).text());
		sup.insertAfter($(this));
	});

	$('sup.wtf[title]').each(function()
	{
        var arg = {
			show: { delay: 1 },
			content: {
				title: { text: $(this).data('title') }
			},
			style: {
				width: { min: 300 },
				title: { 'background-color': '#99cc00', 'color': '#fff' },
			}
		};
        if ($(this).attr('rel') == 'qtip_left')
        {
            arg.position = {
                corner:  {
                    target: 'bottomLeft',
                    tooltip: 'topRight'
                }
            };
        }

		$(this).qtip(arg);
	});

	/*
	 * .qtip-content {
		background-color: #ffffcc;
		}

	 */

	/*
	 * Debug
	 */
	$('a[href=#]').css('border', '1px dashed orange');
});
