function update_tariff(data){
	jQuery('p.frequencies').each(function(){
		jQuery(this).remove();
	});
	jQuery('.expander select.country').after('<p class="frequencies"><em>' + data.frequencies + '</em></p>');
	jQuery('.compatibility.wx160').html('<p><em>' + data.compatibility_wx160 + '</em></p>');
	jQuery('td.callsfromukto').html(data.callsFromUkTo);
	jQuery('td.incoming').html(data.incoming);
	jQuery('td.national').html(data.national);
	jQuery('td.callstouk').html(data.callsToUk);
	jQuery('td.international').html(data.international);
	jQuery('td.textmessage').html(data.textMessage);
	jQuery('td.datarate').html(data.dataRate);
	
}
function clear_tariff(){

}
(function($){
	$(document).bind('ready', function() {
		//expanding boxes-START
		$('.box-content .expander').hide();
		$('.box-info a').toggle(
			function() {
				$(this).next('.expander').slideDown();
			}, 
			function() { 
				$(this).next('.expander').slideUp();
			}
		);
		//expanding boxes-END
		//country select-START
		$('select.country').change(function(){
			//console.log($(this).val());
			var country = $(this).val();
			//make all selects the same
			$('select.country').each(function(){
				$(this).val(country);
			});
			
			//do the ajax call
			if(country){//if the selection is a country and not 'no_selection'	
				$.ajax({
					type: "POST",
					url: "/wp-admin/admin-ajax.php",
					data:'action=tariff&country_slug=' + country,
					dataType: "json",
					success: function(data){
						update_tariff(data);					
					}
				});
			}else{
				clear_tariff();
			}});
		//country select-END
		});	
})(jQuery);
