function fixmailtos() {
	for (var i=0; i<document.links.length; i++) {
		if (document.links[i].href.substr(0,7) == "mailto:") {
			document.links[i].href.replace(/ ?AT ?/, "@");
			document.links[i].href.replace(/ ?DOT ?/, ".");
		}
	}
}

function install(url) {
	if (checkIsMoz() ||
		window.confirm("This software is designed for the mozilla browser. You do not appear to be using mozilla at the moment, do you want to continue anyway?")
		) {
		// trigger the install
		if (InstallTrigger.updateEnabled()) {
	        	InstallTrigger.startSoftwareUpdate(url);
		} else {
	        	window.alert("Software installation has been disabled in your browser.");
		}
	}
	return;
}

function playGame(url,width,height,title) {
	// check that we're using mozilla
	// if not, ask user does he want to proceed anyway
	if (checkIsMoz() ||
		window.confirm("This software is designed for the mozilla browser. You do not appear to be using mozilla at the moment, do you want to continue anyway?")
		) {
		// set the features of the new window
		var features = "centerscreen,chrome,close,titlebar,resizable";
		// including width and height if specified
		if (width && height) {
			features += ",width=" + width + ",height=" + height;
		}
		// set the title if not set
		if (!title) {
			title = "Mozilla";
		}
		// if nn7, just open the xul window (doesn't work otherwise, for some reason)
		if (checkIsNN7()) {
			window.open(url,'game_window',features);
		} else {
			// open new blank window 
			var xulwin = window.open('','game_window',features);
			// set the window to display some text while the xul page is loading
			var loadingtext = "Loading...";
			xulwin.document.write("<html><head><title>" + title + "</title></head><body><br><p align='center'><strong>" + loadingtext + "</strong></p></body></html>");
			xulwin.document.close();
			// reload with xul location
			xulwin.location = url;
		}
	}
}

function checkIsMoz() {
	return (navigator.userAgent.indexOf("Gecko") != -1);
}

function checkIsNN7() {
	return (navigator.userAgent.indexOf("Netscape/7") != -1);
}
