var footH=30;var msgs=Array('Ingrese su <i>email</i> aquí','Este <i>email</i> presenta errores');function loginH(){$('.oaLogin').height($(document).height()-($('.oaHeader').height()+footH));}function toggleForm(num){var id1,id2;if(num==0){id1='#loginForm';id2='#retrieveForm';}else{id2='#loginForm';id1='#retrieveForm';}$(id1).fadeOut(300,function(){$('.mandatoryAlert').hide();$('.input').removeClass('oaMissing').val('');$(id2).fadeIn(300);});}function validateRetrieve(){if($.trim($('#g1').val())==''){$('#g1').addClass('oaMissing').focus();$('#g1').siblings('span.mandatoryAlert').html(msgs[0]).show();}else if(!validateEmail($('#g1').val())){$('#g1').addClass('oaMissing').focus();$('#g1').siblings('span.mandatoryAlert').html(msgs[1]).show();}else{$('.input').removeClass('oaMissing');$('.oaLoading').show();$.ajax({type:'POST',url:'php/login.php',data:'tipo=retrieve&email='+$.trim($('#g1').val())+'&clave='+$('#f3').val(),success:function(msg){alert(msg);$('.oaLoading').hide();}});}}

function validateLogin(){var x=validateBlanks();if(x>0){$('.mandatory').eq(primero).focus();}else validateUser();}function validateUser(){$('.oaLoading').show();$.ajax({type:'POST',url:'php/login.php',data:'tipo=login&usuario='+escape($('#f1').val())+'&password='+escape($('#f2').val())+'&clave='+escape($('#f3').val()),success:function(msg){
			if(msg.substr(0,2)=='OK'){
				if($.browser.msie)$('#msieSucks').submit();
				else{
					$('.oaLoading').html('Bienvenido '+msg.substr(2)+', cargando tus datos...');
					window.location.reload(false);
				}
				
			}else{alert(msg);$('.oaLoading').hide();}},error:function(){alert('ERROR 1001: Server connection fail. Try it again later.');$('.oaLoading').hide();}});}$(function(){loginH();$('#f1,#f2').keypress(function(e){if(e.which==13)validateLogin();});$('#g1').keypress(function(e){if(e.which==13)validateRetrieve();});});