function checkmail(str){var at="@";var dot=".";var lat=str.indexOf(at);var lstr=str.length;var ldot=str.indexOf(dot);var ok ="1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";if (str.indexOf(at)==-1){return false;}for(i=0; i < str.length ;i++){if(ok.indexOf(str.charAt(i))<0){return false;}}if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false;}if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false;}if (str.indexOf(at,(lat+1))!=-1){return false;}if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false;}if (str.indexOf(dot,(lat+2))==-1){return false;}if (str.indexOf(" ")!=-1){return false;}return true;}

YAHOO.namespace("login.container");
function createLogin() {
	YAHOO.login.container.login = new YAHOO.widget.Dialog("ngrsrFrm",{ zindex:4,width:"30em",modal:true,fixedcenter:true,visible:false,constraintoviewport : true,buttons : [ { text:"ingresar", handler:function(){this.submit();}, isDefault:true },{ text:"Cancelar", handler:function() {this.cancel();} }]});
	YAHOO.login.container.login.validate = function() {var data = this.getData();if (data.correo == "" || !(checkmail(data.correo))){alert("Ingrese Email y password con los que se encuentra registrado");return false;}return true;};
	YAHOO.login.container.login.callback = { success:function(o) {var usuario = eval(o.responseText);if( usuario.validated){document.getElementById("usuario_nombre").innerHTML = usuario.nombre_usuario;alert("Bienvenido a nuestro sitio");}else{alert("Email o contraseņa incorrectos!");}},failure: function(o) { alert("Se produjo un error; intentelo nuevamente en unos instantes...");}};
	YAHOO.login.container.login.render();
	YAHOO.util.Event.addListener("try_login", "click", YAHOO.login.container.login.show, YAHOO.login.container.login, true);
}
YAHOO.util.Event.onDOMReady(createLogin);

