﻿function validateLogin(validationid, usernameid, passwordid, formid, url)
{
    $(validationid).style.display = "none";
    
    var username = $(usernameid).value;
    var password = $(passwordid).value;
                
    var parms = 'username=' + username + '&password=' + password;
    new Ajax.Request(url,
        {            
            method: 'post',
            parameters: parms,
            onSuccess: function(transport)
            {
				responseJSON = transport.responseJSON;
                if (responseJSON.IsValid)
                {
					if (typeof(NOTLOGGEDIN_DIV_ID) != "undefined")
					{
						if (typeof($(NOTLOGGEDIN_DIV_ID)) != "undefined")
						{
							$(NOTLOGGEDIN_DIV_ID).hide();
						}
					}
                    
                    if (typeof(LOGGEDIN_DIV_ID) != "undefined")
					{
						if (typeof($(LOGGEDIN_DIV_ID)) != "undefined")
						{
							$(LOGGEDIN_DIV_ID).show();
						}
					}
					
                    $(formid).submit();
                    //loginSuccess();
                }
                else
                {
                    $(validationid).update(responseJSON.ValidationErrorMessage);
                    $(validationid).style.display = "block";
                }
            }
        }
    )
    return false;
}

/*
function loginSuccess()
{
	new Ajax.Request(RENDER_MYGEORGIA_MODULE_URL,
		{
			method: 'get',
			onSuccess: function(transport, response)
			{
				LightboxWindow.close();
				$('myGeorgiaModule').update(transport.responseText);
			}
		}
	);
}
*/

function goRegistration(formid, action)
{
    $(formid).action = action;
    $(formid).submit();
}