// Functions for chart window navigation:

//OpenMusicChart(genre) - Attempts to open a new browser window with the desired music chart,
//		waits 1 second in case a brute force pop-up blocker rears its ugly head, then checks
//		if the new window was killed. If it was, load the page in current window.

var WUSRChartWindow;
var page;

function OpenMusicChart(genre) {
	page = 'charts/' + genre + '.html';
	WUSRChartWindow = window.open(page, "WUSRChartWindow",
													"width=550,height=400,status=no,resizable=yes,location=no,menubar=no,scrollbars=yes");
	window.setTimeout("ConfirmChart()", 1000);
	//Since browser supports Javascript, return false to keep it from following the link:
	return false;
}

//ConfirmChart() : Checks if new window still exists. If not, load page in current window.
function ConfirmChart() {
	if(WUSRChartWindow.closed) {
		window.location.href = page;
	}
}

//PrintCloseMessage() - Spits out code for closing the chart window, if the chart was opened
//		in a new window. Otherwise, go back to main charts page.
function PrintCloseMessage() {
	if(window.name == "WUSRChartWindow") {
		document.write('<a href="javascript:window.close()" class="bodylink">Close Window</a>');
	} else {
		document.write('<a href="../charting.html" class="bodylink">Back to Charts</a>');
	}
}
