//

//Load IP info. Written by GeorgeMoney using Wizardry Dragon's API
var data_ipinfo = new Object();
function ip_callback(data) {
	data_ipinfo = data;
}
try { 
	var ip_regex = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
	if(ip_regex.test(wgTitle)
		||ip_regex.test(location.href.split('/')[location.href.split('/').length - 1].split('?')[0])
		||ip_regex.test(location.href.split('target=')[1].split('&')[0])
	) {
		var ip_use = ip_regex.test(wgTitle)?wgTitle:location.href.replace(/^.*?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*?$/, '$1');
		document.write('<script src="http://hemlock.knams.wikimedia.org/~wizardrydragon/lookup_hostmask.php?ip='+ip_use+'&format=json&lang='+wgContentLanguage+'&callback=ip_callback"></script>');
		document.write(
		'<style type="text/css">'+
		'.ip-info {'+
		'border: 3px solid red;'+
		'padding: 5px;'+
		'background: honeydew'+
		'}'+
		'.ip-info li {'+
		'margin-left: 2em;'+
		'}'+
		'</style>');
		addOnloadHook(function() {
			var tbs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
			addlilink(tbs, "javascript:/*void(load_ipinfo()); */void(get_ipinfo());", "ip info", 'ca-ipinfo', 'Get ip info');
		});
		function iterate_data(newdiv, dat) {
			for(var x in dat) {
				if(typeof dat[x] == 'object') {
					iterate_data(newdiv, dat[x]);
				} else {
					newdiv.innerHTML += '<li><b>'+x+'</b>: '+dat[x]+'</li>\n';
				}
			}
		}
		function load_ipinfo() {
			var script = document.createElement('script');
			script.src = 'http://hemlock.knams.wikimedia.org/~wizardrydragon/lookup_hostmask.php?ip='+ip_use+'&format=json&lang='+wgContentLanguage+'&callback=ip_callback';
			document.getElementsByTagName('head')[0].appendChild(script);
		}
		function get_ipinfo() {
			var newdiv = document.createElement('div');
			newdiv.className = 'ip-info';
			newdiv.id = 'ip-info';
			newdiv.innerHTML = 'IP info for '+ip_use+' <small>(retrieved from <a href="http://hemlock.knams.wikimedia.org/~wizardrydragon/lookup_hostmask.php?ip='+ip_use+'&lang='+wgContentLanguage+'">http://hemlock.knams.wikimedia.org/~wizardrydragon/lookup_hostmask.php?ip='+ip_use+'&lang='+wgContentLanguage+'</a></small>)<br>';
			newdiv.innerHTML += '<ul>';
			iterate_data(newdiv, data_ipinfo);
			newdiv.innerHTML += '</ul>';
			document.getElementById('content').insertBefore(newdiv, document.getElementById('content').getElementsByTagName('h1')[0].nextSibling);
			document.getElementById('ca-ipinfo').firstChild.innerHTML = 'Collapse IP info';
			document.getElementById('ca-ipinfo').firstChild.href = 'javascript:void(hide_ipinfo())';
		}
		function hide_ipinfo() {
			document.getElementById('ca-ipinfo').firstChild.innerHTML = 'ip info';
			document.getElementById('ca-ipinfo').firstChild.href = 'javascript:void(show_ipinfo())';
			document.getElementById('ip-info').style.display = 'none';
		}
		function show_ipinfo() {
			document.getElementById('ca-ipinfo').firstChild.innerHTML = 'Collapse IP info';
			document.getElementById('ca-ipinfo').firstChild.href = 'javascript:void(hide_ipinfo())';
			document.getElementById('ip-info').style.display = 'block';
		}
	}
} catch(e) {  }
//