var idDivModificar;

function init()
{        
	var bodyHTML = '';
    var content = document.getElementById("content");
    content.innerHTML = "";

    if (!YAHOO.example.container.wait) 
	{
    YAHOO.example.container.wait = new YAHOO.widget.Panel("wait", { width: "240px",fixedcenter: true,close: false,draggable: false,modal: true,visible: false});
    YAHOO.example.container.wait.render(document.body);
	}
}
	function bajar()
	{
		var content = document.getElementById("content");
		content.style.visibility = "visible";
		YAHOO.example.container.wait.hide();
	}
	function subir()
	{
		YAHOO.example.container.wait.show();
	}
	var validarRutFunction = function(o)
	{
		var textRespuesta = '';
		var arreglo = new Array();
		var salida = '';
		var urlSalida = '';
		
		
		
		if(o.responseText !== undefined)
		{
	        textRespuesta = o.responseText;
	        arreglo = textRespuesta.split("^")
	        salida = arreglo[0].trim();
	        
	        if(salida=='OK')
	      	{
	      		return;
	      	}
	      	else
	      	{
	      		alert('El RUT Ingresado es Incorrecto');
	      		document.getElementById("user").value = "";
	      	}
		}
	};	
	var handleFailure = function(o)
	{
		var estado = '';
		YAHOO.log("The failure handler was called.  tId: " + o.tId + ".", "info", "example");
		if(o.responseText !== undefined)
		{
			estado += "HTTP status: " + o.status + "\n";
			estado += "Status code message: " + o.statusText + "\n";
		}
		YAHOO.example.container.wait.hide();
		bajar();
	};
	var handleSuccess = function(o)
	{

		var textRespuesta = '';
		var arreglo = new Array();
		var salida = '';
		var urlSalida = '';
		if(o.responseText !== 'undefined')
		{
	        textRespuesta = o.responseText;
	        arreglo = textRespuesta.split("^")
	        salida = arreglo[0];
	        if(salida=='OK')
	      	{
   		        window.location=arreglo[1]; 
	      		urlSalida = arreglo[1].trim();
	      	}
	      	if(salida=='ERROR')
	      	{ 
	      		eval(idDivModificar);
	      	}
		}
	};	
	
	var callback =
	{
	  success:handleSuccess,
	  failure:handleFailure,
	  argument:['foo','bar'],
	  timeout: 35500
	};
	
	var callbackValidar =
	{
	  success:validarRutFunction,
	  failure:handleFailure,
	  argument:['foo','bar'],
	  timeout: 35500
	};
	
	function makeRequest(login,pass)
	{
		 try {
	    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
	   } catch (e) {
	   }
		var sUrl = '/Seguridad/Login';
		var usuario = '';
		var password = '';
	
		usuario = document.getElementById(login).value;
		password = document.getElementById(pass).value;
		
		postData = 'usuario=' + document.getElementById(login).value;
		postData += '&tipo_acc=login';
		postData += '&contrasena=' + document.getElementById(pass).value;
		postData += '&okURL=/privado/web/guest/home';
		postData += '&newURL=/PrestoSecurityWeb/crearClave.do';
		postData += '&loginURL=/Seguridad/index.do';
		postData += '&bloqueoURL=/Seguridad/bloqueado.do';
		var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);	
	}
	
