#!/sw/bin/python
#!/usr/local/bin/python
#!/usr/bin/python

import thsfunctions
import Cookie

user=''
passwd=''

c2 = Cookie.Cookie()
c2.load(thsfunctions.loadCookie())
goodcookie = 1

try:
    user = c2["username"].value
    passwd = c2["password"].value
    # if this doesn't go through checkpass, then it's an invalid entry
except KeyError:
    # No entry was provided in initial submit
    # invalid entry did not occur
    goodcookie = 0
    pass
    
if (thsfunctions.checkPass(user, passwd)) == 1:
    thsfunctions.htmlHeader()
    thsfunctions.login(0, user)
elif (thsfunctions.checkPass(user, passwd)) == 0:
    thsfunctions.htmlHeader()
    thsfunctions.login()
