function populateRegionVariety(){
	var region=$('#region');
	var country_select=$('#country');
	var country_val=country_select.val();
	var selecttype=$('#types');
	$('#region').html('<option>(loading...)</option>');
	if(country_val!='none'){
		$('#selectregion').html('All Regions');
		$.get(template_path+'/includes/getregions.php?country='+country_val,function(data){if(data==''){$('#region').html('<option value="none">All Regions</option>');}else{$('#region').html(data);}});
	}else{
		$('option',selecttype).remove();
		$('option',region).remove();
		$('#selectregion').html('All Regions');
		region.attr('disabled','disabled');
	}
}

function removeValue(){
	$('#location-input').val('');
}

$(document).ready(function(){$('#country').change(function(){populateRegionVariety();});$('#region').change(function(){populateTypeVariety();});$('#location-input').click(function(){removeValue();});});

function addCommas(nStr){
	nStr+='';
	x=nStr.split('.');
	x1=x[0];x2=x.length>1?'.'+x[1]:'';
	var rgx=/(\d+)(\d{3})/;
	while(rgx.test(x1)){
		x1=x1.replace(rgx,'$1'+','+'$2');
	}
	return x1+x2;
}
