// JavaScript Document
function procesa_pass()
	{
	username = $('input#usuario').val();
	password = $('input#password').val();
	
	if ((username != '') && (password  != '')) 
		{
		
		$.getJSON('seguridad/handler.php', { handler: 'json', callback: 'genera_seed' }, function(json) { encript_pass(json.seed)})	
		// compute the hash of the hash of the password and the seed

		}
	}
function encript_pass(jasonseed)	
	{
		var hash;
		hash = hex_sha1(hex_sha1(password) + jasonseed);
		
		$('input#password').val(hash);
		//mejorar
		//document.getElementById('logeo').submit();
		$('#login').submit();
		//Elimina el thickbox
		
	}
	
function procesa_user()
	{
	username = $('input#usuario').val();
	password = $('input#password').val();
	repassword = $('input#repassword').val();
	cuenta_pass = password.length;
	espacios = -1;
	espacios = password.indexOf(' ');
	if ((username!='')&&((repassword != '') && (password  != ''))&&(password === repassword)&&(cuenta_pass>=8)&& (espacios==-1))
		{
			
		// compute the hash of the hash of the password and the seed
		hash = hex_sha1(password) ;
		hash2 = hex_sha1(repassword) ;
		
		$('input#password').val(hash);
		$('input#repassword').val(hash2);
		//mejorar
		document.getElementById('crearusuario').submit();
		}
		else
		{
			window.alert('Los passwords introducidos han de ser iguales, sin espacios y mayores de 8 caracteres.');
		}
	}
/*	
function procesa_user2()
	{

	password = document.getElementById('password').value;
	repassword = document.getElementById('repassword').value;
	if (((repassword != '') && (password  != ''))&&(password === repassword))
		{
			
		// compute the hash of the hash of the password and the seed
		hash = hex_sha1(password) ;
		
		document.getElementById('password').value=hash;
		document.getElementById('repassword').value=hash;
		document.getElementById('cambiar_pass').submit();
		}
		else
		{
			window.alert('Los passwords introducidos han de ser iguales.');
		}
	}
	*/