// Open links to other domains in a new window
function convert_links(obj) {
	$(obj).find('a').bind('click', function(e) {
		var urldomain = this.href.replace('http://','').replace('https://','').split(/[/?#]/)[0];
		if (document.domain != urldomain) {
			e.preventDefault();
			var l = Math.floor(screen.width / 20);
			var w = Math.floor(l * 18);
			var t = Math.floor(screen.height / 20);
			var h = Math.floor(t * 15);
			window.open(this.href, '_blank', 'left='+l+',top='+t+',width='+w+',height='+h+',toolbar=1,status=1', false);
		}
		else return true;
	});
}


// Extracts a GET variable from a passed URL
function getvar(url,name) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( url );
	if( results == null ) return "";
		else return results[1];
}


$(document).ready(function() {

	convert_links(document);

});

