function fetchDocumentCookie( sName )
{
    var sValue = "";
    var index = 0;

    if( document.cookie )
        index = document.cookie.indexOf( sName + "=" );
    else
        index = -1;

    if ( index < 0 )
    {
        sValue = "";
    }
    else
    {
        var countbegin = (document.cookie.indexOf( "=", index ) + 1);
        if ( 0 < countbegin )
        {
            var countend = document.cookie.indexOf( ";", countbegin );
            if ( countend < 0 )
                countend = document.cookie.length;
            sValue = document.cookie.substring( countbegin, countend );
        }
        else
        {
            sValue = "";
        }
    }
    return sValue;
}

function checkForm(f)
{
    if(!f.username.value){alert("Username required");return false;}
    if(f.username.value.indexOf('@')>0){alert("Please log in using your eBay ID, not your e-mail address");return false;}
    if(!f.password.value){alert("Password required");return false;}
    var expDate = new Date();
    expDate.setTime( expDate.getTime() + 365*24*60*60*1000 );
    document.cookie = "blogin=" + f.username.value + "; expires=" + expDate.toGMTString();
    return true;
}

function setUsername()
{
    var xlogin = fetchDocumentCookie('blogin');
    if(xlogin && document.FX && document.FX.username){document.FX.username.value = xlogin;}
}

function $(elem)
{
  return document.getElementById(elem);
}

