function usrLogin()
{
	// Check for the login location
	if ((window.document.aspnetForm.clType(0).checked != true) && (window.document.aspnetForm.clType(1).checked != true))
	{
		alert('You must choose to login to webmail or the control panel.');
		return false;
	}

	// Check for the username
	if ((window.document.aspnetForm.clUsername.value.length < 3) || (window.document.aspnetForm.clUsername.value.length > 100))
	{
		alert('You must enter a username between 3 and 100 characters long.');
		window.document.aspnetForm.clUsername.focus();
		return false;
	}

	// Check for the password
	if ((window.document.aspnetForm.clPassword.value.length < 3) || (window.document.aspnetForm.clPassword.value.length > 25))
	{
		alert('You must enter a password between 3 and 25 characters long.');
		window.document.aspnetForm.clPassword.focus();
		return false;
	}



    // Set Login Cookie
    if (window.document.aspnetForm.clRemember.checked == true)
    {
        WM_setCookie('UTSaveCredentials', 'true', 'Sun, 31 Dec 2023 00:00:00 GMT', '/', 'ubiquitoustechnologies.com');

        if (window.document.aspnetForm.clType[0].checked == true)
        {
            WM_setCookie('CPUsername', window.document.aspnetForm.clUsername.value, 'Sun, 31 Dec 2023 00:00:00 GMT', '/', 'ubiquitoustechnologies.com');
            WM_setCookie('CPPassword', window.document.aspnetForm.clPassword.value, 'Sun, 31 Dec 2023 00:00:00 GMT', '/', 'ubiquitoustechnologies.com');
        }

        if (window.document.aspnetForm.clType[1].checked == true)
        {
            WM_setCookie('WMUsername', window.document.aspnetForm.clUsername.value, 'Sun, 31 Dec 2023 00:00:00 GMT', '/', 'ubiquitoustechnologies.com');
            WM_setCookie('WMPassword', window.document.aspnetForm.clPassword.value, 'Sun, 31 Dec 2023 00:00:00 GMT', '/', 'ubiquitoustechnologies.com');
        }

    } else {
        WM_killCookie('UTSaveCredentials', '/', 'ubiquitoustechnologies.com');
        WM_killCookie('CPUsername', '/', 'ubiquitoustechnologies.com');
        WM_killCookie('CPPassword', '/', 'ubiquitoustechnologies.com');
        WM_killCookie('WMUsername', '/', 'ubiquitoustechnologies.com');
        WM_killCookie('WMPassword', '/', 'ubiquitoustechnologies.com');
    }


    // Set the default login to be RES and login the user
    if (window.document.aspnetForm.clType[0].checked == true)
    {
        WM_setCookie('UTDefaultLogin', 'CP', 'Sun, 31 Dec 2023 00:00:00 GMT', '/', 'ubiquitoustechnologies.com');

        str_FakeForm = '';

        str_FakeForm = '<form name="frmTempLogin" action="http://cp.ubiquitoustechnologies.com/default.asp" method="post">';
        str_FakeForm += '<input type="hidden" name="txtUsername" value="' + window.document.aspnetForm.clUsername.value + '">';
        str_FakeForm += '<input type="hidden" name="txtPassword" value="' + window.document.aspnetForm.clPassword.value + '">';
        str_FakeForm += '<input type="hidden" name="selLanguageCode" value="EN">';
        str_FakeForm += '<input type="hidden" name="selInterface" value="standard_XP">';
        str_FakeForm += '</form>';

        str_FakeForm += "<script language='javascript'>window.document.frmTempLogin.submit();</" + "script>";

        window.document.write(str_FakeForm);
    }

    if (window.document.aspnetForm.clType[1].checked == true)
    {
        WM_setCookie('UTDefaultLogin', 'WM', 'Sun, 31 Dec 2023 00:00:00 GMT', '/', 'ubiquitoustechnologies.com');

        str_FakeForm = '';

        str_FakeForm = '<form name="Login" action="http://webmail.ubiquitoustechnologies.com/Login.aspx" method="post">';
        str_FakeForm += '<input type="hidden" name="txtUserName" value="' + window.document.aspnetForm.clUsername.value + '">';
        str_FakeForm += '<input type="hidden" name="txtPassword" value="' + window.document.aspnetForm.clPassword.value + '">';
        str_FakeForm += '<input type="hidden" name="LanguageList" value="">';
        str_FakeForm += '<input type="hidden" name="__EVENTTARGET" value="LoginImageButton">';
        str_FakeForm += '<input type="hidden" name="__EVENTARGUMENT" value="">';
        str_FakeForm += '</form>';

        str_FakeForm += "<script language='javascript'>window.document.Login.submit();</" + "script>";

        window.document.write(str_FakeForm);
    }
}


// Destroy all login data
function UTDestroyDate()
{
    WM_killCookie('UTSaveCredentials', '/', 'ubiquitoustechnologies.com');
    WM_killCookie('UTDefaultLogin', '/', 'ubiquitoustechnologies.com');
    WM_killCookie('CPUsername', '/', 'ubiquitoustechnologies.com');
    WM_killCookie('CPPassword', '/', 'ubiquitoustechnologies.com');
    WM_killCookie('WMUsername', '/', 'ubiquitoustechnologies.com');
    WM_killCookie('WMPassword', '/', 'ubiquitoustechnologies.com');
}


// Load the cookie onclick
function UTLoadCookie(intType)
{
    if (window.document.aspnetForm.clRemember.checked == true)
    {
        switch (intType)
        {
            case 0:
            {
                if (WM_readCookie('CPUsername') != false)
                {
                    window.document.aspnetForm.clUsername.value = WM_readCookie('CPUsername');
                    window.document.aspnetForm.clPassword.value = WM_readCookie('CPPassword');
                } else {
                    window.document.aspnetForm.clUsername.value = '';
                    window.document.aspnetForm.clPassword.value = '';
                }
                break;
            }
            case 1:
            {
                if (WM_readCookie('WMUsername') != false)
                {
                    window.document.aspnetForm.clUsername.value = WM_readCookie('WMUsername');
                    window.document.aspnetForm.clPassword.value = WM_readCookie('WMPassword');
                } else {
                    window.document.aspnetForm.clUsername.value = '';
                    window.document.aspnetForm.clPassword.value = '';
                }
                break;
            }
            default:
            {
                break;
            }
        }
    } else {
        switch (intType)
        {
            case 0:
            {
                window.document.aspnetForm.clUsername.value = '';
                window.document.aspnetForm.clPassword.value = '';
                break;
            }
            case 1:
            {
                window.document.aspnetForm.clUsername.value = '';
                window.document.aspnetForm.clPassword.value = '';
                break;
            }
            default:
            {
                break;
            }
        }
    }
}


// Check for the save credentials checkbox
if (WM_readCookie('UTSaveCredentials') == 'true')
{
    window.document.aspnetForm.clRemember.checked = true;
}


// If the default login is set, check for the username and password
if (WM_readCookie('UTDefaultLogin') == 'CP')
{
    window.document.aspnetForm.clType[0].checked = true;
    UTLoadCookie(0);
}

if (WM_readCookie('UTDefaultLogin') == 'WM')
{
    window.document.aspnetForm.clType[1].checked = true;
    UTLoadCookie(1);
}