﻿  $(function() {

  // Set up default dates in forms
  var d = new Date();
  var year = d.getFullYear();

  // Add two years, now and next to find hotel
  var options = '<option selected value="' + year + '">' + year + '</option>';
  options += '<option value="' + (year+1) + '">' + (year+1) + '</option>';

  $("select#start_year").html(options);
  $("select#end_year").html(options);

  var month = ('0' + (d.getMonth() + 1)).substring(0,2); // Pad month
  var day = d.getDate();
 
  // Today
  $("#start_day").val(day);
  $("#start_month").val(month);
  
  $("#forDate").datepicker({ dateFormat: 'dd/mm/yy', numberOfMonths: 1 });
  $("#forDate").val(day + '/' + month + '/' + year);
 
  // Tomorrow
  d.setDate(d.getDate() + 1);
  month = ('0' + (d.getMonth() + 1)).substring(0,2); // Pad month
  day = d.getDate();

  $("#end_day").val(day);
  $("#end_month").val(month);

  $("select#SearchUserControl1_DropDownCategory").change(function(){
  $("select#SearchUserControl1_DropDownEvent").attr("disabled","disabled");

  // Get JSON
  $.getJSON("JsonBackend.aspx",{category: $(this).val()}, function(j){
  var options = '';

  if ($("select#SearchUserControl1_DropDownCategory").val().length > 0)
  {
  options = '<option value="">Every event for this category</option>';
  }
  else
  {
  options = '<option value="">Please choose an option above</option>';
  }

  for (var i = 0; i < j.length; i++) {
          options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
  }

  $("select#SearchUserControl1_DropDownEvent").html(options);

  if ($("select#SearchUserControl1_DropDownCategory").val().length > 0)
  {
  $("select#SearchUserControl1_DropDownEvent").attr("disabled","");
  }
  else
  {
  $("select#SearchUserControl1_DropDownEvent").attr("disabled","disabled");
  }


  })
  })
  });

  $(document).ready(function() {
  $("select#SearchUserControl1_DropDownCategory").change();
  });

  function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
  }        

