$(function() {
  $('div#sandwichinfo form').corner().bind('submit',function() {
    var f = this;
    var now = new Date();
    var pickup = (((now.getDay() > 3) && (now.getDay() < 5)) ||
        ((now.getDay() == 3) && (now.getHours() >= 10)) ||
        ((now.getDay() == 5) && (now.getHours() <= 20)))?'Saturday':'Wednesday';
    if (typeof(satonly) != 'undefined') { pickup = 'Saturday morning'; }
    $.prompt('<h4>Please Note</h4><p>Your order will be available on '+pickup+' at the Farmer\'s Market. Continue?</p>',{
      buttons:{ 'Continue':true,'Go back':false },
      prefix:'colsJqi',
      opacity: 0.9,
      show:'slideDown',
      submit:function(v,m) { 
        if (v) { f.submit(); }
        return(true);
      }
    }).children('div:eq(1)').queue('fx',function() { $(this).corner(); });
//    return(confirm('Your order will be available on Wednesday at the Farmer\'s Market. Continue?'));
    return(false);
  });
  $('div#sandwichinfo form select').bind('change keyup',function() {
    if (this.selectedIndex == (this.options.length - 1)) {
      $.prompt('<h4>Large Orders</h4><p>Please contact us ahead of time when ordering more than 4 sandwiches, so that we may better accomodate your order!</p>',{
        buttons:{ 'Continue':true },
        prefix:'colsJqi',
        opacity: 0.9,
        show:'slideDown',
        submit:function(v,m) { 
          document.location.href = '/contact.html';
          return(true);
        }
      }).children('div:eq(1)').queue('fx',function() { $(this).corner(); });
//      alert('Please contact us when ordering over 4 sandwiches so we may better accomodate your order!');
//      document.location.href = '/contact.html';
    }
    return(false);
  });
});
