var LoginCode = new Array;
LoginCode[0] = new Array(27173, 26127);
LoginCode[1] = new Array(7478, 7216);

function check(form) 
{
    var i=0;
    var h1 = makehash(form.login.value, 3);
    var h2 = makehash(form.pass.value, 3);

// alert(h1); alert(h2);

    for (i=0; i<2; i++)
    {
        if (h1 == LoginCode[i][0])
        {
            if (h2==LoginCode[i][1]) 
            {
                top.location="extranet/" + form.login.value + ".html";
                putCookie("LoginName", form.login.value);
                return;
            }
        }
    }

    alert("Onbekende gebruikersnaam / wachtwoord!"); 
}

function makehash(pw, mult)
{
    var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
    var pass=pw.toUpperCase();
    hash=0;
    for (i=0;i<8;i++)
    {
        letter=pass.substring(i,i+1);
        c=alpha.indexOf(letter,0)+1;
        hash=hash*mult+c;
    }
    return(hash);
}

function putCookie(CookieName, CookieValue)
{
    if (document.cookie != document.cookie)
    {
        index = document.cookie.indexOf(CookieName);
    }
    else
    {
        index = -1;
    }

    if (index == -1)
    {
        document.cookie = CookieName + "=" + CookieValue + ";expires=Monday, 04-Apr-2010 05:00:00 GMT";
    }
}


function getCookie(CookieName)
{
    var RetVal = "";

    if (document.cookie)
    {
        index = document.cookie.indexOf(CookieName);
        if (index != -1)
        {
            namestart = (document.cookie.indexOf("=", index) + 1);
            nameend = document.cookie.indexOf(";", index);
            if (nameend == -1)
            {
                nameend = document.cookie.length;
            }
            RetVal = document.cookie.substring(namestart, nameend);
        }
    }
    return RetVal;
}

document.write("<form>");
document.write("Login:<br>");
document.write("<input type=text size=12 maxlength=20 name=login value=" + getCookie("LoginName") + ">");
document.write("<br>Password:<br>");
document.write("<input type=password size=12 maxlength=20 name=pass>");
document.write("<br>");
document.write("<input type=button value=Inloggen onclick=check(this.form)>");
document.write("</form>");
