$(function() {
	
	// hover states on the static widgets
	$('.btn_link').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);

	// Popups	
	$('.mapLink').click(function() {
		popUp($(this).attr('href'), 950, 800);
		return false;
	});
	
	$('.popUp').click(function() {
		popUp($(this).attr('href'));
		return false;
	});
	
});

function popUp(url, width, height) {
	
	if (width == null) width = 800;
	if (height == null) height = 600;
	
	var centeredY = (screen.height - height)/2;
	var centeredX = (screen.width - width)/2;
	
	prevWin=window.open(url,"spop","left="+ centeredX+",top="+ centeredY+",scrollbars=YES,resizable=yes,width=" +width +",height="+height);
	if(prevWin.opener == null) prevWin.opener=self;
	prevWin.focus();
}

function toggleOverlay() {
	var overlay = $('#overlay');
	
	if (overlay.length) {	
		if (overlay.css('display') == 'none') {
			overlay.css('display', 'block');
		}
		else {
			overlay.css('display', 'none');
		}
	}
}
