function update_image(phone_id, elmt_id) {
  $.get('mobiler/billedenavn', {pid: phone_id}, function(data){
    update_image_callback(data, elmt_id);
  });
}

function update_image_callback (data, elmt_id) {
  $('#'+elmt_id).fadeOut('fast', function() {
    $('#'+elmt_id).attr('src', data).fadeIn('fast');
  });
}

function switch_parralel_import(id) {
  preloader_show("#pic_" + id);
  
  $.ajax({
    url: "jx/parrallel_import.php?id=" + id,
    success: function(data) {
      if (data == "") {
      } else if (data == 0) {
        $('#pi_' + id).attr('src', 'images/dkf.gif');
      } else if (data == 1) {
        $('#pi_' + id).attr('src', 'images/dkf_g.gif');
      }
      
      preloader_hide();
    },
    failure: function() {
      preloader_hide();
    }
  });
}

function preloader_show(id) { 
  var p = $(id).position();
  
  $('#preloader2').css({top: p.top + 'px', left: p.left + 'px'});
  $('#preloader2').width($(id).width() + 'px');
  $('#preloader2').height($(id).height() + 'px');
  $('#preloader_img').css({top: 2 + 'px', left: ($(id).width() - 80) / 2 + 'px'});
  
  $('#preloader2').show();
}

function preloader_hide() {
  $('#preloader2').hide();
}
