package org.apache.jsp.membership.parent;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
import com.tootsville.user.*;
import org.starhope.appius.except.*;
import org.starhope.appius.user.*;
import org.starhope.appius.mb.*;
import org.starhope.appius.mb.fields.*;
import com.tootsville.WebUtil;

public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.List _jspx_dependants;

  static {
    _jspx_dependants = new java.util.ArrayList(1);
    _jspx_dependants.add("/WEB-INF/mb-taglib.tld");
  }

  private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fmb_005fengine_005fnobody;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _005fjspx_005ftagPool_005fmb_005fengine_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
  }

  public void _jspDestroy() {
    _005fjspx_005ftagPool_005fmb_005fengine_005fnobody.release();
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

 WebUtil.go(); 
      if (_jspx_meth_mb_005fengine_005f0(_jspx_page_context))
        return;

    MBSession sess = MBSession.get(request);
	Parent sessionUser;
	try {
		sessionUser = sess.getVisitorAsParent ();
	} catch (NotFoundException e) {
		response.sendRedirect ("/membership"); return;
	}
	User selectedChild = (User)(sess.child.getValue ());

      out.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n<head>\n\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\" />\n\t<title>Tootsville™ Parent Account</title>\n\t<link rel=\"shortcut icon\" href=\"/t.png\" type=\"image/png\" />\n\t<link rel=\"stylesheet\" href=\"/membership/style.css\" type=\"text/css\" />\n\t<script type=\"text/javascript\">\n\t<!--\n\tfunction cancel_child(childID) {\n\t\tvar answer = confirm(\"Are you sure you want to disable this Toots Account?  Note:  This will not unsubscribe a V.I.T. membership.\");\n\t\tif (answer)\n\t\t\twindow.location.href = \"/membership/parent/edit/edit-child.jsp?childID=\" + childID + \"&action=deny\";\n\t}\n\t-->\n\t</script>\n</head>\n<body>\n<div class=\"content-pane\">\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "/membership/Header.jsp", out, false);
      out.write("\n<h2><img src=\"/images/text-manage-my-parent-account.png\" alt=\"Manage My Account!\" /></h2>\n<h4>Parent Account</h4>\n\n\n");


final int childID = (null == selectedChild ? -1 : selectedChild.getUserID () );

if (null!=selectedChild && sessionUser.getID() == selectedChild.getParentID()) {
	
      out.write("\n<form  method=\"post\">\n<input type=\"hidden\" name=\"childID\" value=\"");
      out.print( childID );
      out.write("\" />\n<a name=\"child\" />\n<div class=\"fieldset\"><div class=\"legend\"><img src=\"/images/text-user-details.png\" /></div>\nTo update individual or all listed items of the user details, edit the field boxes provided and hit submit.\n<br />\n<br />\n<table style=\"width:100%\">\n<tr>\n<td style=\"width:50%;vertical-align:top;\">\n<span class=\"sel_user\">Child: ");
      out.print( selectedChild.getDisplayName() );
      out.write("</span>\n<br /><br />\n</td>\n<td style=\"width:50%;vertical-align:top;\" rowspan=\"2\">\n");
 if (!selectedChild.isApproved() && !selectedChild.isBanned() ) {
      out.write("\n<a href=\"");
      out.print("/membership/parent/edit/edit-child.jsp?childID=" +  childID + "&action=approve");
      out.write("\">\n<div class=\"child\" style=\"border-color:green; text-align: center;\">\n<img src=\"/images/manageaccount/icon-approve.png\" alt=\"Approve\" style=\"float:left;padding: 0 0.5em;\" />Approve Child Account<br />\n<small style=\"color:green\">(This action will approve your child's account and allow your child to chat in Tootsville™)</small>\n</div>\n</a>\n");

if (!selectedChild.isCanceled()) { 
      out.write("\n<a href=\"");
      out.print("/membership/parent/edit/edit-child.jsp?childID=" +  childID + "&action=deny");
      out.write("\">\n<div class=\"child\" style=\"border-color:red; text-align: center;\">\n<img src=\"/images/manageaccount/icon-denied.png\" alt=\"Deny\" style=\"float:left;padding: 0 0.5em;\" />Cancel Child Account<br />\n<small style=\"color:red\">(This action will cancel your child's account)</small>\n</div>\n</a>\n");
 }}
if (selectedChild.isBanned()) {

      out.write("\n<a href=\"");
      out.print( "mailto:CustomerService@tootsville.com?subject=Why was my child, " + selectedChild.getUserName()
		+ ", banned from Tootsville™?&body=Dear Customer Service," );
      out.write("\">\n<div class=\"child\" style=\"border-color:red;\">\n<img src=\"/images/icon-needs-attention.png\" alt=\"Deny\" style=\"float:left;padding: 0 0.5em;\" />Your child is banned!<br />\n<small style=\"color:red\">(Click here to send Tootsville™'s Customer Service an e-mail)</small>\n</div>\n</a>\n");
 } 
      out.write("\n</td>\n</tr>\n<tr>\n<td>\nStatus:\n");

if (selectedChild.isActive()) {
	// Active
	out.println ("<font color='green'>Active</font>");
} else if (selectedChild.isCanceled()) {
	// Canceled
	out.println ("<font color='gray'>Canceled</font>");
} else if (selectedChild.isBanned()) {
	// Banned
	out.println ("<font color='red'>Banned</font>");
} else if (selectedChild.isKicked()) {
	// Kicked + message
	out.println ("<font color='red'>Kicked: "+selectedChild.getKickedMessage()+"</font>");
}

      out.write("\n</td>\n</tr>\n</table>\n<br />\n<table class=\"edit-child\" >\n");
 if (selectedChild.needsNaming()) { 
      out.write("\n<tr>\n<td colspan=\"2\">\nThe user name your child has requested was not approved.  Please select another user name.\n</td>\n</tr>\n<tr>\n<td>\nNew User Name:\n</td>\n<td>\n<input type=\"text\" name=\"username\" size=\"20\" maxlength=\"30\" />\n</td>\n</tr>\n");
 } 
      out.write("\n<tr>\n<td>\nChild's Password:\n</td>\n<td>\n<input type=\"text\" name=\"childPassword\" value=\"");
      out.print( selectedChild.getPassword() );
      out.write("\" size=\"20\" maxlength=\"30\" />\n</td>\n</tr>\n<tr>\n<td>\nChild's First Name:\n</td>\n<td>\n<input type=\"text\" name=\"childFirstName\" value=\"");
      out.print( null!=selectedChild.getGivenName()?selectedChild.getGivenName():"" );
      out.write("\" size=\"20\" maxlength=\"30\" />\n</td>\n</tr>\n<tr>\n<td>\nAllow Child to Chat\n</td>\n<td>\n<label><input type=\"radio\" name=\"isCanTalk\" value=\"true\" ");
      out.print( selectedChild.isCanTalk()? "checked=\"checked\"":"" );
      out.write(" />Allow</label><br />\n<label><input type=\"radio\" name=\"isCanTalk\" value=\"false\" ");
      out.print( selectedChild.isCanTalk()? "":"checked=\"checked\"" );
      out.write(" />Deny</label>\n</td>\n</tr>\n<tr>\n<td>\nForgotten Password Question:<br />\n");
      out.print( selectedChild.getForgotPasswordQuestion() );
      out.write("\n</td>\n<td>\nForgotten Password Answer:<br />\n<input type=\"text\" name=\"childAnswer\" value=\"");
      out.print( selectedChild.getForgotPasswordAnswer() );
      out.write("\" size=\"20\" maxlength=\"30\" />\n</td>\n</tr>\n<tr>\n<td>\nChild's Date of Birth\n</td>\n<td>\n");
      out.print( Messages.prettyDate(selectedChild.getBirthDate()) );
      out.write("\n</td>\n</tr>\n<tr>\n<td>\n");
 if (!selectedChild.isPaidMember()) { 
      out.write("\n<button type=\"button\" name=\"upgrade\" id=\"parent-upgrade\" onclick=\"document.location=('");
      out.print( "/membership/register/premium/?toot=" + selectedChild.getUserID() );
      out.write("')\"></button>\n");
 } 
      out.write("\n</td>\n<td>\n<input type=\"submit\" name=\"parent-edit-child\" class=\"formbuttons\" id=\"submit\" value=\" \" />\n</td>\n</tr>\n</table>\n");
 if (selectedChild.isApproved()) { 
      out.write("\n<div class=\"cancel_child\" onclick=\"cancel_child(");
      out.print(selectedChild.getUserID());
      out.write(");\">\nDisable This Toots Account\n</div>\n");
 } 
      out.write("\n<br />\n</div>\n</form>\n");

}

      out.write("\n\n\n<div class=\"floatingimage\" id=\"tango-handstand\"><img src=\"/images/icon-tango-handstand.png\" alt=\"Manage My Account\" /></div>\n<div class=\"logoutbutton\">\n<a href=\"/membership/logout.jsp\">\n<img src=\"/images/manageaccount/button-logout1.png\" alt=\"Logout\" />\n</a>\n</div>\n<div class=\"logoutcompensator\">\n<div class=\"fieldset\"><div class=\"legend\"><img src=\"/images/text-account-details.png\" /></div>\n<br />\nHello, ");
      out.print( sessionUser.getDisplayName() + " <small>(" + sessionUser.getMail() + ")</small>" );
      out.write("\n<br />\n<br />\nTo review the details of your child's Toots® Account(s), edit your profile and register\nnew Toots® accounts, please select from the options below.\n<div class=\"parentcontainer\">\n<span class=\"parentpane\" style=\"float: left;\">\n<img src=\"/images/icon-my-child-toots-account.png\" style=\"margin:-1em -1.5em 0.5em -1.5em;width:18em;\" />\n<br />\n<div class=\"toot-select\">\n");

// Sort the child list array
User childList[]=sessionUser.getChildren();
out.println("\n");
for (User child : childList) {
	out.println("<a href=\"?toot=" + child.getUserID() + "\" class=\"child\" style=\"");
	if (child.isCanceled())
		out.print("text-decoration:line-through;");
	if (null != selectedChild && child.getUserID() == selectedChild.getUserID())
		out.print("background-color: #ccff99 !important;");
	out.print("\">");
	if (child.isPaidMember())
		out.println("<img src=\"/images/icon-vit-membership.png\" style=\"float:right\" alt=\"This child has a Very Important Toot membership.\" />");
	if (child.isNeedsParentAttention())
		out.println("<img src=\"/images/icon-needs-attention.png\" style=\"float:right\" alt=\"This child needs attention.\" />");
	out.print("User Name: <br />&raquo;&nbsp;" + child.getUserNameOrRequest ());
	out.println("<br />");
	if (null==child.getGivenName() || child.getGivenName().equals("")
			|| child.getGivenName().equals("null") || child.getGivenName().equals("")) {
		// do nothing
	} else {
		out.print("Child: " + child.getGivenName() + "\n");
	}
	out.println("</a>\n");
}

      out.write("\n</div>\n</span><span class=\"parentpane\" style=\"float: right;\">\n<img src=\"/images/icon-your-parent-box.png\" style=\"margin:-1em -1.5em 0.5em -1.5em;width:18em;\" />\n<br />\n<button type=\"button\" style=\"margin: 1em 1.25em;\" class=\"parentbuttons\" ");

//	if (sessionUser.isRegistered()) {
		out.print("onclick=\"document.location='/membership/parent/?edit=true#edit';\" id=\"edit-account\"");
//	} else {
//		storeValues.put("email", sessionUser.getMail());
//		storeValues.put("emailConfirm", sessionUser.getMail());
//		session.setAttribute("storeValues", storeValues);
//		out.print("onclick=\"document.location='/membership/register/parent/';\" id=\"parent-register\"");
//	}
	
      out.write("> </button>\n<button type=\"button\" style=\"margin: 1em 1.25em;\"  class=\"parentbuttons\"\n  onclick=\"document.location='/membership/register/membership/?register=parent';\" id=\"add-a-child\"> </button>\n</span>\n</div>\n<br clear=\"all\" />\n<img src=\"/images/icon-vit-membership.png\" style=\"float:left\" alt=\"This child has a Very Important Toot membership.\" /> V.I.T. Memberships <br />\n<img src=\"/images/icon-needs-attention.png\" style=\"float:left\" alt=\"This child needs attention.\" /> Your Child's Account Needs Attention\n<br />\n</div>\n");



if (null!=request.getParameter("edit") && !request.getParameter("edit").equals("")) {
	String edit = request.getParameter("edit");
	if (edit.equals("true")) {

      out.write("\n<a name=\"edit\" />\n<form  method=\"post\">\n<div class=\"fieldset\"><div class=\"legend\"><img src=\"/images/manageaccount/text-update-password.png\" /></div>\n<br />\n<table>\n<tr>\n<td colspan=\"\">\nDo you want to change your password?  Type your old password then your new password twice and hit submit!\n<br />\n<br />\n</td>\n</tr>\n<tr>\n<td colspan=\"2\"><br /></td>\n</tr>\n<tr>\n<td>Old Password:</td>\n<td><input type=\"password\" name=\"oldPassword\" maxlength=\"30\" size=\"40\" /></td>\n</tr>\n<tr>\n<td colspan=\"2\"><br /></td>\n</tr>\n<tr>\n<td>New Password:</td>\n<td><input type=\"password\" name=\"newPassword\" maxlength=\"30\" size=\"40\" /></td>\n</tr>\n<tr>\n<td>Confirm New Password:</td>\n<td><input type=\"password\" name=\"newPasswordConfirm\" maxlength=\"30\" size=\"40\" /></td>\n</tr>\n<tr>\n<td><br /></td>\n</tr>\n");

/**
 *<tr>
 *<td colspan="2"><h2>Update E-mail</h2></td>
 *</tr>
 *<tr>
 *<td colspan="2"><br /></td>
 *</tr>
 *<tr>
 *<td>New E-mail:</td>
 *<td><input type="text" name="newEmail" maxlength="50" size="40" /></td>
 *</tr>
 *<tr>
 *<td>Confirm New E-mail:</td>
 *<td><input type="text" name="newEmailConfirm" maxlength="50" size="40" /></td>
 *</tr>
 *<tr>
 *<td colspan="2"><br /></td>
 *</tr>
 */

      out.write("\n<tr>\n<td> </td>\n<td><input type=\"submit\" value=\"\" class=\"formbuttons\" id=\"submit\" /></td>\n</tr>\n</table>\n</div>\n</form>\n");
 }} 
      out.write("\n</div>\n\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "/membership/privacy.jsp", out, false);
      out.write("\n</div>\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "/membership/footer.jsp", out, false);
      out.write("\n\n<div class=\"imagepreload\">\n<img src=\"/images/button-submit1.png\" />\n<img src=\"/images/button-submit2.png\" />\n<img src=\"/images/button-submit3.png\" />\n<img src=\"/images/manageaccount/button-make-me-a-vit1.png\" />\n<img src=\"/images/manageaccount/button-make-me-a-vit2.png\" />\n<img src=\"/images/button-edit-account1.png\" />\n<img src=\"/images/button-edit-account2.png\" />\n<img src=\"/images/button-edit-account3.png\" />\n<img src=\"/images/button-add-a-child1.png\" />\n<img src=\"/images/button-add-a-child2.png\" />\n<img src=\"/images/button-add-a-child3.png\" />\n</div>\n\n</body>\n</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }

  private boolean _jspx_meth_mb_005fengine_005f0(PageContext _jspx_page_context)
          throws Throwable {
    PageContext pageContext = _jspx_page_context;
    JspWriter out = _jspx_page_context.getOut();
    //  mb:engine
    org.starhope.appius.mb.taglib.Engine _jspx_th_mb_005fengine_005f0 = (org.starhope.appius.mb.taglib.Engine) _005fjspx_005ftagPool_005fmb_005fengine_005fnobody.get(org.starhope.appius.mb.taglib.Engine.class);
    _jspx_th_mb_005fengine_005f0.setPageContext(_jspx_page_context);
    _jspx_th_mb_005fengine_005f0.setParent(null);
    int _jspx_eval_mb_005fengine_005f0 = _jspx_th_mb_005fengine_005f0.doStartTag();
    if (_jspx_th_mb_005fengine_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
      _005fjspx_005ftagPool_005fmb_005fengine_005fnobody.reuse(_jspx_th_mb_005fengine_005f0);
      return true;
    }
    _005fjspx_005ftagPool_005fmb_005fengine_005fnobody.reuse(_jspx_th_mb_005fengine_005f0);
    return false;
  }
}
