
function fillCap(comuneId, selectId, label_cap)
{
    
    var date = new Date()
    $j.ajax({
        url: '/geografia.asp',
        dataType: 'json',
        data: "cmd=getCapByComuneId&comuneId=" + comuneId + "&time=" + date.getTime(),
        success: function (data) {
            var ua = $j.browser;
            if ((ua.msie && ua.version == "7.0")) {
                var width = $j("#" + selectId).css("width");
            }
            $j("#" + selectId).empty();
            var option = $j("<option></option>");
            option.val("").html(label_cap)
            $j('#' + selectId).append(option);
            $j.each(data, function (i, item) {
                var option = $j("<option></option>");
                option.val(item.cap).html(item.cap)
                $j('#' + selectId).append(option);
            });            
            if ((ua.msie && ua.version == "7.0")) {
                $j("#" + selectId).css("width", width);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert("Si è verificato un errore durante il caricamento dei C.A.P. Si prega di riprovare. Error:" + textStatus);
        }
    });

}

function fillComuni(id_provincia, selectId, label_citta)
{
    var date = new Date()
    $j.ajax({
        url: '/geografia.asp',
        dataType: 'json',
        data: "cmd=getComuniByProvinciaId&provinciaId=" + id_provincia + "&time=" + date.getTime(),
        success: function(data) {
            var ua = $j.browser;
            if ((ua.msie && ua.version == "7.0")) {
                var width = $j("#" + selectId).css("width");
            }        
            $j("#" + selectId).empty();
            var option = $j("<option></option>");
            option.val("0").html(label_citta)
            $j('#' + selectId).append(option);
            $j.each(data, function(i, item){                        
                var option = $j("<option></option>");
                option.val(item.ComuneId).html(item.Denominazione)
                $j('#' + selectId).append(option);
            });
            if ((ua.msie && ua.version == "7.0")) {
                $j("#" + selectId).css("width", width);
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown)
        {
            alert("Si è verificato un errore durante il caricamento dei comuni. Si prega di riprovare. Error:" + textStatus);
        }
    });

}



        
              
       
    

