$.extend(DateInput.DEFAULT_OPTS, {
  stringToDate: function(string) {
    var matches;
    if (matches = string.match(/^(\d{2,2})\/(\d{2,2})\/(\d{4,4})$/)) {
      return new Date(matches[3], matches[1] - 1, matches[2]);
    } else {
      return null;
    };
  },

  dateToString: function(date) {
    var month = (date.getMonth() + 1).toString();
    var dom = date.getDate().toString();
    if (month.length == 1) month = "0" + month;
    if (dom.length == 1) dom = "0" + dom;
    return  month + "/" + dom + '/' + date.getFullYear();
  }
});

$(document).ready(function() {
	
	if ($('#airdate-field').attr('value') != '') {
		$('#airdate-remove').show();
	}
	$.date_input.initialize;
	$('#airdate-field').date_input();
	
	$('#airdate-field').change(function() {
		if ($('#airdate-field').attr('value') != '') {
			$('#airdate-remove').show();
		} else {
			$('#airdate-remove').hide();
		}
	});
			
	$('#airdate-cal').click(function() {
		$('#airdate-field').focus();
		return false;
	});
	
	$('#airdate-remove').click(function() {
		$('#airdate-field').attr('value', '');
		$(this).hide();
		return false;
	});

});