/**
 * productInit.js
 * @author Emmanuel Sammut (TS)
 * Last modified August 4, 2008 by Emmanuel Sammut (TS)
 */

/*
 * Defined constant of ID element.
 */
 $(".dispoSelects").each(function(){
   		$(this).html(result);
		$(".disponibility").each(function() {
		  $(this).change(function(event) {
		  	var target = event.target;
		    $(".disponibility").each(function() {
		      if (this != target) {
		        $(this).val($(target).val());
		      }
		    });
		  });
		});
      });


function reloadDispoSelects(citySelect, productId) {
    var selectCityIndex = citySelect.selectedIndex;
    var selectCityCode = citySelect.options[selectCityIndex].value;
    var selectedDispo = $("#slt_disponibility").val();
    var selectedDispoDetails = selectedDispo.split("-");
    var urlDepDate = selectedDispoDetails[0] + "/" + selectedDispoDetails[1] + "/" + selectedDispoDetails[2];

    $(".dispoSelects").each(function(){
   		$(this).html("<div style=\"text-align:center\"><img src='/CS/images/ajax-loader.gif' title='Patientez svp' alt='Patientez svp' /></div>")
	});
	$.get("/components/product-disponibilities.jsp", {pid: productId, dpci: selectCityCode, depDate: urlDepDate}, function(result) {
	  $(".dispoSelects").each(function(){
   		$(this).html(result);
		$(".disponibility").each(function() {
		  $(this).change(function(event) {
		  	var target = event.target;
		    $(".disponibility").each(function() {
		      if (this != target) {
		        $(this).val($(target).val());
		      }
		    });
		  });
		});
      });
	});
}