function SJWall(){}SJWall.prototype.initInputFields=function(a){var b=this;this.fieldObj=a;if(this.fieldObj.actionContainerClass!=undefined){$("."+this.fieldObj.actionContainerClass).find("a").click(function(){$("."+b.fieldObj.actionContainerClass).find("a").removeClass("active");b.showLoaders();$(this).addClass("active");b.getTabContents(this)})}};SJWall.prototype.initComment=function(){var $this=this;if(this.fieldObj.commentTAId!=undefined){$("#"+this.fieldObj.commentTAId).focus(function(){if(this.value==$this.fieldObj.defaultCommentText){$this.viewContent()}}).blur(function(){if(this.value==""||this.value==$this.fieldObj.defaultCommentText){$this.setToDefault()}})}if(this.fieldObj.formId!=undefined){$("#"+this.fieldObj.formId).submit(function(){var _postData={commentData:$("#"+$this.fieldObj.commentTAId).val()};$.post($this.fieldObj.submitDataLink,_postData,function(resp){try{var _resp=eval("("+resp+")");if(_resp.success){oSpy.PageUpdate();oSpy.stopActivity();oSpy.iPerPage++;$this.setToDefault();setTimeout("1000",function(){oSpy.bUpdateAllowed=true})}}catch(err){alert("this is the error "+err.description)}});return false})}};SJWall.prototype.setToDefault=function(){try{$("#"+this.fieldObj.commentTAId).val(this.fieldObj.defaultCommentText);$("#"+this.fieldObj.commentTAId).animate({height:"20px"});$("."+this.fieldObj.commentTAActionClass).css("display","none")}catch(a){alert("e "+a.description)}};SJWall.prototype.showLoaders=function(){$(".sjloader").show();$(".content_loader").show()};SJWall.prototype.hideLoaders=function(){$(".sjloader").hide();$(".content_loader").hide()};SJWall.prototype.viewContent=function(){$("#"+this.fieldObj.commentTAId).val("");$("#"+this.fieldObj.commentTAId).animate({height:"40px"});$("."+this.fieldObj.commentTAActionClass).css("display","block")};SJWall.prototype.getTabContents=function(a){var b=this;var c=$(a).attr("value");var d={page:c};$.post(b.fieldObj.getPageLink,d,function(a){$("#"+b.fieldObj.formContainer).html(a).find(".upload-loading").remove();b.hideLoaders();if($("#accepted_files_block").length>0)$("#accepted_files_block").css("background","none")})};SJWall.prototype.initPhotoSubTabs=function(a){var b=this;this.photoActions=a;try{if($("#"+this.photoActions.actionsContainer).length>0){$("#"+this.photoActions.actionsContainer).find("a").click(function(){$("#"+b.photoActions.actionsContainer).find("a").removeClass("active");$(this).addClass("active");$(".content_loader").show();var a={page:$(this).attr("value")};$.post(b.photoActions.link,a,function(a){$(".content_loader").hide();$("#"+b.photoActions.container).html(a);if($(".upload-loading").length>0)$(".upload-loading").remove();if($("#accepted_files_block").length>0)$("#accepted_files_block").css("background","none")})})}}catch(c){alert("this is the error "+c.description)}};SJWall.prototype.initVideoSubTabs=function(a){var b=this;this.videoActions=a;try{if($("#"+this.videoActions.actionsContainer).length>0){$("#"+this.videoActions.actionsContainer).find("a").click(function(){$("#"+b.videoActions.actionsContainer).find("a").removeClass("active");$(this).addClass("active");$(".content_loader").show();var a={page:$(this).attr("value")};$.post(b.videoActions.link,a,function(a){$(".content_loader").hide();$("#"+b.videoActions.container).html(a);if($(".upload-loading").length>0)$(".upload-loading").remove();if($("#accepted_files_block").length>0)$("#accepted_files_block").css("background","none")})})}}catch(c){alert("this is the error "+c.description)}};SJWall.prototype.initActivityActions=function(a){var b=this;var c=a;c.commentBoxDispay=false;if($("#"+c.likeButtonId).length>0){$("#"+c.likeButtonId).click(function(){var a=$("#"+c.actionsContainerId).html()!=""?true:false;var d=this;var e={action:"like",hasData:a,activityId:c.activityId,hasLike:c.hasLikes,text:$(this).html()};$.post(c.xtraActUrl,e,function(a){$("#"+c.actionsContainerId).find(".likes").remove();if($("#"+c.actionsContainerId).find(".top").length>0){if($(a).html()!="")$(a).insertAfter($("#"+c.actionsContainerId).find(".top"))}else{var e=document.createElement("ul");e.className="activity_actions";var f=document.createElement("li");f.className="top";e.appendChild(f);$(e).append(a);$("#"+c.actionsContainerId).append(e)}if($(d).html()=="Like")$(d).html("Unlike");else $(d).html("Like");b.refreshDisplayActions(c)})})}if($("#"+c.commentButtonId).length>0){$("#"+c.commentButtonId).click(function(){if(!c.commentBoxDisplay){c.commentBoxDisplay=true;b.showCommentBox(c)}})}c.viewedAll=false;if($("#"+c.viewAllId).find("a").length>0){$("#"+c.viewAllId).find("a").click(function(){if(!c.viewedAll){var a=this;c.viewedAll=true;var b={actId:c.activityId,count:c.displayedComments};$("#"+c.viewAllId).find("span.common_sjloader").css({display:"inline-block"});$.post(c.viewAllUrl,b,function(b){$(b).fadeTo(0,0).insertAfter($(a).parent()).fadeTo("slow",1,function(){$(a).parent().remove()})})}})}$("#"+c.eventContainerId).mouseover(function(){$(this).find(".event_options").show()}).mouseout(function(){$(this).find(".event_options").hide()}).find(".options").click(function(){if($(this).parent().find(".options_values").css("display")=="none")$(this).parent().find(".options_values").fadeIn("fast");else $(this).parent().find(".options_values").fadeOut("fast")});$("#"+c.facebookId).click(function(){try{FB.ui({method:"feed",name:"MarocNetwork Activity",link:"http://marocnetwork.com/",picture:c.feedImage,caption:c.feedTitle,description:c.feedDescription},function(a){if(a&&a.post_id){alert("Post was published.")}else{alert("Post was not published.")}})}catch(a){alert("this is the error "+a.description)}});if($("#"+c.removeId).length>0){$("#"+c.removeId).click(function(){if(!confirm("Area you sure that you want to remove this data?"))return;document.body.style.cursor="wait";$("a").css({cursor:"wait"});$(this).find(".common_sjloader").show();var a={event_id:c.activityId};$.post(c.removeEventLink,a,function(a){$("#"+c.eventContainerId).fadeOut("fast");document.body.style.cursor="default";$("a").css({cursor:"pointer"})})})}};SJWall.prototype.showCommentBox=function(_this){var _hasData=$("#"+_this.actionsContainerId).html().replace(/\s/gi,"")!=""?true:false;var _commentContainer=document.createElement("li");_commentContainer.className="commentContainer";var _commentFormContainer=document.createElement("form");$(_commentFormContainer).submit(function(){var _commentObj=this;var _taValue=$(this).find("textarea").val();if(_taValue.replace(/\s/gi,"")=="")return false;$(_submitLoader).css({display:"inline-block"});var _postDatas={action:"comment",value:_taValue,activityId:_this.activityId};$.post(_this.xtraActUrl,_postDatas,function(resp){try{var _resp=eval("("+resp+")");$("#"+_this.viewAllId).find("span.count").html(_resp.count);$(_resp.content).insertBefore($(_commentObj).parent());$(_commentObj).parent().slideDown("slow",function(){$(this).remove();_this.commentBoxDisplay=false});_this.displayedComments++}catch(err){alert("this is the error "+err.description)}});return false});var _textarea=document.createElement("textarea");var _submit=document.createElement("input");_submit.type="submit";_submit.value="POST";var _submitLoader=document.createElement("span");_submitLoader.className="common_sjloader";$(_submitLoader).css({display:"none"});_commentFormContainer.appendChild(_textarea);_commentFormContainer.appendChild(document.createElement("br"));_commentFormContainer.appendChild(_submit);_commentFormContainer.appendChild(_submitLoader);_commentContainer.appendChild(_commentFormContainer);if(_hasData){$(_commentContainer).fadeTo(0,0);$(_commentContainer).fadeTo("fast",1).appendTo($("#"+_this.actionsContainerId).find("ul"))}else{var _ul=document.createElement("ul");_ul.className="activity_actions";var _top=document.createElement("li");_top.className="top";_ul.appendChild(_top);_ul.appendChild(_commentContainer);$(_ul).fadeTo(0,0);$(_ul).fadeTo("slow",1).appendTo($("#"+_this.actionsContainerId))}};SJWall.prototype.initCommentBox=function(a){var b=a;if($("#"+b.removeCommentId).length>0){$("#"+b.removeCommentId).click(function(){if(!confirm("Are you sure that you want to remove this comment"))return false;document.body.style.cursor="wait";$("a").css("cursor","wait");var a=this;var c=$(this).attr("value");var d={commentId:c,actId:b.actId};$.post(b.removeCommentUrl,d,function(b){var c=$(a).parent().parent().parent();if(c.find("li.view_all").length>0){c.find("li.view_all").remove();c.find("li.comment_data").fadeOut("slow",function(){$(this).remove()});if(c.find("li.commentContainer").length>0){$(b).fadeTo(0,0).insertBefore(c.find("li.commentContainer")).fadeTo("slow",1)}else{$(b).fadeTo(0,0).appendTo(c).fadeTo("slow",1)}}else{$(a).parent().parent().fadeOut("slow",function(){$(this).remove()})}document.body.style.cursor="default";$("a").css("cursor","pointer")})})}};SJWall.prototype.refreshDisplayActions=function(a){var b=false;if($("#"+a.actionsContainerId).find(".likes").html()!="")b=true;if($("#"+a.actionsContainerId).find(".commentContainer").length>0)b=true;if(!b){$("#"+a.actionsContainerId).html("")}};SJWall.prototype.initPagination=function(a){var b=this;this.paginObj=a;if($("#"+a.paginContainerId).find("a").length>0){$("#"+a.paginContainerId).find("a").click(function(){var a=this;$(this).find("span").show();var c={offset:oSpy.iPerPage,page:b.page};$.post(b.paginObj.paginLink+"?page="+b.page,c,function(c){$(a).find("span").hide();if(c==""){$(a).parent().remove();return}oSpy.iPerPage+=parseInt(b.paginObj.showMore);$("#spy_events").append(c);b.page++})})}}
