$(document).ready(function() {
	if (window.fixPNG) fixPNG('#logo a, #member p.member-button a'); // magic global function, additional pngs to fix
		
	$('a[rel~=popup]').live("click", function(event) {
		if(event.button != ($.browser.msie ? 1 : 0) || event.ctrlKey || event.shiftKey || event.altKey) return; // bug: click bound to a live event detects right/middle buttons
		
		var url 	= event.target.href;
		var width 	= getURLParameter('w', url);
		var height 	= getURLParameter('h', url);
		var scroll 	= getURLParameter('s', url);
		
		openPopup(url, url, width, height, scroll);
		
		return false;
	});
	
});

function openPopup(mypage,myname,w,h,scroll)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
	
	var realname = myname.substring(1,4);
	
	window.open(mypage, realname, settings);
	return false;
}

function getURLParameter(name, url)
{
	url = (url != null)?url:window.location.href;
	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];
}