﻿$(document).ready(function() {
    //attachFormatter($("#tbFromAmount"));
    $("#tbFromAmount").change();
	
	$("#btnConvert").click(function()
	{
		$("#lblResult").hide("fast");
		var data = JSON2.stringify({
			amount: $("#tbFromAmount").val(), 
			fromCode: $("#DropDownList_FromCurrency option:selected").val(), 
			toCode: $("#DropDownList_ToCurrency option:selected").val()
		});
		
		$.ajax({
			type: "POST",
			url: "/Tools/CurrencyConverter/ws.asmx/Convert",
			data: data,
			dataType: "json",
			contentType: "application/json",
			success: function(msg) {
				$("#lblResult").text(msg.d).show("fast"); 
			}
		});
    });

    function attachFormatter(el) {
        el.change(function() {
            el.val(currencyFormated(parseNumber(el.val())));
        });
    }


	
});
