jQuery(document).ready(function() {

  // if new date clicked then update inputbox and update highlights
  jQuery("td a").click(function() {
    var start_date = (jQuery(this).attr("rel"));
//$('#arrival_date').attr('disabled', false);

    //alert (start_date);
    jQuery("input#arrival_date").val(start_date);
    update_highlights();
    return false;
  });


  // if dropdown changes then update highlights..
  jQuery("select#holiday_duration").change(function() {
    update_highlights();
  });

  // update highlights
  function update_highlights() {
    var duration = jQuery("select#holiday_duration").val();
    var start_date = jQuery("input#arrival_date").val();
    var property_id = jQuery("input#property_id").val();
    jQuery("td a").removeClass("selected");

    var start = jQuery("a[rel=" + start_date.replace(/\//g,'\/') + "]");

    start.addClass("selected");

    idx = parseInt( start.parent().attr("rel"));
    for (x=1; x< duration ; x=x+1) {
      $("td[rel=" + (x+idx) + "] a").addClass("selected");
    }

    $.ajax({
      url: '/ajax.php',
      data: "skim=check-availability&property_id=" + property_id + "&start_date=" + start_date + "&duration="+duration,
      success: function(msg) {
        data = msg.split("|");

        //#$('.result').html(data);
        $("div.price").html(data[0]);

        if (data[1] == "1") {
          $("div#sidebar .enquiry").show();
          $("div#sidebar .button-off").hide();
        }
        else
        {
          //$("input#arrival_date").attr('disabled',true);
          $("div#sidebar .enquiry").hide();
          $("div#sidebar .button-off").show();
        }
        //alert(data);
         //alert('Load was performed.');
      }
    });
  }
});

// enquiry form functions
jQuery(document).ready(function() {

$(function() {
  $('.inline_datepicker_enquiry').datepick( {
    showBigPrevNext: true, changeMonth: false, changeYear: false,
    firstDay: 0,
    changeFirstDay: true,
    dateFormat: "dd/mm/yy",
    showOn:  'both',
    buttonImageOnly: true,
    // buttonImage: '/images/datepick/calendar.gif'
    buttonImage: '/includes/images/forms/datepicker-large.gif'
  });
});


                });

