function readCookie(name)
{
	if (document.cookie == '') return false;
	else
	{
		var c0, c1;
		var cookie = document.cookie;
		c0 = cookie.indexOf(name);
		if(c0 != -1)
		{
			c0 += name.length + 1;
			c1 = cookie.indexOf(';', c0);
			if(c1 == -1) c1 = cookie.length;
			return unescape(cookie.substring(c0,c1).replace('+',' '));
		}
		else return false;
    }
}

if (applicationURL == null) applicationURL = "";
if (folderList == null) folderList = "";
userID = readCookie(applicationName+'.USER.ID');
userName = readCookie(applicationName+'.USER.USERNAME');if (!userName) userName="";
if (userID==0)
{

	document.write("<table width=100% cellpadding=0 cellspacing=2 border=0>");
	document.write("<form action='"+applicationURL+folderList+"/index.io' method='post'><input type='hidden' name='Reg.Login.Action' value='verifyUser'><input type='hidden' name='Reg.Login.Return' value='2'>");
	document.write("<tr>");
	document.write("<td align=right class='FanZoneForm'><small>User</small></td>");
	document.write("<td><input class='InputSmall' name='Display.Form.Login.UserName' size=10 maxlength=50 value="+userName+"></td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td align=right class='FanZoneForm'><small>Pass</small></td>");
	document.write("<td><input class='InputSmall' name='Display.Form.Login.Password' type='password' size=10 maxlength=50></td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td align=center colspan=2 class='FanZoneForm'>Remember Me <input type='checkbox' value=1 name='KeepCookie' checked class='Radio'> <input type='submit' class='FanZoneButton' value='LOGIN'></td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td align=left class='FanZone'><a href='"+accountURL+"';' >register</a></td>");
	document.write("<td align=right class='FanZone'><a href='"+passwordURL+"';' >forgot password?</a></td>");
	document.write("</tr>");
	document.write("</form>");
	document.write("</table>");
}
else
{

	document.write("<table width=100% cellpadding=0 cellspacing=2 border=0>");
	document.write("<tr>");
	document.write("<td colspan=2 align=center class='FanZone'>welcome <b><a href='"+accountURL+"' style='font-size:10px;'>"+userName+"</a></b></td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td align=left class='FanZone'><a href='"+logoutURL+"';' >logout</a></td>");
	document.write("<td align=right class='FanZone'><a href='"+accountURL+"';' >view account</a></td>");
	document.write("</tr>");
	document.write("</table>");
}
