//图片按比例缩放
function drawImage(imgD,iwidth,iheight){    //参数(图片,允许的宽度,允许的高度)
   var image = new Image();
   image.src = imgD.src;
   if( image.width > 0 && image.height > 0 ) {
       if( image.width/image.height >= iwidth/iheight ) {
           if( image.width > iwidth ) {
               imgD.width = iwidth;
               imgD.height = (image.height * iwidth)/image.width;
           }
       } else {
           if( image.height > iheight ) {
               imgD.height = iheight;
               imgD.width = (image.width * iheight)/image.height;
           }
       }
   }
}

// 更换动态信息
function changeAct(user_id, range, type) {
    if (type != current_act_type || range != current_act_range) {
        $('#act_list').load('/users/'+ user_id + '/activities/ajax_index?range=' + range +'&type='+type,
            function (data) {
            });
    }
    range_name = $('#act_range_list dd a').eq(range).text();
    $('#act_range_list dt label').text(range_name);
    $(".list_1").attr("class","list_1 list_hide");
    $(".more_list").attr("class", "more_list");
    if (range != current_act_range) {
        $.post('/users/' + user_id + '/set_act_range', {range: range}, function (data){}, 'xml');
        current_act_range = range;
    }
    if (type != current_act_type) {
        current_act_type = type;
        $('.movement .sort a').attr("class", "");
        $('.movement .sort a').eq(type).attr("class", "selected-sort");
    }
}
