var applicationWindow;

function startIntraMaps(projectModule) {

	var availHeight = window.screen.availHeight;
	var	availWidth	= window.screen.availWidth;

	var tooSmall = ( document.bandwidthSelector.bandwidth[1].checked && (availWidth <= 800 && availHeight <= 600) );

	if( tooSmall ) {
		alert( "Your display resolution must be greater than 800x600 pixels to display high bandwidth maps." );
	}

	var width, height, top, left, highBandwidth;

	if( tooSmall || document.bandwidthSelector.bandwidth[0].checked ) {

		// Low bandwidth
		highBandwidth = "false";

		width	= 767;
		height	= 570;

		// Calculate top and left so that the window is centred
		top		= Math.round( (availHeight/2) - (height/2) );
		left	= Math.round( (availWidth/2) - (width/2) );

		// Just position at 0 if the Application top is small, as it's probably a small screen
		// and the toolbar height will cause the window to be partly offscreen
		if( top < 50 ) top = 2;

	} else {

		// High bandwidth
		highBandwidth = "true";

		width	= availWidth;
		height	= availHeight;

		top	= 0;
		left	= 0;
	}

	var dimensionParameters = "highBandwidth=" + highBandwidth + "&width=" + width + "&height=" + height;

	var url;
	if( projectModule != "" ){

		// Parameters - send user straight to application (such as http:ApplicationEngine///server/intramaps/Application.aspx?project=Demo&module=Swimming Pools)
		url = "ApplicationEngine/Application.aspx" + projectModule + "&" + dimensionParameters;

	} else {

		// No query string, send user to project selector
		url = "ApplicationEngine/Project.aspx?" + dimensionParameters;
	}

	// If the application window already exists close it to avoid session unloading deadlocks
	try{
		if( typeof applicationWindow != 'undefined' ) applicationWindow.close();
	} catch(e){}

	applicationWindow = window.open( url, "IntraMapsPublic", 'resizable=no,location=no,status=yes,menubar=no', false );

	// Position and size window, and bring to the front
	try{	applicationWindow.moveTo( left, top );			}catch(e){}
	try{	applicationWindow.resizeTo( width, height );	}catch(e){}
	try{	applicationWindow.focus();						}catch(e){}
}