<?php

/* DorcasTabithaBundle:ClientInformation:clientinformationform.html.twig */
class __TwigTemplate_494ff02ca24f4d9387c433fcff140450 extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = $this->env->loadTemplate("::base.html.twig");

        $this->blocks = array(
            'body' => array($this, 'block_body'),
            'javascripts' => array($this, 'block_javascripts'),
        );
    }

    protected function doGetParent(array $context)
    {
        return "::base.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        $this->parent->display($context, array_merge($this->blocks, $blocks));
    }

    // line 3
    public function block_body($context, array $blocks = array())
    {
        // line 4
        echo "
    <div id=\"override_javascript_alert\"></div>
    <div id=\"override_javascript_alertx\"></div>

    <form id=\"clientform\" action=\"";
        // line 8
        echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("DorcasTabithaBundle_clientinformation_new"), "html", null, true);
        echo "\" method=\"post\" ";
        echo $this->env->getExtension('form')->renderEnctype($this->getContext($context, "form"));
        echo ">
        ";
        // line 9
        $this->env->loadTemplate("DorcasTabithaBundle:ClientInformation:clientinformationlayout.html.twig")->display($context);
        // line 10
        echo "    </form>
\t\t
";
    }

    // line 14
    public function block_javascripts($context, array $blocks = array())
    {
        // line 15
        echo "
    ";
        // line 16
        $this->displayParentBlock("javascripts", $context, $blocks);
        echo "

<script type=\"text/javascript\">

\$(function() {
//    \$( \".datepicker\" ).datepicker({ showAnim: \"slideDown\" });
    \$( \".datepicker\" ).datepicker({ changeMonth: true, changeYear: true, yearRange:\"-90:+0\", maxDate: \"+0d\"
        });
        });

window.alert = function(message) {
\t\$('#override_javascript_alert').html(message).dialog({
\t\tmodal:true,
\t\ttitle:'Tabitha Validation Message',
\t\tbuttons: {
\t\t\t'OK':function(){
\t\t\t\t\$(this).dialog('close');
\t\t\t}
\t\t}
\t});
};

warnusers = function(message) {
\t\$('#override_javascript_alertx').html(message).dialog({
\t\tmodal: true,
                title:'Tabitha Warning Message',
\t\t\tbuttons: {
\t\t\t\t\"Continue to Home Page\": function() {
                                        var form = document.forms[\"clientform\"];
                                        form.submit();
\t\t\t\t\t\$( this ).dialog( \"close\" );
\t\t\t\t},
\t\t\t\tCancel: function() {
\t\t\t\t\t\$( this ).dialog( \"close\" );
\t\t\t\t}
\t\t\t}
\t\t});
\t};


/**--------------------------
//* Validate Date Field script- By JavaScriptKit.com
//* For this script and 100s more, visit http://www.javascriptkit.com
//* This notice must stay intact for usage
---------------------------**/

function checkdate(input){
    var validformat=/^\\d{2}\\/\\d{2}\\/\\d{4}\$/ //Basic check for format validity
    var returnval=false
    if (!validformat.test(input))
    {
//        alert(\"Invalid Date Format. Please correct and submit again.\")
    }
    else{ //Detailed check for valid date ranges
        var monthfield=input.split(\"/\")[0]
        var dayfield=input.split(\"/\")[1]
        var yearfield=input.split(\"/\")[2]
        var dayobj = new Date(yearfield, monthfield-1, dayfield)
        if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
        {
//            alert(\"Invalid Day, Month, or Year range detected. Please correct and submit again.\")
        }
        else
            returnval=true
    }
//    if (returnval==false) input.select()
    return returnval
}


function submitFormClient(navnumber) {
    var form = document.forms[\"clientform\"];
    var hiddenField = document.createElement(\"input\"); 
    hiddenField.setAttribute(\"type\", \"hidden\"); 
    hiddenField.setAttribute(\"name\", \"passnav\"); 
    hiddenField.setAttribute(\"value\", navnumber); 
    form.appendChild(hiddenField);
    if (navnumber == 9)
    {
        savenext(true)
    }
    else
    {
        savenext(false);
    }
}

function savenext(nav)
{ 
    // Read all values
    var ssn = document.getElementById('clientinformationform_ssn').value;
    var firstName = document.getElementById('clientinformationform_first_name').value;
    var lastName = document.getElementById('clientinformationform_last_name').value;
    var city = document.getElementById('clientinformationform_city').value;
    var state = document.getElementById('clientinformationform_state').value;
    var genderF = document.getElementById('clientinformationform_gender_f').checked;
    var genderM = document.getElementById('clientinformationform_gender_m').checked;
    var birthDate = document.getElementById('clientinformationform_birth_date').value;
    var otherAdultOneSsn = document.getElementById('clientinformationform_other_adult_oneSsn').value;
    var otherAdultTwoSsn = document.getElementById('clientinformationform_other_adult_twoSsn').value;
    var homePhone = document.getElementById('clientinformationform_home_phone').value;
    var cellPhone = document.getElementById('clientinformationform_cell_phone').value;
    var workPhone = document.getElementById('clientinformationform_work_phone').value;
    var email = document.getElementById('clientinformationform_email').value;

    okaytosubmit = true;
    alertMessage = \"\";

    // Check SSN for blank or length < 11 characters
    if (!ssn || ssn.length < 11)
    {
        alertMessage = alertMessage + '&#8227 Please enter Social Security Number. <br/>';
        okaytosubmit = false;
    }

    // Check First Name for blank
    if (!firstName)
    {
        alertMessage = alertMessage + '&#8227 Please enter First Name. <br/>';
        okaytosubmit = false;
    }

    // Check Last Name for blank
    if (!lastName)
    {
        alertMessage = alertMessage + '&#8227 Please enter Last Name. <br/>';
        okaytosubmit = false;
    }

    // Check City for blank
    if (!city)
    {
        alertMessage = alertMessage + '&#8227 Please enter City. <br/>';
        okaytosubmit = false;
    }


    // Check State for blank
    if (!state)
    {
        alertMessage = alertMessage + '&#8227 Please enter City. <br/>';
        okaytosubmit = false;
    }

    // Check Gender for checked
    if (!genderF && !genderM)
    {
        alertMessage = alertMessage + '&#8227 Please enter Gender. <br/>';
        okaytosubmit = false;
    }

    // Check Home Phone length < 14 characters
    if (homePhone && homePhone.length < 14)
    {
        alertMessage = alertMessage + '&#8227 Please correct Home Phone. <br/>';
        okaytosubmit = false;
    }

    // Check Cell Phone length < 14 characters
    if (cellPhone && cellPhone.length < 14)
    {
        alertMessage = alertMessage + '&#8227 Please correct Cell Phone. <br/>';
        okaytosubmit = false;
    }

    // Check Work Phone length < 14 characters
    if (workPhone && workPhone.length < 14)
    {
        alertMessage = alertMessage + '&#8227 Please correct Work Phone. <br/>';
        okaytosubmit = false;
    }

    // Check Birth Date for blank
    if (!birthDate)
    {
        alertMessage = alertMessage + '&#8227 Please enter Birth Date. <br/>';
        okaytosubmit = false;
    }

    // Check Birth Date for valid date
    if (birthDate && !checkdate(birthDate))
    {
        alertMessage = alertMessage + '&#8227 Please enter a valid Birth Date. <br/>';
        okaytosubmit = false;
    }


    // Check Other Adult One SSN for not blank and length = 11 characters
    if (otherAdultOneSsn && otherAdultOneSsn.length < 11)
    {
        alertMessage = alertMessage + '&#8227 Please correct Other Adult #1 SSN. <br/>';
        okaytosubmit = false;
    }

    // Check Other Adult Two SSN for not blank and length = 11 characters
    if (otherAdultTwoSsn && otherAdultTwoSsn.length < 11)
    {
        alertMessage = alertMessage + '&#8227 Please correct Other Adult #2 SSN. <br/>';
        okaytosubmit = false;
    }
    
    // Check Email for valid (kinda) address   
    if ( email )
    {
        var atpos = email.indexOf(\"@\");
        var dotpos = email.lastIndexOf(\".\");
        if ( atpos <1 || dotpos < atpos+2 || dotpos+2 >= email.length)
        //if ( email && email.indexOf(\"@\") == -1 ))
        {
            alertMessage = alertMessage + '&#8227 Please enter a valid Email address.<br/>';
            okaytosubmit = false;
        }
    }

    if (okaytosubmit == true)
    {
        var form = document.forms[\"clientform\"];
        form.submit();
    }
    else
    {
        // If HOME Nav is selected, then it is okay to redirect without saving
            if(nav)
            {
                alertMessage = '<p style = \"color:red;\"> Warning: Your changes to Client Information will not be saved! </p>';
                warnusers(alertMessage);
            }
            else
            {
                alert(alertMessage);
            }
    }
}



</script>
    
";
    }

    public function getTemplateName()
    {
        return "DorcasTabithaBundle:ClientInformation:clientinformationform.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  56 => 16,  53 => 15,  50 => 14,  44 => 10,  42 => 9,  36 => 8,  30 => 4,  27 => 3,);
    }
}
