jQuery.noConflict();
jQuery(document).ready(function(){
	
	jQuery("select#r_class_type").change(function () {	
		var type = jQuery("#r_class_type").val();
		if(type)
		{
			jQuery('#r_src_county').children().remove().end().append('<option value=""> ...Loading... </option>');
			jQuery.get(script_url+"/index.php",{
				class_type: jQuery("#r_class_type").val(),
				module: "ajax",
				action: "populate_county"
			},
			function(xml){
				add_options(xml);
			});
			function add_options(xml) {
				jQuery('#r_src_county').children().remove().end().append('<option value=""> Select Any </option>');
				jQuery("county",xml).each(function(id) {
					county = jQuery("county",xml).get(id);				
					result = '<option value="'+jQuery("_value",county).text()+'">'+jQuery("_value",county).text()+'</option>'
					jQuery("#r_src_county").append(result);
				});
			}
		}		
	});
	
    jQuery("select#r_src_county").change(function () {
		jQuery('#r_src_area').children().remove().end().append('<option value=""> ...Loading... </option>');	
		jQuery.get(script_url+"/index.php",{
			src_county: jQuery("#r_src_county").val(),
			class_type: jQuery("#r_class_type").val(),
			module: "ajax",
			action: "populate_search"
		},
		function(xml){
			add_options(xml);
		});
		function add_options(xml) {
			jQuery('#r_src_area').children().remove().end().append('<option value=""> Select Any </option>');
			jQuery("area",xml).each(function(id) {
				area = jQuery("area",xml).get(id);				
				result = '<option value="'+jQuery("_value",area).text()+'">'+jQuery("_value",area).text()+'</option>'
				jQuery("#r_src_area").append(result);
			});
		}		
	});	
	
});

