function doLogin(userNameId, passwordId, dbPath, specialURL){
	dojo.xhrPost({
		url: "/names.nsf?login",
		content: {
			username: dojo.byId(userNameId).value, 
			password: dojo.byId(passwordId).value
		},
		load: function(data) {
			if (specialURL)
				window.location.href = specialURL;
			else
				window.location.href = window.location.href;
		},
		error: function(data) {
			if (specialURL)
				window.location.href = specialURL;
			else
				window.location.href = window.location.href;
		} 
	});
	return false;
}

function resetPassword(buttonId, emailId){
	dojo.byId(buttonId).style.display = "none";
	dojo.byId("ajaxresponseholder").innerHTML = "<img src=\"" + dbPath + "/loading.gif\" />";
	dojo.xhrPost({
		url: dbPath + "/resetPassword",
		content: {
			username: dojo.byId(emailId).value 
		},
		load: function(data) {
			dojo.byId("ajaxresponseholder").innerHTML = data;
			if(data.indexOf("has not been registered") > -1)
				dojo.byId(buttonId).style.display = "inline";
		},
		error: function(data) {
			dojo.byId("ajaxresponseholder").innerHTML = data;
			dojo.byId(buttonId).style.display = "inline";
		} 
	});
	return false;
}

function changePassword(buttonId, passwordId, confirmpasswordId){
	if (dojo.byId(passwordId).value != dojo.byId(confirmpasswordId).value){
		dojo.byId("ajaxresponseholder").innerHTML = "Please make sure that the two passwords match";
		return false;
	}else if(dojo.byId(passwordId).value == ""){
		dojo.byId("ajaxresponseholder").innerHTML = "Please enter a new password";
		return false;
	}else{
		dojo.byId(buttonId).style.display = "none";
		dojo.byId("ajaxresponseholder").innerHTML = "<img src=\"" + dbPath + "/loading.gif\" />";
		dojo.xhrPost({
			url: dbPath + "/changePassword",
			content: {
				username: username, 
				password: dojo.byId(passwordId).value 
			},
			load: function(data) {
				dojo.byId("ajaxresponseholder").innerHTML = data;
			},
			error: function(data) {
				dojo.byId("ajaxresponseholder").innerHTML = data;
				dojo.byId(buttonId).style.display = "block";
			} 
		});
	}
	return false;
}

var nn=(document.layers)?true:false;
var ie=(document.all)?true:false;
function getKeyPressed(e) {
	var evt = window.event? event : e;
	var iKey = (evt.charCode)?evt.charCode: ((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
	return iKey;
}

