/*
 * Ex: get_currency('USD', 'BRL');
 * Tipo de retorno: json. valores de BID e OFFER.
 * nota: sempre usando amount = 1
*/
function get_currency(from, to, callbackFunction) {
	var url = "http://www.maximarn.com.br/wp-content/plugins/wordpress-currency-exchange/wpress_currency_mexchange.php";
	$.ajax({
		type: "GET",
		url: url,
		data: "curfrom=" + from + "&curto=" + to,
		success: function(retorno){
			var bid = $('.fourUp.bidAsk', retorno)[0];
			var offer = $('.fourUp.bidAsk.last', retorno);
			bid = $('.currData', bid).text();
			offer = $('.currData', offer).text();
			var valores = {'bid': bid, 'offer': offer};
			if(typeof callbackFunction == 'function'){
				callbackFunction.call(this, valores);
			}
		},
		error: function() {
			var valores = {'bid': '-', 'offer': '-'};
			if(typeof callbackFunction == 'function'){
				callbackFunction.call(this, valores);
			}
		}
	 });
}

function imprimir_currencies(valores, elbid, eloffer) {
	$(elbid).text(valores['bid']);
	$(eloffer).text(valores['offer']);
}
