var response;
var pwd_new;
var ext_phone;
var un_current;

function createRequestObject() {
	var ro;
 	var browser = navigator.appName;
 	if(browser == "Microsoft Internet Explorer"){
    	ro = new ActiveXObject("Microsoft.XMLHTTP");
 	}
 	else{
    	ro = new XMLHttpRequest();
 	}
 	return ro;
}

var httpRequest = createRequestObject();

function sendOldPassword() {	
	get_info_reset();	
	httpRequest.open("GET", "/ForgotPassword?ext_phone=" + ext_phone +"&un_current=" + un_current, true);
	httpRequest.onreadystatechange = checkResponse;	
	httpRequest.send(null);	
}

function checkResponse() {
	if(httpRequest.readyState == 4){
		if(httpRequest.status == 200){	
			response = httpRequest.responseText;	//response = match
			if (response==0){
				document.getElementById('error_msg').innerHTML = "Ooops! something is wrong with your information!";
			}
			else if (response==1){
			    document.getElementById('error_msg').innerHTML = "Check your email!";
			}
		}
 	}
}
//==========================GET USERNAME AND NEW PASSWORD==================================================
function get_info_reset(){
	un_current = document.getElementById('un_reset').value;
	
	
	//ext_phone = document.getElementById('ext_phone_reset').value;
	
	var ext_phone1 = 0 //document.getElementById('ext_phone_reset1').value;
	var ext_phone2 = 0 //document.getElementById('ext_phone_reset2').value;
	var ext_phone3 = 0 //document.getElementById('ext_phone_reset3').value;
	
	ext_phone = "1"+ext_phone1+ext_phone2+ext_phone3;	
	document.getElementById('error_msg').innerHTML = "hold on...";
	//pwd_new = document.getElementById('pwd_reset').value;
		
}
