addEvent_s(window, 'load', iniciar_s, false);

function iniciar_s()
{
	var refForm = document.getElementById("formSesion");
	addEvent_s(refForm, 'submit', envia_s, false);
}

function envia_s(e)
{
	if(window.event){
		window.event.returnValue = false;
		cargaForm_s();
	}else{
		if(e){
			e.target.defaultValue();
			cargaForm_s();
		}
	}
}

function parametros_s()
{	
	var url = "";
	var refUsuario = document.getElementById("Usr").value;
	var refClave = document.getElementById("Clv").value;
	url = "Usuario=" + encodeURIComponent(refUsuario) + "&Clave=" + encodeURIComponent(refClave);
	return url;
}

var conexion_s;
function cargaForm_s()
{
	conexion_s = creaXMLHttpRequest_s();
	conexion_s.onreadystatechange = procesaEnvios;
	conexion_s.open('POST', '../validaSesion.php', true);
	conexion_s.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	conexion_s.send(parametros_s());
}

function procesaEnvios()
{
	var refRes = document.getElementById("resultado");
	if(conexion_s.readyState == 4){
		if(conexion_s.responseText == 1){
			location.href = "../usuarios/index.php?nucleo=cuenta";
		}else{
			refRes.innerHTML = conexion_s.responseText;
		}
	}else{
		refRes.innerHTML = "<img src='images/silics.gif' width='40' />"
	}
}

function addEvent_s(elemento, evento, funcion, valor)
{
	if(elemento.attachEvent){
		elemento.attachEvent('on' + evento, funcion, valor);
		return true;
	}else{
		if(elemento.addEventListener){
			elemento.addEventListener(evento, funcion, valor);
			return true;
		}else{
			return false;
		}
	}
}

function creaXMLHttpRequest_s() 
{
  var xmlHttp=null;
  if (window.ActiveXObject) 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else 
    if (window.XMLHttpRequest) 
      xmlHttp = new XMLHttpRequest();
  return xmlHttp;
}

