function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}
//Efectos de Prototype...
Effect.OpenUp = function(element) {
  element = $(element);
  new Effect.BlindDown(element, arguments[1] || {});
};
Effect.CloseDown = function(element) {
  element = $(element);
  new Effect.BlindUp(element, arguments[1] || {});
};
function hacerLogin() {  
  Dialog.confirm($('login').innerHTML, {
  windowParameters: {className:"alphacube", width:400}, 
  okLabel: "Enviar", cancelLabel: "Cerrar",
  ok:function(win){
  	$('imagen_load').innerHTML = '<img src="imagenes/loading.gif">';
  	var url = 'ajax/login.php';
	var opt = {
     method: 'post',
     postBody: 'usuario='+escape($('usuario').value)+'&password='+escape($('password').value),
     onSuccess: function(t) {     	     	
     	respuesta = t.responseText.split('|');   
     	
     	if (TrimString(respuesta[0])=='OK') {
     		$(Windows.focusedWindow.getId()).innerHTML = 'Correcto,<a href="profesionales.php">continuar</a>';
     		window.location = 'profesionales.php';     		
     		return false;
     	} else {
     		$('login_error_msg').innerHTML='Usuario o password incorrectos'+respuesta[1];
    		$('login_error_msg').visualEffect('Appear'); 
    		$('imagen_load').innerHTML = "";
    		Dialog.win.updateHeight();
    		new Effect.Shake(Windows.focusedWindow.getId());
    		return false;
     	}
    },
    onFailure: function(t) {
        $('login_error_msg').innerHTML='Error de login!';
    	$('login_error_msg').show(); 
    	Dialog.win.updateHeight();
    	new Effect.Shake(Windows.focusedWindow.getId());
    	return false;
     }
	};
	
	new Ajax.Request(url, opt);
  }
 });
    
}
