function GetCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    value = document.cookie.substring(offset, endstr);
    if(value == 'null' || value == '' || value == null) return null;
    else return unescape(value);
}

function GetCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;

    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return GetCookieVal (j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

function SetCookie (name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function DeleteCookie(name) {
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = GetCookie (name);
    if (cval != null) {
        document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
    }
}

function check_in(){
    saveID = GetCookie("save_neoid");
    fm = document.form;

    if (fm.saveid != null && saveID != null && saveID != '') {
        fm.saveid.checked = true;
        fm.userid.value = saveID;
    }
}

function save_id()
{
    fm = document.form;
    if(fm.saveid != null && fm.saveid.checked == true) {
        saveID = document.form.userid.value;

        var thenewdate = new Date ();
        thenewdate.setTime(thenewdate.getTime() + (365 * 24 * 3600 * 1000));

        SetCookie("save_neoid", saveID, thenewdate);
    } else {
        DeleteCookie("save_neoid");
    }
}

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}
function changeLanguage() {
    var fm = document.getElementById('form1');
    fm.method = 'get';
    fm.action = 'index.neo';
    fm.submit();
}
///////////////////////////////////////////////////////////////////////////////
// SEARCH ID OR PASSWORD
function miss_open(miss, wname){
  missWin = window.open(miss,wname,'scrollbars=auto,location=no,status=no,width=430,height=250,resizable=no,menubar=no');
}

//
// OPEN POPUP
function notice(cmd, name, wi, hi)
{
    noticeWindow = window.open(cmd, name, 'scrollbars=no,toolbar=no,location=no,directories=no,menubar=no,status=no,width='+wi+',height='+hi+',resizable=no,top=30,left=250');
    noticeWindow.focus();
}

///////////////////////////////////////////////////////////////////////////////
// NEWS
function notice_open(notice){
  noticeWin = window.open(notice,'news','scrollbars=yes,location=no,status=no,width=800,height=600,resizable=no','top=5','left=5');
}

//
// CHECK ID, PASSWORD
function login_user() {
    Frm = document.form;

    if(Frm.userid.value=="" || Frm.pass.value=="") {
        if(Frm.userid.value=="") {
             alert(strEnterId);
             Frm.userid.focus();
             return false;
        } else if(Frm.pass.value=="") {
             alert(strEnterPassword);
             Frm.pass.focus();
             return false;
        }
    } else {
        save_id(); // index.js
    }
    return true;
}

function getCookie( name )
{
        var nameOfCookie = name + "=";
        var x = 0;
        while ( x <= document.cookie.length )
        {
                var y = (x+nameOfCookie.length);
                if ( document.cookie.substring( x, y ) == nameOfCookie ) {
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                                endOfCookie = document.cookie.length;
                        return unescape( document.cookie.substring( y, endOfCookie ) );
                }
                x = document.cookie.indexOf( " ", x ) + 1;
                if ( x == 0 )
                       break;
        }
        return "";
}
function setCookie( name, value, expiredays ) {
  var todayDate = new Date();
  todayDate.setDate( todayDate.getDate() + expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + "; domain=" + "."+";";
}

