def register(n):
    nav = utils.nav([["/",app.getFn()],["Register"]])

    er = ""
    if n:
        if n == 1:
            erno = "Username already in use"
        elif erno == 2:
            erno = "Passwords don't match"
        er = '<div class="alert alert-danger"><strong>Error:</strong> %s</div>'%(erno)

    return """
<div id="header">Register</div>%s
<div style="width:300px;margin-left:auto;margin-right:auto;">
%s
<form method="post">
<table class="table">
<tr class="active"><td><input tabindex="1" name="username" type="text" class="form-control" placeholder="Username" /></td></tr>
<tr class="active"><td><input tabindex="2" name="password" type="password" class="form-control" placeholder="Password" /></td></tr>
<tr class="active"><td><input tabindex="3" name="password2" type="password" class="form-control" placeholder="Confirm Password" /></td></tr>
<tr class="active"><td style="text-align:center">Already have an account?  Login by clicking <a href="login">here</a></td></tr>
<tr class="active"><td style="text-align:center"><input tabindex="4" type="submit" class="btn btn-primary" value="Register" /></td></tr>
</table>
</form>
</div>%s"""%(nav,er,nav)
def delthread(n):
    thread = getThread(n)
    forum = getForum(thread["fid"])
    nav = utils.nav([
            ["/",app.getFn()],
            ["/forum-%d"%(forum['id']),forum["name"]],
            ["thread-%d"%(thread['id']),thread["title"]],
            ["Delete Thread"]
            ])

    r = """
<div id="header">Are you sure you wish to delete this thread?</div>%s
<form method="post">
<input type="hidden" name="tid" value="%d" />
<div style="text-align:center">
<input type="submit" value="Yes, delete this thread" class="btn btn-danger" name="del" />
<br /><br /><a href="thread-%d">No, take me back to the thread</a>
</div>
</form>%s"""%(nav,n,n,nav)
    return r
def login(n):
    nav = utils.nav([["/",app.getFn()],["Login"]])

    er = ""
    if n:
        if n == 1:
            erno = "Username/password combination does not exist"
        er = '<div class="alert alert-danger"><strong>Error:</strong> %s</div>'%(erno)

    return """
<div id="header">Login</div>%s
<div style="width:300px;margin-left:auto;margin-right:auto;">
%s
<form method="post">
<table class="table">
<tr class="active"><td><input tabindex="1" name="username" type="text" class="form-control" placeholder="Username" /></td></tr>
<tr class="active"><td><input tabindex="2" name="password" type="password" class="form-control" placeholder="Password" /></td></tr>
<tr class="active"><td style="text-align:center">Don't have an account?  Register an account by clicking <a href="register">here</a></td></tr>
<tr class="active"><td style="text-align:center"><input tabindex="3" type="submit" class="btn btn-primary" value="Login" /></td></tr>
</table>
</form>
</div>%s"""%(nav,er,nav)
def newthread(n):
    forum = getForum(n)
    nav = utils.nav([
            ["/",app.getFn()],
            ["/forum-%d"%(forum['id']),forum["name"]],
            ["Create New Thread"]
            ])

    r = """
<div id="header">Create New Thread</div>%s
<form method="post">
<input type="hidden" name="fid" value="%d" />
<table class="table">
<tr class="active"><td><div class="col-xs-3"><input name="title" type="text" class="form-control" placeholder="Enter your title here..."  /></div></td></tr>
<tr class="active"><td><div class="col-xs-8"><input name="desc" type="text" class="form-control" placeholder="Enter a description here... (Optional)"  /></div></td></tr>
<tr class="active"><td><textarea name="content" class="form-control" rows="12" placeholder="Enter your post here..."></textarea></td></tr>
<tr class="active"><td style="text-align:center;">
  <input type="submit" class="btn btn-primary" value="Create Thread" name="reply" />
  <input type="submit" class="btn btn-primary" value="Cancel" name="cancel" />
</td></tr>
</table>
</form>%s"""%(nav,n,nav)
    return r
def reply(n):
    thread = getThread(n)
    forum = getForum(thread["fid"])
    nav = utils.nav([
            ["/",app.getFn()],
            ["/forum-%d"%(forum['id']),forum["name"]],
            ["thread-%d"%(thread['id']),thread["title"]],
            ["Reply"]
            ])

    r = """
<div id="header">Reply</div>%s
<form method="post">
<input type="hidden" name="tid" value="%d" />
<table class="table">
<tr class="active"><td><textarea name="content" class="form-control" rows="12" placeholder="Enter your post here..."></textarea></td></tr>
<tr class="active"><td style="text-align:center;">
  <input type="submit" class="btn btn-primary" value="Reply" name="reply" />
  <input type="submit" class="btn btn-primary" value="Cancel" name="cancel" />
</td></tr>
</table>
</form>%s"""%(nav,n,nav)
    return r
def edittitle(n):
    thread = getThread(n)
    forum = getForum(thread["fid"])
    nav = utils.nav([
            ["/",app.getFn()],
            ["/forum-%d"%(forum['id']),forum["name"]],
            ["thread-%d"%(thread['id']),thread["title"]],
            ["Edit Thread Title"]
            ])

    r = """
<div id="header">Edit Thread Title</div>%s
<form method="post">
<input type="hidden" name="tid" value="%d" />
<table class="table">
<tr class="active"><td><div class="col-xs-3"><input name="title" type="text" class="form-control" placeholder="Enter your title here..." value="%s" /></div></td></tr>
<tr class="active"><td><div class="col-xs-8"><input name="desc" type="text" class="form-control" placeholder="Enter a description here... (Optional)" value="%s" /></div></td></tr>
<tr class="active"><td>
  <input type="submit" class="btn btn-primary" value="Edit Title" name="reply" />
  <a class="btn btn-primary" href="thread-%d">Cancel</a>
</td></tr>
</table>
</form>%s"""%(nav,n,cgi.escape(thread["title"]),cgi.escape(thread["desc"]),n,nav)
    return r