var stime = 0;
function validpwd()
{
	var tmppd = document.getElementById("tmppd").value;	
	var xmlhttp;
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}else{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	stime++;
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("password").value=xmlhttp.responseText;
			document.getElementById('form').submit();
		}else{
			if(stime<3)
				validpwd();
			else
				$('form input[name=tmppd]').get(0).focus();
		}
	}
	xmlhttp.open("GET",P8CONFIG.url+'/api/encode.php?t='+Math.random()+'&tmppd='+tmppd,true);
	xmlhttp.send();
}