package SGN::View::Mason::Commands;
use strict;
use vars qw($m $c);
HTML::Mason::Component::FileBased->new(
'code' => sub {
use utf8; local $SGN::View::Mason::Commands::m = $HTML::Mason::Commands::m;
HTML::Mason::Exception::Params->throw
    ( error =>
      "Odd number of parameters passed to component expecting name/value pairs"
    ) if @_ % 2;
my ( $contact_form_human_answer, $contact_form_human_question, $website_name, $email_address_to_display );
{
    my %pos;
    for ( my $x = 0; $x < @_; $x += 2 )
    {
        $pos{ $_[$x] } = $x + 1;
    }
#line 2 "/home/production/cxgn/sgn/mason/help/contact.mas"
     $contact_form_human_answer = exists $pos{'contact_form_human_answer'} ? $_[ $pos{'contact_form_human_answer'} ] :  '';
#line 3 "/home/production/cxgn/sgn/mason/help/contact.mas"
     $contact_form_human_question = exists $pos{'contact_form_human_question'} ? $_[ $pos{'contact_form_human_question'} ] :  '';
#line 4 "/home/production/cxgn/sgn/mason/help/contact.mas"
     $website_name = exists $pos{'website_name'} ? $_[ $pos{'website_name'} ] :  '';
#line 5 "/home/production/cxgn/sgn/mason/help/contact.mas"
     $email_address_to_display = exists $pos{'email_address_to_display'} ? $_[ $pos{'email_address_to_display'} ] :  '';
}
$m->debug_hook( $m->current_comp->path ) if ( HTML::Mason::Compiler::IN_PERL_DB() );

#line 7 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( '
' );
#line 8 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->comp(   "/page/page_title.mas", title => "Contact $website_name"   
); #line 8 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( '

<div class="container-fluid">
    <div class="well">

    <div id="contact_form_return_message">
    </div>

' );
#line 16 "/home/production/cxgn/sgn/mason/help/contact.mas"
 #The form
$m->print( '  <form class="form-horizontal" name="contactForm">

' );
#line 19 "/home/production/cxgn/sgn/mason/help/contact.mas"
 #Uses Perl to print out the fields with similar HTML tags

my $infoNeeded = ["name", "email", "subject", ];
#line 23 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( '
' );
#line 24 "/home/production/cxgn/sgn/mason/help/contact.mas"
 foreach my $info_category (@$infoNeeded) {
$m->print( '    <div class="form-group">
      <label class="col-sm-2 control-label">' );
#line 26 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print(  ucfirst $info_category  );
#line 26 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( '* : 
      </label>
      <div class="col-sm-10">
        <input type="text" class="form-control" value="" name="' );
#line 29 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print(  $info_category  );
#line 29 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( '"></input>
      </div>
    </div>
' );
#line 32 "/home/production/cxgn/sgn/mason/help/contact.mas"
 }
$m->print( '
    <div class="form-group">
      <label class="col-sm-2 control-label">Body* : 
      </label>
      <div class="col-sm-10">
        <textarea rows="12" class="form-control" name="body"></textarea>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label">What is <br/>' );
#line 42 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print(  $contact_form_human_question  );
#line 42 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( '?* : 
      </label>
      <div class="col-sm-10">
        <input type="text" class="form-control" value="" name="contact_form_human_answer"></input>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label"></label>
      <div class="col-sm-10">
        <h5 valign="middle" style="color:red; font-size:90%; font-style:italic;">Fields Marked With ' );
#line 51 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( (map {; $m->interp->apply_escapes($_, 'h') } ( '"*"')) );
#line 51 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( ' Are Required.</h5>
      </div>
    </div>
    <hr>
    <button style="float:right" type="submit" class="btn btn-primary btn-lg" id="contact_form_submit">Submit</button>
    <br/><br/>

  </form>
  </div>
  
  <br/>
  <h2>Contact Us</h2>
  <br/>
  <table class="table table-hover table-bordered">
     <tbody>
      <tr>
        <td><b>Email</b></td>
	<td>Note that the contact email address ' );
#line 68 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print(  $email_address_to_display  );
#line 68 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( ' has been deactivated due to extreme levels of spam. <br/>Use this contact form instead.</td>
      </tr>
      <tr>
        <td><b>Mailing Address</b></td>
	<td>Sol Genomics Network<br />
	Boyce Thompson Institute for Plant Research<br />
	Room 221<br />
	Tower Road<br />
	Ithaca, NY 14853<br />
	USA<br /></td>
      </tr>
      <tr>
        <td><b>Phone</b></td>
        <td>(607) 255-6557</td>
      </tr>
      <tr>
        <td><b>Mailing List</b></td>
        <td>To stay informed of developments at SGN you can subscribe to our <a href="http://rubisco.sgn.cornell.edu/mailman/listinfo/sgn-announce/">mailing list</a>. <br/>This is a low-volume list (usually no more than 2 messages per month).</td>
      </tr>
    </tbody>
  </table>

  </div>   
</div>

<div class="modal fade" id="submit_contact_form_response" name="submit_contact_form_response" tabindex="-1" role="dialog" aria-labelledby="submitContactResponseDialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header" style="text-align: center">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="submitContactResponseDialog">Contact Form</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div id="submit_contact_form_response_message">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

<script>

jQuery(document).ready(function () {

    jQuery(\'#contact_form_submit\').on(\'click\',function (e){ 
        var subject = jQuery(\'input[name="subject"]\').val();
        var name = jQuery(\'input[name="name"]\').val();
        var email = jQuery(\'input[name="email"]\').val();
        var body = jQuery(\'textarea[name="body"]\').val();
        var challenge_answer = jQuery(\'input[name="contact_form_human_answer"]\').val();
        if (challenge_answer != ' );
#line 123 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print(  $contact_form_human_answer  );
#line 123 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( '){
            jQuery(\'#submit_contact_form_response_message\').html("Please prove you are a human by answering the simple math question.");
            jQuery(\'#submit_contact_form_response\').modal(\'show\');
        } else if (subject == \'\' || !subject){
            jQuery(\'#submit_contact_form_response_message\').html("Subject is required. Please fill in this field.");
            jQuery(\'#submit_contact_form_response\').modal(\'show\');
        } else if (name == \'\' || !name){
            jQuery(\'#submit_contact_form_response_message\').html("Name is required. Please fill in this field.");
            jQuery(\'#submit_contact_form_response\').modal(\'show\');
        } else if (email == \'\' || !email){
            jQuery(\'#submit_contact_form_response_message\').html("Email is required. Please fill in this field.");
            jQuery(\'#submit_contact_form_response\').modal(\'show\');
        } else if (body == \'\' || !body){
            jQuery(\'#submit_contact_form_response_message\').html("Body is required. Please fill in this field.");
            jQuery(\'#submit_contact_form_response\').modal(\'show\');
        } else {
            jQuery.ajax ( {
                url : \'/ajax/contact/submit\',
                type: "POST",
                beforeSend: function(){
                    jQuery(\'#working_modal\').modal(\'show\');
                },
                data: {
                    "title": subject,
                    "body": body + \'\\n\\nFrom: \' + name + \'\\nEmail: \' + email,
                    "security_answer": ' );
#line 148 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print(  $contact_form_human_answer  );
#line 148 "/home/production/cxgn/sgn/mason/help/contact.mas"
$m->print( ',
                    "security_attempt": challenge_answer
                },
                success: function(response){
                    //console.log(response);
                    jQuery(\'#working_modal\').modal(\'hide\');
                    var html = \'\';
                    var html_return;
                    if (response.error){
                        html = response.error;
                        html_return = \'<div class="panel panel-danger"><div class="panel-heading">Error</div><div class="panel-body">\'+html+\'</div></div>\';
                    } else {
                        html = "Thank you for your message. We will reply as soon as possible.";
                        html_return = \'<div class="panel panel-success"><div class="panel-heading">Success</div><div class="panel-body">\'+html+\'</div></div>\';
                    }
                    jQuery(\'#contact_form_return_message\').html(html_return);
                    jQuery(\'#submit_contact_form_response_message\').html(html);
                    jQuery(\'#submit_contact_form_response\').modal(\'show\');
                },
                error: function(response){
                    console.log(response);
                    jQuery(\'#working_modal\').modal(\'hide\');
                    var html = "Error posting message! Please contact us. : "+response;
                    var html_return = \'<div class="panel panel-danger"><div class="panel-heading">Error</div><div class="panel-body">\'+html+\'</div></div>\';
                    jQuery(\'#contact_form_return_message\').html(html_return);
                    jQuery(\'#submit_contact_form_response_message\').html(html);
                    jQuery(\'#submit_contact_form_response\').modal(\'show\');
                }
            });
        }
        e.preventDefault();
    });

});

</script>
' );
;return;
},
'declared_args' => {
  '$contact_form_human_answer' => { default => ' \'\'' },
  '$contact_form_human_question' => { default => ' \'\'' },
  '$email_address_to_display' => { default => ' \'\'' },
  '$website_name' => { default => ' \'\'' }
},
'load_time' => 1763094965,

)
;