$(document).ready(function() {
    $('span.geo').each(function(index,el) {
		var e = $(el);
        var geo  = e.attr("geo");

        var param = "";
        if("undefined" != typeof(geo)) {
            param = 'geo='+geo;
        } else {
            var geodata = e.attr("address");
            if (typeof(geodata) == "undefined") geodata = e.text();
            param = 'geo='+geodata;
        }

        e.css("border-bottom","1px dashed").css("cursor","pointer").qtip({
            content: {
                text: $('<div id="loading" style="text-align:center;margin-top:135px;"><img style="vertical-align:middle;" src="http://geo.academ.org/i/loading.gif"></div><iframe src="http://geo.academ.org/?'+param+'"  width="1" height="1" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"><p>Необходима поддержка iframes для просмотра этого содержимого.</p></iframe>').load(function(){
					$(this).prev("div#loading").remove();
					$(this).width(400).height(300);
				})
            },
			style: {
				margin: 0,
				padding: 0,
				border: {
					width: 1,
					color: "#c0c0c0"
				},
				width: 402,
				height: 302
			},
            position: {
                target: false,
                corner: {
                    target: 'leftBottom'
                },
                adjust: {
                    screen: true
                }
            },
            hide: {
				delay: 500,
                fixed: true,
                when: 'mouseout'
            }
        });
    });
});