/**
  * Shipping Estimator
  * @category blocks
  *
  * @author Aaron Weatherall / AU PHP Developer / Sitefx.com.au
  * @copyright Sitefx Online Pty Ltd
  * @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
  * @version 1.0
  */
  
function updateCarriers(id_country, id_state)
{
	
	var country_array = id_country.split('-'); 
	var process_estimate = 'FALSE';
	var getstates = 'FALSE';
	
	if (country_array[0] == 1) {
		$('#ajaxarea').slideUp('normal');
		getstates = 'TRUE';
	} else if (country_array[0] == 2) {
		document.getElementById('statearea').innerHTML = "";
		process_estimate = 'TRUE';
	} else {
		process_estimate = 'TRUE';
	}
	
	id_country = country_array[1];
	
	if (getstates == 'TRUE') {
		$.ajax({
			type: 'GET',
			url:	baseDir + 'modules/shippingestimate/shippingestimate-ajax.php',
			async: true,
			cache: false,
			data: 'action=getstates&id_country=' + id_country,
			success: function(data)
			{
				//$('#states').slideUp('normal');
				document.getElementById('statearea').innerHTML = data;
				//$('#states').slideDown('normal');
			}
		});	
	}
	
	if (process_estimate == 'TRUE') {
		$.ajax({
			type: 'GET',
			url:	baseDir + 'modules/shippingestimate/shippingestimate-ajax.php',
			async: true,
			cache: false,
			data: 'id_country=' + id_country + '&id_state=' + id_state + '&token=' + static_token,
			success: function(data)
			{
				$('#ajaxarea').slideUp('normal');
				document.getElementById('ajaxarea').innerHTML = data;
				$('#ajaxarea').slideDown('normal');
			}
		});	
	}
}
