function insertLoginForm( object , responseText ){
	object.innerHTML = "<span id=\"loginText\">Login Required</span>\n";
	object.innerHTML+= "<span id=\"usernameInputLabel\">Username:</span><input id=\"usernameInput\" type=\"text\" value=\"\" />\n";
	object.innerHTML+= "<span id=\"passwordInputLabel\">Password:</span><input id=\"passwordInput\" type=\"password\" value=\"\" />\n";
	object.innerHTML+= "<input onkeypress=\"if(event.keyCode==13) return authorise();\"onMouseDown=\"return authorise();\" id=\"submitButton\" type=\"submit\" value=\"Login\" />\n";
	object.innerHTML+= "<br/>\n";
	if( responseText != undefined )
		object.innerHTML += "<span id=\"loadingText\">" + responseText + "</span><br/><br/>\n";
	object.innerHTML+= "<img id=\"assertisLogo\" src=\"templates/admin/images/login-background.gif\" width=\"127\" height=\"32\" style=\"float: right; width:12.7em; height:3.2em;\" alt=\"Assertis LTD\" />\n";
	object.innerHTML+= "<br style=\"clear: both;\" />\n";
	object.innerHTML+= "<img id=\"corner-bottomleft\" src=\"templates/admin/images/login-corner-bottomleft.gif\" width=\"10\" height=\"10\" style=\"float: right; width:1em; height:1em;\" alt=\"corner\" />\n";
}

function handleAuthorise(){
	if( this.req.responseText == 1 )
		self.location = 'index.php';
	else
		insertLoginForm( document.getElementById( "loginBox" ) , "User not known or incorrect password" );
}

function authorise(){
	var username = document.getElementById( 'usernameInput' ).value;
	var password = document.getElementById( 'passwordInput' ).value;
	insertLoginForm( document.getElementById( "loginBox" ) , "Processing login, please wait" );
	var loader = new net.ContentLoader('dologin.php?user='+username+'&pass='+password, handleAuthorise );
}

window.onload = function(){
insertLoginForm( document.getElementById( "loginBox" ) );
}

