/**
 * The login static class.
 * 
 * @version 2010-12-24
 * @author <a href="mailto:r.tennapel@griponservice.nl?SUBJECT=Login script.js">R. ten Napel, ing.</a>
 **/
function Login() {}

/**
 * Handle login action.
 * 
 * @param widgetId			The widget ID.
 * @param handler			The path to the login-handler.
 * @param action			The login action.
 **/
Login.send = function(widgetId, handler, action) {
	// Define the params string:
	var params = "widgetId=" + widgetId + "&action=" + action;
	params += (action == "login") ? "&" + $(widgetId).getValues("INPUT", "URL") : "";
	
	// Create / retrieve the widget:
	var widget = new Widget($(widgetId).$().parentNode, "Login", params);
	
	// Onsuccess handler:
	var onSuccess = function(response) {
		//var response = JSON.parse(response);
		
		
	
		
		
		// Refresh the widget:
		widget.refresh(params);
		setTimeout(function() { document.location = handler.replace('Framework/Widgets/Login/ajaxlogin.php',''												); }, 0);
	};
	
	// Ajax-request:
	new Ajax(null, handler + "?" + params, null, null, onSuccess).request();
};
