function ShowWidgetExpl() {
  var select = $('#widgetTypeSelect').val();
  $('.media_exp').css('display', 'none');
  $('#Expl_' + select).css('display', 'block');
  if (select != '') {
    $('#MdaWdgDiv').css('display', 'block');
    $('.MdaWdgExpl').css('display', 'block');
  }
  else {
    $('#MdaWdgDiv').css('display', 'none');
    $('.MdaWdgExpl').css('display', 'none');
  }
}

function activateMdaWdgTab(formname) {
  if ($('#MdaWdgTab_action').val() == 'none') {
    $('#MdaWdgTab_action').val('add');
    if (typeof (addRequiredField) != 'undefined' && formname != null) {
      addRequiredField(formname, 'MdaWdgTab.Tit', 'Titel');
      addRequiredField(formname, 'MdaWdgTab.AltUrl', 'Alternatieve URL');
    }
  }
}

function loadWidgets() {
  $("a.MediaElement:visible").each(function() {
    $(this).createFlashObject(widgetInfo[$(this).attr("id")]["objurl"], widgetInfo[$(this).attr("id")]["objwidth"], widgetInfo[$(this).attr("id")]["objheight"], widgetInfo[$(this).attr("id")]["objargs"]);
  });
  $("a.MediaFrame:visible").each(function() {
    placeMediaFrame(this, widgetInfo[$(this).attr("id")]["objurl"], widgetInfo[$(this).attr("id")]["objwidth"], widgetInfo[$(this).attr("id")]["objheight"]);
  });
}

function placeMediaFrame(targetObj, objurl, objwidth, objheight) {
  targetObj.removeChild(targetObj.firstChild);
  var o = document.createElement("iframe");
  o.width = objwidth;
  o.height = objheight;
  o.src = objurl;
  o.frameBorder = 0;

  targetObjParent = targetObj.parentNode;
  targetObjParent.removeChild(targetObj);
  targetObjParent.appendChild(o);

}