jQuery.fn.bindAll=function(a){var b=this;jQuery.each(a,function(c,d){b.bind(c,d)});return this};function errorNotification(a){$("#"+a.id,this).fadeOut("slow",function(){$(this).remove()});$(".upload-notifications",this).slideDown();setTimeout(function(){$(".upload-notifications",this).fadeOut()},10000)}$(function(){var render_div="";var primary_photo_post="";var primary_photo_obj="";var listeners={swfuploadLoaded:function(event){},fileQueued:function(event,file){if($(".files-list-table",this).css("display")=="none"){$(".files-list-table",this).fadeIn()}$(".before-upload h2",this).hide();$(".before-upload",this).css("text-align","left");var row=$("<tr></tr>");row.attr("id",file.id);var name_col=$("<td></td>");name_col.attr("id",file.id+"_title").attr("class","file-name-column");row.append(name_col);name_col.append("<p>"+file.name+"</p>");var progress_bar=$("<div></div>");progress_bar.attr("class","ui-progressbar");name_col.append(progress_bar);var size_col=$("<td></td>");size_col.attr("id",file.id+"_progressbar");size_col.css("text-align","center");row.append(size_col);var size;if(file.size<1024){size=file.size.toFixed(2)+" B"}else{if(file.size<1048576){size=(file.size/1024).toFixed(2)+" KB"}else{size=(file.size/1048576).toFixed(2)+" MB"}}size_col.append("<p>"+size+"</p>");var action_col=$("<td></td>");action_col.css("text-align","center");row.append(action_col);if($(".swfupload-control-primary-params",this).length){var primary_photo_link=$("<a></a>").attr({id:file.id+"_primary_link",href:"#",title:language.set_as_primary_photo}).html("&nbsp;").addClass("photo-star-icon set-primary-button").css("display","none");action_col.append(primary_photo_link)}$(".files-list-table",this).find("tbody").append(row);$("#"+file.id,this).find(".ui-progressbar").progressbar({value:5});$(this).swfupload("startUpload")},fileQueueError:function(event,file,errorCode,message){if(errorCode==-110){alert(language.wrong_video_size)}},fileDialogStart:function(event){},fileDialogComplete:function(event,numFilesSelected,numFilesQueued){},uploadStart:function(event,file){showLoader()},uploadProgress:function(event,file,bytesLoaded,bytesTotal){var percent=Math.ceil((bytesLoaded/bytesTotal)*100);$("#"+file.id,this).find(".ui-progressbar").progressbar("option","value",percent)},uploadSuccess:function(event,file,serverData){server_data=eval("("+serverData+")");if($(".swfupload-control-primary-params",this).length){primary_photo_post=$(".swfupload-control-primary-params",this).val()+server_data.id;primary_photo_obj=$(".swfupload-control-primary-params",this).attr("rel");if(server_data.set_pp){$.ajax({type:"POST",url:primary_photo_post,cache:false,data:{id:server_data.id},success:function(response){$("#"+primary_photo_obj).html(response)}})}else{$("#"+file.id,this).find(".set-primary-button").show("fast");$("#"+file.id,this).find(".set-primary-button").click(function(){$.ajax({type:"POST",url:primary_photo_post,cache:false,data:{id:server_data.id},success:function(response){$("#"+primary_photo_obj).html(response)}});return false})}}},uploadComplete:function(event,file){var obj=this;$(this).swfupload("startUpload");$("#"+file.id,obj).find(".ui-progressbar").fadeOut("slow");setTimeout(function(){$("#"+file.id,obj).fadeOut("slow")},7000);render_div=$(".swfupload-control-params",this).attr("value");render_post_link=$(".swfupload-control-params",this).attr("rel");$.ajax({type:"GET",url:render_post_link,cache:false,success:function(response){$("#"+render_div).html(response);hideLoader()}})},uploadError:function(event,file,errorCode,message){errorNotification(file);hideLoader()}};$(".swfupload-control").bindAll(listeners)});$(function(){$(".swfupload-control").each(function(){$(this).swfupload({upload_url:$(".upload-button",this).attr("rel"),file_size_limit:"10240",file_types:$(".upload-button",this).attr("value"),file_types_description:$(".upload-button",this).attr("name"),file_upload_limit:"0",flash_url:"/flash/swfupload.swf",button_image_url:"/images/upload-photos-button.png",button_width:133,button_height:29,button_placeholder:$(".upload-button",this)[0],debug:false})})});function bindMediaListing(){$(".media-item").hover(function(){$(this).addClass("media-item-hover");$(".media-item-actions",this).css({opacity:1})},function(){$(this).removeClass("media-item-hover");$(".media-item-actions",this).css({opacity:0.5})})};