var uploader,uploader_init,topWin=window.dialogArguments||opener||parent||top;function fileQueued(e){jQuery(".media-blank").remove();var r=jQuery("#media-items").children(),a=post_id||0;1==r.length&&r.removeClass("open").find(".slidetoggle").slideUp(200),jQuery('
').attr("id","media-item-"+e.id).addClass("child-of-"+a).append('
0%
',jQuery('
').text(" "+e.name)).appendTo(jQuery("#media-items")),jQuery("#insert-gallery").prop("disabled",!0)}function uploadStart(){try{void 0!==topWin.tb_remove&&topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}catch(e){}return!0}function uploadProgress(e,r){var a=jQuery("#media-item-"+r.id);jQuery(".bar",a).width(200*r.loaded/r.size),jQuery(".percent",a).html(r.percent+"%")}function fileUploading(e,r){var a=104857600;aa&&setTimeout(function(){r.status<3&&0===r.loaded&&(wpFileError(r,pluploadL10n.big_upload_failed.replace("%1$s",'').replace("%2$s","")),e.stop(),e.removeFile(r),e.start())},1e4)}function updateMediaForm(){var e=jQuery("#media-items").children();1==e.length?(e.addClass("open").find(".slidetoggle").show(),jQuery(".insert-gallery").hide()):1(\d+)<\/pre>$/,"$1")).match(/media-upload-error|error-div/)?a.html(r):(jQuery(".percent",a).html(pluploadL10n.crunching),prepareMediaItem(e,r),updateMediaForm(),post_id&&a.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(+jQuery("#attachments-count").text()+1))}function setResize(e){e?window.resize_width&&window.resize_height?uploader.settings.resize={enabled:!0,width:window.resize_width,height:window.resize_height,quality:100}:uploader.settings.multipart_params.image_resize=!0:delete uploader.settings.multipart_params.image_resize}function prepareMediaItem(e,r){var a="undefined"==typeof shortform?1:2,i=jQuery("#media-item-"+e.id);2==a&&2

'+e+"

")}function wpFileError(e,r){itemAjaxError(e.id,r)}function itemAjaxError(e,r){var a=jQuery("#media-item-"+e),i=a.find(".filename").text();a.data("last-err")!=e&&a.html('
'+pluploadL10n.dismiss+""+pluploadL10n.error_uploading.replace("%s",jQuery.trim(i))+" "+r+"
").data("last-err",e)}function deleteSuccess(e){var r;return"-1"==e?itemAjaxError(this.id,"You do not have permission. Has your session expired?"):"0"==e?itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?"):(r=this.id,e=jQuery("#media-item-"+r),(r=jQuery("#type-of-"+r).val())&&jQuery("#"+r+"-counter").text(jQuery("#"+r+"-counter").text()-1),post_id&&e.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1),1==jQuery("form.type-form #media-items").children().length&&0 '+pluploadL10n.deleted+" ").siblings("a.toggle").hide(),jQuery(".filename",e).append(jQuery("a.undo",e).removeClass("hidden")),void jQuery(".menu_order_input",e).hide())}function deleteError(){}function uploadComplete(){jQuery("#insert-gallery").prop("disabled",!1)}function switchUploader(e){e?(deleteUserSetting("uploader"),jQuery(".media-upload-form").removeClass("html-uploader"),"object"==typeof uploader&&uploader.refresh()):(setUserSetting("uploader","1"),jQuery(".media-upload-form").addClass("html-uploader"))}function uploadError(e,r,a,i){var t=104857600;switch(r){case plupload.FAILED:wpFileError(e,pluploadL10n.upload_failed);break;case plupload.FILE_EXTENSION_ERROR:wpFileExtensionError(i,e,pluploadL10n.invalid_filetype);break;case plupload.FILE_SIZE_ERROR:uploadSizeError(i,e);break;case plupload.IMAGE_FORMAT_ERROR:wpFileError(e,pluploadL10n.not_an_image);break;case plupload.IMAGE_MEMORY_ERROR:wpFileError(e,pluploadL10n.image_memory_exceeded);break;case plupload.IMAGE_DIMENSIONS_ERROR:wpFileError(e,pluploadL10n.image_dimensions_exceeded);break;case plupload.GENERIC_ERROR:wpQueueError(pluploadL10n.upload_failed);break;case plupload.IO_ERROR:tt?wpFileError(e,pluploadL10n.big_upload_failed.replace("%1$s",'').replace("%2$s","")):wpQueueError(pluploadL10n.io_error);break;case plupload.HTTP_ERROR:wpQueueError(pluploadL10n.http_error);break;case plupload.INIT_ERROR:jQuery(".media-upload-form").addClass("html-uploader");break;case plupload.SECURITY_ERROR:wpQueueError(pluploadL10n.security_error);break;default:wpFileError(e,pluploadL10n.default_error)}}function uploadSizeError(e,r){var a=pluploadL10n.file_exceeds_size_limit.replace("%s",r.name),a=jQuery("
").attr({id:"media-item-"+r.id,"class":"media-item error"}).append(jQuery("

").text(a));jQuery("#media-items").append(a),e.removeFile(r)}function wpFileExtensionError(e,r,a){jQuery("#media-items").append('

'+a+"

"),e.removeFile(r)}jQuery(document).ready(function(d){d(".media-upload-form").bind("click.uploader",function(e){var r,a=d(e.target);a.is('input[type="radio"]')?(r=a.closest("tr")).hasClass("align")?setUserSetting("align",a.val()):r.hasClass("image-size")&&setUserSetting("imgsize",a.val()):a.is("button.button")?(r=(r=e.target.className||"").match(/url([^ '"]+)/))&&r[1]&&(setUserSetting("urlbutton",r[1]),a.siblings(".urlfield").val(a.data("link-url"))):a.is("a.dismiss")?a.parents(".media-item").fadeOut(200,function(){d(this).remove()}):a.is(".upload-flash-bypass a")||a.is("a.uploader-html")?(d("#media-items, p.submit, span.big-file-warning").css("display","none"),switchUploader(0),e.preventDefault()):a.is(".upload-html-bypass a")?(d("#media-items, p.submit, span.big-file-warning").css("display",""),switchUploader(1),e.preventDefault()):a.is("a.describe-toggle-on")?(a.parent().addClass("open"),a.siblings(".slidetoggle").fadeIn(250,function(){var e,r,a=d(window).scrollTop(),i=d(window).height(),t=d(this).offset().top,o=d(this).height();i&&t&&o&&(r=a+i)<(e=t+o)&&(e-r