
$myDFjQuery = jQuery.noConflict();

$myDFjQuery(function(){
	var ajax_region_url=$myDFjQuery('#ajax_region_url').val();

	if($myDFjQuery('#country_id').val()=="") $myDFjQuery('#region').show();
	else {
		$myDFjQuery.get(ajax_region_url, { country: $myDFjQuery('#country_id').val(), current_region: $myDFjQuery('#current_region_id').val() },
		   function(data){
				if(data=="no-region"){
					$myDFjQuery("label[for='region_id']").html('State/Province');
					$myDFjQuery('#region').show();
					$myDFjQuery('#region_select').hide();
				} else {
					$myDFjQuery("label[for='region_id']").html('<em>*</em>State/Province');
					$myDFjQuery('#region').hide();
					$myDFjQuery('#region_select').show();
			   		$myDFjQuery('#region_select').html(data);
				}
		   }
		);
	}
	$myDFjQuery('#country_id').change(function(){
		if($myDFjQuery(this).val()=="") $myDFjQuery('#region').show();
		else {
			//get region collection based on country code and show the select
			$myDFjQuery.get(ajax_region_url, { country: $myDFjQuery(this).val(), current_region: $myDFjQuery('#current_region_id').val() },
			   function(data){
					if(data=="no-region"){
						$myDFjQuery("label[for='region_id']").html('State/Province');
						$myDFjQuery('#region').show();
						$myDFjQuery('#region_select').hide();
					} else {
						$myDFjQuery("label[for='region_id']").html('<em>*</em>State/Province');
						$myDFjQuery('#region').hide();
						$myDFjQuery('#region_select').show();
				   		$myDFjQuery('#region_select').html(data);
					}
			   }
			);
		}
	})
});
