<?php
$role_id = $this->session->userdata('role_id');
$person_id = $this->session->userdata('person_id');
$person_role = $this->session->userdata('person_role');
?>
<script>

    var xmlhttp = false;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest !== 'undefined') {
        xmlhttp = new XMLHttpRequest();
    }

    var urlValue = '';
</script>
<div class="col-sm-10 "> 
    <h3 class="text-center gray">Add User Information</h3>
    <div class="col-sm-12 gray" >
        <div class="col-sm-12">
            <?php
            //formID2
            $url = 'super-admin/add-user';
            echo form_open_multipart($url, 'class="cmxform" id="formID2" name="userForm"');
            ?>
            <div class="form-group col-sm-12">
                <div class="form-group col-sm-5">
                    <input name="person_first_name" 
                           class="form-control validate[required, custom[personName], custom[firstNameLength]] text-input" 
                           id="person_first_name" 
                           oninput="getUrlValue(this.value,person_last_name.value,urlValue);"
                           type="text" 
                           placeholder="Please type First Name" 
                           value="<?php echo set_value('person_first_name'); ?>"
                           maxlength="100"
                           data-errormessage-value-missing="Person First Name is required!">
                    <span id="person_first_name_error" style="color:red"><?php echo form_error('person_first_name'); ?></span>
                </div>
                

                <div class="form-group col-sm-5">
                    <input name="person_last_name" 
                           class="form-control validate[custom[personName], custom[lastNameLength]] text-input" 
                           id="person_last_name" 
                           oninput="getUrlValue(person_first_name.value,this.value,urlValue);" 
                           type="text" 
                           placeholder="please type Last Name" 
                           value="<?php echo set_value('person_last_name'); ?>" 
                           maxlength="100"
                           data-errormessage-value-missing=" ">
                    <span id="person_last_name_error" style="color:red"><?php echo form_error('person_last_name'); ?></span>
                </div>
            </div>

            <div class="form-group col-sm-12">
                <div class="form-group col-sm-5">
                    <input name="profile_url" 
                           class="form-control validate[required, custom[urlSpecialCaracter], custom[spaceFunction], custom[urlExistence], custom[noCapital], custom[checkUrlHypen], custom[checkUrlHypenLast]]" 
                           id="profile_url" 
                           oninput="getUrlValue(person_first_name.value,person_last_name.value,this.value);" 
                           type="text" 
                           placeholder="Please type Profile URL" 
                           value="<?php echo set_value('profile_url'); ?>" 
                           data-errormessage-value-missing="Profile URl is required!">
                    <input name="url_exist" id="url_exist" type="hidden" value="">
                    <span id="profile_url_error" style="color:red"><?php echo form_error('profile_url'); ?></span>
                </div>
                <script>
                    
                    function checkUrlCharacter(profileID) {
                        for (i = 0; profileID.length > i; i++) {
                            if (profileID.charAt(i) === ' ') {
                                profileID = profileID.replace(/ +/g, '-');
                            }
                            if (profileID.charAt(i) === '.') {
                                profileID = profileID.replace(/\./g, '');
                            }
                            if (profileID.charAt(i) === '-') {
                                profileID = profileID.replace(/--/g, '-');
                            }

                        }
                        profileID = profileID.replace(/[&\/\\#@!^_=,+()$~%.'":*?<>{}]/g, '');
                        if (profileID.charAt(profileID.length - 1) === '-') {
                            profileID = setCharAt(profileID, profileID.length - 1, '');
                        }
                        profileID = profileID.replace(/--/g, '-');
                        profileID = profileID.replace(' ', '-');
                        return profileID;
                    }

                    function makeProfileID(firstName, secondName) {
                        var profileID = '';
                        var personFirstName = firstName;
                        var personLastName = secondName;
                        if (personLastName == '') {
                            profileID = personFirstName.toLowerCase();
                        } else {
                            profileID = personFirstName.toLowerCase() + '-' + personLastName.toLowerCase();
                        }

                        var profileID1 = checkUrlCharacter(profileID);
                        serverPage = '<?php echo base_url(); ?>super_admin/check_profile_id_existance2/' + profileID1;
                        xmlhttp.open("GET", serverPage);
                        xmlhttp.onreadystatechange = function ()
                        {
                            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                            {
                                document.getElementById('profile_url').value = xmlhttp.responseText;                                
                                documentID('profile_url_error').innerHTML = '';
                            }
                        }
                        xmlhttp.send(null);
                    }

                    function checkProfileUrl(given_text)
                    {
                        if (given_text != '') {
                            serverPage = '<?php echo base_url(); ?>super_admin/check_profile_id_existance/' + given_text;
                            xmlhttp.open("GET", serverPage);
                            xmlhttp.onreadystatechange = function ()
                            {
                                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                                {
                                    if (xmlhttp.responseText == 1)
                                    {
                                        document.getElementById('url_exist').value = '1';                                        
                                        documentID('profile_url_error').innerHTML = '';
                                    } else if (xmlhttp.responseText == 2)
                                    {
                                        document.getElementById('url_exist').value = '';                                       
                                        documentID('profile_url_error').innerHTML = '';
                                    }
                                }
                            }
                            xmlhttp.send(null);
                        } else if (given_text == '') {
//                                document.getElementById(objID).innerHTML = '<p style="color:red;"></p>';
                        }
                    }

                    function getUrlValue(firstName, secondName, urlInput) {
                        urlValue = urlInput;
                        if (urlValue === '') {
                            makeProfileID(firstName, secondName);
                        } else {
                            checkProfileUrl(urlInput);
                        }
                    }
                </script>
                <div class="form-group col-sm-5">
                    <input name="email_status_value" id="email_status_value" type="hidden" value="1">
                    <input name="person_email" 
                           class="form-control validate[required, custom[email], custom[emailExist]] text-input" 
                           id="person_email" 
                           type="email"
                           oninput="checkUserEmail(this.value)"
                           placeholder="Please Type email address" 
                           value="<?php echo set_value('person_email'); ?>"
                           maxlength="256"
                           data-errormessage-value-missing="Person Email is required!">
                    <span id="person_email_error" style="color:red"><?php echo form_error('person_email'); ?></span>
                </div>
                <script>
                    function checkUserEmail(given_text)
                    {
                        if (given_text == '') {
                            document.getElementById('email_status_value').value = 0;                           
                        } else {
                            serverPage = '<?php echo base_url(); ?>super_admin/check_user_email/' + given_text; // passing person_email Field value 
                            xmlhttp.open("GET", serverPage);
                            xmlhttp.onreadystatechange = function ()
                            {
                                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                                {
                                    if (xmlhttp.responseText == 1)
                                    {
                                        document.getElementById('email_status_value').value = 2;                                       
                                        documentID('person_email_error').innerHTML = '';
                                    } else if (xmlhttp.responseText == 2)
                                    {
                                        document.getElementById('email_status_value').value = 1;                                       
                                        documentID('person_email_error').innerHTML = '';
                                    }
                                }
                            }
                            xmlhttp.send(null);
                        }
                    }

                </script>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-5 ">
                    <div id="image_field">
                        <script>
                            $(":file").filestyle({icon: false});
                        </script>
                        <input class="filestyle" id="filestyle-0"  
                               type="file" 
                               data-icon="false"
                               onchange="readURL(this, 'photo_0');"
                               data-placeholder="Upload profile image (jpg,png,jpeg)"
                               name="person_image"
                               value="<?php echo set_value('person_image'); ?>">
                    </div>
                </div>
                <div class="form-group col-sm-6 ">
                    <div id="image" style="float:left;width: 150px; height: 50px;" ></div>
                </div>
                <span class="col-sm-12" id="person_image_error" style="color:red; margin-top: -25px;"><?php echo form_error('person_image'); ?></span>
            </div>

            <input style="float:left;" type='hidden' name="image_path" id="image_path" value="<?php echo set_value('image_path'); ?>"/>
            <script>
                function readURL(input, objID) {
                    document.getElementById('image').innerHTML = '';
                    var node = document.createElement("img");
                    document.getElementById("image").appendChild(node);
                    node.setAttribute("id", objID);
                    node.setAttribute("src", "");
                    var file = input.files[0];
                    if ((file.type === "image/jpeg") || (file.type === "image/gif") || (file.type === "image/png") || (file.type === "image/bmp"))
                    {
                        if (file.size > 2097152) {
                            document.getElementById('filestyle-0').value = '';
                            document.getElementById('image').innerHTML = '<span style="color:red;">Image size must less then 2 Mb</span>';
                        } else {
                            if (input.files && input.files[0]) {
                                var reader = new FileReader();
                                reader.onload = function (e) {
                                    $('#' + objID)
                                            .attr('src', e.target.result)
                                            .width(40)
                                            .height(40);
                                    document.getElementById('image_path').value = e.target.result;
                                    var image_name = input.files[0]['name'];
                                    document.getElementById('image_name').value = image_name;
                                };
                                reader.readAsDataURL(input.files[0]);
                            }
                        }
                    } else {
                        document.getElementById('filestyle-0').value = '';
                        document.getElementById('image').innerHTML = '<span style="color:red;">Image Format will be JPG,PNG,GIF,BMP</span>';
                    }
                }
            </script>
            <div class="form-group  col-sm-12">
                <div class="form-group col-sm-5">
                    <input type="password"  
                           data-errormessage-value-missing="* Password field is required!"
                           class="form-control validate[required,custom[userPassword], custom[passwordMaxLength], custom[passwordLength]]  text-input" 
                           id="person_password" 
                           name="person_password"
                           oninput="checkPassword()"
                           value=""
                           min="6"
                           maxlength="32"
                           placeholder="Enter Your Password Here">
                    <span id="person_password_error" style="color:red"><?php echo form_error('person_password'); ?></span>
                </div>

                <div class="form-group col-sm-5">
                    <input type="password"  
                           data-errormessage-value-missing="* Person Confirm Password is required!"
                           class="form-control validate[required, custom[matchuserPassword], custom[passwordMaxLength], custom[passwordLength]]"
                           id="confirm_password" 
                           name="confirm_password"  
                           min="6"
                           oninput="checkConfirmPassword()"
                           value=""
                           maxlength="32"
                           placeholder="Please enter  Confirm Password ..">
                    <span id="confirm_person_password_error" style="color:red"><?php echo form_error('person_password'); ?></span>
                </div>
                <script>
                    function checkPassword() {                       
                        documentID('person_password_error').innerHTML = '';
                    }
                    function checkConfirmPassword() {                       
                        documentID('confirm_person_password_error').innerHTML = '';
                    }
                </script>
            </div>
            <div class="col-sm-12">                
                <div class="form-group col-sm-5">
                    <div class="controls">
                        <select name="person_country" 
                                class="form-control validate[required] text-input" 
                                id="person_country" 
                                data-errormessage-value-missing="Person Country is required!">
                            <script language="javascript">
                                populateCountries("person_country", "person_city"); // ....for Country with State
                            </script>
                        </select>
                        <span id="person_country_error" style="color:red"><?php echo form_error('person_country'); ?></span>
                    </div>

                    <div class="form-group col-sm-4" id="country_status"></div>
                </div>
                <div class="form-group col-sm-5">
                    <div class="controls">
                        <select name="person_city" 
                                class="form-control validate[required] text-input" 
                                id="person_city" 
                                data-errormessage-value-missing="Person City is required!">
                        </select>
                        <span id="person_city_error" style="color:red"><?php echo form_error('person_city'); ?></span>
                    </div>
                    <div class="form-group col-sm-4" id="city_status"></div>
                </div>

                <script>
                    $(document).ready(function () {
                        $("#person_country").on("chnage", function () {                            
                            documentID('person_country_error').innerHTML = '';
                        });
                    });
                    $(document).ready(function () {
                        $("#person_city").on("chnage", function () {                          
                            documentID('person_city_error').innerHTML = '';
                        });
                    });
                </script>

            </div>


            <div class="form-group col-sm-12">
                <div class="form-group col-sm-2">
                    <input name="country_code"
                           class="form-control col-sm-4 text-input"
                           id="country_code" 
                           class="form-control" 
                           type="text" 
                           placeholder="Country code" 
                           value="<?php echo set_value('country_code'); ?>"
                           readonly="readonly">
                </div>

                <div class="form-group col-sm-3">
                    <input name="person_contact_number"
                           data-errormessage-value-missing="Person Contact Number is required!"
                           class="form-control col-sm-4 validate[required,custom[integer],custom[contactNumberLength]] text-input" 
                           type="text"  
                           id ="person_contact_number" 
                           placeholder="Please Type contact Number"
                           minlength="8" maxlength="16"
                           value="<?php echo set_value('person_contact_number'); ?>">
                    <span id="person_contact_number_error" style="color:red"><?php echo form_error('person_contact_number'); ?></span>
                </div>


                <div class="form-group col-sm-5">
                    <input name="person_zip"
                           id="person_zip"
                           class="form-control validate[required, custom[number] , custom[zipLength]] text-input" 
                           type="text" 
                           maxlength="11" 
                           placeholder="Please type your zip code" 
                           value="<?php echo set_value('person_zip'); ?>" 
                           data-errormessage-value-missing="Person Zip/Postal Code is required!">
                    <span id="person_zip_error" style="color:red"><?php echo form_error('person_zip'); ?></span>
                </div>


                <script>
                    $(document).ready(function () {
                        $("#person_contact_number").on("input", function () {                            
                            documentID('person_contact_number_error').innerHTML = '';
                        });
                    });
                    $(document).ready(function () {
                        $("#person_zip").on("input", function () {                            
                            documentID('person_zip_error').innerHTML = '';
                        });
                    });
                </script>

            </div>

            <div class="form-group col-sm-12">
                <div class="form-group col-sm-10">
                    <textarea name="person_address"
                              id="person_address"
                              oninput="checkAddress()"
                              data-errormessage-value-missing="Person Address is required!"
                              class="form-control col-sm-4 validate[required] text-input" 
                              placeholder="Please type your address"><?php echo set_value('person_address'); ?></textarea>
                    <span id="person_address_error" style="color:red"><?php echo form_error('person_address'); ?></span>
                </div>
                <script>
                    function checkAddress() {                        
                        documentID('person_address_error').innerHTML = '';
                    }
                </script>
            </div>
            <div class="form-group col-sm-12">
                <div class="form-group col-sm-5">
                    <select data-errormessage-value-missing="Person Role is required!"
                            class="form-control validate[required] text-input"
                            name="person_role" 
                            id="person_role"
                            onchange="checkPersonRole(this.value);">
                        <option value="">--Select User Person Role--</option>
                        <?php
                        if ($person_role == 6) {
                            echo '<option value="6">Super Admin </option>';
                        }
                        ?>
                        <option value="1">Admin</option>
                        <option value="2">Account Officer</option>
                        <option value="4">Organization</option>
                        <option value="3">Individual Teacher</option>
                        <option value="5">Learner</option>
                        <option value="8">Quiz Editor</option>
                        <option value="9">Course Editor</option>
                    </select>
                    <span id="person_role_error" style="color:red"><?php echo form_error('person_role'); ?></span>
                </div>
                <script>
                    documentID('person_role').value = '<?php echo set_value('person_role'); ?>';
                </script>


                <div class="form-group col-sm-5" id="resourcePersonType" 
                <?php
                if (set_value('person_role') == 3) {
                    echo 'style="display: block"';
                } else {
                    echo 'style="display: none"';
                }
                ?> >
                    <label class="col-sm-4" for="resource_person_type"> Talha Training  :  &nbsp;&nbsp;</label>
                    <div class="radio radio-success col-sm-6 margin-zero">
                        <input type="radio"
                               data-errormessage-value-missing="Please Select Resourse Person Type"
                               class="validate[required]" 
                               name="resource_person_type" 
                               id="yes" 
                               value="1">
                        <label for="yes">Yes</label>
                        <span style="margin-right: 30px"></span>
                        <input type="radio"
                               data-errormessage-value-missing="Please Select Resourse Person Type"
                               class="validate[required]" 
                               name="resource_person_type" 
                               id="no" 
                               value="2">
                        <label for="no">No</label>
                    </div>
                    <span class="col-sm-12" id="resource_person_type_error" style="color:red; margin-top: -20px;"><?php echo form_error('resource_person_type'); ?></span>
                    <script>
                        document.forms['userForm'].elements['resource_person_type'].value = '<?php echo set_value('resource_person_type'); ?>';
                    </script>
                </div>
            </div>




            <div class="form-group col-sm-12" id="organization_view" 
            <?php
            if (set_value('person_role') == 4) {
                echo 'style="display: block"';
            } else {
                echo 'style="display: none"';
            }
            ?> >
                <div class="form-group col-sm-5" id="organization_name_form">
                    <input type="text" 
                           data-errormessage-value-missing="Organization Name is required!"
                           class="form-control validate[required, custom[organizarionNameLength]] text-input" 
                           name="organization_name"
                           id="organization_name"
                           oninput="checkOrganizationName()"
                           value="<?php echo set_value('organization_name'); ?>"
                           maxlength="150"
                           placeholder="Please type your Organization Name">
                    <span class="col-sm-12" id="organization_name_error" style="color:red"><?php echo form_error('organization_name'); ?></span>
                </div>

                <div class="form-group col-sm-5">
                    <input name="organization_code_status_value" id="organization_code_status_value" type="hidden" value="1">
                    <input type="text" 
                           data-errormessage-value-missing="Organization Code is required!"
                           class="form-control validate[required,custom[organizarionCodeExits],custom[urlSpecialCaracter], custom[spaceFunction], custom[organizarionCodeLength]] text-input" 
                           name="organization_code"
                           id="organization_code"
                           oninput="checkOrganizationCode(this.value)"
                           value="<?php echo set_value('organization_code'); ?>"
                           maxlength="25"
                           placeholder="Please type your Organization code">
                    <span class="col-sm-12" id="organization_code_error" style="color:red"><?php echo form_error('organization_code'); ?></span>
                    <script>
                        function checkOrganizationName() {                            
                            documentID('organization_name_error').innerHTML = '';
                        }

                        function checkOrganizationCode(given_text) {
                            documentID('organization_code_error').innerHTML = '';
                            if (given_text == '') {
                                document.getElementById('organization_code_status_value').value = 0;                                
                            } else {
                                serverPage = '<?php echo base_url(); ?>super_admin/check_user_organization_code/' + given_text; // passing person_organization_code Field value 
                                xmlhttp.open("GET", serverPage);
                                xmlhttp.onreadystatechange = function ()
                                {
                                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                                    {
                                        //                                            alert(xmlhttp.status);
                                        if (xmlhttp.responseText == 1) {
                                            document.getElementById('organization_code_status_value').value = 2;                                            
                                        } else if (xmlhttp.responseText == 2)
                                        {
                                            document.getElementById('organization_code_status_value').value = 1;                                          
                                        }
                                    }
                                }
                                xmlhttp.send(null);
                            }
                        }
                    </script>
                </div>
            </div>





            <script>
                function checkPersonRole(GivenText) {
                    jQuery('#person_role').validationEngine('validate');
                    documentID('person_role_error').innerHTML = '';
                    if (GivenText === '4') {
                        documentID('organization_view').style.display = 'block';
                        documentID('resourcePersonType').style.display = 'none';
                    } else if ((GivenText === '3')) {
                        documentID('resourcePersonType').style.display = 'block';
                        documentID('organization_view').style.display = 'none';
                    } else {
                        documentID('resourcePersonType').style.display = 'none';
                        documentID('organization_view').style.display = 'none';
                    }
                }
            </script>
            <div class="form-group col-sm-12">
                <div class="form-group" class="col-sm-5">
                    <div class="form-group col-sm-5">
                        <div class="input-group date" id="datetimepicker1">
                            <input type="text" 
                                   data-errormessage-value-missing="Person Birth Date is Required!" 
                                   class="form-control validate[required,custom[maxdate]] text-input" 
                                   name="person_birthday" id="class_date" 
                                   aria-describedby="basic-addon1"
                                   value="<?php
                                   if (set_value('person_birthday')) {
                                       echo set_value('person_birthday');
                                   }
                                   ?>"
                                   min="<?php echo date('Y-m-d'); ?>"
                                   placeholder="Person Birthday Date" >
                            <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                        </div>
                        <span id="person_birthday_error" style="color:red"><?php echo form_error('person_birthday'); ?></span>
                    </div>
                </div>

                <script type="text/javascript">
                    //for Date   #datetimepicker1 is ID for Date Input Field     
                    $(function () {
                        $('#datetimepicker1').datetimepicker({
                            viewMode: 'years',
                            format: 'YYYY-MM-DD'

                        });
                    });
                    //for Time #datetimepicker3 is ID for Time input Field
                    $(function () {
                        $('#datetimepicker3').datetimepicker({
                            format: 'LT'
                        });
                    });
                </script>
            </div>
            <div class="form-group col-sm-12">
                <div class="form-group col-sm-5">
                    <label class="col-sm-3" for="person_gender"> Gender  :  &nbsp;&nbsp;</label>
                    <div class="radio radio-success col-sm-6 margin-zero">
                        <input type="radio"
                               data-errormessage-value-missing="Please Select Person Gender" 
                               class="validate[required]" 
                               name="person_gender" 
                               id="male" 
                               value="1">
                        <label for="published">Male</label>
                        <span style="margin-right: 30px"></span>
                        <input type="radio"
                               data-errormessage-value-missing="Please Select Person Gender"
                               class="validate[required]"
                               name="person_gender" 
                               id="female" 
                               value="2">
                        <label for="unpublishded">Female</label>

                    </div>
                    <script>
                        document.forms['userForm'].elements['person_gender'].value = '<?php echo set_value('person_gender'); ?>';
                    </script>
                    <span class="col-sm-12" id="person_gender_error" style="color:red"><?php echo form_error('person_gender'); ?></span>
                </div>
                <div class="form-group col-sm-5">
                    <label class="col-sm-3" for="person_status"> Status  :  &nbsp;&nbsp;</label>
                    <div class="radio radio-success col-sm-6 margin-zero">
                        <input type="radio"
                               data-errormessage-value-missing="Please Select Person Status"
                               class="validate[required]" 
                               name="person_status" 
                               id="published" 
                               value="1">
                        <label for="published">Active</label>
                        <span style="margin-right: 30px"></span>
                        <input type="radio"
                               data-errormessage-value-missing="Please Select Person Status"
                               class="validate[required]" 
                               name="person_status" 
                               id="unpublished" 
                               value="3">
                        <label for="unpublishded">Inactive</label>
                    </div>
                    <span class="col-sm-12" id="person_status_error" style="color:red"><?php echo form_error('person_status'); ?></span>
                </div>
                <script>
                    document.forms['userForm'].elements['person_status'].value = '<?php echo set_value('person_status'); ?>';
                </script>
            </div>

            <input type="hidden" name="person_time_zone" id="person_time_zone" value="">

            <div class=" col-sm-4  col-sm-offset-4">
                <button class="btn btn-success" id="submit" type="submit">Add User</button>
            </div>
            <?php echo form_close(); ?>
        </div>
    </div>
    <div class="col-sm-12 "><br></div>
    <div class="col-sm-12 gray" style="padding-left: 10px">
        <a href="<?php echo base_url(); ?>super_admin">Dashboard</a>->> <span><a href="<?php echo base_url(); ?>super-admin/all-user">User Management</a></span>->> <span>Add User Information</span>
    </div>
    <div class="col-sm-12 "><br><br></div>
</div>


<!--<noscript>
<meta http-equiv="refresh" content="0; url=<?php // echo base_url() . 'logout';                                                 ?>" />
For full functionality of this page it is necessary to enable JavaScript. Here are the 
<a href="http://www.enable-javascript.com" target="_blank"> 
    instructions how to enable JavaScript in your web browser
</a>
</noscript>-->


<script>
    document.forms['userForm'].elements['person_country'].value = '<?php echo set_value('person_country'); ?>';
    populateStates('person_country', 'person_city');
    document.forms['userForm'].elements['person_city'].value = '<?php echo set_value('person_city'); ?>';
//    checkPersonRole(3);
</script>

<script type="text/javascript">
    $(document).ready(function () {
        var tz = jstz.determine();
        response_text = 'No timezone found';
        if (typeof (tz) === 'undefined') {
            response_text = 'No timezone found';
        } else {
            response_text = tz.name();
        }

        document.getElementById('person_time_zone').value = response_text;
        $('#code-example').html("> var timezone = jstz.determine();\n" +
                "> timezone.name(); \n" +
                "\"" + tz.name() + "\"\n\n");
        $('#tz_info').show();
        prettyPrint();
    });
</script>
