/**
 * This function wraps around the creation of a login dialog to ensure that the
 * browser is using a compatible version.
 */
function main(blankImageUrl, forgotPasswordUrl, submitUrl, error) {
	Ext.BLANK_IMAGE_URL = blankImageUrl;
	Ext.ns('DJS');
	
	Ext.onReady(function() {
		// Get the user agent info so that user information can be extracted
		var ua = navigator.userAgent.toLowerCase();
		
		// Test for supported browsers
		if (!(Ext.isChrome ||
		      Ext.isGecko && Ext.isGecko3 ||
			  Ext.isIE && Ext.isIE8 ||
			  Ext.isOpera ||
			  Ext.isSafari && (Ext.isSafari3 || Ext.isSafari4)))
		{
			createMessagePanel(
				'Incompatible Browser',
				'<p>Your browser is incompatible. Please use one of the ' +
				'following browsers of at least the listed versions:' +
				'</p><br />' +
				'<ul style="list-style: disc inside none">' +
				'<li>Apple Safari 3</li>' +
				'<li>Google Chrome 2</li>' +
				'<li>Internet Explorer 8</li>' +
				'<li>Mozilla Firefox 3</li>' +
				'<li>Opera 9</li>' +
				'</ul><br />' +
				'<p>This site was developed for Mozilla Firefox 3.5, so it is' +
				' recommended that you use that browser.</p><br />' +
				'<p>Note that if there is a later version than the one listed' +
				' here, it is probably wise to upgrade to the latest version ' +
				'(so long as it is not an alpha or beta version).</p>'
			);
		}
		
		// The browser version is fine, so show the dialog
		else {
			new DJS.Login({
				error: error,
				forgotPasswordURL: forgotPasswordUrl,
				renderTo: 'theform',
				submitURL: submitUrl
			});
		}
	});
}

function createMessagePanel(title, message) {
	new Ext.Panel({
		html: '<div style="margin: 10px">' + message + '</div>',
		renderTo: 'theform',
		style: 'font-size: 12px; font-weight: normal; text-align: left',
		title: title,
		width: 329
	});
}