function getAddress(){
var email = $("#email").val();
$("#deliveryinfo").html("");
$.get(currentUrl, {email: email, getAddress: 1},
  function(data){
		$("#deliveryinfo").append(data);
		idSelectedCountry = $("#selectedState").val();
		updateState();
		//updateShippingState();
  });
}

function ToggleInvoiceLayer()
{
 	var style = document.getElementById('contentinvoice').style;
	style.display = style.display == 'block' ? 'none' : 'block';
}

function updateStateinv()
{
	$('select#invid_state option:not(:first-child)').remove();
	var states = countries[$('select#invid_country').val()];
	if( typeof(states) != 'undefined' )
	{
		for (indexState in states)
		{
			//ie bug fix
			if (indexState != 'indexOf')
			$('select#invid_state').append('<option value="'+indexState+'"'+ ($('#selectedinvState').val() == indexState ? ' selected="selected' : '') + '">'+states[indexState]+'</option>');
		}
		$('p.invid_state:hidden').slideDown('slow');
	}
	else
		$('p.invid_state').slideUp('fast');
}

function updateStatedel()
{
	$('select#id_state option:not(:first-child)').remove();
	var states = countries[$('select#id_country').val()];
	if( typeof(states) != 'undefined' )
	{
		for (indexState in states)
		{
			//ie bug fix
			if (indexState != 'indexOf')
			$('select#id_state').append('<option value="'+indexState+'"'+ (idSelectedCountry == indexState ? ' selected="selected' : '') + '">'+states[indexState]+'</option>');
		}
		$('p.id_state:hidden').slideDown('slow');
		$("#shippingoptions").html("");
	}
	else
	{	
		$('p.id_state').slideUp('fast');
		updateShippingState();
	}
}

function updateShippingState()
{
	var id_country = $("select#id_country").val();
	var id_state = $("select#id_state").val();
	$("#shippingoptions").html("");
	if(id_country>0)
	{
	$.get(currentUrl, {getShippingOptions: 1, id_lang: id_lang, id_cart: id_cart, id_country: id_country, id_state: id_state},
	  function(data){
			$("#shippingoptions").append(data);
			tb_init('a.thickbox, area.thickbox, input.thickbox');
			imgLoader=new Image();
			imgLoader.src=tb_pathToImage;
	  });
	  }
}

function addDiscount()
{
$("#vouchersdiv").html("");
	$.get(currentUrl, {adddiscount: $('#discount_name').val(), id_lang: id_lang, id_cart: id_cart},
	  function(data){
			$("#vouchersdiv").append(data);
	  });
}

function deleteDiscount(id)
{
$("#vouchersdiv").html("");
	$.get(currentUrl, {deleteDiscount: id, id_lang: id_lang, id_cart: id_cart},
	  function(data){
			$("#vouchersdiv").append(data);
	  });
}