var gNewCommentId;function findPosX(a){var b=0;if(a.offsetParent){while(1){b+=a.offsetLeft;if(!a.offsetParent){break}a=a.offsetParent}}else{if(a.x){b+=a.x}}return b}function findPosY(b){var a=0;if(b.offsetParent){while(1){a+=b.offsetTop;if(!b.offsetParent){break}b=b.offsetParent}}else{if(b.y){a+=b.y}}return a}function mouseX(a){var b=0;if(a.pageX){b=a.pageX}else{if(a.clientX){b=a.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);b=b-(findPosX(document.getElementById("Comments_Container1"))/2)}}return b}function mouseY(a){var b=0;if(a.pageY){b=a.pageY}else{if(a.clientY){b=a.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);b=b-(findPosY(document.getElementById("Comments_Container1"))/2)}}return b}function ReportAbuseViaDaapi(){HideDiv("ReportAbuse_Menu");var b=document.getElementById("ReportAbuse_Url").value;var f=document.getElementById("ReportAbuse_CommentText").value;var e=document.getElementById("ReportAbuse_Reason").value;var c=getCommandParam("ReportAbuse_Command","plckTargetKey");var d=getCommandParam("ReportAbuse_Command","plckTargetKeyType");if(c!=""&&d!=""){var a=false;switch(d){case"Comment":a=new CommentKey(c);break}if(a){var g=new RequestBatch();g.AddToRequest(new ReportAbuseAction(a,e,f));g.BeginRequest(serverUrl,ReportAbuseViaDaapi_callback)}}}function getCommandParam(a,g){var h=document.getElementById(a).value;var f=h.split("&");var d="";var e="";for(var c=0;c<f.length;c++){var b=f[c].split("=");if(b[0]==g){return(b[1])}}return""}function ReportAbuseViaDaapi_callback(c){invalidateCache();var b={};b.ugcSiteID=publicusPath;b.ugcType="abuse";b.ugcData=jQuery.trim($("#ReportAbuse_Reason").val())+" ["+jQuery.trim($("#ReportAbuse_CommentText").val())+"]";b.articleKey=plckArticleKey;b.articleUrl=plckArticleUrl;b.articleTitle=plckArticleTitle;b.articleDescription=getNonHtmlText(500,plckArticleDescription);b.articleDate=plckArticleDate;b.authorPluckUserKey=CurrentUser;b.authorSSOKey=retrieveSSOCookieUserId();b.authorDisplayName=RetrieveSSOCookieDisplayName();b.authorAvatarPhotoUrl=RetrieveUserAvatarCookie();b.itemType=getCommandParam("ReportAbuse_Command","plckTargetKeyType").toLowerCase();b.itemUgcKey=getCommandParam("ReportAbuse_Command","plckTargetKey");b=escape(JSON.stringify(b));var a=PluckUIPath+"/utils/utils/pluckUtils/store.php?jsoncallback=?&action=abuseReport&data="+b;$.getJSON(a,function(d){})}function reorderComments(a){if(a&&a!=""){oldurl=document.URL;newUrl=oldurl.replace(/&?sort=(timestampascending|timestampdescending|recommendationsdescending|recommendationsascending)/gi,"");newUrl+="&sort="+a;window.location=newUrl}return false}gSiteLife.CommentsOutputWithURLFix=function(d,c,f,a,e){e=e||"TimeStampDescending";var b=document.URL;if(!b.match("plckCurrentPage")){b=b+"&"}return this.CommentsInternal(d,c,a,e,null,null,b,null,false,true,null,f)};function formSubmit(b){if(b.elements.namedItem("comment.Body").value.trim()==""){document.getElementById("CommentError").innerHTML="* Please provide a comment.";return false}fbConnect=document.getElementById("fbConnect");if(fbConnect&&fbConnect.checked){var a=[];try{pluckArticleDescription=unescape("<pbs:macro name=ArticleDescriptionPluck>");slFB.submitArticleComment(PlickArticleTitle,document.location.href,pluckArticleDescription,b.elements.namedItem("comment.Body").value.trim(),a,fbCommentSubmitCallback);return false}catch(c){return true}}else{return true}}function LimitLength(b,a){var c=b.value;if(!c||c.length==0){return false}if(c.length>a){b.value=c.substring(0,a)}document.getElementById("CommentCharacterCount").innerHTML=c.length;return false}function fbCommentSubmitCallback(){document.forms.commentSubmitForm.submit()}function submitCommentViaDaapi(){var e="a,b,blockquote,br,cite,del,em,i,ins,li,ol,p,q,s,strike,strong,sub,sup,u,ul";var c=jQuery.trim($("#commentBody").val());c=c.substr(0,950);c=c.replace(/\n/gi,"<br/>");c=stripTags(c,e);c=stripCommentSGML(c);c=tagURLs(c);$("#commentBody").val(c);if(c==""){$("#CommentError").html("* Please provide a comment.");return false}$("#commentListing").html("<img src='"+publicusPath+"/Global/images/wheelOfJoy.gif' alt='downloading content'>"+$("#commentListing").html());if($("#daapiSubmit").length>0){$("#daapiSubmit")[0].disabled=true}var d=new RequestBatch();var a=new ArticleKey(plckArticleKey);var b=new CommentAction(a,plckArticleUrl,plckArticleTitle,c);d.AddToRequest(b);d.BeginRequest(serverUrl,afterDaapiCommentSubmission)}function afterDaapiCommentSubmission(e){invalidateCache();if(e.Messages.length>0&&e.Messages[0].Message=="ok"){var d={};d.ugcSiteID=publicusPath;d.ugcType="comment";d.ugcData=escape(jQuery.trim($("#commentBody").val()));d.articleKey=plckArticleKey;d.articleUrl=plckArticleUrl;d.articleTitle=plckArticleTitle;d.articleDescription=getNonHtmlText(500,plckArticleDescription);d.articleDate=plckArticleDate;d.authorPluckUserKey=CurrentUser;d.authorSSOKey=retrieveSSOCookieUserId();d.authorDisplayName=RetrieveSSOCookieDisplayName();d.authorAvatarPhotoUrl=RetrieveUserAvatarCookie();d.itemType="story";d.itemVendorID=plckArticleKey;d=encodeURIComponent(JSON.stringify(d));var c=PluckUIPath+"/utils/utils/pluckUtils/store.php?jsoncallback=?&action=commentAction&data="+d;var b={};b.dataType="json";b.error=function(i,j,h){alert("Your comment could not be added to the Community Hub.  It will still appear in the article's comments section, but will not appear within the Hub itself.  We are sorry for the inconvenience, and are working to correct this problem.")};b.success=function(h){fixupCommentDbKey(h.newId)};b.timeout=5000;b.type="GET";b.url=c;$.ajax(b);fbConnect=document.getElementById("fbConnect");if(fbConnect&&fbConnect.checked){var a=[];try{slFB.submitArticleComment(plckArticleTitle,document.location.href,plckArticleDescription,jQuery.trim($("#commentBody").val()),a,fbDaapiCommentSubmitCallback)}catch(g){}}}else{if(e.Messages.length>0){var f="<div class='error'>Comment submission failed:  "+e.Messages[0].Message+"</div>";$("#CommentError").html(f)}}if($("#daapiSubmit").length>0){$("#daapiSubmit")[0].disabled=false}$("#commentBody").val("");$("#CommentCharacterCount").html("<strong>0</strong>")}function fbDaapiCommentSubmitCallback(){}function getNonHtmlText(a,b){b.replace(/(<br ?\/?>)/ig,"\n");b.replace(/(<([^>]+)>)/ig,"");if(a>0){b=b.substr(0,a)}return b}function addRecommendToDb(c,a){var b={};b.ugcSiteID=publicusPath;b.ugcType="recommend";b.ugcData="";b.authorPluckUserKey=CurrentUser;b.authorSSOKey=retrieveSSOCookieUserId();b.authorDisplayName=RetrieveSSOCookieDisplayName();b.authorAvatarPhotoUrl=RetrieveUserAvatarCookie();switch(c){case"ExternalResource":b.articleKey=plckArticleKey;b.articleUrl=plckArticleUrl;b.articleTitle=plckArticleTitle;b.articleDescription=getNonHtmlText(500,plckArticleDescription.replace(/'/g,"&#39;"));b.articleDate=plckArticleDate;b.itemType="story";b.itemVendorID=a;b=escape(JSON.stringify(b));addToDb_Go("recommendAction",b);break;case"Comment":b.articleKey=plckArticleKey;b.articleUrl=plckArticleUrl;b.articleTitle=plckArticleTitle;b.articleDescription=getNonHtmlText(500,plckArticleDescription.replace(/'/g,"&#39;"));b.articleDate=plckArticleDate;b.itemType="comment";b.itemUgcKey=a;b=escape(JSON.stringify(b));addToDb_Go("recommendAction",b);break;case"Post":var d=new RequestBatch();d.AddToRequest(new BlogPostKey(a));d.BeginRequest(serverUrl,function(g){if(g.Responses.length>0){var e=g.Responses[0];if(e.BlogPost!=null){var h=e.BlogPost;dataQuery={};dataQuery.type="post";dataQuery.itemUgcKey=h.BlogKey;dataQuery=escape(JSON.stringify(dataQuery));var f=PluckUIPath+"/utils/utils/pluckUtils/store.php?jsoncallback=?&action=query&data="+dataQuery;$.getJSON(f,function(k){var j=k.dataOut;if(j.error==""&&j.queryResults.length==0){var i=h.SiteOfOrigin.toLowerCase();i=i.replace(/sitelife/g,"");if(i[0]=="."){i="www"+i}i="http://"+i;dataPost={};dataPost.ugcSiteID=i;dataPost.ugcType="post";dataPost.ugcData=h.PostBody.replace(/'/g,"&#39;");dataPost.ugcDate=h.PostDate;dataPost.authorPluckUserKey=h.PostAuthor.UserKey.Key;dataPost.authorSSOKey=h.PostAuthor.Email;dataPost.authorDisplayName=h.PostAuthor.DisplayName;dataPost.authorAvatarPhotoUrl=h.PostAuthor.AvatarPhotoUrl;dataPost.articleKey=h.BlogPostKey.Key;dataPost.articleUrl=h.Url;dataPost.articleTitle=h.PostTitle;dataPost.articleDescription=getNonHtmlText(500,h.PostBody.replace(/'/g,"&#39;"));dataPost.articleDate=h.PostDate;dataPost.itemType="post";dataPost.itemUgcKey=h.BlogPostKey.Key;dataPost=escape(JSON.stringify(dataPost));addToDb_Go("postAction",dataPost)}});b.articleKey=h.BlogPostKey;b.articleUrl=h.Url;b.articleTitle=h.PostTitle;b.articleDescription=getNonHtmlText(500,h.PostBody.replace(/'/g,"&#39;"));b.articleDate=h.PostDate;b.itemType="post";b.itemUgcKey=h.BlogPostKey.Key;b=escape(JSON.stringify(b));addToDb_Go("recommendAction",b)}}});break;case"Photo":var d=new RequestBatch();d.AddToRequest(new PhotoKey(a));d.BeginRequest(serverUrl,function(h){if(h.Responses.length>0){var e=h.Responses[0];if(e.Photo!=null){var g=e.Photo;dataQuery={};dataQuery.type="photo";dataQuery.itemUgcKey=g.PhotoKey.Key;dataQuery=escape(JSON.stringify(dataQuery));var f=PluckUIPath+"/utils/utils/pluckUtils/store.php?jsoncallback=?&action=query&data="+dataQuery;$.getJSON(f,function(k){var j=k.dataOut;if(j.error==""&&j.queryResults.length==0){var i=g.SiteOfOrigin.toLowerCase();i=i.replace(/sitelife/g,"");if(i[0]=="."){i="www"+i}i="http://"+i;dataPost={};dataPost.ugcSiteID=i;dataPost.ugcType="photo";ugcData={};ugcData.PhotoKey=g.PhotoKey;ugcData.GalleryKey=g.GalleryKey;ugcData.Image=g.Image;ugcData.Title=g.Title;ugcData.Description=g.Description;dataPost.ugcData=ugcData;dataPost.ugcDate=g.CreatedOn;dataPost.authorPluckUserKey=g.Author.UserKey.Key;dataPost.authorSSOKey=g.Author.Email;dataPost.authorDisplayName=g.Author.DisplayName;dataPost.authorAvatarPhotoUrl=g.Author.AvatarPhotoUrl;dataPost.articleKey=g.PhotoKey.Key;dataPost.articleUrl=PluckUIPath+"/utils/photogalleries/ui/publicgallery.php?plckPhotoID="+g.PhotoKey.Key+"&plckGalleryID="+g.GalleryKey.Key;dataPost.articleTitle=g.Title;dataPost.articleDescription=getNonHtmlText(500,g.Description.replace(/'/g,"&#39;"));dataPost.articleDate=g.CreatedOn;dataPost.itemType="photo";dataPost.itemUgcKey=g.PhotoKey.Key;dataPost=escape(JSON.stringify(dataPost));addToDb_Go("photoAction",dataPost)}});b.articleKey=g.PhotoKey.Key;b.articleUrl=PluckUIPath+"/utils/photogalleries/ui/publicgallery.php?plckPhotoID="+g.PhotoKey.Key+"&plckGalleryID="+g.GalleryKey.Key;b.articleTitle=g.Title;b.articleDescription=getNonHtmlText(500,g.Description.replace(/'/g,"&#39;"));b.articleDate=g.CreatedOn;b.itemType="photo";b.itemUgcKey=g.PhotoKey.Key;b=escape(JSON.stringify(b));addToDb_Go("recommendAction",b)}}});break;case"Video":var d=new RequestBatch();d.AddToRequest(new VideoKey(a));d.BeginRequest(serverUrl,function(g){if(g.Responses.length>0){var e=g.Responses[0];if(e.Video!=null){var h=e.Video;dataQuery={};dataQuery.type="video";dataQuery.itemUgcKey=h.VideoKey.Key;dataQuery=escape(JSON.stringify(dataQuery));var f=PluckUIPath+"/utils/utils/pluckUtils/store.php?jsoncallback=?&action=query&data="+dataQuery;$.getJSON(f,function(k){var j=k.dataOut;if(j.error==""&&j.queryResults.length==0){var i=h.SiteOfOrigin.toLowerCase();i=i.replace(/sitelife/g,"");if(i[0]=="."){i="www"+i}i="http://"+i;dataPost={};dataPost.ugcSiteID=i;dataPost.ugcType="video";ugcData={};ugcData.VideoKey=h.VideoKey;ugcData.GalleryKey=h.GalleryKey;ugcData.VideoUrl=h.VideoUrl;ugcData.VideoThumbnail=h.VideoThumbnail;ugcData.Title=h.Title;ugcData.Description=h.Description;dataPost.ugcData=ugcData;dataPost.ugcDate=h.CreatedOn;dataPost.authorPluckUserKey=h.Author.UserKey.Key;dataPost.authorSSOKey=h.Author.Email;dataPost.authorDisplayName=h.Author.DisplayName;dataPost.authorAvatarVideoUrl=h.Author.AvatarVideoUrl;dataPost.articleKey=h.VideoKey.Key;dataPost.articleUrl=PluckUIPath+"/utils/uservideo/PlayMovie.php?PluckGalleryId="+h.GalleryKey.Key+"&PluckVideoId="+h.VideoKey.Key+"&PluckGalleryDesc=video gallery&PlcukGalleryTitle=video gallery";dataPost.articleTitle=h.Title;dataPost.articleDescription=getNonHtmlText(500,h.Description.replace(/'/g,"&#39;"));dataPost.articleDate=h.CreatedOn;dataPost.itemType="video";dataPost.itemUgcKey=h.VideoKey.Key;dataPost=escape(JSON.stringify(dataPost));addToDb_Go("videoAction",dataPost)}});b.articleKey=h.VideoKey.Key;b.articleUrl=PluckUIPath+"/utils/uservideo/PlayMovie.php?PluckGalleryId="+h.GalleryKey.Key+"&PluckVideoId="+h.VideoKey.Key+"&PluckGalleryDesc=video gallery&PlcukGalleryTitle=video gallery";b.articleTitle=h.Title;b.articleDescription=getNonHtmlText(500,h.Description.replace(/'/g,"&#39;"));b.articleDate=h.CreatedOn;b.itemType="video";b.itemUgcKey=h.VideoKey.Key;b=escape(JSON.stringify(b));addToDb_Go("recommendAction",b)}}});break;case"UserProfileKey":var d=new RequestBatch();d.AddToRequest(new UserKey(a));d.BeginRequest(serverUrl,function(h){if(h.Responses.length>0){var f=h.Responses[0];if(f.User!=null){var e=f.User;dataQuery={};dataQuery.type="user";dataQuery.itemUgcKey=e.UserKey.Key;dataQuery=escape(JSON.stringify(dataQuery));var g=PluckUIPath+"/utils/utils/pluckUtils/store.php?jsoncallback=?&action=query&data="+dataQuery;$.getJSON(g,function(j){var i=j.dataOut;if(i.error==""&&i.queryResults.length==0){dataPost={};dataPost.ugcSiteID="";dataPost.ugcType="user";dataPost.ugcData=e.DisplayName;dataPost.ugcDate=e.CreatedOn;dataPost.authorPluckUserKey=e.UserKey.Key;dataPost.authorSSOKey=e.Email;dataPost.authorDisplayName=e.DisplayName;dataPost.authorAvatarPhotoUrl=e.AvatarPhotoUrl;dataPost.articleKey=e.UserKey.Key;dataPost.articleUrl=appsPath+"/utils/usergalleries/ui/publicgallery.php?plckuserID="+e.UserKey.Key+"&plckGalleryID="+e.UserKey.Key;dataPost.articleTitle=e.Title;dataPost.articleDescription=getNonHtmlText(500,e.AboutMe.replace(/'/g,"&#39;"));dataPost.articleDate=e.CreatedOn;dataPost.itemType="user";dataPost.itemUgcKey=e.UserKey.Key;dataPost=escape(JSON.stringify(dataPost));addToDb_Go("userAction",dataPost)}});b.articleKey=e.UserKey.Key;b.articleUrl=appsPath+"/utils/usergalleries/ui/publicgallery.php?plckuserID="+e.UserKey.Key+"&plckGalleryID="+e.UserKey.Key;b.articleTitle=e.DisplayName;b.articleDescription=getNonHtmlText(500,e.AboutMe.replace(/'/g,"&#39;"));b.articleDate=e.CreatedOn;b.itemType="user";b.itemUgcKey=e.UserKey.Key;b=escape(JSON.stringify(b));addToDb_Go("recommendAction",b)}}});break;default:break}}function addToDb_Go(c,b){var a=PluckUIPath+"/utils/utils/pluckUtils/store.php?jsoncallback=?&action="+c+"&data="+b;$.getJSON(a,function(d){})}function fixupCommentDbKey(a){gNewCommentId=a;var b=new RequestBatch();b.AddToRequest(getCommentPageRequest(plckArticleKey,10,1,"TimeStampDescending"));b.BeginRequest(serverUrl,fixupCommentDbKey_callback)}function fixupCommentDbKey_callback(e){for(var f=0;f<e.Responses.length;f++){var a=e.Responses[f];if(a.CommentPage&&a.CommentPage.Comments.length>0){for(var j=0;j<a.CommentPage.Comments.length;j++){var g=RetrieveSSOCookieDisplayName();var h=a.CommentPage.Comments[j];if(h.Author.DisplayName==g){var d={};d.commentKey=h.CommentKey.Key;d.commentId=gNewCommentId;d=escape(JSON.stringify(d));var b=PluckUIPath+"/utils/utils/pluckUtils/store.php?jsoncallback=?&action=fixupCommentKey&data="+d;$.getJSON(b,function(c){});break}}}}}gSiteLife.PostRecommendation=function(f,b,d,g,c){c=c||window.location.href;var e=this.__baseUrl+"/Recommend/PostRecommendation?plckElementId="+d+"&plckTargetKey="+gSiteLife.EscapeValue(b)+"&plckTargetKeyType="+f+"&plckTargetUrl="+gSiteLife.EscapeValue(c);if(g){try{e+="&plckParentTitle="+plckArticleTitle}catch(a){e+="&plckParentTitle="+gSiteLife.EscapeValue(g)}}this.__Send(e);if(DappiPath!=""){var h=DappiPath+"/utils/utils/pluckUtils/cachingProxy/pluck.service.php?action=invalidatecache&uid="+uniqueCacheGroupKey}else{var h=PluckUIPath+"/utils/utils/pluckUtils/cachingProxy/pluck.service.php?action=invalidatecache&uid="+uniqueCacheGroupKey}this.__Send(h);addRecommendToDb(f,b);return false};gSiteLife.ArticleRecommend=function(d,a,b){d=d||"ExternalResource";a=a||gSiteLife.__StripAnchorFromUrl(window.location.href);b=b||window.location.href;a=a;var c=this.__baseUrl+"/Recommend/Recommend?plckElementId=articleRecommend&plckTargetKey="+gSiteLife.EscapeValue(a)+"&plckTargetKeyType="+d+"&plckTargetUrl="+gSiteLife.EscapeValue(b);this.__Send(c);return false};gSiteLife.CommentsInputWithTitle=function(a,c,b){return this.CommentsInternal("ExternalResource",a,null,null,null,null,null,c,true,false,b,false)};SiteLifeProxy.prototype.Blog=function(b,c){if(!c){c="blogDest";this.WriteDiv("blogDest","Persona_Main")}var d=this.GetParameter("plckBlogPage");if(!b){b=this.GetParameter("plckBlogId")}if(d&&d!="Blog"&&(typeof this[d]=="function")){return this[d](b)}else{var a=this.GetParameter("plckCurrentPage")?"plckCurrentPage="+this.GetParameter("plckCurrentPage"):"";return this.BlogSend("Blog","Blog",c,"blogScript",b,a)}};SiteLifeProxy.prototype.PersonaHeader=function(a,b){if(!b){b="personaHDest";this.WriteDiv("personaHDest","Persona_Main")}this.AddEventHandler("persona:header",function(){gSiteLife.PersonaHeaderInbox()});this.PersonaHeaderRequest(a)};SiteLifeProxy.prototype.Persona=function(a,b){if(!b){b="personaDest";this.WriteDiv("personaDest","Persona_Main")}var c=this.GetParameter("plckPersonaPage");if(c&&(typeof this[c]=="function")){this[c](a)}else{this.PersonaHome(a)}};SiteLifeProxy.prototype.PhotoUpload=function(b){if(!b){b="plcksubmit";this.WriteDiv(b)}var c=gSiteLife.GetParameter("plckGalleryID");var a=this.__baseUrl+"/Photo/PhotoUpload?plckElementId="+b+"&plckGalleryID="+c;this.__Send(a);return false};SiteLifeProxy.prototype.PublicGallery=function(b){if(!b){b="plckgallery";this.WriteDiv(b)}var c=gSiteLife.GetParameter("plckGalleryID");var d=gSiteLife.GetParameter("plckPageNum");var a=this.__baseUrl+"/Photo/PublicGallery?plckElementId="+b+"&plckGalleryID="+c+"&plckPageNum="+d;this.__Send(a);return false};SiteLifeProxy.prototype.GalleryPhoto=function(b){if(!b){elementId="plckphoto";this.WriteDiv(b)}var d=gSiteLife.GetParameter("plckPhotoID");var c=gSiteLife.ReadFindCommentKey(null,"widget:galleryPhoto");var a=this.__baseUrl+"/Photo/GalleryPhoto?plckElementId="+b+"&plckPhotoID="+d+"&plckFindCommentKey="+c;this.__Send(a,null,"widget:galleryPhoto");return false};SiteLifeProxy.prototype.PublicGalleries=function(b){if(!b){b="plckgalleries";this.WriteDiv(b)}var c=gSiteLife.GetParameter("plckPageNum")?gSiteLife.GetParameter("plckPageNum"):"0";var a=this.__baseUrl+"/Photo/PublicGalleries?plckElementId="+b+"&plckPageNum="+c;this.__Send(a);return false};