function rsvp_inject_add_guests_js($attendeeID)
{
    if (get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") {
        // TODO: Need to move this into the main JS file but not sure how to do that with the options and the custom questions.
        //       - Moving the options would be fairly easy. Just set two JS variables in here and then go off of that.
        //       - No clue on custom questions....
        $yesText = __("Yes", 'rsvp-plugin');
        $noText = __("No", 'rsvp-plugin');
        $numGuests = 3;
        if (get_option(OPTION_RSVP_NUM_ADDITIONAL_GUESTS) != "") {
            $numGuests = get_option(OPTION_RSVP_NUM_ADDITIONAL_GUESTS);
            if (!is_numeric($numGuests) || $numGuests < 0) {
                $numGuests = 3;
            }
        }
        $form = "<script type=\"text/javascript\" language=\"javascript\">\r\n\n\t\t\t\t\t\t\tfunction handleAddRsvpClick() {\n\t\t\t\t\t\t\t\tvar numAdditional = jQuery(\"#additionalRsvp\").val();\n\t\t\t\t\t\t\t\tnumAdditional++;\n\t\t\t\t\t\t\t\tif(numAdditional > " . $numGuests . ") {\n\t\t\t\t\t\t\t\t\talert('" . __("You have already added " . $numGuests . " additional rsvp\\'s you can add no more.", 'rsvp-plugin') . "');\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tjQuery(\"#additionalRsvpContainer\").append(\"<div class=\\\"rsvpAdditionalAttendee\\\">\" + \r\n\n                      \"<div class=\\\"rsvpAdditionalAttendeeQuestions\\\">\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n                      \"\t<label for=\\\"newAttending\" + numAdditional + \"FirstName\\\">" . __("Person's first name", 'rsvp-plugin') . "&nbsp;</label>\" + \r\n \n\t\t\t\t\t\t\t\t\t\t\t\t\"  <input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"FirstName\\\" id=\\\"newAttending\" + numAdditional + \"FirstName\\\" />\" + \r\n\n\t\t\t\t\t\t\t\t\t  \t\"</div>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n                      \"\t<label for=\\\"newAttending\" + numAdditional + \"LastName\\\">" . __("Person's last name", 'rsvp-plugin') . "</label>\" + \r\n \n\t\t\t\t\t\t\t\t\t\t\t\t\"  <input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"LastName\\\" id=\\\"newAttending\" + numAdditional + \"LastName\\\" />\" + \r\n\n                      \"</div>\" + \r\n";
        if (get_option(OPTION_RSVP_HIDE_EMAIL_FIELD) != "Y") {
            $form .= "\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n                        \"\t<label for=\\\"newAttending\" + numAdditional + \"Email\\\">" . __("Person's email address", 'rsvp-plugin') . "</label>\" + \r\n \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"  <input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"Email\\\" id=\\\"newAttending\" + numAdditional + \"Email\\\" />\" + \r\n\n                        \"</div>\" + \r\n";
        }
        $form .= "\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<p>" . __("Will this person be attending?", 'rsvp-plugin') . "</p>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"Y\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"Y\\\">{$yesText}</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"N\\\"> <label for=\\\"newAttending\" + numAdditional + \"N\\\">{$noText}</label>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\"</div>\" + \r\n";
        if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
            $form .= "\"<div class=\\\"rsvpFormField\\\">\" + \n                        \"<p>" . __("Does this person need a kids meal?", 'rsvp-plugin') . "</p>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealY\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealY\\\">{$yesText}</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealN\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealN\\\">{$noText}</label>\" + \n                        \"</div>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\"</div>\" + \r\n";
        }
        if (get_option(OPTION_HIDE_VEGGIE) != "Y") {
            $form .= "\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n                        \"<p>" . __("Does this person need a vegetarian meal?", 'rsvp-plugin') . "</p>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\">{$yesText}</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\">{$noText}</label>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\"</div>\" + ";
        }
        $tmpVar = str_replace("\r\n", "", str_replace("||", "\"", addSlashes(rsvp_buildAdditionalQuestions($attendeeID, "|| + numAdditional + ||"))));
        $form .= "\"" . $tmpVar . "\" + \n                        \"<p><button onclick=\\\"removeAdditionalRSVP(this);\\\">" . __("Remove Guest", 'rsvp-plugin') . "</button></p>\" + \n\t\t\t\t\t\t\t\t\t\t\"</div>\");\n\t\t\t\t\t\t\t\t\tjQuery(\"#additionalRsvp\").val(numAdditional);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n              \n              function removeAdditionalRSVP(rsvp) {\n\t\t\t\t\t\t\t\tvar numAdditional = jQuery(\"#additionalRsvp\").val();\n\t\t\t\t\t\t\t\tnumAdditional--;\n                jQuery(rsvp).parent().parent().remove();\n                jQuery(\"#additionalRsvp\").val(numAdditional);\n              }\n\t\t\t\t\t\t</script>\r\n";
        echo $form;
    }
}
function rsvp_frontend_main_form($attendeeID, $rsvpStep = "handleRsvp")
{
    global $wpdb, $rsvp_form_action, $rsvp_saved_form_vars;
    $attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, email, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal, personalGreeting   \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM " . ATTENDEES_TABLE . " \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE id = %d", $attendeeID));
    $sql = "SELECT id FROM " . ATTENDEES_TABLE . " \n\t \tWHERE (id IN (SELECT attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE associatedAttendeeID = %d) \n\t\t\tOR id in (SELECT associatedAttendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE attendeeID = %d)) \n\t\t\t AND additionalAttendee = 'Y'";
    $newRsvps = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID));
    $yesText = __("Yes", 'rsvp-plugin');
    $noText = __("No", 'rsvp-plugin');
    $yesVerbiage = trim(get_option(OPTION_YES_VERBIAGE)) != "" ? get_option(OPTION_YES_VERBIAGE) : __("Yes, of course I will be there! Who doesn't like family, friends, weddings, and a good time?", 'rsvp-plugin');
    $noVerbiage = trim(get_option(OPTION_NO_VERBIAGE)) != "" ? get_option(OPTION_NO_VERBIAGE) : __("Um, unfortunately, there is a Star Trek marathon on that day that I just cannot miss.", 'rsvp-plugin');
    $kidsVerbiage = trim(get_option(OPTION_KIDS_MEAL_VERBIAGE)) != "" ? get_option(OPTION_KIDS_MEAL_VERBIAGE) : __("We have the option of getting cheese pizza for the kids (and only kids).  Do you want pizza instead of \"adult food?\"", 'rsvp-plugin');
    $veggieVerbiage = trim(get_option(OPTION_VEGGIE_MEAL_VERBIAGE)) != "" ? get_option(OPTION_VEGGIE_MEAL_VERBIAGE) : __("We also have the option of getting individual vegetarian meals instead of the fish or meat.  Would you like a vegetarian dinner?", 'rsvp-plugin');
    $noteVerbiage = trim(get_option(OPTION_NOTE_VERBIAGE)) != "" ? get_option(OPTION_NOTE_VERBIAGE) : __("If you have any <strong style=\"color:red;\">food allergies</strong>, please indicate what they are in the &quot;notes&quot; section below.  Or, if you just want to send us a note, please feel free.  If you have any questions, please send us an email.", 'rsvp-plugin');
    $form = "<form id=\"rsvpForm\" name=\"rsvpForm\" method=\"post\" action=\"{$rsvp_form_action}\" autocomplete=\"off\">";
    $form .= "\t<input type=\"hidden\" name=\"attendeeID\" value=\"" . $attendeeID . "\" />";
    $form .= "\t<input type=\"hidden\" name=\"rsvpStep\" value=\"{$rsvpStep}\" />";
    // New Attendee fields when open registration is allowed
    if ($attendeeID <= 0) {
        $form .= RSVP_START_PARA;
        $form .= rsvp_BeginningFormField("", "") . "<label for=\"attendeeFirstName\">" . __("First Name: ", 'rsvp-plugin') . "</label>" . "<input type=\"text\" name=\"attendeeFirstName\" id=\"attendeeFirstName\" value=\"" . htmlspecialchars($rsvp_saved_form_vars['attendeeFirstName']) . "\" />" . RSVP_END_FORM_FIELD;
        $form .= RSVP_END_PARA;
        $form .= RSVP_START_PARA;
        $form .= rsvp_BeginningFormField("", "") . "<label for=\"attendeeLastName\">" . __("Last Name: ", 'rsvp-plugin') . "</label>" . "<input type=\"text\" name=\"attendeeLastName\" id=\"attendeeLastName\" value=\"" . htmlspecialchars($rsvp_saved_form_vars['attendeeLastName']) . "\" />" . RSVP_END_FORM_FIELD;
        $form .= RSVP_END_PARA;
    }
    $form .= RSVP_START_PARA;
    if (trim(get_option(OPTION_RSVP_QUESTION)) != "") {
        $form .= trim(get_option(OPTION_RSVP_QUESTION));
    } else {
        $form .= __("So, how about it?", 'rsvp-plugin');
    }
    $form .= RSVP_END_PARA . rsvp_BeginningFormField("", "") . "<input type=\"radio\" name=\"mainRsvp\" value=\"Y\" id=\"mainRsvpY\" " . ($attendee->rsvpStatus == "No" || $rsvp_saved_form_vars['mainRsvp'] == "N" ? "" : "checked=\"checked\"") . " /> <label for=\"mainRsvpY\">" . $yesVerbiage . "</label>" . RSVP_END_FORM_FIELD . rsvp_BeginningFormField("", "") . "<input type=\"radio\" name=\"mainRsvp\" value=\"N\" id=\"mainRsvpN\" " . ($attendee->rsvpStatus == "No" || $rsvp_saved_form_vars['mainRsvp'] == "N" ? "checked=\"checked\"" : "") . " /> " . "<label for=\"mainRsvpN\">" . $noVerbiage . "</label>" . RSVP_END_FORM_FIELD;
    if (!empty($attendee->personalGreeting)) {
        $form .= rsvp_BeginningFormField("rsvpCustomGreeting", "") . nl2br(stripslashes($attendee->personalGreeting)) . RSVP_END_FORM_FIELD;
    }
    if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
        $form .= rsvp_BeginningFormField("", "rsvpBorderTop") . RSVP_START_PARA . $kidsVerbiage . RSVP_END_PARA . "<input type=\"radio\" name=\"mainKidsMeal\" value=\"Y\" id=\"mainKidsMealY\" " . ($attendee->kidsMeal == "Y" || $rsvp_saved_form_vars['mainKidsMeal'] == "Y" ? "checked=\"checked\"" : "") . " /> <label for=\"mainKidsMealY\">{$yesText}</label> " . "<input type=\"radio\" name=\"mainKidsMeal\" value=\"N\" id=\"mainKidsMealN\" " . ($attendee->kidsMeal == "Y" || $rsvp_saved_form_vars['mainKidsMeal'] == "Y" ? "" : "checked=\"checked\"") . " /> <label for=\"mainKidsMealN\">{$noText}</label>" . RSVP_END_FORM_FIELD;
    }
    if (get_option(OPTION_HIDE_VEGGIE) != "Y") {
        $form .= rsvp_BeginningFormField("", "rsvpBorderTop") . RSVP_START_PARA . $veggieVerbiage . RSVP_END_PARA . "<input type=\"radio\" name=\"mainVeggieMeal\" value=\"Y\" id=\"mainVeggieMealY\" " . ($attendee->veggieMeal == "Y" || $rsvp_saved_form_vars['mainVeggieMeal'] == "Y" ? "checked=\"checked\"" : "") . "/> <label for=\"mainVeggieMealY\">{$yesText}</label> " . "<input type=\"radio\" name=\"mainVeggieMeal\" value=\"N\" id=\"mainVeggieMealN\" " . ($attendee->veggieMeal == "Y" || $rsvp_saved_form_vars['mainVeggieMeal'] == "Y" ? "" : "checked=\"checked\"") . " /> <label for=\"mainVeggieMealN\">{$noText}</label>" . RSVP_END_FORM_FIELD;
    }
    if (get_option(OPTION_RSVP_HIDE_EMAIL_FIELD) != "Y") {
        $form .= rsvp_BeginningFormField("", "rsvpBorderTop") . RSVP_START_PARA . "<label for=\"mainEmail\">" . __("Email Address", 'rsvp-plugin') . "</label>" . RSVP_END_PARA . "<input type=\"text\" name=\"mainEmail\" id=\"mainEmail\" value=\"" . htmlspecialchars($attendee->email) . "\" />" . RSVP_END_FORM_FIELD;
    }
    $form .= rsvp_buildAdditionalQuestions($attendeeID, "main");
    if (get_option(RSVP_OPTION_HIDE_NOTE) != "Y") {
        $form .= RSVP_START_PARA . $noteVerbiage . RSVP_END_PARA . rsvp_BeginningFormField("", "") . "<textarea name=\"rsvp_note\" id=\"rsvp_note\" rows=\"7\" cols=\"50\">" . (!empty($attendee->note) ? $attendee->note : $rsvp_saved_form_vars['rsvp_note']) . "</textarea>" . RSVP_END_FORM_FIELD;
    }
    $sql = "SELECT id, firstName, lastName FROM " . ATTENDEES_TABLE . " \n\t \tWHERE (id IN (SELECT attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE associatedAttendeeID = %d) \n\t\t\tOR id in (SELECT associatedAttendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE attendeeID = %d) OR \n      id IN (SELECT waa1.attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " waa1 \n           INNER JOIN " . ASSOCIATED_ATTENDEES_TABLE . " waa2 ON waa2.attendeeID = waa1.attendeeID  OR \n                                                     waa1.associatedAttendeeID = waa2.attendeeID \n           WHERE waa2.associatedAttendeeID = %d AND waa1.attendeeID <> %d)) \n\t\t\t AND rsvpStatus <> 'NoResponse'";
    $rsvpd = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID, $attendeeID, $attendeeID));
    if (count($rsvpd) > 0) {
        $form .= "<div class=\"rsvpAdditionalAttendee\">\r\n";
        $form .= RSVP_START_PARA . __("The following people associated with you have already registered:", 'rsvp-plugin') . " ";
        foreach ($rsvpd as $r) {
            $form .= "<br />" . htmlspecialchars($r->firstName . " " . $r->lastName);
        }
        $form .= RSVP_END_PARA;
        $form .= "</div>";
    }
    $sql = "SELECT id, firstName, lastName, email, personalGreeting FROM " . ATTENDEES_TABLE . " \n\t \tWHERE (id IN (SELECT attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE associatedAttendeeID = %d) \n\t\t\tOR id in (SELECT associatedAttendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE attendeeID = %d) OR \n      id IN (SELECT waa1.attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " waa1 \n           INNER JOIN " . ASSOCIATED_ATTENDEES_TABLE . " waa2 ON waa2.attendeeID = waa1.attendeeID  OR \n                                                     waa1.associatedAttendeeID = waa2.attendeeID \n           WHERE waa2.associatedAttendeeID = %d AND waa1.attendeeID <> %d)) \n\t\t\t AND rsvpStatus = 'NoResponse'";
    $associations = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID, $attendeeID, $attendeeID));
    if (count($associations) > 0) {
        $form .= "<h3>" . __("The following people are associated with you.  At this time you can RSVP for them as well.", 'rsvp-plugin') . "</h3>";
        foreach ($associations as $a) {
            if ($a->id != $attendeeID) {
                $form .= "<div class=\"rsvpAdditionalAttendee\">\r\n";
                $form .= "<div class=\"rsvpAdditionalAttendeeQuestions\">\r\n";
                $form .= rsvp_BeginningFormField("", "") . RSVP_START_PARA . sprintf(__(" Will %s be attending?", 'rsvp-plugin'), htmlspecialchars($a->firstName . " " . $a->lastName)) . RSVP_END_PARA . "<input type=\"radio\" name=\"attending" . $a->id . "\" value=\"Y\" id=\"attending" . $a->id . "Y\" /> " . "<label for=\"attending" . $a->id . "Y\">{$yesText}</label> \n  \t\t\t\t\t\t\t<input type=\"radio\" name=\"attending" . $a->id . "\" value=\"N\" id=\"attending" . $a->id . "N\" /> " . "<label for=\"attending" . $a->id . "N\">{$noText}</label>" . RSVP_END_FORM_FIELD;
                if (!empty($a->personalGreeting)) {
                    $form .= RSVP_START_PARA . nl2br($a->personalGreeting) . RSVP_END_PARA;
                }
                if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
                    $form .= rsvp_BeginningFormField("", "") . RSVP_START_PARA . sprintf(__("Does %s need a kids meal?", 'rsvp-plugin'), htmlspecialchars($a->firstName)) . RSVP_END_PARA . "&nbsp; " . "<input type=\"radio\" name=\"attending" . $a->id . "KidsMeal\" value=\"Y\" id=\"attending" . $a->id . "KidsMealY\" /> " . "<label for=\"attending" . $a->id . "KidsMealY\">{$yesText}</label> \n  \t\t\t\t\t<input type=\"radio\" name=\"attending" . $a->id . "KidsMeal\" value=\"N\" id=\"attending" . $a->id . "KidsMealN\" checked=\"checked\" /> " . "<label for=\"attending" . $a->id . "KidsMealN\">{$noText}</label>" . RSVP_END_FORM_FIELD;
                }
                if (get_option(OPTION_HIDE_VEGGIE) != "Y") {
                    $form .= rsvp_BeginningFormField("", "") . RSVP_START_PARA . sprintf(__("Does %s need a vegetarian meal?", 'rsvp-plugin'), htmlspecialchars($a->firstName)) . RSVP_END_PARA . "&nbsp; " . "<input type=\"radio\" name=\"attending" . $a->id . "VeggieMeal\" value=\"Y\" id=\"attending" . $a->id . "VeggieMealY\" /> " . "<label for=\"attending" . $a->id . "VeggieMealY\">{$yesText}</label> \n      \t\t\t\t\t\t<input type=\"radio\" name=\"attending" . $a->id . "VeggieMeal\" value=\"N\" id=\"attending" . $a->id . "VeggieMealN\" checked=\"checked\" /> " . "<label for=\"attending" . $a->id . "VeggieMealN\">{$noText}</label>" . RSVP_END_FORM_FIELD;
                }
                if (get_option(OPTION_RSVP_HIDE_EMAIL_FIELD) != "Y") {
                    $form .= rsvp_BeginningFormField("", "rsvpBorderTop") . RSVP_START_PARA . "<label for=\"attending" . $a->id . "Email\">" . __("Email Address", 'rsvp-plugin') . "</label>" . RSVP_END_PARA . "<input type=\"text\" name=\"attending" . $a->id . "Email\" id=\"attending" . $a->id . "Email\" value=\"" . htmlspecialchars($a->email) . "\" />" . RSVP_END_FORM_FIELD;
                }
                $form .= rsvp_buildAdditionalQuestions($a->id, $a->id);
                $form .= "</div>\r\n";
                //-- rsvpAdditionalAttendeeQuestions
                $form .= "</div>\r\n";
            }
            // if($a->id != ...)
        }
        // foreach($associations...)
    }
    if (get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") {
        $text = __("Did we slip up and forget to invite someone? If so, please add him or her here:", 'rsvp-plugin');
        if (trim(get_option(OPTION_RSVP_ADD_ADDITIONAL_VERBIAGE)) != "") {
            $text = get_option(OPTION_RSVP_ADD_ADDITIONAL_VERBIAGE);
        }
        $form .= "<h3>{$text}</h3>\r\n";
        $form .= "<div id=\"additionalRsvpContainer\">\r\n\n\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"additionalRsvp\" id=\"additionalRsvp\" value=\"" . count($newRsvps) . "\" />\n\t\t\t\t\t\t\t\t<div style=\"text-align:right\"><img " . "src=\"" . get_option("siteurl") . "/wp-content/plugins/rsvp/plus.png\" width=\"24\" height=\"24\" border=\"0\" id=\"addRsvp\" /></div>" . "</div>";
    }
    $form .= RSVP_START_PARA . "<input type=\"submit\" value=\"RSVP\" />" . RSVP_END_PARA;
    if (get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") {
        // TODO: Need to move this into the main JS file but not sure how to do that with the options and the custom questions.
        //       - Moving the options would be fairly easy. Just set two JS variables in here and then go off of that.
        //       - No clue on custom questions....
        $numGuests = 3;
        if (get_option(OPTION_RSVP_NUM_ADDITIONAL_GUESTS) != "") {
            $numGuests = get_option(OPTION_RSVP_NUM_ADDITIONAL_GUESTS);
            if (!is_numeric($numGuests) || $numGuests < 0) {
                $numGuests = 3;
            }
        }
        $form .= "<script type=\"text/javascript\" language=\"javascript\">\r\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tfunction handleAddRsvpClick() {\n\t\t\t\t\t\t\t\t\tvar numAdditional = jQuery(\"#additionalRsvp\").val();\n\t\t\t\t\t\t\t\t\tnumAdditional++;\n\t\t\t\t\t\t\t\t\tif(numAdditional > " . $numGuests . ") {\n\t\t\t\t\t\t\t\t\t\talert('" . __("You have already added " . $numGuests . " additional rsvp\\'s you can add no more.", 'rsvp-plugin') . "');\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tjQuery(\"#additionalRsvpContainer\").append(\"<div class=\\\"rsvpAdditionalAttendee\\\">\" + \r\n\n                        \"<div class=\\\"rsvpAdditionalAttendeeQuestions\\\">\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n                        \"\t<label for=\\\"newAttending\" + numAdditional + \"FirstName\\\">" . __("Person's first name", 'rsvp-plugin') . "&nbsp;</label>\" + \r\n \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"  <input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"FirstName\\\" id=\\\"newAttending\" + numAdditional + \"FirstName\\\" />\" + \r\n\n\t\t\t\t\t\t\t\t\t\t  \t\"</div>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n                        \"\t<label for=\\\"newAttending\" + numAdditional + \"LastName\\\">" . __("Person's last name", 'rsvp-plugin') . "</label>\" + \r\n \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"  <input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"LastName\\\" id=\\\"newAttending\" + numAdditional + \"LastName\\\" />\" + \r\n\n                        \"</div>\" + \r\n";
        if (get_option(OPTION_RSVP_HIDE_EMAIL_FIELD) != "Y") {
            $form .= "\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n                          \"\t<label for=\\\"newAttending\" + numAdditional + \"Email\\\">" . __("Person's email address", 'rsvp-plugin') . "</label>\" + \r\n \n  \t\t\t\t\t\t\t\t\t\t\t\t\t\"  <input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"Email\\\" id=\\\"newAttending\" + numAdditional + \"Email\\\" />\" + \r\n\n                          \"</div>\" + \r\n";
        }
        $form .= "\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<p>Will this person be attending?</p>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"Y\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"Y\\\">{$yesText}</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"N\\\"> <label for=\\\"newAttending\" + numAdditional + \"N\\\">{$noText}</label>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"</div>\" + \r\n";
        if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
            $form .= "\"<div class=\\\"rsvpFormField\\\">\" + \n                          \"<p>" . __("Does this person need a kids meal?", 'rsvp-plugin') . "</p>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealY\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealY\\\">{$yesText}</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealN\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealN\\\">{$noText}</label>\" + \n                          \"</div>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"</div>\" + \r\n";
        }
        if (get_option(OPTION_HIDE_VEGGIE) != "Y") {
            $form .= "\"<div class=\\\"rsvpFormField\\\">\" + \r\n\n                          \"<p>" . __("Does this person need a vegetarian meal?", 'rsvp-plugin') . "</p>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\">{$yesText}</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\">{$noText}</label>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"</div>\" + ";
        }
        $tmpVar = str_replace("\r\n", "", str_replace("|", "\"", addSlashes(rsvp_buildAdditionalQuestions($attendeeID, "| + numAdditional + |"))));
        $form .= "\"" . $tmpVar . "\" + \n                          \"<p><button onclick=\\\"removeAdditionalRSVP(this);\\\">Remove Guest</button></p>\" + \n\t\t\t\t\t\t\t\t\t\t\t\"</div>\");\n\t\t\t\t\t\t\t\t\t\tjQuery(\"#additionalRsvp\").val(numAdditional);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n                \n                function removeAdditionalRSVP(rsvp) {\n\t\t\t\t\t\t\t\t\tvar numAdditional = jQuery(\"#additionalRsvp\").val();\n\t\t\t\t\t\t\t\t\tnumAdditional--;\n                  jQuery(rsvp).parent().parent().remove();\n                  jQuery(\"#additionalRsvp\").val(numAdditional);\n                }\n\t\t\t\t\t\t\t</script>\r\n";
    }
    $form .= "</form>\r\n";
    return $form;
}
function rsvp_frontend_main_form($attendeeID)
{
    global $wpdb;
    $attendee = $wpdb->get_row($wpdb->prepare("SELECT id, firstName, lastName, rsvpStatus, note, kidsMeal, additionalAttendee, veggieMeal, personalGreeting   \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM " . ATTENDEES_TABLE . " \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE id = %d", $attendeeID));
    $sql = "SELECT id FROM " . ATTENDEES_TABLE . " \n\t \tWHERE (id IN (SELECT attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE associatedAttendeeID = %d) \n\t\t\tOR id in (SELECT associatedAttendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE attendeeID = %d)) \n\t\t\t AND additionalAttendee = 'Y'";
    $newRsvps = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID));
    $form = "<script type=\"text/javascript\" language=\"javascript\">\r\n\n\t\t\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\t\t\tjQuery.validator.addMethod(\"customNote\", function(value, element) {\n\t\t\t\t\t\t      if((jQuery(\"#additionalRsvp\").val() > 0) && (jQuery(\"#note\").val() == \"\")) {\n\t\t\t\t\t\t        return false;\n\t\t\t\t\t\t      }\n\n\t\t\t\t\t\t      return true;\n\t\t\t\t\t\t    }, \"<br />Please enter an email address that we can use to contact you about the extra guest.  We have to keep a pretty close eye on the number of attendees.  Thanks!\");\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery(\"#rsvpForm\").validate({\r\n\n\t\t\t\t\t\t\t\t\trules: {\n\t\t\t\t\t\t\t\t\t\tnote: \"customNote\",\n\t\t\t\t\t\t\t\t\t\tnewAttending1LastName:  \"required\",\n\t\t\t\t\t\t\t\t\t\tnewAttending1FirstName: \"required\", \n\t\t\t\t\t\t\t\t\t\tnewAttending2LastName:  \"required\",\n\t\t\t\t\t\t\t\t\t\tnewAttending2FirstName: \"required\",\n\t\t\t\t\t\t\t\t\t\tnewAttending3LastName:  \"required\",\n\t\t\t\t\t\t\t\t\t\tnewAttending3FirstName: \"required\"\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tmessages: {\n\t\t\t\t\t\t\t\t\t\tnote: \"<br />If you are adding additional RSVPs please enter your email address in case we have questions\",\n\t\t\t\t\t\t\t\t\t\tnewAttending1LastName:  \"<br />Please enter a last name\",\n\t\t\t\t\t\t\t\t\t\tnewAttending1FirstName: \"<br />Please enter a first name\", \n\t\t\t\t\t\t\t\t\t\tnewAttending2LastName:  \"<br />Please enter a last name\",\n\t\t\t\t\t\t\t\t\t\tnewAttending2FirstName: \"<br />Please enter a first name\",\n\t\t\t\t\t\t\t\t\t\tnewAttending3LastName:  \"<br />Please enter a last name\",\n\t\t\t\t\t\t\t\t\t\tnewAttending3FirstName: \"<br />Please enter a first name\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t</script>\r\n";
    $form .= "<style text/css>\r\n" . "\tlabel.error { font-weight: bold; clear:both;}\r\n" . "\tinput.error, textarea.error { border: 2px solid red; }\r\n" . "</style>\r\n";
    $form .= "<form id=\"rsvpForm\" name=\"rsvpForm\" method=\"post\">\r\n";
    $form .= "\t<input type=\"hidden\" name=\"attendeeID\" value=\"" . $attendeeID . "\" />\r\n";
    $form .= "\t<input type=\"hidden\" name=\"rsvpStep\" value=\"handleRsvp\" />\r\n";
    $form .= "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\">\r\n";
    $yesVerbiage = trim(get_option(OPTION_YES_VERBIAGE)) != "" ? get_option(OPTION_YES_VERBIAGE) : "Yes, of course I will be there! Who doesn't like family, friends, weddings, and a good time?";
    $noVerbiage = trim(get_option(OPTION_NO_VERBIAGE)) != "" ? get_option(OPTION_NO_VERBIAGE) : "Um, unfortunately, there is a Star Trek marathon on that day that I just cannot miss.";
    $kidsVerbiage = trim(get_option(OPTION_KIDS_MEAL_VERBIAGE)) != "" ? get_option(OPTION_KIDS_MEAL_VERBIAGE) : "We have the option of getting cheese pizza for the kids (and only kids).  Do you want pizza instead of \"adult food?\"";
    $veggieVerbiage = trim(get_option(OPTION_VEGGIE_MEAL_VERBIAGE)) != "" ? get_option(OPTION_VEGGIE_MEAL_VERBIAGE) : "We also have the option of getting individual vegetarian meals instead of the fish or meat.  Would you like a vegetarian dinner?";
    $noteVerbiage = trim(get_option(OPTION_NOTE_VERBIAGE)) != "" ? get_option(OPTION_NOTE_VERBIAGE) : "If you have any <strong style=\"color:red;\">food allergies</strong>, please indicate what they are in the &quot;notes&quot; section below.  Or, if you just want to send us a note, please feel free.  If you have any questions, please send us an email.";
    $form .= "  <tr>\r\n\n\t\t\t\t\t\t\t\t<td align=\"left\">";
    if (trim(get_option(OPTION_RSVP_QUESTION)) != "") {
        $form .= trim(utf8_decode(get_option(OPTION_RSVP_QUESTION)));
    } else {
        $form .= "So, how about it?";
    }
    $form .= "</td>\n\t\t\t\t\t\t\t</tr>\r\n\n\t\t\t\t\t\t\t<tr>\r\n\n\t\t\t\t\t\t\t\t<td colspan=\"2\" align=\"left\"><input type=\"radio\" name=\"mainRsvp\" value=\"Y\" id=\"mainRsvpY\" " . ($attendee->rsvpStatus == "No" ? "" : "checked=\"checked\"") . " /> - <label for=\"mainRsvpY\">" . $yesVerbiage . "</label></td>\n\t\t\t\t\t\t\t</tr>\r\n\n\t\t\t\t\t\t\t<tr>\r\n\n\t\t\t\t\t\t\t\t<td align=\"left\" colspan=\"2\"><input type=\"radio\" name=\"mainRsvp\" value=\"N\" id=\"mainRsvpN\" " . ($attendee->rsvpStatus == "No" ? "checked=\"checked\"" : "") . " /> - \n\t\t\t\t\t\t\t\t\t\t\t<label for=\"mainRsvpN\">" . $noVerbiage . "</label></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr><td><br /></td></tr>";
    if (!empty($attendee->personalGreeting)) {
        $form .= "<tr>\r\n\n\t\t\t\t\t\t<td colspan=\"2\" align=\"left\">" . nl2br(utf8_decode(stripslashes($attendee->personalGreeting))) . "</td>\r\n\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr><td><br /></td></tr>\r\n";
    }
    if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
        $form .= "\t<tr><td colspan=\"2\"><hr /></td></tr>\r\n\n\t\t\t\t\t\t\t\t<tr>\r\n\n\t\t\t\t\t\t\t\t\t<td colspan=\"2\" align=\"left\">" . $kidsVerbiage . "</td>\n\t\t\t\t\t\t\t\t</tr>\r\n\n\t\t\t\t\t\t\t\t<tr>\r\n\n\t\t\t\t\t\t\t\t\t<td align=\"center\" colspan=\"2\"><input type=\"radio\" name=\"mainKidsMeal\" value=\"Y\" id=\"mainKidsMealY\" \n\t\t\t\t\t\t\t\t\t \t" . ($attendee->kidsMeal == "Y" ? "checked=\"checked\"" : "") . " /> <label for=\"mainKidsMealY\">Yes</label> \n\t\t\t\t\t\t\t\t\t\t\t<input type=\"radio\" name=\"mainKidsMeal\" value=\"N\" id=\"mainKidsMealN\" \n\t\t\t\t\t\t\t\t\t\t\t" . ($attendee->kidsMeal == "Y" ? "" : "checked=\"checked\"") . " /> <label for=\"mainKidsMealN\">No</label></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr><td><br /></td></tr>";
    }
    if (get_option(OPTION_HIDE_VEGGIE) != "Y") {
        $form .= "\t<tr><td colspan=\"2\"><hr /></td></tr>\r\n\n\t\t\t\t\t\t\t\t<tr>\r\n\n\t\t\t\t\t\t\t\t\t<td align=\"left\" colspan=\"2\">" . $veggieVerbiage . "</td> \n\t\t\t\t\t\t\t\t</tr>\r\n\n\t\t\t\t\t\t\t\t<tr>\r\n\n\t\t\t\t\t\t\t\t\t<td align=\"center\" colspan=\"2\"><input type=\"radio\" name=\"mainVeggieMeal\" value=\"Y\" id=\"mainVeggieMealY\"\n\t\t\t\t\t\t\t\t\t \t\t" . ($attendee->veggieMeal == "Y" ? "checked=\"checked\"" : "") . "/> <label for=\"mainVeggieMealY\">Yes</label> \n\t\t\t\t\t\t\t\t\t\t\t<input type=\"radio\" name=\"mainVeggieMeal\" value=\"N\" id=\"mainVeggieMealN\" \n\t\t\t\t\t\t\t\t\t\t\t" . ($attendee->veggieMeal == "Y" ? "" : "checked=\"checked\"") . " /> <label for=\"mainVeggieMealN\">No</label></td>\n\t\t\t\t\t\t\t\t</tr>\r\n";
    }
    $form .= rsvp_buildAdditionalQuestions($attendeeID, "main");
    $form .= " <tr><td><br /></td></tr>\r\n\n\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t<td valign=\"top\" align=\"left\" colspan=\"2\">" . $noteVerbiage . "</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colspan=\"2\"><textarea name=\"rsvp_note\" id=\"rsvp_note\" rows=\"7\" cols=\"50\">" . $attendee->note . "</textarea></td>\n\t\t\t\t\t\t </tr>";
    $form .= "</table>\r\n";
    $sql = "SELECT id, firstName, lastName FROM " . ATTENDEES_TABLE . " \n\t \tWHERE (id IN (SELECT attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE associatedAttendeeID = %d) \n\t\t\tOR id in (SELECT associatedAttendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE attendeeID = %d)) \n\t\t\t AND rsvpStatus <> 'NoResponse'";
    $rsvpd = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID));
    if (count($rsvpd) > 0) {
        $form .= "<p>The following people associated with you have already registered: ";
        foreach ($rsvpd as $r) {
            $form .= "<br />" . htmlentities($r->firstName . " " . $r->lastName);
        }
        $form .= "</p>\r\n";
    }
    $sql = "SELECT id, firstName, lastName, personalGreeting FROM " . ATTENDEES_TABLE . " \n\t \tWHERE (id IN (SELECT attendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE associatedAttendeeID = %d) \n\t\t\tOR id in (SELECT associatedAttendeeID FROM " . ASSOCIATED_ATTENDEES_TABLE . " WHERE attendeeID = %d)) \n\t\t\t AND rsvpStatus = 'NoResponse'";
    $associations = $wpdb->get_results($wpdb->prepare($sql, $attendeeID, $attendeeID));
    if (count($associations) > 0) {
        $form .= "<h3>The following people are associated with you.  At this time you can RSVP for them as well.</h3>";
        foreach ($associations as $a) {
            $form .= "<div style=\"text-align:left;border-top: 1px solid;\">\r\n\n\t\t\t\t\t\t\t<p><label for=\"rsvpFor" . $a->id . "\">RSVP for " . htmlentities(utf8_decode($a->firstName . " " . $a->lastName)) . "?</label> \n\t\t\t\t\t\t\t\t\t<input type=\"checkbox\" name=\"rsvpFor" . $a->id . "\" id=\"rsvpFor" . $a->id . "\" value=\"Y\" /></p>";
            $form .= "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\">\r\n";
            $form .= "  <tr>\r\n\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\">Will " . htmlentities(utf8_decode($a->firstName)) . " be attending?</td>\r\n\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\"><input type=\"radio\" name=\"attending" . $a->id . "\" value=\"Y\" id=\"attending" . $a->id . "Y\" checked=\"checked\" /> \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<label for=\"attending" . $a->id . "Y\">Yes</label> \n\t\t\t\t\t\t\t\t\t\t\t\t<input type=\"radio\" name=\"attending" . $a->id . "\" value=\"N\" id=\"attending" . $a->id . "N\" /> <label for=\"attending" . $a->id . "N\">No</label></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr><td><br /></td></tr>";
            if (!empty($a->personalGreeting)) {
                $form .= "<tr>\r\n\n\t\t\t\t\t\t\t\t<td colspan=\"2\" align=\"left\">" . nl2br(utf8_decode($a->personalGreeting)) . "</td>\r\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr><td><br /></td></tr>\r\n";
            }
            if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
                $form .= "\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td align=\"left\">Does " . htmlentities(utf8_decode($a->firstName)) . " need a kids meal?&nbsp;</td> \n\t\t\t\t\t\t\t\t\t\t\t<td align=\"left\"><input type=\"radio\" name=\"attending" . $a->id . "KidsMeal\" value=\"Y\" id=\"attending" . $a->id . "KidsMealY\" /> \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<label for=\"attending" . $a->id . "KidsMealY\">Yes</label> \n\t\t\t\t\t\t\t\t\t\t\t\t\t<input type=\"radio\" name=\"attending" . $a->id . "KidsMeal\" value=\"N\" id=\"attending" . $a->id . "KidsMealN\" checked=\"checked\" /> \n\t\t\t\t\t\t\t\t\t\t\t\t\t<label for=\"attending" . $a->id . "KidsMealN\">No</label></td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr><td><br /></td></tr>";
            }
            if (get_option(OPTION_HIDE_VEGGIE) != "Y") {
                $form .= "\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td align=\"left\">Does " . htmlentities(utf8_decode($a->firstName)) . " need a vegetarian meal?&nbsp;</td> \n\t\t\t\t\t\t\t\t\t\t\t<td align=\"left\"><input type=\"radio\" name=\"attending" . $a->id . "VeggieMeal\" value=\"Y\" id=\"attending" . $a->id . "VeggieMealY\" /> \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<label for=\"attending" . $a->id . "VeggieMealY\">Yes</label> \n\t\t\t\t\t\t\t\t\t\t\t\t\t<input type=\"radio\" name=\"attending" . $a->id . "VeggieMeal\" value=\"N\" id=\"attending" . $a->id . "VeggieMealN\" checked=\"checked\" /> \n\t\t\t\t\t\t\t\t\t\t\t\t\t<label for=\"attending" . $a->id . "VeggieMealN\">No</label></td>\n\t\t\t\t\t\t\t\t\t\t</tr>";
            }
            $form .= rsvp_buildAdditionalQuestions($a->id, $a->id);
            $form .= "</table>\r\n";
            $form .= "</div>\r\n";
        }
    }
    if (get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") {
        $form .= "<h3>Did we slip up and forget to invite someone? If so, please add him or her here:</h3>\r\n";
        $form .= "<div id=\"additionalRsvpContainer\">\r\n\n\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"additionalRsvp\" id=\"additionalRsvp\" value=\"" . count($newRsvps) . "\" />\n\t\t\t\t\t\t\t\t<div style=\"text-align:right\"><img \n\t\t\t\t\t\t\t\t\tsrc=\"" . get_option("siteurl") . "/wp-content/plugins/rsvp/plus.png\" width=\"24\" height=\"24\" border=\"0\" id=\"addRsvp\" /></div>\n\t\n\t\t\t\t\t\t\t</div>";
    }
    $form .= "<p><input type=\"submit\" value=\"RSVP\" /></p>\r\n";
    if (get_option(OPTION_HIDE_ADD_ADDITIONAL) != "Y") {
        $form .= "<script type=\"text/javascript\" language=\"javascript\">\r\n\n\t\t\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\t\t\tjQuery(\"#addRsvp\").click(function() {\n\t\t\t\t\t\t\t\t\t\thandleAddRsvpClick();\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tfunction handleAddRsvpClick() {\n\t\t\t\t\t\t\t\t\tvar numAdditional = jQuery(\"#additionalRsvp\").val();\n\t\t\t\t\t\t\t\t\tnumAdditional++;\n\t\t\t\t\t\t\t\t\tif(numAdditional > 3) {\n\t\t\t\t\t\t\t\t\t\talert('You have already added 3 additional rsvp\\'s you can add no more.');\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tjQuery(\"#additionalRsvpContainer\").append(\"<div style=\\\"text-align:left;border-top: 1px solid;\\\">\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\"<table cellpadding=\\\"2\\\" cellspacing=\\\"0\\\" border=\\\"0\\\">\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<tr>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"\t<td align=\\\"left\\\">Person's first name&nbsp;</td>\" + \r\n \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"  <td align=\\\"left\\\"><input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"FirstName\\\" id=\\\"newAttending\" + numAdditional + \"FirstName\\\" /></td>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t  \t\t\"</tr>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"<tr>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"\t<td align=\\\"left\\\">Person's last name</td>\" + \r\n \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"  <td align=\\\"left\\\"><input type=\\\"text\\\" name=\\\"newAttending\" + numAdditional + \"LastName\\\" id=\\\"newAttending\" + numAdditional + \"LastName\\\" /></td>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"</tr>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t  \t\t\"<tr>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<td align=\\\"left\\\">Will this person be attending?&nbsp;</td>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<td align=\\\"left\\\">\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"Y\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"Y\\\">Yes</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"N\\\"> <label for=\\\"newAttending\" + numAdditional + \"N\\\">No</label></td>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"</tr>\" + \r\n";
        if (get_option(OPTION_HIDE_KIDS_MEAL) != "Y") {
            $form .= "\"<tr>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<td align=\\\"left\\\">Does this person need a kids meal?&nbsp;</td> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<td align=\\\"left\\\"><input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealY\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealY\\\">Yes</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"KidsMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"KidsMealN\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"KidsMealN\\\">No</label></td>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"</tr>\" + \r\n";
        }
        if (get_option(OPTION_HIDE_VEGGIE) != "Y") {
            $form .= "\"<tr>\" + \r\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<td align=\\\"left\\\">Does this person need a vegetarian meal?&nbsp;</td> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<td align=\\\"left\\\"><input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"Y\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealY\\\">Yes</label> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<input type=\\\"radio\\\" name=\\\"newAttending\" + numAdditional + \"VeggieMeal\\\" value=\\\"N\\\" id=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\" checked=\\\"checked\\\" /> \" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"<label for=\\\"newAttending\" + numAdditional + \"VeggieMealN\\\">No</label></td>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\"</tr>\" + ";
        }
        $tmpVar = str_replace("\r\n", "", str_replace("|", "\"", addSlashes(rsvp_buildAdditionalQuestions(0, "| + numAdditional + |"))));
        $form .= "\"" . $tmpVar . "\" + ";
        $form .= "\"</table>\" + \n\t\t\t\t\t\t\t\t\t\t\t\t\"<br />\" + \n\t\t\t\t\t\t\t\t\t\t\t\"</div>\");\n\t\t\t\t\t\t\t\t\t\tjQuery(\"#additionalRsvp\").val(numAdditional);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</script>\r\n";
    }
    $form .= "</form>\r\n";
    return $form;
}