var boardStatusTimerSuccess=null;var boardStatusTimerError=null;function formatItem(post){res="";editMode=post.edit_mode;msgId=post.idsonico_user_board;msgFriendId=post.board_id_user;msgFriendCompleteName=post.board_first_name+" "+post.board_last_name;msgFriendLink='<a href="/profile.php?u='+msgFriendId+'">'+msgFriendCompleteName+"</a>";msgTimestamp=post.board_date;msgVideoSiteId=post.video_site_id;msgOwnPost=(msgFriendId==userId);isVideo=post.isVideo;if(post.board_message){msgText=post.board_message;msgTextShort=(msgText.length>boardBoardMaxFieldLength)?msgText.substring(0,boardBoardMaxFieldLength)+"... ":msgText;msgTextCanCollapse=(msgText.length>boardBoardMaxFieldLength)}if(post.is_newsfeed_elmt||post.is_activity_event){return post.msg}if(isVideo){msgVideoSonicoId=post.sonico_video_id;msgVideoUrl=(msgVideoSonicoId?'<a href="/videos_detail.php?u='+msgFriendId+"&v="+msgVideoSonicoId+'">'+msg_video_video+"</a>":msg_video_video);msgPhraseFriendWrote='<strong><span class="icon i-video"></span> '+(editMode?msgFriendCompleteName:msgFriendLink)+" "+msg_video_published+" "+msgVideoUrl+'</strong><span class="datetime">- '+msgTimestamp+"</span>";msgVideoId=post.video_id;msgVideoTitle=post.video_title;msgVideoTitleShort=(msgVideoTitle.length>boardVideoMaxTitleLength?msgVideoTitle.substring(0,boardVideoMaxTitleLength)+"...":msgVideoTitle);msgVideoDesc=post.video_description?post.video_description:msg_withoutDescription;msgVideoDescShort=(msgVideoDesc.length>boardVideoMaxDescriptionLength?msgVideoDesc.substring(0,boardVideoMaxDescriptionLength)+"...":msgVideoDesc);msgVideoDuration=videoDuration(post.video_duration);msgVideoSrc=(post.video_thumbnail?post.video_thumbnail:"http://img.youtube.com/vi/"+msgVideoId+"/2.jpg");msgVideoMenuMinimized=array_clean({0:(msgVideoSonicoId?'<a href="/videos_detail.php?u='+msgFriendId+"&v="+msgVideoSonicoId+'">'+msg_comment+"</a>":""),1:'<a href="javascript:void(0);" class="openwin" src="layers/popup_videos_share.php?sv='+getVideoURL(msgVideoSiteId,msgVideoId)+'">'+msg_share+"</a>"}).join(" - ");msgVideoMenuMaximized=array_clean({0:(msgVideoSonicoId?'<a href="/videos_detail.php?u='+msgFriendId+"&v="+msgVideoSonicoId+'">'+msg_comment+"</a>":""),1:'<a href="javascript:void(0);" class="openwin" src="layers/popup_videos_share.php?sv='+getVideoURL(msgVideoSiteId,msgVideoId)+'">'+msg_share+"</a>",2:'<a href="#" onClick="return toggleVideo('+msgId+');">'+msg_minimize+"</a>"}).join(" - ");res+='<li id="boardVideoPostsMinimized'+msgId+'" class="new-video boardVisible">    <dl>        <dt>'+msgPhraseFriendWrote+'</dt>        <dd><ul class="list-videos-full"><li>            <dl class="f-wrap">                <dt>                    <a class="thumb video-thumb" href="#" onClick="return toggleVideo('+msgId+');" '+(msgVideoSiteId==2?"onMouseover=\"videoRollS('VBT"+msgId+'\');" onMouseout="videoRollS(false);"':"")+'>                        <img src="'+msgVideoSrc+'" id="VBT'+msgId+'" />                        <img class="overlay" src="'+static_host+'img/play.gif" />                    </a>                </dt>                <dd>                    '+(editMode?'<a href="#" class="link-close" onClick="return deletePost(POST_TYPE_VIDEO, '+msgId+", "+userId+", "+userDb+", "+msgFriendId+', msg_delete_sure, boardPostDeletionEffect);"><span class="icon i-close">X</span></a>':"")+'                    <a href="#" class="bold larger" title="'+msgVideoTitle+'" onClick="return toggleVideo('+msgId+');">'+msgVideoTitleShort+'</a> <span class="datetime">- '+msgVideoDuration+'</span>                    <p class="spacet">'+msgVideoDescShort+'</p>                    <div class="edit-tools spacet">'+msgVideoMenuMinimized+"</div>                </dd>            </dl>        </li></ul></dd>    </dl></li>";res+='<li id="boardVideoPostsMaximized'+msgId+'" class="new-video" style="display: none">    <dl>        <dt>'+msgPhraseFriendWrote+'</dt>        <dd class="video-full-view">            '+(editMode?'<a href="#" class="link-close" onClick="return deletePost(POST_TYPE_VIDEO, '+msgId+", "+userId+", "+userDb+", "+msgFriendId+', msg_delete_sure, boardPostDeletionEffect);"><span class="icon i-close">X</span></a>':"")+'            <a href="#" class="bold larger" title="'+msgVideoTitle+'" onClick="return toggleVideo('+msgId+');">'+msgVideoTitleShort+'</a> <span class="datetime">- '+msgVideoDuration+'</span>            <p class="spacet">'+msgVideoDescShort+"</p>            "+swf_embed(getVideoEmbed(msgVideoSiteId,msgVideoId),478,392,"")+'            <div class="edit-tools spacet space1b">'+msgVideoMenuMaximized+"</div>        </dd>    </dl></li>"}else{msgBoardImg=post.imgSrc;msgPhraseFriendWrote='<strong><span class="icon i-comment"></span>'+(editMode?msgFriendCompleteName:msgFriendLink)+" "+msg_wrote+'</strong> <span class="datetime">- '+msgTimestamp+"</span>";msgBoardMenu=array_clean({0:((editMode&&!msgOwnPost)?'<a href="/profile.php?u='+msgFriendId+'">'+msg_boardResponse+"</a>":""),1:("")}).join(" - ");res+='<li class="new-user-msg boardVisible" id="boardMessagesPost'+msgId+'">    <dl class="f-wrap">        <dt class="f-wrap">'+msgPhraseFriendWrote+'</dt>        <dd class="user-pic">            <a href="/profile.php?u='+msgFriendId+'" class="thumb">'+msgBoardImg+'</a>        </dd>        <dd class="user-msg">            '+(editMode?'<a href="#" class="link-close" onClick="return deletePost(POST_TYPE_MESSAGE, '+msgId+", "+userId+", "+userDb+", "+msgFriendId+', msg_delete_sure, boardPostDeletionEffect);"><span class="icon i-close">X</span></a>':"")+"            "+(msgTextCanCollapse?'<p id="boardMessageShortText'+msgId+'">'+msgTextShort+' <a href="#" id="boardMessageMoreTitle'+msgId+'" class="smaller" onClick="return collapseText(\'boardMessageShortText'+msgId+"', 'boardMessageFullText"+msgId+"', boardMessageFieldCollapseEffect);\"><strong>"+msg_seeMore+'</strong></a></p><p id="boardMessageFullText'+msgId+'" class="collapse">'+msgText+' <a href="#" id="boardMessageMoreTitle'+msgId+'" class="smaller" onClick="return collapseText(\'boardMessageFullText'+msgId+"', 'boardMessageShortText"+msgId+"', boardMessageFieldCollapseEffect);\"><strong>"+msg_seeLess+"</strong></a></p>":"<p>"+msgText+"</p>")+'            <span class="edit-tools">'+msgBoardMenu+"</span>        </dd>    </dl></li>"}return res}function formatPager(userId,userDb,pager){var res="";if(pager.previous_page<pager.page){res+='<a href="#"onClick="return loadPosts('+userId+", "+userDb+", "+pager.previous_page+');">&laquo; </a>'}$.each(pager.previous,function(key,page){res+='<a href="#"onClick="return loadPosts('+userId+", "+userDb+", "+page+');">'+page+"</a>"});res+='<em class="current">'+pager.page+"</em>";$.each(pager.next,function(key,page){res+='<a href="#"onClick="return loadPosts('+userId+", "+userDb+", "+page+');">'+page+"</a>"});if(pager.next_page>pager.page){res+='<a href="#"onClick="return loadPosts('+userId+", "+userDb+", "+pager.next_page+');"> &raquo;</a>'}return res}function post(){var boardMessage=$.trim($("#boardMessagesText").val());var boardVideo=$.trim($("#boardVideoOwnVideoUrl").val());var boardVideoMessage=$.trim($("#boardVideoOwnMessage").val());var isEmptyMessage=(boardMessage==""||boardMessage==msg_writeSomething);var isEmptyVideo=(boardVideo=="");var isEmptyVideoMessage=(boardVideoMessage==""||boardVideoMessage==msg_writeSomething);var isLargerMessage=(boardMessage.length>5000);if(isEmptyMessage&&isEmptyVideo){return false}if(isEmptyMessage&&!isEmptyVideo){if(!isEmptyVideoMessage){$("#boardMessagesText").val($("#boardVideoOwnMessage").val())}else{$("#boardMessagesText").val("")}}if(isLargerMessage){setStatus(STATUS_ERROR,msg_lengthMessage);return false}securityControlsLock(BOARD_TAB_ALL,true);$("#boardForm").ajaxSubmit({url:"/add_board_msg.php",type:"POST",dataType:"json",error:function(){setStatus(STATUS_ERROR,msg_errorGral);securityControlsLock(BOARD_TAB_ALL,true)},success:function(post){if(post){if(post.videorepeat){setStatus(STATUS_ERROR,msg_duplicatedVideo)}else{addPost(post);adjustRightColSize()}resetControls(BOARD_TAB_ALL)}else{setStatus(STATUS_ERROR,msg_errorGral)}securityControlsLock(BOARD_TAB_ALL,false)}});return false}function loadPosts(userId,userDb,page){$.ajax({url:"/get_board_msg.php",type:"POST",data:{u:userId,db:userDb,p:page},dataType:"json",error:function(){setStatus(STATUS_ERROR,msg_errorGral)},success:function(post){$("#boardMessages").empty();$.each(post[0],function(){addPost(this)});$("#boardPager").empty();addPager(userId,userDb,post[1]);adjustRightColSize()}});return false}function addPost(post){if(post.error||(!post.sonico_users_idsonico_users&&!post.is_newsfeed_elmt&&!post.is_activity_event)){setStatus(STATUS_ERROR,msg_errorGral);return false}var newPost=formatItem(post);$("#boardMessages").prepend(newPost);$("#ex2").jqmAddTrigger("a.openwin")}function addPager(userId,userDb,pager){$("#boardPager").html(formatPager(userId,userDb,pager));return false}function deletePost(postType,postId,ownerUserId,ownerUserDb,friendUserId,confirmMessage,effect){var callback="";if(!confirm(confirmMessage)){return false}$.ajax({url:"/del_board_msg.php",type:"POST",data:{m:postId,u:ownerUserId,uf:friendUserId},dataType:"json",error:function(){setStatus(STATUS_ERROR,msg_errorGral)},success:function(res){if(res){if($("#boardMessages").children(".boardVisible").length<=1){callback="loadPosts("+ownerUserId+", "+ownerUserDb+", 1);"}callback+="setStatus(STATUS_SUCCESS, msg_delete_successful);";deletePostFromBoard(postType,postId,effect,callback)}else{setStatus(STATUS_ERROR,msg_errorGral)}}});return false}function deletePostFromBoard(postType,postId,effect,callback){if(typeof(effect)=="undefined"||!effect){effect="none"}if(typeof(callback)=="undefined"||!callback){callback=null}switch(effect){case"none":default:switch(postType){case 0:default:$("#boardMessagesPost"+postId).remove();break;case 1:$("#boardVideoPostsMinimized"+postId).remove();break}if(callback){eval(callback)}break;case"fade":switch(postType){case 0:default:$("#boardMessagesPost"+postId).fadeOut("slow",function(){$(this).remove();if(callback){eval(callback)}});break;case 1:$("#boardVideoPostsMinimized"+postId).fadeOut("slow",function(){$(this).remove();$("#boardVideoPostsMaximized"+postId).remove();if(callback){eval(callback)}});break}break;case"slide":switch(postType){case 0:default:$("#boardMessagesPost"+postId).slideUp("slow",function(){$(this).remove();if(callback){eval(callback)}});break;case 1:$("#boardVideoPostsMinimized"+postId).slideUp("slow",function(){$(this).remove();$("#boardVideoPostsMaximized"+postId).remove();if(callback){eval(callback)}});break}break}return false}function setStatus(statusType,message){switch(statusType){case STATUS_ERROR:default:$("#boardError").html('<p class="larger col-last">'+message+"</p>").fadeIn("slow");break;case STATUS_SUCCESS:$("#boardSuccess").html('<p class="larger col-last">'+message+"</p>").fadeIn("slow");break}clearTimeout(boardStatusTimerSuccess);clearTimeout(boardStatusTimerError);boardStatusTimerSuccess=setTimeout("$('#boardSuccess').fadeOut('slow', function() { $('#boardSuccess').html(''); });",5000);boardStatusTimerError=setTimeout("$('#boardError').fadeOut('slow', function() { $('#boardError').html(''); });",5000);return false}function resetControls(which){var isTabAll=(which==BOARD_TAB_ALL);var isTabMessages=(which==BOARD_TAB_MESSAGES);var isTabVideos=(which==BOARD_TAB_VIDEOS);if(isTabAll){changeTab("boardTabs","boardContent","boardTabMessages","boardContentMessages","none","current-tab first","current-tab","changeTabBoardHelper(BOARD_TAB_MESSAGES)")}if(isTabMessages||isTabAll){magicTxtHelp(EVENT_ONBLUR,"boardMessagesText",msg_writeSomething,"quiet",true)}if(isTabVideos||isTabAll){magicTxtHelp(EVENT_ONBLUR,"boardVideoOwnMessage",msg_writeSomething,"quiet",true);magicTxtHelp(EVENT_ONBLUR,"boardVideoUrl",msg_addVideo,"quiet",true);$("#boardVideoOwnTitle").html("");$("#boardVideoOwnDescription").html("");$("#boardVideoOwnUrlStatic").html("");$("#boardVideoOwnVideoDuration").val("");$("#boardVideoOwnVideoId").val("");$("#boardVideoOwnVideoSite").val("");$("#boardVideoOwnVideoThumbnail").val("");$("#boardVideoOwnVideoSiteId").val("");$("#boardVideoOwnVideoUrl").val("");$("#boardVideoOwnTitleEditInput").val("");$("#boardVideoOwnDescriptionEditInput").val("");$("#boardVideoOwnVideoIdx").val("")}return false}function loadVideo(url){if(typeof(url)=="undefined"||!url){url=$("#boardVideoUrl").val()}if(url==msg_addVideo){return false}securityControlsLock(BOARD_TAB_VIDEOS_SHARE_YT,true);$.ajax({url:"/ajax_responser.php",type:"POST",data:{action:"getVideoData",v:url},dataType:"json",error:function(){setStatus(STATUS_ERROR,msg_errorGral);securityControlsLock(BOARD_TAB_VIDEOS_SHARE_YT,false)},success:function(res){if(res.error){setStatus(STATUS_ERROR,res.error)}else{if(res){changeTabBoardVideos(BOARD_TAB_VIDEOS_SHARE_YT2);res.url=url;boardVideoYT=res;loadBoardVideo(null,res)}else{setStatus(STATUS_ERROR,msg_errorGral)}}securityControlsLock(BOARD_TAB_VIDEOS_SHARE_YT,false)}});return false};