CC.MediaList=function(A){this.params={};this.url=A};CC.MediaList.prototype.initialize=function(B,A){this.type=B;this.elementID=A};CC.MediaList.prototype.filter=function(B){if(B&&B.length>0){this.params.filters=B;var A=this.url+"?"+CC.Url.arrayToQueryString(this.params);CC.loadContent(this.elementID,A,function(){if(CC.Workspace&&CC.Workspace.College){CC.Workspace.College.refreshAccordion()}})}};CC.MediaList.prototype.clearFilter=function(){this.params.filters="";var A=this.url+"?"+CC.Url.arrayToQueryString(this.params);CC.loadContent(this.elementID,A,function(){if(CC.Workspace&&CC.Workspace.College){CC.Workspace.College.refreshAccordion()}})};CC.MediaList.prototype.sort=function(B){this.params.sort_by=B;if(this.params.sort_direction=="DESC"){this.params.sort_direction="ASC"}else{this.params.sort_direction="DESC"}var A=this.url+"?"+CC.Url.arrayToQueryString(this.params);CC.loadContent(this.elementID,A)};CC.MediaList.prototype.filterByCategory=function(B){this.params.college_category_id=B;var A=this.url+"?"+CC.Url.arrayToQueryString(this.params);CC.loadContent(this.elementID,A)};CC.Media={editorUrl:"/media/editor_dialog.php",viewerUrl:"/media/viewer.inc.php",collegeUrl:"/college/",dashboardUrl:"/dashboard/",ratingUrl:"/media/rating.inc.php",commentUrl:"/media/comment_list.inc.php",mediaListUrls:["/media/photo_list.inc.php","/media/video_list.inc.php","/media/links_list.inc.php"],workspaceID:null,initialize:function(A){this.elementID=A;if(arguments.length==2){this.workspaceID=arguments[1]}if(CC.Workspace&&CC.Workspace.College){CC.Workspace.College.refreshAccordion()}},registerCategoryOnClick:function(){$$("#category_list a").each(function(B){var A=B.id.split("category_link_")[1];B.removeEvents("click");B.addEvent("click",function(){CC.College.resetCategoryListClass();this.addClass("selected");CC.College.selectedCategoryID=A;CC.Media.Video.filterByCategory(A);CC.Media.Photo.filterByCategory(A)})});$$("#reset_category a").each(function(A){A.removeEvents("click");A.addEvent("click",function(){CC.College.resetCategoryListClass();CC.College.selectedCategoryID="";CC.Media.Video.filterByCategory("");CC.Media.Photo.filterByCategory("")})})},view:function(A){MOOdalBox.open("/common/ajax/media.php?action=view&id="+A,"Your Media","800 500")},showEditor:function(){var A=this.editorUrl;if(arguments.length>0){A+="?"+Object.toQueryString(arguments[0])}MOOdalBox.open(A,"Upload Your Media","728 255")},load:function(C){var B="";var A=false;if((arguments.length>1)&&!window.ie){if(this.workspaceID){B=this.dashboardUrl+"?active_mod=college&"}else{B=this.collegeUrl+"?"}B+="show=media&media_id="+C+"&college_id="+arguments[1];A=true}else{B=this.viewerUrl+"?media_id="+C}if(this.workspaceID){B+="&workspace_id="+this.workspaceID}if(A){window.location.href=B}else{CC.loadContent(this.elementID,B,function(){if(CC.Workspace&&CC.Workspace.College){CC.Workspace.College.refreshAccordion()}MOOdalBox.close()})}},loadByType:function(D,C,A){var B=this.mediaListUrls[D-1]+"?college_id="+C;CC.loadContent(A,B,function(){MOOdalBox.close()})},loadRating:function(C,A){var B=this.ratingUrl+"?media_id="+C+"&element_id="+A;CC.loadContent(A,B)},loadComment:function(C,A){var D=(arguments.length==3)?arguments[2]:Class.empty();var B=this.commentUrl+"?media_id="+C+"&element_id="+A;CC.loadContent(A,B,D)},filterByType:function(E,C,D,A){if(D&&D.length>0){var B=this.mediaListUrls[E-1]+"?college_id="+C+"&filters="+D;CC.loadContent(A,B)}},showFlagForm:function(A){CC.Flag.showFlagForm("CC.Media.flag(this, "+A+")")},flag:function(A,B){new Ajax("/common/ajax/media.php?action=flag&media_id="+B,{method:"post",postBody:A,onComplete:function(){MOOdalBox.close();CC.Media.disableFlagButton("flag_media_"+B)}}).request()},showCommentFlagForm:function(A){CC.Flag.showFlagForm("CC.Media.flagComment(this, "+A+")")},flagComment:function(B,A){new Ajax("/common/ajax/media.php?action=flag_comment&comment_id="+A,{method:"post",postBody:B,onComplete:function(){MOOdalBox.close();CC.Media.disableFlagButton("flag_media_comment_"+A)}}).request()},disableFlagButton:function(A){if($(A)&&$(A+"_disabled")){$(A).setStyle("display","none");$(A+"_disabled").setStyle("display","inline")}}};CC.Media.Video=new CC.MediaList("/media/video_list.inc.php");CC.Media.Photo=new CC.MediaList("/media/photo_list.inc.php");CC.Media.Links=new CC.MediaList("/media/links_list.inc.php");CC.Media.TitleList={url:"/media/title_list.inc.php",limits:{},initialize:function(A,B){this.elementID=A;this.collegeID=B},setLimitByType:function(B,A){this.limits[B]=A},loadByType:function(B){var A=this.url+"?college_id="+this.collegeID+"&media_type="+B+"&limit="+this.limits[B];CC.loadContent(this.elementID,A)}};CC.Media.Editor={initialize:function(){this.urlBox=$("urlBox");this.urlBox.setStyle("visibility","hidden");this.urlCaption=$("urlCaption");this.urlSuffix=$("urlSuffix");this.uploadSlider=new Fx.Slide("uploadBox");this.uploadSlider.hide();$ES(".media_type").each(function(A){if(A.checked){CC.Media.Editor.changeMediaType(A.value)}});CC.attachAutocompleter("college_name","/common/ajax/college.php",{"function":"search_college_name_and_nickname"})},changeMediaType:function(A){this.urlBox.setStyle("visibility","visible");if(A==1){this.urlSuffix.setHTML("or");this.uploadSlider.slideIn()}else{this.urlSuffix.setHTML("");this.uploadSlider.slideOut()}if(A==2){this.urlCaption.setHTML("Embed code")}else{this.urlCaption.setHTML("Url")}}};CC.MediaLink={initialize:function(G,D){var B=$(D.contTogID);var C=new Fx.Slide(D.contID,{onComplete:function(){if(CC.Workspace&&CC.Workspace.College){CC.Workspace.College.refreshAccordion()}}});C.hide();B.addEvent("click",function(){var I=$(D.amountBoxID).innerHTML.toInt();var H=this.fx;if(I>0&&$(D.commentBoxID).innerHTML==""){CC.Media.loadComment(G,D.commentBoxID,function(){C.slideIn()})}else{C.toggle()}});var F=$(D.editorTogID);if(F){var A=new Fx.Slide(D.editorID,{onComplete:function(){this.contFx.show();var H=this.tog;if(this.wrapper.offsetHeight==0){H.removeClass("show");H.addClass("hide")}else{H.removeClass("hide");H.addClass("show")}if(CC.Workspace&&CC.Workspace.College){CC.Workspace.College.refreshAccordion()}}});A.contFx=C;A.hide();A.tog=F;F.addEvent("click",function(){A.toggle()});var E=$E("form",$(D.editorID));E.mediaID=G;E.contID=D.contID;E.contFx=C;E.commentBoxID=D.commentBoxID;E.amountBoxID=D.amountBoxID;E.editorFx=A}},addComment:function(B){var A="/common/ajax/media.php?action=add_comment&id="+B.mediaID;var C=new Ajax(A,{method:"post",data:$(B).toQueryString(),onComplete:function(){if(this.response.text!=""){$(B.amountBoxID).setHTML(this.response.text);CC.Media.loadComment(B.mediaID,B.commentBoxID,function(){B.reset();B.editorFx.slideOut()})}}});C.request()}};CC.Media.Flag={initialize:function(B,A){this.mediaID=B;this.elementID=A}};CC.Media.Rating={add:function(E,C,A){var B="/common/ajax/media.php?action=rate&id="+E+"&rating="+C+"&element_id="+A;var D=new Ajax(B,{method:"get",onComplete:function(){CC.Media.loadRating(E,A)}});D.request()}};CC.Media.Comment={listUrl:"/media/comment_list.inc.php",ratingUrl:"/media/comment_rating.inc.php",initialize:function(D,E,A,B,C){this.mediaID=D;if($(A)){this.editorID=A;this.editorFx=new Fx.Slide(A,{onComplete:function(){var F=$(E);if(this.wrapper.offsetHeight==0){F.removeClass("show");F.addClass("hide")}else{F.removeClass("hide");F.addClass("show")}CC.refreshFlexcroll()}});this.editorFx.hide()}this.nCommentID=B;this.commentBoxID=C},load:function(){CC.Media.loadComment(this.mediaID,this.commentBoxID)},toggleEditor:function(){this.editorFx.toggle()},add:function(B){var A="/common/ajax/media.php?action=add_comment&id="+this.mediaID;var C=new Ajax(A,{method:"post",data:$(B).toQueryString(),onComplete:function(){if(this.response.text!=""){var D=Json.evaluate(this.response.text);if(D.successful){CC.Media.Comment.publishCommentToFacebook(D.feedId,D.type,D.link);$(CC.Media.Comment.nCommentID).setHTML(D.count)}}CC.Media.Comment.load()}});this.editorFx.slideOut();B.reset();C.request()},publishCommentToFacebook:function(A,B,D){if(CC.debug){}else{var C={type:B,link:D};CC.Facebook.showFeedDialog(A,C)}},loadRating:function(C,A){var B=this.ratingUrl+"?comment_id="+C+"&rating_element_id="+A;CC.loadContent(A,B,function(){},false)},rate:function(C,D,A){var B="/common/ajax/media.php?action=rate_comment&comment_id="+C+"&rating="+D;var E=new Ajax(B,{method:"get",onComplete:function(){CC.Media.Comment.loadRating(C,A)}});E.request()}};