var categoryXML="";
	// Run after document is ready
$(document).ready(function () {
    // Get Categories from xml file and populate category dropdown
    $.ajax({
        type: "GET",
        url: "/api/CategorySearch.ashx",
        dataType: "xml",
        success: function (xml) {
            categoryXML = xml;
            $(xml).find('overallcategory').each(function () {
                var strName = $(this).attr('name');
                var strValue = $(this).attr('value');
                $('.search-category').append($("<option></option>").attr("value", strValue).text(strName));
            });
        }
    });
    // On category dropdown change, call onCategoryChange function
    $(".search-category").change(onCategoryChange);

    // Event date calendar
    $(".search-date").datepicker({
        showButtonPanel: true,
        minDate: +1,
        showOtherMonths: true
    });


});
	
	// On Category change, get instrument
	function onCategoryChange(){
		var val=$(".search-category").val();
		$(".search-instrument").empty().append('<option selected="selected" value="">Select category...</option>')
		if (val.length) {
			$(categoryXML).find('overallcategory').each(function(){
				if($(this).attr('value')==val){
					$(this).find('category').each(function(){
						$('.search-instrument').append($("<option></option>").attr("value",$(this).attr('value')).text($(this).attr('name')));
					});
					$('.search-instrument').removeAttr('disabled');
				}
			});
		} else {
			$(".search-instrument").attr("disabled", true); 
		}
	}

