function JS_login_authenticated(){
	if(AJAX_http.readyState == 4){
		resp = AJAX_http.responseText;
		//alert(resp);
		
		if(resp == 1){
			sta  = "";
			if(document.getElementById('retP')){
				act = document.getElementById('retP').value;
				if(document.getElementById('retS')){
					sta = "&stage=" + document.getElementById('retS').value;
				}
			}else{
				act = 32;
			}

			document.location= "redirect3.php?action_val=" + act + sta;
			JS_login_attempts = 0;
		}else if(resp == 2){
			JS_login_attempts = 0;
			alert("Your details could not be recognised - please contact us to reset your username and password");
		}else{
			alert("Login failed - please check your username and password");
			JS_login_attempts +=1;
		}
		if( JS_login_attempts > 2){
			JS_ajax_process(me.site + '/12july07/ajax/AJ_login.php?f=1', 'JS_login_authenticated', 'get');	
		}
	}
}

var me = new base();

function login_logging(thisIn, num){
	JS_ajax_process(me.site + '/12july07/ajax/AJ_login.php' + '?u=' + document.getElementById(thisIn.id + "usr").value + '&p=' + document.getElementById(thisIn.id + "pwd").value + '&l=' + num, 'JS_login_authenticated', 'get');
	return false;
}

function JS_login_goto(thisIn){
	if(document.getElementById('retP')){
		newLoc = thisIn.href + "&r=" + document.getElementById('retP').value;
		if(document.getElementById('retP')){
			newLoc += "&stage=" + document.getElementById('retS').value;
		}
		document.location = newLoc;
		return false;
	}
}

function JS_login_pressEnter(evt, idIn){
	var tSub = document.getElementById(idIn);
	if(evt.keyCode == 13){
		login_logging(tSub, 99);
		return false;
	}
}

function JS_login_enter_submit(num, idIn){
	if(event.keyCode == 13){
		document.getElementById(idIn).focus();
		JS_login_submit(num, idIn);

	}
}

function JS_login_submit(num, idIn){
	document.getElementById('login_b1').value = document.getElementById(idIn + "usr").value;
	document.getElementById('login_b2').value = document.getElementById(idIn + "pwd").value;
	return true;
}




contextActions.contextTest2 = function(T_id, T_ref){
	alert("the other choice.");
}