  
  $(function()
  {
    $('#country').chainSelect('#destination', siteURL + '/ajax.php',
  	{ 
  		before: function (target) //before request hide the target combobox and display the loading message
  		{ 
  			$("#loading").show().css({opacity:'0.7',cursor:'default'});
  		},
  		after: function (target) //after request show the target combobox and hide the loading message
  		{ 
  			$("#loading").hide().css({opacity:'1.0'});
  		}
  	});
  
    $('#destination').chainSelect('#location', siteURL + '/ajax.php',
    {
      before:function (target) 
  		{ 
  			$("#loading").show().css({opacity:'0.7',cursor:'default'});
  		},
  		after:function (target) 
  		{ 
  			$("#loading").hide().css({opacity:'1.0'});
  		}
  	});

    $('#country2').chainSelect('#destination2', siteURL + '/ajax.php',
  	{ 
  		before: function (target) //before request hide the target combobox and display the loading message
  		{ 
  			$("#loading").show().css({opacity:'0.7',cursor:'default'});
  		},
  		after: function (target) //after request show the target combobox and hide the loading message
  		{ 
  			$("#loading").hide().css({opacity:'1.0'});
  		}
  	});
  
    $('#destination2').chainSelect('#location2', siteURL + '/ajax.php',
    {
      before:function (target) 
  		{ 
  			$("#loading").show().css({opacity:'0.7',cursor:'default'});
  		},
  		after:function (target) 
  		{ 
  			$("#loading").hide().css({opacity:'1.0'});
  		}
  	});
  	
  	assignDefaultOptions('#destination', 'Please select a "Country"');
  	assignDefaultOptions('#location', 'Please select a "Region"');
  	assignDefaultOptions('#destination2', 'Please select a "Country"');
  	assignDefaultOptions('#location2', 'Please select a "Region"');
  	
  	// todo: Assign [loading] values to the destination and the location as default
  	// $('destination').
  	
  	function assignDefaultOptions(target, textDisplay) {
  	  $(target).html(""); // remove the default value
      option = document.createElement("OPTION");//create a new option
      option.value = '0';//set option value	
      option.innerText = textDisplay; // i.e
      option.text = textDisplay;
      $(target).append(option);//insert the option into the select
    }
  	
  });
