function domain() {
var url = document.location.href;
url = url.replace(/^(http:\/\/|https:\/\/)*([a-zA-Z0-9-_\.=]+):*.*/, "$2");
var res = url.match(/^(mail|webmail|www|freemail|)\.(.*)/);
if (res) { url = res[2] }
return url;
}
function submit()
{
document.login.submit();
return true;
}
function gotonmc()
{
window.open("/nmc","","");
return false;
}

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") + (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function genNowTime() {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    return now;
}

function rememberMe (f) {
    var now = genNowTime();
    if (f.username != null){
       if (f.name=='login')
          setCookie('wmail_username', f.username.value, now, '/', '', '');
       if (f.name=='login_corp')
          setCookie('wmail_username_corp', f.username.value, now, '/', '', '');
    }
    if (f.domain != null){
       setCookie('wmail_domain', f.domain.value, now, '/', '', '');
    }
}

function rememberAll (f) {
    var now = genNowTime();
    rememberMe(f);
    if (f.password != null)
        setCookie('wmail_passwd', f.password.value, now, '/', '', '');
}

function forgetMe (f) {
    if (f.bakecookie.checked) return;
    if (f.name=='login')
    	deleteCookie('wmail_username', '/', '');
    deleteCookie('wmail_passwd', '/', '');
    if (f.name=='login_corp'){
        deleteCookie('wmail_username_corp', '/', '');
        deleteCookie('wmail_domain', '/', '');
    }	
    //f.username.value = '';
    //f.domain.value = '';
    //f.password.value = '';
}


function checkType (f) {
    if (f.bakecookie.checked) rememberMe(f);
    return true;
   // if (f.bakecookie[1].checked) rememberAll(f);
}

function setFocus() {
    var f = document.forms['login'];
    if (f) {
        if (f.username.value == null || f.username.value == "") {
            f.username.focus();
        } else {
            f.password.focus();
        }
    }
}
<!--
function submit()
{
document.login.submit();
return true;
}
function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") + (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function genNowTime() {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    return now;
}

function rememberMe (f) {
    var now = genNowTime();
    if (f.username != null)
       setCookie('wmail_username', f.username.value, now, '/', '', '');
    if (f.domain != null)
       setCookie('wmail_domain', f.domain.value, now, '/', '', '');
}

function rememberAll (f) {
    var now = genNowTime();
    rememberMe(f);
    if (f.password != null)
        setCookie('wmail_passwd', f.password.value, now, '/', '', '');
}

function forgetMe (f) {
    if (f.bakecookie.checked) return;
    deleteCookie('wmail_username', '/', '');
    deleteCookie('wmail_domain', '/', '');
    deleteCookie('wmail_passwd', '/', '');
    //f.username.value = '';
    //f.domain.value = '';
    //f.password.value = '';
}


function checkType (f) {
    if (f.bakecookie.checked) rememberMe(f);
    return true;
   // if (f.bakecookie[1].checked) rememberAll(f);
}

function setFocus() {
    var f = document.forms['login'];
    if (f) {
	if (f.username.value == null || f.username.value == "") {
	    f.username.focus();
	} else {
	    f.password.focus();
	}
    }
}
//-->


