$(document).ready(function() {

  $('.message-close').show();

  // Setup smooth scrolling
  var target = $('#content');
  $('a[href*=#]').click(function(){
    var link = $(this).attr('href');
    target.scrollTo( 
      link,
      900,
      {
        axis:'x'
      });
    return false;
  });

  // Request price links
  $('a.request-price').click(function(){
    $('li #form_request').attr('checked', 'checked');
    $(':input:first').focus();
  });

  $('a.voucher').click(function(){
    $('#form_voucher').focus();
  });

  // Modal window
  if($('.alert_box').length != 0){
    $('.alert_box').hide();
    $('.alert_box').modal({overlayClose:true});

    $('a.message-close').click(function(){
      $.modal.close();
      return false;
    });
  }

  if((navigator.userAgent.match(/iPhone|iPod|iPad/i))) {
	  $('#header').css({'padding' : '0 10px 0 18px'});
  }

/*
  // Form sumbmission
  var getFields = function(form) {

    // Input
    $(form + ' input[type=text]').each(function(){
      var field = $(this);

      console.log(field.val());
    });

    // Text field
    $(form + ' textarea').each(function(){
      var field = $(this);

      console.log(field.val());
    });

    // Check box
    $(form + ' input[type="checkbox"]').each(function(){
      var field = $(this);

      console.log(field.val());
    });


  };
  
  var submitForm = function(person) {

    var data = [];
//    var personId = person.parents('li').attr('id').replace(/person_/, '');
//    var moduleId = $('#breadcrumb a.module').attr('id').replace(/module_/, '');

    $.getJSON(
      '/home/ajaxsubmit',
      {
        data: data
      },
      function(response){
        if(response.validated == 'true')
        {
          console.log('Validated');
        }
        else if(response.validated == 'false')
        {
          console.log('NOT Validated');
          if(response.error)
          {
            getFields('#contact-form');
          }
        }
    });

  };

  var Form = $('div#contact-form button#submit');

  Form.bind('click', function()
  {
    var self = $(this);
    if(!self.hasClass('disabled'))
    {
      submitForm(self);
    }
    return false;
  });
*/
});
