function popUpWindow(URLStr, left, top, width, height, scroll, resize, winID)
{
	var winVar = this[winID];
	if(winVar) {
		if(!winVar.closed) winVar.close();
	}
	winVar = open(URLStr, winID, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + (scroll ? "yes" : "no") + ',resizable=' + (resize ? "yes" : "no") + ',copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function launchCopilot(whichCopilot, whichLanguage)
{
	var width, height, left, top, siteDir, languageFile;
	switch(whichCopilot) {
		case "sm":
			width =  screen.availWidth - 10;
			height =  screen.availHeight - 29;
			left = 0;
			top = 0;
			siteDir = "supermoto";
			languageFile = "sm_language_";
			break;
			
		case "ar":
			width = (screen.availWidth > 1280) ? 1278 : screen.availWidth - 10;
			height = (screen.availHeight > 1024) ? 1022 : screen.availHeight - 29;
			left = Math.floor((screen.availWidth - width) / 2) - 5;
			top = Math.floor((screen.availHeight - height) / 2) - 14;
			siteDir = "air_race";
			languageFile = "ar_language_";
			break;
			
		case "dh":
			width = (screen.availWidth > 1280) ? 1278 : screen.availWidth - 10;
			height = (screen.availHeight > 1024) ? 1022 : screen.availHeight - 29;
			left = Math.floor((screen.availWidth - width) / 2) - 5;
			top = Math.floor((screen.availHeight - height) / 2) - 14;
			siteDir = "downhill";
			languageFile = "dh_language_";
			break;
	}
	
	var sitePage = siteDir + "/launch.html?languageFile=" + languageFile + whichLanguage + ".xml";
	popUpWindow(sitePage, left, top, width, height, false, true, "siteWin");
		
}

function resizeMe(whichCopilot)
{
	var width, height, left, top;
	switch(whichCopilot) {
		case "sm":
			width =  screen.availWidth - 10;
			height =  screen.availHeight - 29;
			left = 0;
			top = 0;
			break;
			
		case "ar":
			width = (screen.availWidth > 1280) ? 1278 : screen.availWidth - 10;
			height = (screen.availHeight > 1024) ? 1022 : screen.availHeight - 29;
			left = Math.floor((screen.availWidth - width) / 2) - 5;
			top = Math.floor((screen.availHeight - height) / 2) - 14;
			break;
			
		case "dh":
			width = (screen.availWidth > 1280) ? 1278 : screen.availWidth - 10;
			height = (screen.availHeight > 1024) ? 1022 : screen.availHeight - 29;
			left = Math.floor((screen.availWidth - width) / 2) - 5;
			top = Math.floor((screen.availHeight - height) / 2) - 14;
			break;
	}
	
	/* Note
		we move the window twice to take supermoto in to account.
		failing to move the window to the upper left hand corner
		before resizing can fail to resize the window in some browsers
	*/
	this.window.moveTo(left, top);
	this.window.resizeTo(width, height);
	this.window.moveTo(left, top);
}