<table cellspacing="0" cellpadding="2">
<tr>
	<td><span class="lbl_cpw">Anterior Clave</span></td>
	<td><input type="password" id="cla_ant" maxlength="6" class="txt_pwd"  /></td>
    <td width="350"><span id="err_ant"  class="err_cpw" ></span></td>
</tr>

<tr>
	<td><span class="lbl_cpw">Nueva Clave</span></td>
	<td><input type="password" id="cla_nue" maxlength="6" class="txt_pwd" /></td>
    <td><span id="err_nue" class="err_cpw" ></span></td>
</tr>
<tr>
	<td><span class="lbl_cpw">Repita Clave</span></td>
	<td><input type="password" id="cla_rep" maxlength="6" class="txt_pwd" /></td>
    <td><span id="err_rep" class="err_cpw" ></span></td>
</tr>

</table>
<div align="center"><input type="button" id="btn_nue" class="btn_standard" value="Actualizar" onclick="actualiza_clave();" /></div>
<div id="err_msg" style="color:#000000;"></div>
<script type="text/javascript">
function actualiza_clave()
{
	var ant=document.getElementById('cla_ant').value;
	var nue=document.getElementById('cla_nue').value;
	var rep=document.getElementById('cla_rep').value;
	if(ant.length!=6)
	{
		document.getElementById('err_ant').innerHTML='* Clave de 6 Cacacteres';
		document.getElementById('cla_ant').focus();
		return false;
	}
	else
	{
		document.getElementById('err_ant').innerHTML='';	
	}
	
	if(nue.length!=6)
	{
		document.getElementById('err_nue').innerHTML='* Clave de 6 Cacacteres';
		document.getElementById('cla_nue').focus();
		return false;
	}
	else
	{
		document.getElementById('err_nue').innerHTML='';	
	}

	if(nue!=rep)
	{
		document.getElementById('err_nue').innerHTML='* Claves no Coinciden';
		document.getElementById('cla_nue').focus();
		
		return false;
	}
	document.getElementById('btn_nue').disabled=true;
	document.getElementById('err_msg').innerHTML='<img src="../img/loading.gif" width=35/>';
	$.ajax({
		url:'../lib/clave.php',
		type:'POST',
		data:{vieja:ant,nueva:nue},
		success: function(dato)
		{
			document.getElementById('err_msg').innerHTML=dato;
			document.getElementById('btn_nue').disabled=false;
		},
		error:function(objeto)
		{
			console.log(objeto);
			document.getElementById('btn_nue').disabled=false;
			document.getElementById('err_msg').innerHTML='';
		}	
	
	
	});

	document.getElementById('cla_ant').value='';
	document.getElementById('cla_nue').value='';
	document.getElementById('cla_rep').value='';
	
	
}
</script>