function showCustPassword()
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert (ajaxErrMsg);
		return;
	}
	loadAccPage(true, null);
	var url = 'account_Password.php?purpose=showCustPassword&'+Math.random();
	xmlHttp.onreadystatechange = stateChanged_showCustPassword;
	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);
}
function stateChanged_showCustPassword()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{
		if (xmlHttp.responseText.indexOf('E~X~P~I~R~E~D') != -1)
			window.location = 'login.php?m=2';
		else
			loadAccPage(false, xmlHttp.responseText);
	}
}

function validPassword()
{
	var form = document.getElementById('PasswordForm');
		if (form.oldPw.value.length < 4)
		{
			alert ('Old password must have at least 4 characters!');
			form.oldPw.focus();
			return false;
		}
		if (!IsPasswordOk(form.NewPw, form.NewPwV)) return false;
	saveCustPasswordForm(form);
}
function saveCustPasswordForm(form)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert (ajaxErrMsg);
		return false;
	}
	var postVars = makeCustPwdPostVars(form);
	document.getElementById('statusSavePwd').innerHTML = '&nbsp;';
	document.getElementById('btnSavePassword').disabled = true;	
	document.getElementById('statusLoaderPwd').style.display = '';
	var url = 'account_Password.php?purpose=saveCustPasswordForm&'+Math.random();
	xmlHttp.onreadystatechange = stateChanged_saveCustPasswordForm;
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xmlHttp.setRequestHeader('Content-length', postVars.length);
	xmlHttp.setRequestHeader('Connection', 'close');
	xmlHttp.send(postVars);
}
function stateChanged_saveCustPasswordForm()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{
		document.getElementById('btnSavePassword').disabled = false;
		document.getElementById('statusLoaderPwd').style.display = 'none';
		if (xmlHttp.responseText.indexOf('E~R~R~O~R') != -1)
			document.getElementById('statusSavePwd').innerHTML = '<font color="#FF0000">' + xmlHttp.responseText.split('HAM~JAM')[1] + '</font>';
		else
		{
			document.getElementById('statusSavePwd').innerHTML = xmlHttp.responseText;			
		}
		resetAccForm();
	}
}

function makeCustPwdPostVars(form)
{
	var postVars = '';
	postVars += '&oldPw='+form.oldPw.value;
	postVars += '&NewPw='+form.NewPw.value;	
	postVars += '&custId='+form.custId.value;
	return postVars;
}

