 var l_aValidVideoFileFormats = new Array("mp4", "VOB", "MPG", "3GP", "AVI", "ASF", "WMV", "MOV", "FLV");
var l_aValidPhotoFileFormats = new Array("jpeg", "gif", "png", "jpg", "bmp");
 

function handleErrorsType($p_xType, responseBatch) {
var s = '';
for (var i = 0; i < responseBatch.Messages.length; i++) {
s = s + responseBatch.Messages[i].Message + '\n\n';
}
alert(s);
}
function handleErrors(responseBatch) {
var s = '';
for (var i = 0; i < responseBatch.Messages.length; i++) {
s = s + responseBatch.Messages[i].Message + '\n\n';
}
alert(s);
}
 _xValidate = {
validateAvatarPhoto: function(l_sFileName){
var l_bIsValid = false;
$('#error').html('false');
splitName = l_sFileName.split(".");
fileType = splitName[splitName.length-1];
fileType = fileType.toLowerCase();
for(var i = 0; i < l_aValidPhotoFileFormats.length; i++){
if(fileType == l_aValidPhotoFileFormats[i]){
 l_bIsValid = true;
 $('#error').html('false');
}
}
if(l_bIsValid == false){
$('#invalid_file_format').html("Invalid File Format");
 $('#error').html('true');
}
else{
$('#invalid_file_format').html("");
_xPluckPhoto.uploadAvatarPhoto();
}
},
validateMedia: function(l_sFileName, p_sType){
var l_bIsValid = false;
$('#error').html('false');
splitName = l_sFileName.split(".");
fileType = splitName[splitName.length-1];
fileType = fileType.toLowerCase();
switch(p_sType){
case 'image':
 for(var i = 0; i < l_aValidPhotoFileFormats.length; i++){
 if(fileType == l_aValidPhotoFileFormats[i].toLowerCase()){
l_bIsValid = true;
 $('#error').html('false');
}
}
break;
case 'video':
for(var i = 0; i < l_aValidVideoFileFormats.length; i++){
 if(fileType == l_aValidVideoFileFormats[i].toLowerCase()){
l_bIsValid = true;
 $('#error').html('false');
}
}
break;
}
if(l_bIsValid == false){
 $('#invalid_file_format').html("Invalid File Format");
 $('#error').html('true');
 } else{
 $('#invalid_file_format').html("");
}
}, 
validateCreateGroupForm:function(){
l_aErrors = Array();
var l_bIsValid = false;
$('#error').html('false');
 if($('#title').val()){
 l_bIsValid = true;
$('#invalid_title').html("");
 }else{
 l_aErrors.push("Please Enter Title");
 $('#invalid_title').html("Please enter Title.");
 $('#error').html('true');
 l_bIsValid = false;
 }
 
if($('#group_section_list').val()){
l_bIsValid = true;
 }else{
 l_aErrors.push("Please enter your sport Name.");
 $('#error').html('true');
 l_bIsValid = false;
 }
 
if($('#avatarphotokey').html() == "null"){
 var l_bIsMediaValid = false;
 $('#invalid_media').html("Please Upload Group Image.");
 }else{
 $('#invalid_media').html("");
 l_bIsMediaValid = true;
 }
 
 var l_sAvatarKey = $('#avatarphotokey').html();
 
 if(l_sAvatarKey.indexOf("Anonymous") != -1){
var l_bIsMediaValid = false;
$('#invalid_media').html("Anonymous user is not allowed to upload photos. Please login!");
 }
 
 
 
 if(l_bIsValid && l_bIsMediaValid){
return true;
}else{
 return false;
 }
 
 
 
 
},
validateMediaForm:function(){
l_aErrors = Array();
var l_bIsValid = true;
if($('#title').val()){
$('#invalid_title').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_title').html("Please enter title");
}
 if($('#error').html() == 'true'){
 l_bIsValid = false; 
$('#invalid_file_format').html("Please upload media");
 }else{
 $('#invalid_file_format').html("");
 }
 
 if(l_bIsValid){
 return true;
}else{
 return false;
 }
 
 
 
},
validateBlogForm:function(){
l_aErrors = Array();
var l_bIsValid = true;
if($('#title').val()){
$('#invalid_title').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_title').html("Please enter title.");
 }
 if($('#desc').val()){
$('#invalid_desc').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_desc').html("Please enter post.");
}
 
 if(l_bIsValid){
 return true;
}else{
 return false;
 }
},
validateEventForm:function(){
 l_aErrors = Array();
var l_bIsValid = true;
if($('#title').val()){
$('#invalid_title').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_title').html("Please enter Title");
}
if($('#desc').val()){
$('#invalid_desc').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_desc').html("Please enter Description.");
}
if($('#loc').val()){
$('#invalid_loc').html("");
}else{
 l_bIsValid = false; 
$('#invalid_loc').html("Please enter valid location.");
}
 
if($('#start_time_picker').val()){
$('#invalid_sdate').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_sdate').html("Please enter Start Date.");
}

if($('#start_time_entry').val()){
$('#invalid_stime').html("");
}else{
 l_bIsValid = false;
 $('#invalid_stime').html("Please enter Start Time.");
 }
if($('#end_time_picker').val()){
$('#invalid_edate').html("");
}else{
 l_bIsValid = false; 
$('#invalid_edate').html("Please enter End Date.");
}
//check for valid start and end dates
l_sStartDateJS = new Date($('#start_time_picker').val());
l_sEndDateJS = new Date($('#end_time_picker').val());
if(l_sStartDateJS.getTime() > l_sEndDateJS.getTime()){
 l_bIsValid = false; 
 $('#invalid_setdate').html("Please enter valid Start and End Date.");
}
 if($('#end_time_entry').val()){
$('#invalid_etime').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_etime').html("Please enter End Time.");
}
if($('#url').val()){
$('#invalid_url').html("");
}else{
 l_bIsValid = false;
 $('#invalid_url').html("Please enter valid url.");
 }
 
if($('#name').val()){
$('#invalid_urlname').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_urlname').html("Please enter valid url name.");
}
 
 
 if(l_bIsValid){
 return true;
}else{
return false;
 }
}, 
isEmpty: function(aTextField) {
 if ((aTextField.value.length==0) ||(aTextField.value==null)) {
return true;
 }
 else { return false; }
 },
 
 getCookie:function(name) {
var theCookies = document.cookie.split(/[; ]+/);
for (var i = 0 ; i < theCookies.length; i++) {
var aName = theCookies[i].substring(0,theCookies[i].indexOf('='));
if (aName == name) {
return theCookies[i];
}
}
}, 
validateCookie:function(name){
var theCookies = document.cookie.split(/[; ]+/);
for (var i = 0 ; i < theCookies.length; i++) {
var aName = theCookies[i].substring(0,theCookies[i].indexOf('='));
if (aName == name) {
return theCookies[i];
}
}
}
 
 }

var p_xResponseBatch = "";
var p_xResponsebatch = "";
function callbackPublicPhotoGalleryModule(p_xResponseBatch){
_xCallback.callback('public-photo-gallery',p_xResponseBatch);
}
function callbackPublicVideoGalleryModule(p_xResponseBatch){
_xCallback.callback('public-video-gallery',p_xResponseBatch);
}
function callbackSimilarContent(p_xResponseBatch){
_xCallback.callback('similar-content-module',p_xResponseBatch);
}
function callbackDiscoverContentGroupLandingModule(p_xResponsebatch){
_xCallback.callback('discover-content-group-landing',p_xResponsebatch);
 
}
function callbackMostPopularGroups(p_xResponsebatch){
 _xCallback.callback('most-popular-groups', p_xResponsebatch);
}
function callbackNewestGroups(p_xResponseBatch){
 _xCallback.callback('newest-groups', p_xResponseBatch);
}
function callbackMostActiveGroupsFilter(p_xResponseBatch){
 _xCallback.callback('most-active-groups-filter', p_xResponseBatch);
}
function callbackRecentActivityFeedModule(p_xResponsebatch){
_xCallback.callback('recent-activity-feed',p_xResponsebatch);
}
function callbackMostCommentedPhotos(p_xResponsebatch){
_xCallback.callback('most-recommended-photos',p_xResponsebatch);
}
function callbackGetCommunityGroupPageAggregate(p_xResponseBatch){
 _xCallback.callback('community-group-page-aggregate',p_xResponseBatch);
}
function callbackCommunitySearchResultsModule(p_xResponseBatch){
_xCallback.callback('community-search-results',p_xResponseBatch);
}
function callbackGroupStatsModule(p_xResponseBatch){
 _xCallback.callback('community-group-stats',p_xResponseBatch);
}
function callbackGroupTabModule(p_xResponseBatch){
_xCallback.callback('community-group-tab-module', p_xResponseBatch);
_xHandleFunctionCallback.callback('group-id-set', p_xResponseBatch);
_xHandleFunctionCallback.callback('moderator-info', p_xResponseBatch);
_xHandleFunctionCallback.callback('similar-content-info', p_xResponseBatch);
_xHandleFunctionCallback.callback('recent-events-info', p_xResponseBatch);
_xHandleFunctionCallback.callback('group-membership', p_xResponseBatch);
_xInitCallback.loadData(p_xResponseBatch);
}
function callbackPictureDetail(p_xResponseBatch){
_xHandleFunctionCallback.callback('photo-detail-id-set', p_xResponseBatch);
}

//Group Photos
function callbackGroupPhotosSubModule(p_xResponseBatch){
_xCallback.callback('sub-module-group-photos',p_xResponseBatch);
}
function callbackPhotoDetail(p_xResponseBatch){
_xCallback.callback('photo-detail',p_xResponseBatch);
}
//Group Videos
function callbackBlogDetail(p_xResponseBatch){
 _xCallback.callback('blog-detail', p_xResponseBatch);
}
function callbackGroupVideosSubModule(p_xResponseBatch){
_xCallback.callback('sub-module-group-videos',p_xResponseBatch);
}
function callbackVideoDetail(p_xResponseBatch){
_xCallback.callback('video-detail',p_xResponseBatch);
}
//Group Events
function callbackGroupEventsBadgeModule(p_xResponseBatch){
_xCallback.callback('sub-module-group-events',p_xResponseBatch);
}
function callbackUpcomingEventsModule(p_xResponseBatch){
_xCallback.callback('upcoming-events-module',p_xResponseBatch);
}
function callbackRecentEventsModule(p_xResponseBatch){
_xCallback.callback('recent-events-module',p_xResponseBatch);
}
//Group Blogs
function callbackSubModuleBlogs(p_xResponseBatch){
_xCallback.callback('sub-module-group-blogs',p_xResponseBatch);
}
//Group Forums
function callbackSubModuleForums(p_xResponseBatch){
_xCallback.callback('sub-module-group-forums',p_xResponseBatch);
}
//Comments Widget
function callbackComments(p_xResponseBatch){
 document._nCommentSent = false;
_xCallback.callback('comments',p_xResponseBatch);
}
function callbackPluckCommentsYesNo(p_xResponseBatch){
document._nCommentSent = false;
$('#plck_comment_body').val("Type your smack here...");
_xCallback.callback('comments-yes-no',p_xResponseBatch);
}
function callbackCMSCommentsYesNo(p_xResponseBatch){
document._nCommentSent = false;
$('#plck_comment_body').val("Type your smack here...");
 _xCallback.HandleCMSYesNoCommentsResponse(p_xResponseBatch);
}
function callbackJoinedGroup(p_xResponseBatch){
_xCallback.callback('joined-group', p_xResponseBatch);
}
function callbackGeneric(responseBatch) {
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}

}
function callbackActionYesNoComments(responseBatch){
//console.log(responseBatch);
if(document._nCommentSent){
 _xCore.getComments(document._nCommentSent,2, 1, "TimeStampDescending", "", "article", false, "Pluck"); 
 l_nAddCount = parseInt($('#plck-comment-count').html()) + 1;
 $('#plck-comment-count').html(l_nAddCount)
 
}
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}

}
function callbackGetCommunity(p_xResponsebatch){
//console.log(p_xResponsebatch);
if (p_xResponsebatch.Responses.length == 0) {
if (p_xResponsebatch.Messages.length == 1 && p_xResponsebatch.Messages[0].Message == 'ok') return;
handleErrors(p_xResponsebatch);
return;
}
}
function callbackGroupModeratorModule(p_xResponseBatch){
_xCallback.callback('group-moderator-module',p_xResponseBatch);
}
function callbackGroupRecentEventsMiniModule(p_xResponseBatch){
_xCallback.callback('recent-events-mini-module',p_xResponseBatch);
}
function callbackUserExists(p_xResponseBatch){
 $('#persona-loader').addClass('plk_always_hide');
 if (p_xResponseBatch.Responses[0].User.DisplayName == p_xResponseBatch.Responses[0].User.UserKey.Key) {
$('#persona_not_exist').css('display', 'inline');
}else{
$('#persona_exist').css('display', 'inline');
}
}
function callbackForumExists(p_xResponseBatch){
 //console.log(p_xResponseBatch);
 $('#forum-loader').addClass('plk_always_hide');
 //if (p_xResponseBatch.Responses[0].User.DisplayName == p_xResponseBatch.Responses[0].User.UserKey.Key) {
 // $('#persona_not_exist').css('display', 'inline');
//}else{
 // $('#persona_exist').css('display', 'inline');
//}
}
function callbackRecommend(p_xResponseBatch){
if (p_xResponseBatch.Responses.length == 0) {
if (p_xResponseBatch.Messages.length == 1 && p_xResponseBatch.Messages[0].Message == 'ok'){
 var f = document._xRecommend;
 $(f.parentNode).removeClass("fireitup_button sprite").addClass("fireitup_button sprite sprite_selected");
 
 if(document._xIncrementRecommend){
 l_nFireCount = parseInt($(".firecount").html());
 l_nFireCount += 1;
 $(".firecount").html(l_nFireCount);
 document._xIncrementRecommend = false;
 }
}else{
handleErrors(p_xResponseBatch);
return;
}
}
}
function callbackUpdateCommunityGroupMembership(p_xResponseBatch){
if (p_xResponseBatch.Responses.length == 0) {
if (p_xResponseBatch.Messages.length == 1 && p_xResponseBatch.Messages[0].Message == 'ok'){
 var f = document._xMembership;
 switch($(f).html()){
case 'Promote Members':
$(f).html("Promoted");
//$(f).parent().html("Manager");
break;
case 'Ban Members':
$(f).html("Banned");
//$(f).parent().html("Banned");
break;
case 'Demote Members':
$(f).html("Demoted");
//$(f).parent().html("Demoted");
 break;
 case 'Unban Members':
$(f).html("Unbanned");
//$(f).parent().html("Unbanned");
 break;
 }
}else{
handleErrors(p_xResponseBatch);
return;
}
}
}
function callbackArticleExists(p_xResponseBatch){
 if (p_xResponseBatch.Messages.length == 1 && p_xResponseBatch.Messages[0].Message == 'ok'){
for (var i = 0; i < p_xResponseBatch.Responses.length; i++) {
var response = p_xResponseBatch.Responses[i];
if (response.Article.ArticleKey != null) {
 _xDisplay.displayArticleDetail(response);
} 
}
 }else{
 
//call update Article here: 
//FOR DEBUG:
//alert(l_sCMSArticleSlug); //=> From CMS Data
//alert(l_sCMSArticleTitle); //=> From CMS Data
//alert(l_aCMSArticleIds["yes"]); //=> From _xCore.getYesNoCommentIds
//alert(l_aCMSArticleIds["no"]); //=> From _xCore.getYesNoCommentIds
//alert(l_aCMSArticleIds["article_key"]); //=> From _xCore.getYesNoCommentIds
//alert(l_sCMSArticleSection); //=>From Article Template
//alert(l_aCMSArticleTags); // =>From Article Template
//Call updateArticleAction 
//1=>ArticleKey 2=>Article Comments Yes 3=> Article Comments No
_xCore.updateArticle(l_aCMSArticleIds["yes"], l_sCMSArticleSlug, "I'm in! ... "+l_sCMSArticleTitle, l_sCMSArticleSection, l_aCMSArticleTags);
_xCore.updateArticle(l_aCMSArticleIds["no"], l_sCMSArticleSlug, "No Way! ... "+l_sCMSArticleTitle, l_sCMSArticleSection, l_aCMSArticleTags);
_xCore.updateArticle(l_aCMSArticleIds["article_key"], l_sCMSArticleSlug, l_sCMSArticleTitle, l_sCMSArticleSection, l_aCMSArticleTags);
}
}
function callbackReportAbuse(p_xResponseBatch){
if (p_xResponseBatch.Responses.length == 0) {
if (p_xResponseBatch.Messages.length == 1 && p_xResponseBatch.Messages[0].Message == 'ok'){
 var f = document._xAbuse;
 $(f.parentNode).removeClass("flag_button sprite").addClass("flag_button sprite sprite_selected");
}else{
handleErrors(p_xResponseBatch);
return;
}
}
}
function callbackEmailSent(p_xResponseBatch){
if (p_xResponseBatch.Responses.length == 0) {
if (p_xResponseBatch.Messages.length == 1 && p_xResponseBatch.Messages[0].Message == 'ok'){
$('#groupeditor_content').removeClass('groupeditor_content').addClass('plk_always_hide');
$('#thankyou').removeClass('plk_always_hide').addClass('groupeditor_content');
var l_sStartText = 'YOUR EMAIL IS SENT!';
var l_aTextInfo = { c:'000000',type:'med','bg':'ffffff',tran:true,s:14,w:238,cen:true,t:l_sStartText}
var l_sImageUrl = makeCustomImage(l_aTextInfo);
$('#thankyou').append( '<img class="finishtext" src="'+l_sImageUrl+'" >');
 
}else{
handleErrors(p_xResponseBatch);
return;
}
}
}
function callbackUserActivityModeration(p_xResponseBatch){
 _xCallback.callback('user-activity-moderation',p_xResponseBatch);
}
function callbackUserActivityMembershipOne(p_xResponseBatch){
 _xCallback.callback('user-activity-membership-1',p_xResponseBatch);
}
function callbackUserActivityMembershipTwo(p_xResponseBatch){
 _xCallback.callback('user-activity-membership-2',p_xResponseBatch);
}
function callbackCommunityUserMembership(p_xResponseBatch){
 _xCallback.callback('user-membership',p_xResponseBatch);
}
function callbackCommunityUserAdminMembership(p_xResponseBatch){
 _xCallback.callback('user-admin-membership',p_xResponseBatch);
}
function callbackCommunityUserBannedMembership(p_xResponseBatch){
 _xCallback.callback('user-banned-membership',p_xResponseBatch);
}
//callbackBlogInfoAfterUpload
function callbackBlogInfoAfterUpload(p_xResponseBatch){
 _xCallback.callback('blog-info-after-upload',p_xResponseBatch);
}

_xInitCallback = {

loadData:function(responseBatch){
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}
//console.log(responseBatch);
//get type
//TODO: FIND BETTER WAY OF GETTING GET VALUES
var l_aGet = window.location.href.split("/");
var l_sType = l_aGet[6];
//get response data
var response = responseBatch.Responses[0];
//Load data based on content type
 switch(l_sType){
case '':
if (response.CommunityGroup.CommunityGroupKey.Key != null) {
_xInit.initGroupHome(response.CommunityGroup.CommunityGroupKey.Key);
} 
break;
case 'events':
if (response.CommunityGroup.EventSetKey.Key != null) {
_xInit.initGroupEvents(response.CommunityGroup.EventSetKey.Key);
}
break;
case 'forum':
if (response.CommunityGroup.ForumKey.Key != null) {
_xInit.initGroupForums(response.CommunityGroup.ForumKey.Key);
}
break;
case 'videos':
if (response.CommunityGroup.VideoGalleryKey.Key != null) {
_xInit.initGroupVideos(response.CommunityGroup.VideoGalleryKey.Key);
}
break;
case 'pictures':
if (response.CommunityGroup.PhotoGalleryKey.Key != null) {
_xInit.initGroupPictures(response.CommunityGroup.PhotoGalleryKey.Key);
}
break;
case 'blogs':
if (response.CommunityGroup.BlogKey.Key != null) {
_xInit.initGroupBlogs(response.CommunityGroup.BlogKey.Key);
}
break;
 }
}
};


_xCallback = {
callback:function(p_sType,responseBatch){
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}
 switch (p_sType){
case 'recent-activity-feed':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.RecentMiniFeedActivity.NumberOfActivities != "0") {
_xDisplay.displayRecentFeedModule(response.RecentMiniFeedActivity);
} else {
_xDisplay.displayNoContentImage('home_no_content');
}
}
break;
 case 'discover-content-group-landing':
_xDisplay.displayDiscoverContentGroupLandingModule(responseBatch);
 break; 
 case 'most-popular-groups':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.DiscoverContentAction.DiscoveredContent != null) {
 displayMostPopularGroups(response.DiscoverContentAction);
} 
}
 break;
 case 'newest-groups':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.DiscoverContentAction.DiscoveredContent != null) {
 displayNewestGroups(response.DiscoverContentAction);
} 
}
 break;
 case 'most-recommended-photos':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.DiscoverContentAction.DiscoveredContent != null) {
 displayMostRecommendedPhotos(response.DiscoverContentAction);
} 
}
 break;
 case 'community-group-page-aggregate':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroupPage.CommunityGroups != null) {
_xDisplay.displayCommunityGroupPageAggregate(response.CommunityGroupPage);
} 
}
break;
 case 'most-active-groups-filter':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.DiscoverContentAction.DiscoveredContent != null) {
 displayMostActiveGroupsFilter(response.DiscoverContentAction);
} 
}
break;
case 'community-search-results':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.SearchResult.SearchResults != null) {
 displayCommunitySearchResults(response);
} 
}
break;
case 'community-group-stats':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.CommunityGroupKey.Key != null) {
_xDisplay.displayCommunityBadgeModule(response.CommunityGroup.CommunityGroupStats.MemberCount, "home");
} 
}
 break;
case 'community-group-tab-module':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup != null) {
_xDisplay.displayCommunityTabModule(response.CommunityGroup.AvatarImageUrl, 
response.CommunityGroup.Title, 
response.CommunityGroup.Description, 
response.CommunityGroup.CommunityGroupKey.Key,
response.CommunityGroup.RequestingUsersMembershipTier);
_xDisplayMiniModules.displayCommunityTitleandYear(response.CommunityGroup.Title, 
response.CommunityGroup.CreatedDate);
 } 
}
break;
case 'upcoming-events-module':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.EventsPage.NumberOfEvents != "0") {
 _xDisplay.displayGroupUpcomingEvents(response.EventsPage);
} 
}
break;
case 'recent-events-module':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.EventsPage.NumberOfEvents != "0") {
 _xDisplay.displayGroupPreviousEvents(response.EventsPage);
} 
}
break;
case 'public-photo-gallery':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
//if (response.EventsPage.NumberOfEvents != "0") {
 //displayPublicPhotoGallery(response.EventsPage);
//} 
}
break;
case 'public-video-gallery':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
//if (response.EventsPage.NumberOfEvents != "0") {
 //displayPublicVideoGallery(response.EventsPage);
//} 
}
break;
case 'sub-module-group-photos':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.PhotoPage.NumberOfPhotos != "0") {
//remove no content image and links
$('#plck_picture_page_template_final').removeClass("no_content");
$('#plck-no-content-links').addClass("plk_always_hide");
 _xDisplay.displayCommunityGroupPictures(response.PhotoPage);
}else {
$('#groups_search_form').addClass("plk_always_hide");
$('#plck-photo-dropdown-holder').removeClass("full_dropdown_holder full_dropdown_holder_sort").addClass("plk_always_hide");
_xDisplay.displayNoContentImage('plck_picture_page_template_final');
}
_xDisplay.displayCommunityBadgeModule(response.PhotoPage.NumberOfPhotos, "pictures");
}
break;
case 'photo-detail':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.Photo != null) {
 _xDisplay.displayCommunityGroupPictureDetail(response.Photo);
} 
}
break;
case 'blog-detail':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.BlogPost!= null) {
 _xDisplay.displayCommunityBlogDetail(response.BlogPost);
} 
}
break;
case 'sub-module-group-videos':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.VideoPage.NumberOfVideos != "0") {
 //remove no content image and links
$('#plck_video_page_template_final').removeClass("no_content");
$('#plck-no-content-links').addClass("plk_always_hide");
 _xDisplay.displayCommunityGroupVideos(response.VideoPage);
}else {
$('#groups_search_form').addClass("plk_always_hide");
$('#plck-video-dropdown-holder').removeClass("full_dropdown_holder full_dropdown_holder_sort").addClass("plk_always_hide");
_xDisplay.displayNoContentImage('plck_video_page_template_final');
}
_xDisplay.displayCommunityBadgeModule(response.VideoPage.NumberOfVideos, "videos");
}
break;
case 'video-detail':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.Video != null) {
 _xDisplay.displayCommunityGroupVideoDetail(response.Video);
} 
}
break;
case 'sub-module-group-events':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.EventsPage.NumberOfEvents != "0") {
//remove no content image and links
$('#plck_events_page_template_upcoming_events_final').removeClass("no_content");
$('#plck-no-content-links').addClass("plk_always_hide");
 _xDisplay.displayCommunityBadgeModule(response.EventsPage.NumberOfEvents, "events");
}else{
$('#groups_search_form').addClass("plk_always_hide");
$('#plck-event-dropdown-holder').removeClass("full_dropdown_holder full_dropdown_holder_sort").addClass("plk_always_hide");
_xDisplay.displayNoContentImage('plck_events_page_template_upcoming_events_final');
}
_xDisplay.displayCommunityBadgeModule(response.EventsPage.NumberOfEvents, "events");
}
break;
case 'sub-module-group-blogs':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.BlogPostPage.NumberOfBlogPosts != "0") {
//remove no content image and links
$('#plck_blog_page_template_final').removeClass("no_content");
$('#plck-no-content-links').addClass("plk_always_hide");
 _xDisplay.displayCommunityGroupBlogs(response.BlogPostPage);
}else {
$('#groups_search_form').addClass("plk_always_hide");
$('#plck-blog-dropdown-holder').removeClass("full_dropdown_holder full_dropdown_holder_sort").addClass("plk_always_hide");
_xDisplay.displayNoContentImage('plck_blog_page_template_final');
}
_xDisplay.displayCommunityBadgeModule(response.BlogPostPage.NumberOfBlogPosts, "blogs");
}
break;
case 'sub-module-group-forums':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.ForumDiscussionsPage.NumberOfDiscussions != "0") {
//POST LAUNCH TODO :if time permits: Replace Forum template with DAPPI forums
 //_xDisplay.displayCommunityGroupForums(response.BlogPostPage);
}
_xDisplay.displayCommunityBadgeModule(response.ForumDiscussionsPage.NumberOfDiscussions, "forums");
}
break;
case 'comments-yes-no':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = "";
var response = responseBatch.Responses[i];
if (response.CommentPage.NumberOfComments != "0") {
 _xDisplay.displayComments(response.CommentPage, response.CommentPage.ArticleKey.Key);
} 
else{
 _xDisplay.BeTheFirstToComment(response.CommentPage, response.CommentPage.ArticleKey.Key);
}
}
break;
 case 'user-activity-moderation':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.RecentUserActivity.UserActivities != null) {
 _xDisplay.displayUserActivity(response.RecentUserActivity.UserActivities, "plck_moderator_activity");
} 
}
 
break;
case 'user-activity-membership-1':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.RecentUserActivity.UserActivities != null) {
 _xDisplay.displayUserActivity(response.RecentUserActivity.UserActivities, "plck_membership_user_activity_1");
} 
}
 
break;
case 'user-activity-membership-2':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.RecentUserActivity.UserActivities != null) {
 _xDisplay.displayUserActivity(response.RecentUserActivity.UserActivities, "plck_membership_user_activity_2");
} 
}
 
break;
case 'comments':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommentPage.NumberOfComments != "0") {
 displayComments(response.CommentPage, null);
} 
}
break;
case 'group-moderator-module':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.User.UserKey.Key != "0") {
 _xDisplayMiniModules.displayModeratorModule(response.User);
_xCore.getActivitiesForUser(response.User.UserKey.Key, "callbackUserActivityModeration");
} 
}
 break;
case 'similar-content-module':
 var l_aAvatarImageUrl = new Array();
 var l_aTitle = new Array();
 var l_aMemberCount = new Array();
 var l_aCommunityGroupUrl = new Array();
 var l_bSimilarContent = false;
 if (responseBatch.Responses[0].DiscoverContentAction.DiscoveredContent != null) {
 l_bSimilarContent = true;
 for (var i = 0; i < responseBatch.Responses[0].DiscoverContentAction.DiscoveredContent.length; i++) {
l_aAvatarImageUrl.push(responseBatch.Responses[0].DiscoverContentAction.DiscoveredContent[i].AvatarImageUrl);
l_aTitle.push(responseBatch.Responses[0].DiscoverContentAction.DiscoveredContent[i].Title);
l_aMemberCount.push(responseBatch.Responses[0].DiscoverContentAction.DiscoveredContent[i].CommunityGroupStats.MemberCount);
l_aCommunityGroupUrl.push(responseBatch.Responses[0].DiscoverContentAction.DiscoveredContent[i].CommunityGroupKey.Key);
 }
 if(l_bSimilarContent){
_xDisplayMiniModules.displaySimilarContent(l_aAvatarImageUrl,l_aTitle,l_aMemberCount,l_aCommunityGroupUrl);
 }
 }
break;
case 'recent-events-mini-module':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.EventsPage.NumberOfEvents != "0") {
$('#plk-recent-events-module').removeClass("plk_always_hide");
_xDisplayMiniModules.displayEventsMiniModule(response.EventsPage);
}
}
break;
case 'user-membership':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroupMembershipPage.CommunityGroupMemberships != "0") {
 _xDisplayMiniModules.displayGroupMemberships(response.CommunityGroupMembershipPage);
} 
}
 
break;
case 'user-admin-membership':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroupMembershipPage.CommunityGroupMemberships != "0") {
 _xDisplayMiniModules.displayGroupAdminMemberships(response.CommunityGroupMembershipPage);
} 
}
 
break;
case 'user-banned-membership':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroupBannedUserPage.BannedUsers != "0") {
 _xDisplayMiniModules.displayGroupBannedMemberships(response.CommunityGroupBannedUserPage);
}else{
_xDisplayMiniModules.displayGroupNoMemberships();
}
}
 
break;
case 'joined-group':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroupMembershipKey.Key) {
//remove join button
$('#plck_jointhisgroup').css('display','none');
//refresh newest members module
if($('#plck-group-key-set').html()){
_xCore.getGroupMembershipPage($('#plck-group-key-set').html(), 2, 1, "TimeStampDescending");
//refresh stats module
_xCore.getStats($('#plck-group-key-set').html(), "community");
}
//refresh page 
location.reload(true);
_xTruebox.makePopup('join','group');
} 
}
break;
case 'blog-info-after-upload':
l_xBlogData = responseBatch.Responses[0].BlogPost;
if(l_xBlogData.BlogKey.Key && l_xBlogData.AssociatedCommunityGroupKey.Key){
 //TO REFRESH CONTENT AFTER BLOG IS UPLOADED: START//////////////////////////////////
 var l_sCurrentLoc = window.location.href;
 var l_sCommunitySlug = "/community/";
 if(l_sCurrentLoc.match(l_sCommunitySlug) && l_xBlogData.BlogKey.Key && l_xBlogData.AssociatedCommunityGroupKey.Key){
var l_aGet = l_sCurrentLoc.split("/");
var l_sBlogSlug = l_aGet[6];
switch(l_sBlogSlug){
 case '':
 //update group feeds with blog
 _xCommunity.getRecentActivityFeedModule(l_xBlogData.AssociatedCommunityGroupKey.Key, 1, 10);
 break;
 case 'blogs':
 //update blogs tab with blog
 _xCommunityBlogs.getBlogsModule(l_xBlogData.BlogKey.Key, 10, 1, 'TimeStampDescending');
 break;
}
}
document._sContentType = null;
//TO REFRESH CONTENT AFTER BLOG IS UPLOADED: END//////////////////////////////////
}
break;
}
},
HandleCMSYesNoCommentsResponse:function(responseBatch){
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') {
}else{
alert("Source:CMS Article: Should Call updateArticleAction now!")
handleErrors(responseBatch);
}
}
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = "";
var response = responseBatch.Responses[i];
if (response.CommentPage.NumberOfComments != "0") {
 _xDisplay.displayComments(response.CommentPage, response.CommentPage.ArticleKey.Key);
} 
else{
 _xDisplay.BeTheFirstToComment(response.CommentPage, response.CommentPage.ArticleKey.Key);
}
}
}
 };
 
 
 ////////HANDLE FORM UPDATES CALLBACK/////////////////////
 //////////////////////////////////////////////////
 function callbackUpdateCommunityGroup(p_xResponsebatch){
 _xUpdateFormsCallback.callback('update-community-group',p_xResponsebatch);
}
function callbackUpdateBlog(p_xResponsebatch){
_xUpdateFormsCallback.callback('update-blog',p_xResponsebatch);
}
function callbackUpdateGallery(p_xResponseBatch){
_xUpdateFormsCallback.callback('update-gallery',p_xResponseBatch);
}
function callbackUpdateGroupSubModuleEvents(p_xResponseBatch){
 _xUpdateFormsCallback.callback('update-community-event',p_xResponseBatch);
}
function callbackUpdateForumPost(p_xResponsebatch){
 _xUpdateFormsCallback.callback('update-forum-post',p_xResponsebatch);
}
function callbackAddForumPost(p_xResponsebatch){
 _xCallback.callback('add-forum-post',p_xResponsebatch);
}
_xUpdateFormsCallback = {
callback:function(p_sType,responseBatch){
//console.log(responseBatch);
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}
 switch (p_sType){
case 'update-community-group':
for (var i = 0; i < responseBatch.Responses.length; i++) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') {
}else{
$('#asseteditor_content').removeClass('asseteditor_content').addClass('plk_always_hide');
$('#asseteditor').addClass('image_error');
handleErrors(responseBatch);
}
var response = responseBatch.Responses[i];
if (response.CommunityGroupKey.Key != null) {
 $('#groupeditor_content').removeClass('groupeditor_content').addClass('plk_always_hide');
$('#thankyou').removeClass('plk_always_hide').addClass('groupeditor_content');
var l_sStartText = 'THANK YOU FOR CREATING THIS GROUP';
var l_aTextInfo = { c:'000000',type:'med','bg':'ffffff',tran:true,s:14,w:238,cen:true,t:l_sStartText}
var l_sImageUrl = makeCustomImage(l_aTextInfo);
$('#thankyou').append( '<img class="finishtext" src="'+l_sImageUrl+'" >');
 
$('#takemetocontent').html('<a href = "/community/group/' + response.CommunityGroupKey.Key + '/">Take me to my group</a>');
} 
}
break;
case 'update-blog':
//console.log(responseBatch);
for (var i = 0; i < responseBatch.Responses.length; i++) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') {
}else{
$('#asseteditor_content').removeClass('asseteditor_content').addClass('plk_always_hide');
$('#asseteditor').addClass('image_error');
handleErrors(responseBatch);
}
var response = responseBatch.Responses[i];
if (response.PostKey.Key != null) {

 $('#groupeditor_content').removeClass('groupeditor_content').addClass('plk_always_hide');
$('#thankyou').removeClass('plk_always_hide').addClass('groupeditor_content');
var l_sStartText = 'THANK YOU FOR POSTING A BLOG';
var l_aTextInfo = { c:'000000',type:'med','bg':'ffffff',tran:true,s:14,w:238,cen:true,t:l_sStartText}
var l_sImageUrl = makeCustomImage(l_aTextInfo);
$('#thankyou').append( '<img class="finishtext" src="'+l_sImageUrl+'" >');
//Refresh group content blog and recent feed pages.
_xCore.getBlogInfoAfterUpload(response.PostKey.Key);
//Maybe modified later
//$('#takemetocontent').html('<a href = "/blogs/">Take me to this blog entry</a>');
//
} 
}
break;
case 'update-community-event':
for (var i = 0; i < responseBatch.Responses.length; i++) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') {
}else{
$('#asseteditor_content').removeClass('asseteditor_content').addClass('plk_always_hide');
$('#asseteditor').addClass('image_error');
handleErrors(responseBatch);
}
var response = responseBatch.Responses[i];
if (response.EventKey.Key != null) {
 $('#groupeditor_content').removeClass('groupeditor_content').addClass('plk_always_hide');
$('#thankyou').removeClass('plk_always_hide').addClass('groupeditor_content');
 
var l_sStartText = 'THANK YOU FOR ADDING AN EVENT';
var l_aTextInfo = { c:'000000',type:'med','bg':'ffffff',tran:true,s:14,w:238,cen:true,t:l_sStartText}
var l_sImageUrl = makeCustomImage(l_aTextInfo);
$('#thankyou').append( '<img class="finishtext" src="'+l_sImageUrl+'" >');
 
 var l_aGet = window.location.href.split("/");
 var l_sType = l_aGet[6];
 switch(l_sType){
 case '':
var l_sCommunityGroupKey = $('#plck-group-key-set').html();
//update group feeds with blog
_xCommunity.getRecentActivityFeedModule(l_sCommunityGroupKey, 1, 10);
 break;
 case 'events':
//update Photos tab with blog
var l_sEventKey = $('#plck-group-event-set-key-set').html();
_xCommunityEvents.getUpcomingEventsModule(l_sEventKey, 3, 1);
//_xCommunityEvents.getRecentEventsMiniModule(l_sEventKey, 2, 1, "TimeStampDescending");
 break;
 }
} 
}
break;
case 'update-gallery':
alert("Your Gallery is updated/created Successfully!");
break;
case 'update-forum-post':
alert("Forum Post is successfully updated");
break;
case 'add-forum-post':
alert("Forum Post is successfully added");
break;
 }
}
};
 
 
 
 
 ////////HANDLE FORMS EDIT CALLBACK////////////////
 //////////////////////////////////////////////////
function callbackEditGroupEvent(p_xResponseBatch){
_xEditFormsCallback.callback('edit-group-event',p_xResponseBatch);
}
function callbackEditBlog(p_xResponseBatch){
_xEditFormsCallback.callback('edit-blog',p_xResponseBatch);
}
function callbackEditGroup(p_xResponseBatch){
_xEditFormsCallback.callback('edit-group',p_xResponseBatch);
}
function callbackEditGroup(p_xResponseBatch){
_xEditFormsCallback.callback('edit-group',p_xResponseBatch);
}

function callbackEditPhoto(p_xResponseBatch){
_xEditFormsCallback.callback('edit-photo',p_xResponseBatch);
}


_xEditFormsCallback = {
callback:function(p_sType,responseBatch){
//console.log(responseBatch);
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}
 switch (p_sType){
case 'edit-group-event':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.Event.EventKey != null) {
postEventData(response.Event);
} 
 }
 break;
case 'edit-blog':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.BlogPost.BlogPostKey != null) {
postBlogData(response.BlogPost);
} 
 }
 break;
 case 'edit-group':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.CommunityGroupKey != null) {
postGroupData(response.CommunityGroup);
} 
 }
 break;
 case 'edit-photo':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.Photo.PhotoKey != null) {
postPhotoData(response.Photo);
} 
 }
 break;
 
 
 
 
 
 }
}
};

//////HANDLE FUNCTION CALLBACK/////////////
///////////////////////////////////////////
_xHandleFunctionCallback = {
callback:function(p_sType,responseBatch){
//console.log(responseBatch);
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}
 switch (p_sType){
case 'get-upcoming-events-module':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.EventSetKey != null) {
 getUpcomingEventsModule(response.CommunityGroup.EventSetKey.Key);
} 
}
 
break;
case 'group-id-set':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.CommunityGroupKey.Key != null) {
 //set Forum Href:
//$("a[href='http://www.google.com/']").attr('href', 'http://www.live.com/');
$("[href='/community/group/"+response.CommunityGroup.CommunityGroupKey.Key+"/forum/']").attr('href','/community/group/'+response.CommunityGroup.CommunityGroupKey.Key+'/forum/?slPage=showDiscussion&slGroupKey='+response.CommunityGroup.CommunityGroupKey.Key+'&slForumDiscussionKey='+response.CommunityGroup.ForumKey.Key+'&slShowNewDiscussion=false');
$('#plck-group-photo-gallery-key-set').html(response.CommunityGroup.PhotoGalleryKey.Key);
$('#plck-group-video-gallery-key-set').html(response.CommunityGroup.VideoGalleryKey.Key);
$('#plck-group-event-set-key-set').html(response.CommunityGroup.EventSetKey.Key);
$('#plck-group-blog-key-set').html(response.CommunityGroup.BlogKey.Key);
$('#plck-group-forum-key-set').html(response.CommunityGroup.ForumKey.Key)
$('#plck-group-owner-key-set').html(response.CommunityGroup.Owner);
$('#plck-group-key-set').html(response.CommunityGroup.CommunityGroupKey.Key);
$('#plck-group-membership-tier').html(response.CommunityGroup.RequestingUsersMembershipTier);
$('#plck-group-title').html(response.CommunityGroup.Title);
} 
}
 
break;
case 'photo-detail-id-set':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.EventSetKey != null) {
 setNumberOfComments(response.Photo.NumberOfComments);
} 
}
break;
case 'moderator-info':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.CommunityGroupKey.Key != null) {
_xCommunity.getModeratorInfo(response.CommunityGroup.Owner);
}
}
break;
case 'similar-content-info':
 //get page type
 //TODO: FIND BETTER WAY OF GETTING GET VALUES
 var l_aGet = window.location.href.split("/");
 var l_sPageType = l_aGet[6];
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.CommunityGroupKey.Key != null) {
_xCommunity.getSimilarContent(response.CommunityGroup.Categories, response.CommunityGroup.Section, l_sPageType);
}
}
break;
case 'recent-events-info':
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.CommunityGroupKey.Key != null) {
_xCommunityEvents.getRecentEventsMiniModule(response.CommunityGroup.EventSetKey.Key, 2, 1, "TimeStampDescending");
}
}
break;
case 'group-membership':
for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.CommunityGroupKey.Key != null) {
_xCore.getGroupMembershipPage(response.CommunityGroup.CommunityGroupKey.Key, 2, 1, "TimeStampDescending");
}
if($('#plck-group-membership-tier').html() == "GroupAdmin"){
var l_bLoadMemberDirectory = true;
$('#plck-admin-button-holder').removeClass('plk_always_hide');
}
}
break;

}

}
};

function customCallbackForPhotoDetail(p_xResponseBatch){
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}
 for (var i = 0; i < responseBatch.Responses.length; i++) {
var response = responseBatch.Responses[i];
if (response.CommunityGroup.EventSetKey != null) {
 setGroupOwnerKey(response.CommunityGroup.Owner);
} 
 }
}
 
 
 
 
/* http://keith-wood.name/timeEntry.html
 Time entry for jQuery v1.4.6.
 Written by Keith Wood (kbwood{at}iinet.com.au) June 2007.
 Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
 MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 
 Please attribute the author if you use it. */

/* Turn an input field into an entry point for a time value.
 The time can be entered via directly typing the value,
 via the arrow keys, or via spinner buttons.
 It is configurable to show 12 or 24-hour time, to show or hide seconds,
 to enforce a minimum and/or maximum time, to change the spinner image,
 and to constrain the time to steps, e.g. only on the quarter hours.
 Attach it with $('input selector').timeEntry(); for default settings,
 or configure it with options like:
 $('input selector').timeEntry(
{spinnerImage: 'spinnerSquare.png?v=213)', spinnerSize: [20, 20, 0]}); */

(function($) { // Hide scope, no $ conflict

/* TimeEntry manager.
 Use the singleton instance of this class, $.timeEntry, to interact with the time entry
 functionality. Settings for (groups of) fields are maintained in an instance object
 (TimeEntryInstance), allowing multiple different settings on the same page. */
function TimeEntry() {
this._disabledInputs = []; // List of time entry inputs that have been disabled
this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings
show24Hours: false, // True to use 24 hour time, false for 12 hour (AM/PM)
separator: ':', // The separator between time fields
ampmPrefix: '', // The separator before the AM/PM text
ampmNames: ['AM', 'PM'], // Names of morning/evening markers
spinnerTexts: ['Now', 'Previous field', 'Next field', 'Increment', 'Decrement']
// The popup texts for the spinner image areas
};
this._defaults = {
appendText: '', // Display text following the input box, e.g. showing the format
showSeconds: false, // True to show seconds as well, false for hours/minutes only
timeSteps: [1, 1, 1], // Steps for each of hours/minutes/seconds when incrementing/decrementing
initialField: 0, // The field to highlight initially, 0 = hours, 1 = minutes, ...
useMouseWheel: true, // True to use mouse wheel for increment/decrement if possible,
// false to never use it
defaultTime: null, // The time to use if none has been set, leave at null for now
minTime: null, // The earliest selectable time, or null for no limit
maxTime: null, // The latest selectable time, or null for no limit
spinnerImage: 'spinnerDefault.png?v=213)', // The URL of the images to use for the time spinner
// Seven images packed horizontally for normal, each button pressed, and disabled
spinnerSize: [20, 20, 8], // The width and height of the spinner image,
// and size of centre button for current time
spinnerBigImage: '', // The URL of the images to use for the expanded time spinner
// Seven images packed horizontally for normal, each button pressed, and disabled
spinnerBigSize: [40, 40, 16], // The width and height of the expanded spinner image,
// and size of centre button for current time
spinnerIncDecOnly: false, // True for increment/decrement buttons only, false for all
spinnerRepeat: [500, 250], // Initial and subsequent waits in milliseconds
// for repeats on the spinner buttons
beforeShow: null, // Function that takes an input field and
// returns a set of custom settings for the time entry
beforeSetTime: null // Function that runs before updating the time,
// takes the old and new times, and minimum and maximum times as parameters,
// and returns an adjusted time if necessary
};
$.extend(this._defaults, this.regional['']);
}

var PROP_NAME = 'timeEntry';

$.extend(TimeEntry.prototype, {
/* Class name added to elements to indicate already configured with time entry. */
markerClassName: 'hasTimeEntry',

/* Override the default settings for all instances of the time entry.
 @paramoptions(object) the new settings to use as defaults (anonymous object)
 @return(DateEntry) this object */
setDefaults: function(options) {
extendRemove(this._defaults, options || {});
return this;
},

/* Attach the time entry handler to an input field.
 @paramtarget (element) the field to attach to
 @paramoptions(object) custom settings for this instance */
_connectTimeEntry: function(target, options) {
var input = $(target);
if (input.hasClass(this.markerClassName)) {
return;
}
var inst = {};
inst.options = $.extend({}, options);
inst._selectedHour = 0; // The currently selected hour
inst._selectedMinute = 0; // The currently selected minute
inst._selectedSecond = 0; // The currently selected second
inst._field = 0; // The selected subfield
inst.input = $(target); // The attached input field
$.data(target, PROP_NAME, inst);
var spinnerImage = this._get(inst, 'spinnerImage');
var spinnerText = this._get(inst, 'spinnerText');
var spinnerSize = this._get(inst, 'spinnerSize');
var appendText = this._get(inst, 'appendText');
var spinner = (!spinnerImage ? null : 
$('<span class="timeEntry_control" style="display: inline-block; ' +
'background: url(\'' + spinnerImage + '\') 0 0 no-repeat; ' +
'width: ' + spinnerSize[0] + 'px; height: ' + spinnerSize[1] + 'px;' +
($.browser.mozilla && $.browser.version < '1.9' ? // FF 2- (Win)
' padding-left: ' + spinnerSize[0] + 'px; padding-bottom: ' +
(spinnerSize[1] - 18) + 'px;' : '') + '"></span>'));
input.wrap('<span class="timeEntry_wrap"></span>').
after(appendText ? '<span class="timeEntry_append">' + appendText + '</span>' : '').
after(spinner || '');
input.addClass(this.markerClassName).bind('focus.timeEntry', this._doFocus).
bind('blur.timeEntry', this._doBlur).bind('click.timeEntry', this._doClick).
bind('keydown.timeEntry', this._doKeyDown).bind('keypress.timeEntry', this._doKeyPress);
// Check pastes
if ($.browser.mozilla) {
input.bind('input.timeEntry', function(event) { $.timeentry._parseTime(inst); });
}
if ($.browser.msie) {
input.bind('paste.timeEntry', 
function(event) { setTimeout(function() { $.timeentry._parseTime(inst); }, 1); });
}
// Allow mouse wheel usage
if (this._get(inst, 'useMouseWheel') && $.fn.mousewheel) {
input.mousewheel(this._doMouseWheel);
}
if (spinner) {
spinner.mousedown(this._handleSpinner).mouseup(this._endSpinner).
mouseover(this._expandSpinner).mouseout(this._endSpinner).
mousemove(this._describeSpinner);
}
},

/* Enable a time entry input and any associated spinner.
 @paraminput(element) single input field */
_enableTimeEntry: function(input) {
this._enableDisable(input, false);
},

/* Disable a time entry input and any associated spinner.
 @paraminput(element) single input field */
_disableTimeEntry: function(input) {
this._enableDisable(input, true);
},

/* Enable or disable a time entry input and any associated spinner.
 @paraminput(element) single input field
 @paramdisable(boolean) true to disable, false to enable */
_enableDisable: function(input, disable) {
var inst = $.data(input, PROP_NAME);
if (!inst) {
return;
}
input.disabled = disable;
if (input.nextSibling && input.nextSibling.nodeName.toLowerCase() == 'span') {
$.timeEntry._changeSpinner(inst, input.nextSibling, (disable ? 5 : -1));
}
$.timeEntry._disabledInputs = $.map($.timeEntry._disabledInputs,
function(value) { return (value == input ? null : value); }); // Delete entry
if (disable) {
$.timeEntry._disabledInputs.push(input);
}
},

/* Check whether an input field has been disabled.
 @paraminput(element) input field to check
 @return(boolean) true if this field has been disabled, false if it is enabled */
_isDisabledTimeEntry: function(input) {
return $.inArray(input, this._disabledInputs) > -1;
},

/* Reconfigure the settings for a time entry field.
 @paraminput(element) input field to change
 @paramoptions(object) new settings to add */
_changeTimeEntry: function(input, options) {
var inst = $.data(input, PROP_NAME);
if (inst) {
var currentTime = this._extractTime(inst);
extendRemove(inst.options, options || {});
if (currentTime) {
this._setTime(inst, new Date(0, 0, 0,
currentTime[0], currentTime[1], currentTime[2]));
}
}
$.data(input, PROP_NAME, inst);
},

/* Remove the time entry functionality from an input.
 @paraminput(element) input field to affect */
_destroyTimeEntry: function(input) {
$input = $(input);
if (!$input.hasClass(this.markerClassName)) {
return;
}
$input.removeClass(this.markerClassName).unbind('.timeEntry');
if ($.fn.mousewheel) {
$input.unmousewheel();
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value == input ? null : value); }); // Delete entry
$input.parent().replaceWith($input);
$.removeData(input, PROP_NAME);
},

/* Initialise the current time for a time entry input field.
 @paraminput(element) input field to update
 @paramtime (Date) the new time (year/month/day ignored) or null for now */
_setTimeTimeEntry: function(input, time) {
var inst = $.data(input, PROP_NAME);
if (inst) {
this._setTime(inst, time ? (typeof time == 'object' ?
new Date(time.getTime()) : time) : null);
}
},

/* Retrieve the current time for a time entry input field.
 @paraminput(element) input field to update
 @return(Date) current time (year/month/day zero) or null if none */
_getTimeTimeEntry: function(input) {
var inst = $.data(input, PROP_NAME);
var currentTime = (inst ? this._extractTime(inst) : null);
return (!currentTime ? null :
new Date(0, 0, 0, currentTime[0], currentTime[1], currentTime[2]));
},

/* Initialise time entry.
 @paramtarget(element) the input field or
 (event) the focus event */
_doFocus: function(target) {
var input = (target.nodeName && target.nodeName.toLowerCase() == 'input' ? target : this);
if ($.timeEntry._lastInput == input || $.timeEntry._isDisabledTimeEntry(input)) {
$.timeEntry._focussed = false;
return;
}
var inst = $.data(input, PROP_NAME);
$.timeEntry._focussed = true;
$.timeEntry._lastInput = input;
$.timeEntry._blurredInput = null;
var beforeShow = $.timeEntry._get(inst, 'beforeShow');
extendRemove(inst.options, (beforeShow ? beforeShow.apply(input, [input]) : {}));
$.data(input, PROP_NAME, inst);
$.timeEntry._parseTime(inst);
setTimeout(function() { $.timeEntry._showField(inst); }, 10);
},

/* Note that the field has been exited.
 @paramevent(event) the blur event */
_doBlur: function(event) {
$.timeEntry._blurredInput = $.timeEntry._lastInput;
$.timeEntry._lastInput = null;
},

/* Select appropriate field portion on click, if already in the field.
 @paramevent(event) the click event */
_doClick: function(event) {
var input = event.target;
var inst = $.data(input, PROP_NAME);
if (!$.timeEntry._focussed) {
var fieldSize = $.timeEntry._get(inst, 'separator').length + 2;
inst._field = 0;
if (input.selectionStart != null) { // Use input select range
for (var field = 0; field <= Math.max(1, inst._secondField, inst._ampmField); field++) {
var end = (field != inst._ampmField ? (field * fieldSize) + 2 :
(inst._ampmField * fieldSize) + $.timeEntry._get(inst, 'ampmPrefix').length +
$.timeEntry._get(inst, 'ampmNames')[0].length);
inst._field = field;
if (input.selectionStart < end) {
break;
}
}
}
else if (input.createTextRange) { // Check against bounding boxes
var src = $(event.srcElement);
var range = input.createTextRange();
var convert = function(value) {
return {thin: 2, medium: 4, thick: 6}[value] || value;
};
var offsetX = event.clientX + document.documentElement.scrollLeft -
(src.offset().left + parseInt(convert(src.css('border-left-width')), 10)) -
range.offsetLeft; // Position - left edge - alignment
for (var field = 0; field <= Math.max(1, inst._secondField, inst._ampmField); field++) {
var end = (field != inst._ampmField ? (field * fieldSize) + 2 :
(inst._ampmField * fieldSize) + $.timeEntry._get(inst, 'ampmPrefix').length +
$.timeEntry._get(inst, 'ampmNames')[0].length);
range.collapse();
range.moveEnd('character', end);
inst._field = field;
if (offsetX < range.boundingWidth) { // And compare
break;
}
}
}
}
$.data(input, PROP_NAME, inst);
$.timeEntry._showField(inst);
$.timeEntry._focussed = false;
},

/* Handle keystrokes in the field.
 @paramevent(event) the keydown event
 @return(boolean) true to continue, false to stop processing */
_doKeyDown: function(event) {
if (event.keyCode >= 48) { // >= '0'
return true;
}
var inst = $.data(event.target, PROP_NAME);
switch (event.keyCode) {
case 9: return (event.shiftKey ?
// Move to previous time field, or out if at the beginning
$.timeEntry._changeField(inst, -1, true) :
// Move to next time field, or out if at the end
$.timeEntry._changeField(inst, +1, true));
case 35: if (event.ctrlKey) { // Clear time on ctrl+end
$.timeEntry._setValue(inst, '');
}
else { // Last field on end
inst._field = Math.max(1, inst._secondField, inst._ampmField);
$.timeEntry._adjustField(inst, 0);
}
break;
case 36: if (event.ctrlKey) { // Current time on ctrl+home
$.timeEntry._setTime(inst);
}
else { // First field on home
inst._field = 0;
$.timeEntry._adjustField(inst, 0);
}
break;
case 37: $.timeEntry._changeField(inst, -1, false); break; // Previous field on left
case 38: $.timeEntry._adjustField(inst, +1); break; // Increment time field on up
case 39: $.timeEntry._changeField(inst, +1, false); break; // Next field on right
case 40: $.timeEntry._adjustField(inst, -1); break; // Decrement time field on down
case 46: $.timeEntry._setValue(inst, ''); break; // Clear time on delete
}
return false;
},

/* Disallow unwanted characters.
 @paramevent(event) the keypress event
 @return(boolean) true to continue, false to stop processing */
_doKeyPress: function(event) {
var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
if (chr < ' ') {
return true;
}
var inst = $.data(event.target, PROP_NAME);
$.timeEntry._handleKeyPress(inst, chr);
return false;
},

/* Increment/decrement on mouse wheel activity.
 @paramevent(event) the mouse wheel event
 @paramdelta(number) the amount of change */
_doMouseWheel: function(event, delta) {
if ($.timeEntry._isDisabledTimeEntry(event.target)) {
return;
}
delta = ($.browser.opera ? -delta / Math.abs(delta) :
($.browser.safari ? delta / Math.abs(delta) : delta));
var inst = $.data(event.target, PROP_NAME);
inst.input.focus();
if (!inst.input.val()) {
$.timeEntry._parseTime(inst);
}
$.timeEntry._adjustField(inst, delta);
event.preventDefault();
},

/* Expand the spinner, if possible, to make it easier to use.
 @paramevent(event) the mouse over event */
_expandSpinner: function(event) {
var spinner = $.timeEntry._getSpinnerTarget(event);
var inst = $.data($.timeEntry._getInput(spinner), PROP_NAME);
var spinnerBigImage = $.timeEntry._get(inst, 'spinnerBigImage');
if (spinnerBigImage) {
inst._expanded = true;
var offset = $(spinner).offset();
var relative = null;
$(spinner).parents().each(function() {
var parent = $(this);
if (parent.css('position') == 'relative' ||
parent.css('position') == 'absolute') {
relative = parent.offset();
}
return !relative;
});
var spinnerSize = $.timeEntry._get(inst, 'spinnerSize');
var spinnerBigSize = $.timeEntry._get(inst, 'spinnerBigSize');
$('<div class="timeEntry_expand" style="position: absolute; left: ' +
(offset.left - (spinnerBigSize[0] - spinnerSize[0]) / 2 -
(relative ? relative.left : 0)) + 'px; top: ' + (offset.top -
(spinnerBigSize[1] - spinnerSize[1]) / 2 - (relative ? relative.top : 0)) +
'px; width: ' + spinnerBigSize[0] + 'px; height: ' +
spinnerBigSize[1] + 'px; background: transparent url(' +
spinnerBigImage + ') no-repeat 0px 0px; z-index: 10;"></div>').
mousedown($.timeEntry._handleSpinner).mouseup($.timeEntry._endSpinner).
mouseout($.timeEntry._endExpand).mousemove($.timeEntry._describeSpinner).
insertAfter(spinner);
}
},

/* Locate the actual input field from the spinner.
 @paramspinner(element) the current spinner
 @return(element) the corresponding input */
_getInput: function(spinner) {
return $(spinner).siblings('.' + $.timeEntry.markerClassName)[0];
},

/* Change the title based on position within the spinner.
 @paramevent(event) the mouse move event */
_describeSpinner: function(event) {
var spinner = $.timeEntry._getSpinnerTarget(event);
var inst = $.data($.timeEntry._getInput(spinner), PROP_NAME);
spinner.title = $.timeEntry._get(inst, 'spinnerTexts')
[$.timeEntry._getSpinnerRegion(inst, event)];
},

/* Handle a click on the spinner.
 @paramevent(event) the mouse click event */
_handleSpinner: function(event) {
var spinner = $.timeEntry._getSpinnerTarget(event);
var input = $.timeEntry._getInput(spinner);
if ($.timeEntry._isDisabledTimeEntry(input)) {
return;
}
if (input == $.timeEntry._blurredInput) {
$.timeEntry._lastInput = input;
$.timeEntry._blurredInput = null;
}
var inst = $.data(input, PROP_NAME);
$.timeEntry._doFocus(input);
var region = $.timeEntry._getSpinnerRegion(inst, event);
$.timeEntry._changeSpinner(inst, spinner, region);
$.timeEntry._actionSpinner(inst, region);
$.timeEntry._timer = null;
$.timeEntry._handlingSpinner = true;
var spinnerRepeat = $.timeEntry._get(inst, 'spinnerRepeat');
if (region >= 3 && spinnerRepeat[0]) { // Repeat increment/decrement
$.timeEntry._timer = setTimeout(
function() { $.timeEntry._repeatSpinner(inst, region); },
spinnerRepeat[0]);
$(spinner).one('mouseout', $.timeEntry._releaseSpinner).
one('mouseup', $.timeEntry._releaseSpinner);
}
},

/* Action a click on the spinner.
 @paraminst(object) the instance settings
 @paramregion(number) the spinner "button" */
_actionSpinner: function(inst, region) {
if (!inst.input.val()) {
$.timeEntry._parseTime(inst);
}
switch (region) {
case 0: this._setTime(inst); break;
case 1: this._changeField(inst, -1, false); break;
case 2: this._changeField(inst, +1, false); break;
case 3: this._adjustField(inst, +1); break;
case 4: this._adjustField(inst, -1); break;
}
},

/* Repeat a click on the spinner.
 @paraminst(object) the instance settings
 @paramregion(number) the spinner "button" */
_repeatSpinner: function(inst, region) {
if (!$.timeEntry._timer) {
return;
}
$.timeEntry._lastInput = $.timeEntry._blurredInput;
this._actionSpinner(inst, region);
this._timer = setTimeout(
function() { $.timeEntry._repeatSpinner(inst, region); },
this._get(inst, 'spinnerRepeat')[1]);
},

/* Stop a spinner repeat.
 @paramevent(event) the mouse event */
_releaseSpinner: function(event) {
clearTimeout($.timeEntry._timer);
$.timeEntry._timer = null;
},

/* Tidy up after an expanded spinner.
 @paramevent(event) the mouse event */
_endExpand: function(event) {
$.timeEntry._timer = null;
var spinner = $.timeEntry._getSpinnerTarget(event);
var input = $.timeEntry._getInput(spinner);
var inst = $.data(input, PROP_NAME);
$(spinner).remove();
inst._expanded = false;
},

/* Tidy up after a spinner click.
 @paramevent(event) the mouse event */
_endSpinner: function(event) {
$.timeEntry._timer = null;
var spinner = $.timeEntry._getSpinnerTarget(event);
var input = $.timeEntry._getInput(spinner);
var inst = $.data(input, PROP_NAME);
if (!$.timeEntry._isDisabledTimeEntry(input)) {
$.timeEntry._changeSpinner(inst, spinner, -1);
}
if ($.timeEntry._handlingSpinner) {
$.timeEntry._lastInput = $.timeEntry._blurredInput;
}
if ($.timeEntry._lastInput && $.timeEntry._handlingSpinner) {
$.timeEntry._showField(inst);
}
$.timeEntry._handlingSpinner = false;
},

/* Retrieve the spinner from the event.
 @paramevent(event) the mouse click event
 @return(element) the target field */
_getSpinnerTarget: function(event) {
return event.target || event.srcElement;
},

/* Determine which "button" within the spinner was clicked.
 @paraminst (object) the instance settings
 @paramevent(event) the mouse event
 @return(number) the spinner "button" number */
_getSpinnerRegion: function(inst, event) {
var spinner = this._getSpinnerTarget(event);
var pos = ($.browser.opera || $.browser.safari ?
$.timeEntry._findPos(spinner) : $(spinner).offset());
var scrolled = ($.browser.safari ? $.timeEntry._findScroll(spinner) :
[document.documentElement.scrollLeft || document.body.scrollLeft,
document.documentElement.scrollTop || document.body.scrollTop]);
var spinnerIncDecOnly = this._get(inst, 'spinnerIncDecOnly');
var left = (spinnerIncDecOnly ? 99 : event.clientX + scrolled[0] -
pos.left - ($.browser.msie ? 2 : 0));
var top = event.clientY + scrolled[1] - pos.top - ($.browser.msie ? 2 : 0);
var spinnerSize = this._get(inst, (inst._expanded ? 'spinnerBigSize' : 'spinnerSize'));
var right = (spinnerIncDecOnly ? 99 : spinnerSize[0] - 1 - left);
var bottom = spinnerSize[1] - 1 - top;
if (spinnerSize[2] > 0 && Math.abs(left - right) <= spinnerSize[2] &&
Math.abs(top - bottom) <= spinnerSize[2]) {
return 0; // Centre button
}
var min = Math.min(left, top, right, bottom);
return (min == left ? 1 : (min == right ? 2 : (min == top ? 3 : 4))); // Nearest edge
},

/* Change the spinner image depending on button clicked.
 @paraminst (object) the instance settings
 @paramspinner(element) the spinner control
 @paramregion (number) the spinner "button" */
_changeSpinner: function(inst, spinner, region) {
$(spinner).css('background-position', '-' + ((region + 1) *
this._get(inst, (inst._expanded ? 'spinnerBigSize' : 'spinnerSize'))[0]) + 'px 0px');
},

/* Find an object's position on the screen.
 @paramobj(element) the control
 @return(object) position as .left and .top */
_findPos: function(obj) {
var curLeft = curTop = 0;
if (obj.offsetParent) {
curLeft = obj.offsetLeft;
curTop = obj.offsetTop;
while (obj = obj.offsetParent) {
var origCurLeft = curLeft;
curLeft += obj.offsetLeft;
if (curLeft < 0) {
curLeft = origCurLeft;
}
curTop += obj.offsetTop;
}
}
return {left: curLeft, top: curTop};
},

/* Find an object's scroll offset on the screen.
 @paramobj(element) the control
 @return(number[]) offset as [left, top] */
_findScroll: function(obj) {
var isFixed = false;
$(obj).parents().each(function() {
isFixed |= $(this).css('position') == 'fixed';
});
if (isFixed) {
return [0, 0];
}
var scrollLeft = obj.scrollLeft;
var scrollTop = obj.scrollTop;
while (obj = obj.parentNode) {
scrollLeft += obj.scrollLeft || 0;
scrollTop += obj.scrollTop || 0;
}
return [scrollLeft, scrollTop];
},

/* Get a setting value, defaulting if necessary.
 @paraminst(object) the instance settings
 @paramname(string) the setting name
 @return(any) the setting value */
_get: function(inst, name) {
return (inst.options[name] != null ?
inst.options[name] : $.timeEntry._defaults[name]);
},

/* Extract the time value from the input field, or default to now.
 @paraminst(object) the instance settings */
_parseTime: function(inst) {
var currentTime = this._extractTime(inst);
var showSeconds = this._get(inst, 'showSeconds');
if (currentTime) {
inst._selectedHour = currentTime[0];
inst._selectedMinute = currentTime[1];
inst._selectedSecond = currentTime[2];
}
else {
var now = this._constrainTime(inst);
inst._selectedHour = now[0];
inst._selectedMinute = now[1];
inst._selectedSecond = (showSeconds ? now[2] : 0);
}
inst._secondField = (showSeconds ? 2 : -1);
inst._ampmField = (this._get(inst, 'show24Hours') ? -1 : (showSeconds ? 3 : 2));
inst._lastChr = '';
inst._field = Math.max(0, Math.min(
Math.max(1, inst._secondField, inst._ampmField), this._get(inst, 'initialField')));
if (inst.input.val() != '') {
this._showTime(inst);
}
},

/* Extract the time value from the input field as an array of values, or default to null.
 @paraminst(object) the instance settings
 @return(number[3]) the time components (hours, minutes, seconds)
or null if no value */
_extractTime: function(inst) {
var value = inst.input.val();
var separator = this._get(inst, 'separator');
var currentTime = value.split(separator);
if (separator == '' && value != '') {
currentTime[0] = value.substring(0, 2);
currentTime[1] = value.substring(2, 4);
currentTime[2] = value.substring(4, 6);
}
var ampmNames = this._get(inst, 'ampmNames');
var show24Hours = this._get(inst, 'show24Hours');
if (currentTime.length >= 2) {
var isAM = !show24Hours && (value.indexOf(ampmNames[0]) > -1);
var isPM = !show24Hours && (value.indexOf(ampmNames[1]) > -1);
var hour = parseInt(currentTime[0], 10);
hour = (isNaN(hour) ? 0 : hour);
hour = ((isAM || isPM) && hour == 12 ? 0 : hour) + (isPM ? 12 : 0);
var minute = parseInt(currentTime[1], 10);
minute = (isNaN(minute) ? 0 : minute);
var second = (currentTime.length >= 3 ?
parseInt(currentTime[2], 10) : 0);
second = (isNaN(second) || !this._get(inst, 'showSeconds') ? 0 : second);
return this._constrainTime(inst, [hour, minute, second]);
} 
return null;
},

/* Constrain the given/current time to the time steps.
 @paraminst(object) the instance settings
 @paramfields(number[3]) the current time components (hours, minutes, seconds)
 @return(number[3]) the constrained time components (hours, minutes, seconds) */
_constrainTime: function(inst, fields) {
var specified = (fields != null);
if (!specified) {
var now = this._determineTime(this._get(inst, 'defaultTime')) || new Date();
fields = [now.getHours(), now.getMinutes(), now.getSeconds()];
}
var reset = false;
var timeSteps = this._get(inst, 'timeSteps');
for (var i = 0; i < timeSteps.length; i++) {
if (reset) {
fields[i] = 0;
}
else if (timeSteps[i] > 1) {
fields[i] = Math.round(fields[i] / timeSteps[i]) * timeSteps[i];
reset = true;
}
}
return fields;
},

/* Set the selected time into the input field.
 @paraminst(object) the instance settings */
_showTime: function(inst) {
var show24Hours = this._get(inst, 'show24Hours');
var separator = this._get(inst, 'separator');
var currentTime = (this._formatNumber(show24Hours ? inst._selectedHour :
((inst._selectedHour + 11) % 12) + 1) + separator +
this._formatNumber(inst._selectedMinute) +
(this._get(inst, 'showSeconds') ? separator +
this._formatNumber(inst._selectedSecond) : '') +
(show24Hours ?'' : this._get(inst, 'ampmPrefix') +
this._get(inst, 'ampmNames')[(inst._selectedHour < 12 ? 0 : 1)]));
this._setValue(inst, currentTime);
this._showField(inst);
},

/* Highlight the current time field.
 @paraminst(object) the instance settings */
_showField: function(inst) {
var input = inst.input[0];
if (inst.input.is(':hidden') || $.timeEntry._lastInput != input) {
return;
}
var separator = this._get(inst, 'separator');
var fieldSize = separator.length + 2;
var start = (inst._field != inst._ampmField ? (inst._field * fieldSize) :
(inst._ampmField * fieldSize) - separator.length + this._get(inst, 'ampmPrefix').length);
var end = start + (inst._field != inst._ampmField ? 2 : this._get(inst, 'ampmNames')[0].length);
if (input.setSelectionRange) { // Mozilla
input.setSelectionRange(start, end);
}
else if (input.createTextRange) { // IE
var range = input.createTextRange();
range.moveStart('character', start);
range.moveEnd('character', end - inst.input.val().length);
range.select();
}
if (!input.disabled) {
input.focus();
}
},

/* Ensure displayed single number has a leading zero.
 @paramvalue(number) current value
 @return(string) number with at least two digits */
_formatNumber: function(value) {
return (value < 10 ? '0' : '') + value;
},

/* Update the input field and notify listeners.
 @paraminst (object) the instance settings
 @paramvalue(string) the new value */
_setValue: function(inst, value) {
if (value != inst.input.val()) {
inst.input.val(value).trigger('change');
}
},

/* Move to previous/next field, or out of field altogether if appropriate.
 @paraminst (object) the instance settings
 @paramoffset (number) the direction of change (-1, +1)
 @parammoveOut(boolean) true if can move out of the field
 @return(boolean) true if exitting the field, false if not */
_changeField: function(inst, offset, moveOut) {
var atFirstLast = (inst.input.val() == '' || inst._field ==
(offset == -1 ? 0 : Math.max(1, inst._secondField, inst._ampmField)));
if (!atFirstLast) {
inst._field += offset;
}
this._showField(inst);
inst._lastChr = '';
$.data(inst.input[0], PROP_NAME, inst);
return (atFirstLast && moveOut);
},

/* Update the current field in the direction indicated.
 @paraminst(object) the instance settings
 @paramoffset(number) the amount to change by */
_adjustField: function(inst, offset) {
if (inst.input.val() == '') {
offset = 0;
}
var timeSteps = this._get(inst, 'timeSteps');
this._setTime(inst, new Date(0, 0, 0,
inst._selectedHour + (inst._field == 0 ? offset * timeSteps[0] : 0) +
(inst._field == inst._ampmField ? offset * 12 : 0),
inst._selectedMinute + (inst._field == 1 ? offset * timeSteps[1] : 0),
inst._selectedSecond + (inst._field == inst._secondField ? offset * timeSteps[2] : 0)));
},

/* Check against minimum/maximum and display time.
 @paraminst(object) the instance settings
 @paramtime(Date) an actual time or
 (number) offset in seconds from now or
 (string) units and periods of offsets from now */
_setTime: function(inst, time) {
time = this._determineTime(time);
var fields = this._constrainTime(inst, time ?
[time.getHours(), time.getMinutes(), time.getSeconds()] : null);
time = new Date(0, 0, 0, fields[0], fields[1], fields[2]);
// Normalise to base date
var time = this._normaliseTime(time);
var minTime = this._normaliseTime(this._determineTime(this._get(inst, 'minTime')));
var maxTime = this._normaliseTime(this._determineTime(this._get(inst, 'maxTime')));
// Ensure it is within the bounds set
time = (minTime && time < minTime ? minTime :
(maxTime && time > maxTime ? maxTime : time));
var beforeSetTime = this._get(inst, 'beforeSetTime');
// Perform further restrictions if required
if (beforeSetTime) {
time = beforeSetTime.apply(inst.input[0],
[this._getTimeTimeEntry(inst.input[0]), time, minTime, maxTime]);
}
inst._selectedHour = time.getHours();
inst._selectedMinute = time.getMinutes();
inst._selectedSecond = time.getSeconds();
this._showTime(inst);
$.data(inst.input[0], PROP_NAME, inst);
},

/* A time may be specified as an exact value or a relative one.
 @paramsetting(Date) an actual time or
(number) offset in seconds from now or
(string) units and periods of offsets from now
 @return(Date) the calculated time */
_determineTime: function(setting) {
var offsetNumeric = function(offset) { // E.g. +300, -2
var time = new Date();
time.setTime(time.getTime() + offset * 1000);
return time;
};
var offsetString = function(offset) { // E.g. '+2m', '-4h', '+3h +30m'
var time = new Date();
var hour = time.getHours();
var minute = time.getMinutes();
var second = time.getSeconds();
var pattern = /([+-]?[0-9]+)\s*(s|S|m|M|h|H)?/g;
var matches = pattern.exec(offset);
while (matches) {
switch (matches[2] || 's') {
case 's' : case 'S' :
second += parseInt(matches[1], 10); break;
case 'm' : case 'M' :
minute += parseInt(matches[1], 10); break;
case 'h' : case 'H' :
hour += parseInt(matches[1], 10); break;
}
matches = pattern.exec(offset);
}
time = new Date(0, 0, 10, hour, minute, second, 0);
if (/^!/.test(offset)) { // No wrapping
if (time.getDate() > 10) {
time = new Date(0, 0, 10, 23, 59, 59);
}
else if (time.getDate() < 10) {
time = new Date(0, 0, 10, 0, 0, 0);
}
}
return time;
};
return (setting ? (typeof setting == 'string' ? offsetString(setting) :
(typeof setting == 'number' ? offsetNumeric(setting) : setting)) : null);
},

/* Normalise time object to a common date.
 @paramtime(Date) the original time
 @return(Date) the normalised time */
_normaliseTime: function(time) {
if (!time) {
return null;
}
time.setFullYear(1900);
time.setMonth(0);
time.setDate(0);
return time;
},

/* Update time based on keystroke entered.
 @paraminst(object) the instance settings
 @paramchr (ch) the new character */
_handleKeyPress: function(inst, chr) {
if (chr == this._get(inst, 'separator')) {
this._changeField(inst, +1, false);
}
else if (chr >= '0' && chr <= '9') { // Allow direct entry of time
var key = parseInt(chr, 10);
var value = parseInt(inst._lastChr + chr, 10);
var show24Hours = this._get(inst, 'show24Hours');
var hour = (inst._field != 0 ? inst._selectedHour :
(show24Hours ? (value < 24 ? value : key) :
(value >= 1 && value <= 12 ? value :
(key > 0 ? key : inst._selectedHour)) % 12 +
(inst._selectedHour >= 12 ? 12 : 0)));
var minute = (inst._field != 1 ? inst._selectedMinute :
(value < 60 ? value : key));
var second = (inst._field != inst._secondField ? inst._selectedSecond :
(value < 60 ? value : key));
var fields = this._constrainTime(inst, [hour, minute, second]);
this._setTime(inst, new Date(0, 0, 0, fields[0], fields[1], fields[2]));
inst._lastChr = chr;
}
else if (!this._get(inst, 'show24Hours')) { // Set am/pm based on first char of names
var ampmNames = this._get(inst, 'ampmNames');
if ((chr == ampmNames[0].substring(0, 1).toLowerCase() &&
inst._selectedHour >= 12) ||
(chr == ampmNames[1].substring(0, 1).toLowerCase() &&
inst._selectedHour < 12)) {
var saveField = inst._field;
inst._field = inst._ampmField;
this._adjustField(inst, +1);
inst._field = saveField;
this._showField(inst);
}
}
}
});

/* jQuery extend now ignores nulls!
 @paramtarget(object) the object to update
 @paramprops (object) the new settings 
 @return(object) the updated object */
function extendRemove(target, props) {
$.extend(target, props);
for (var name in props) {
if (props[name] == null) {
target[name] = null;
}
}
return target;
}

/* Attach the time entry functionality to a jQuery selection.
 @paramcommand(string) the command to run (optional, default 'attach')
 @paramoptions(object) the new settings to use for these countdown instances (optional)
 @return(jQuery) for chaining further calls */
$.fn.timeEntry = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
if (typeof options == 'string' && (options == 'isDisabled' || options == 'getTime')) {
return $.timeEntry['_' + options + 'TimeEntry'].apply($.timeEntry, [this[0]].concat(otherArgs));
}
return this.each(function() {
var nodeName = this.nodeName.toLowerCase();
if (nodeName == 'input') {
if (typeof options == 'string') {
$.timeEntry['_' + options + 'TimeEntry'].apply($.timeEntry, [this].concat(otherArgs));
}
else {
// Check for settings on the control itself
var inlineSettings = ($.fn.metadata ? $(this).metadata() : {});
$.timeEntry._connectTimeEntry(this, $.extend(inlineSettings, options));
}
} 
});
};

/* Initialise the time entry functionality. */
$.timeEntry = new TimeEntry(); // Singleton instance

})(jQuery);

/*
 * jQuery UI 1.7.2
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
jQuery.ui||(function(c){var i=c.fn.remove,d=c.browser.mozilla&&(parseFloat(c.browser.version)<1.9);c.ui={version:"1.7.2",plugin:{add:function(k,l,n){var m=c.ui[k].prototype;for(var j in n){m.plugins[j]=m.plugins[j]||[];m.plugins[j].push([l,n[j]])}},call:function(j,l,k){var n=j.plugins[l];if(!n||!j.element[0].parentNode){return}for(var m=0;m<n.length;m++){if(j.options[n[m][0]]){n[m][1].apply(j.element,k)}}}},contains:function(k,j){return document.compareDocumentPosition?k.compareDocumentPosition(j)&16:k!==j&&k.contains(j)},hasScroll:function(m,k){if(c(m).css("overflow")=="hidden"){return false}var j=(k&&k=="left")?"scrollLeft":"scrollTop",l=false;if(m[j]>0){return true}m[j]=1;l=(m[j]>0);m[j]=0;return l},isOverAxis:function(k,j,l){return(k>j)&&(k<(j+l))},isOver:function(o,k,n,m,j,l){return c.ui.isOverAxis(o,n,j)&&c.ui.isOverAxis(k,m,l)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(d){var f=c.attr,e=c.fn.removeAttr,h="http://www.w3.org/2005/07/aaa",a=/^aria-/,b=/^wairole:/;c.attr=function(k,j,l){var m=l!==undefined;return(j=="role"?(m?f.call(this,k,j,"wairole:"+l):(f.apply(this,arguments)||"").replace(b,"")):(a.test(j)?(m?k.setAttributeNS(h,j.replace(a,"aaa:"),l):f.call(this,k,j.replace(a,"aaa:"))):f.apply(this,arguments)))};c.fn.removeAttr=function(j){return(a.test(j)?this.each(function(){this.removeAttributeNS(h,j.replace(a,""))}):e.call(this,j))}}c.fn.extend({remove:function(){c("*",this).add(this).each(function(){c(this).triggerHandler("remove")});return i.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var j;if((c.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){j=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(c.curCSS(this,"position",1))&&(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}else{j=this.parents().filter(function(){return(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!j.length?c(document):j}});c.extend(c.expr[":"],{data:function(l,k,j){return !!c.data(l,j[3])},focusable:function(k){var l=k.nodeName.toLowerCase(),j=c.attr(k,"tabindex");return(/input|select|textarea|button|object/.test(l)?!k.disabled:"a"==l||"area"==l?k.href||!isNaN(j):!isNaN(j))&&!c(k)["area"==l?"parents":"closest"](":hidden").length},tabbable:function(k){var j=c.attr(k,"tabindex");return(isNaN(j)||j>=0)&&c(k).is(":focusable")}});function g(m,n,o,l){function k(q){var p=c[m][n][q]||[];return(typeof p=="string"?p.split(/,?\s+/):p)}var j=k("getter");if(l.length==1&&typeof l[0]=="string"){j=j.concat(k("getterSetter"))}return(c.inArray(o,j)!=-1)}c.widget=function(k,j){var l=k.split(".")[0];k=k.split(".")[1];c.fn[k]=function(p){var n=(typeof p=="string"),o=Array.prototype.slice.call(arguments,1);if(n&&p.substring(0,1)=="_"){return this}if(n&&g(l,k,p,o)){var m=c.data(this[0],k);return(m?m[p].apply(m,o):undefined)}return this.each(function(){var q=c.data(this,k);(!q&&!n&&c.data(this,k,new c[l][k](this,p))._init());(q&&n&&c.isFunction(q[p])&&q[p].apply(q,o))})};c[l]=c[l]||{};c[l][k]=function(o,n){var m=this;this.namespace=l;this.widgetName=k;this.widgetEventPrefix=c[l][k].eventPrefix||k;this.widgetBaseClass=l+"-"+k;this.options=c.extend({},c.widget.defaults,c[l][k].defaults,c.metadata&&c.metadata.get(o)[k],n);this.element=c(o).bind("setData."+k,function(q,p,r){if(q.target==o){return m._setData(p,r)}}).bind("getData."+k,function(q,p){if(q.target==o){return m._getData(p)}}).bind("remove",function(){return m.destroy()})};c[l][k].prototype=c.extend({},c.widget.prototype,j);c[l][k].getterSetter="option"};c.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled")},option:function(l,m){var k=l,j=this;if(typeof l=="string"){if(m===undefined){return this._getData(l)}k={};k[l]=m}c.each(k,function(n,o){j._setData(n,o)})},_getData:function(j){return this.options[j]},_setData:function(j,k){this.options[j]=k;if(j=="disabled"){this.element[k?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",k)}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(l,m,n){var p=this.options[l],j=(l==this.widgetEventPrefix?l:this.widgetEventPrefix+l);m=c.Event(m);m.type=j;if(m.originalEvent){for(var k=c.event.props.length,o;k;){o=c.event.props[--k];m[o]=m.originalEvent[o]}}this.element.trigger(m,n);return !(c.isFunction(p)&&p.call(this.element[0],m,n)===false||m.isDefaultPrevented())}};c.widget.defaults={disabled:false};c.ui.mouse={_mouseInit:function(){var j=this;this.element.bind("mousedown."+this.widgetName,function(k){return j._mouseDown(k)}).bind("click."+this.widgetName,function(k){if(j._preventClickEvent){j._preventClickEvent=false;k.stopImmediatePropagation();return false}});if(c.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(c.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(l){l.originalEvent=l.originalEvent||{};if(l.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(l));this._mouseDownEvent=l;var k=this,m=(l.which==1),j=(typeof this.options.cancel=="string"?c(l.target).parents().add(l.target).filter(this.options.cancel).length:false);if(!m||j||!this._mouseCapture(l)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){k.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(l)&&this._mouseDelayMet(l)){this._mouseStarted=(this._mouseStart(l)!==false);if(!this._mouseStarted){l.preventDefault();return true}}this._mouseMoveDelegate=function(n){return k._mouseMove(n)};this._mouseUpDelegate=function(n){return k._mouseUp(n)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(c.browser.safari||l.preventDefault());l.originalEvent.mouseHandled=true;return true},_mouseMove:function(j){if(c.browser.msie&&!j.button){return this._mouseUp(j)}if(this._mouseStarted){this._mouseDrag(j);return j.preventDefault()}if(this._mouseDistanceMet(j)&&this._mouseDelayMet(j)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,j)!==false);(this._mouseStarted?this._mouseDrag(j):this._mouseUp(j))}return !this._mouseStarted},_mouseUp:function(j){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(j.target==this._mouseDownEvent.target);this._mouseStop(j)}return false},_mouseDistanceMet:function(j){return(Math.max(Math.abs(this._mouseDownEvent.pageX-j.pageX),Math.abs(this._mouseDownEvent.pageY-j.pageY))>=this.options.distance)},_mouseDelayMet:function(j){return this.mouseDelayMet},_mouseStart:function(j){},_mouseDrag:function(j){},_mouseStop:function(j){},_mouseCapture:function(j){return true}};c.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);;/*
 * jQuery UI Datepicker 1.7.2
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Datepicker
 *
 * Depends:
 *ui.core.js
 */
(function($){$.extend($.ui,{datepicker:{version:"1.7.2"}});var PROP_NAME="datepicker";function Datepicker(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._datepickerShowing=false;this._inDialog=false;this._mainDivId="ui-datepicker-div";this._inlineClass="ui-datepicker-inline";this._appendClass="ui-datepicker-append";this._triggerClass="ui-datepicker-trigger";this._dialogClass="ui-datepicker-dialog";this._disableClass="ui-datepicker-disabled";this._unselectableClass="ui-datepicker-unselectable";this._currentClass="ui-datepicker-current-day";this._dayOverClass="ui-datepicker-days-cell-over";this.regional=[];this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],dateFormat:"mm/dd/yy",firstDay:0,isRTL:false};this._defaults={showOn:"focus",showAnim:"show",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:false,hideIfNoPrevNext:false,navigationAsDateFormat:false,gotoCurrent:false,changeMonth:false,changeYear:false,showMonthAfterYear:false,yearRange:"-10:+10",showOtherMonths:false,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"normal",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:true,showButtonPanel:false};$.extend(this._defaults,this.regional[""]);this.dpDiv=$('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>')}$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",log:function(){if(this.debug){console.log.apply("",arguments)}},setDefaults:function(settings){extendRemove(this._defaults,settings||{});return this},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase();var inline=(nodeName=="div"||nodeName=="span");if(!target.id){target.id="dp"+(++this.uuid)}var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{});if(nodeName=="input"){this._connectDatepicker(target,inst)}else{if(inline){this._inlineDatepicker(target,inst)}}},_newInst:function(target,inline){var id=target[0].id.replace(/([:\[\]\.])/g,"\\\\$1");return{id:id,input:target,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:inline,dpDiv:(!inline?this.dpDiv:$('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}},_connectDatepicker:function(target,inst){var input=$(target);inst.append=$([]);inst.trigger=$([]);if(input.hasClass(this.markerClassName)){return}var appendText=this._get(inst,"appendText");var isRTL=this._get(inst,"isRTL");if(appendText){inst.append=$('<span class="'+this._appendClass+'">'+appendText+"</span>");input[isRTL?"before":"after"](inst.append)}var showOn=this._get(inst,"showOn");if(showOn=="focus"||showOn=="both"){input.focus(this._showDatepicker)}if(showOn=="button"||showOn=="both"){var buttonText=this._get(inst,"buttonText");var buttonImage=this._get(inst,"buttonImage");inst.trigger=$(this._get(inst,"buttonImageOnly")?$("<img/>").addClass(this._triggerClass).attr({src:buttonImage,alt:buttonText,title:buttonText}):$('<button type="button"></button>').addClass(this._triggerClass).html(buttonImage==""?buttonText:$("<img/>").attr({src:buttonImage,alt:buttonText,title:buttonText})));input[isRTL?"before":"after"](inst.trigger);inst.trigger.click(function(){if($.datepicker._datepickerShowing&&$.datepicker._lastInput==target){$.datepicker._hideDatepicker()}else{$.datepicker._showDatepicker(target)}return false})}input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).bind("setData.datepicker",function(event,key,value){inst.settings[key]=value}).bind("getData.datepicker",function(event,key){return this._get(inst,key)});$.data(target,PROP_NAME,inst)},_inlineDatepicker:function(target,inst){var divSpan=$(target);if(divSpan.hasClass(this.markerClassName)){return}divSpan.addClass(this.markerClassName).append(inst.dpDiv).bind("setData.datepicker",function(event,key,value){inst.settings[key]=value}).bind("getData.datepicker",function(event,key){return this._get(inst,key)});$.data(target,PROP_NAME,inst);this._setDate(inst,this._getDefaultDate(inst));this._updateDatepicker(inst);this._updateAlternate(inst)},_dialogDatepicker:function(input,dateText,onSelect,settings,pos){var inst=this._dialogInst;if(!inst){var id="dp"+(++this.uuid);this._dialogInput=$('<input type="text" id="'+id+'" size="1" style="position: absolute; top: -100px;"/>');this._dialogInput.keydown(this._doKeyDown);$("body").append(this._dialogInput);inst=this._dialogInst=this._newInst(this._dialogInput,false);inst.settings={};$.data(this._dialogInput[0],PROP_NAME,inst)}extendRemove(inst.settings,settings||{});this._dialogInput.val(dateText);this._pos=(pos?(pos.length?pos:[pos.pageX,pos.pageY]):null);if(!this._pos){var browserWidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;var browserHeight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[(browserWidth/2)-100+scrollX,(browserHeight/2)-150+scrollY]}this._dialogInput.css("left",this._pos[0]+"px").css("top",this._pos[1]+"px");inst.settings.onSelect=onSelect;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);if($.blockUI){$.blockUI(this.dpDiv)}$.data(this._dialogInput[0],PROP_NAME,inst);return this},_destroyDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return}var nodeName=target.nodeName.toLowerCase();$.removeData(target,PROP_NAME);if(nodeName=="input"){inst.append.remove();inst.trigger.remove();$target.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress)}else{if(nodeName=="div"||nodeName=="span"){$target.removeClass(this.markerClassName).empty()}}},_enableDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return}var nodeName=target.nodeName.toLowerCase();if(nodeName=="input"){target.disabled=false;inst.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else{if(nodeName=="div"||nodeName=="span"){var inline=$target.children("."+this._inlineClass);inline.children().removeClass("ui-state-disabled")}}this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value)})},_disableDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return}var nodeName=target.nodeName.toLowerCase();if(nodeName=="input"){target.disabled=true;inst.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",cursor:"default"})}else{if(nodeName=="div"||nodeName=="span"){var inline=$target.children("."+this._inlineClass);inline.children().addClass("ui-state-disabled")}}this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value)});this._disabledInputs[this._disabledInputs.length]=target},_isDisabledDatepicker:function(target){if(!target){return false}for(var i=0;i<this._disabledInputs.length;i++){if(this._disabledInputs[i]==target){return true}}return false},_getInst:function(target){try{return $.data(target,PROP_NAME)}catch(err){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(target,name,value){var inst=this._getInst(target);if(arguments.length==2&&typeof name=="string"){return(name=="defaults"?$.extend({},$.datepicker._defaults):(inst?(name=="all"?$.extend({},inst.settings):this._get(inst,name)):null))}var settings=name||{};if(typeof name=="string"){settings={};settings[name]=value}if(inst){if(this._curInst==inst){this._hideDatepicker(null)}var date=this._getDateDatepicker(target);extendRemove(inst.settings,settings);this._setDateDatepicker(target,date);this._updateDatepicker(inst)}},_changeDatepicker:function(target,name,value){this._optionDatepicker(target,name,value)},_refreshDatepicker:function(target){var inst=this._getInst(target);if(inst){this._updateDatepicker(inst)}},_setDateDatepicker:function(target,date,endDate){var inst=this._getInst(target);if(inst){this._setDate(inst,date,endDate);this._updateDatepicker(inst);this._updateAlternate(inst)}},_getDateDatepicker:function(target){var inst=this._getInst(target);if(inst&&!inst.inline){this._setDateFromField(inst)}return(inst?this._getDate(inst):null)},_doKeyDown:function(event){var inst=$.datepicker._getInst(event.target);var handled=true;var isRTL=inst.dpDiv.is(".ui-datepicker-rtl");inst._keyEvent=true;if($.datepicker._datepickerShowing){switch(event.keyCode){case 9:$.datepicker._hideDatepicker(null,"");break;case 13:var sel=$("td."+$.datepicker._dayOverClass+", td."+$.datepicker._currentClass,inst.dpDiv);if(sel[0]){$.datepicker._selectDay(event.target,inst.selectedMonth,inst.selectedYear,sel[0])}else{$.datepicker._hideDatepicker(null,$.datepicker._get(inst,"duration"))}return false;break;case 27:$.datepicker._hideDatepicker(null,$.datepicker._get(inst,"duration"));break;case 33:$.datepicker._adjustDate(event.target,(event.ctrlKey?-$.datepicker._get(inst,"stepBigMonths"):-$.datepicker._get(inst,"stepMonths")),"M");break;case 34:$.datepicker._adjustDate(event.target,(event.ctrlKey?+$.datepicker._get(inst,"stepBigMonths"):+$.datepicker._get(inst,"stepMonths")),"M");break;case 35:if(event.ctrlKey||event.metaKey){$.datepicker._clearDate(event.target)}handled=event.ctrlKey||event.metaKey;break;case 36:if(event.ctrlKey||event.metaKey){$.datepicker._gotoToday(event.target)}handled=event.ctrlKey||event.metaKey;break;case 37:if(event.ctrlKey||event.metaKey){$.datepicker._adjustDate(event.target,(isRTL?+1:-1),"D")}handled=event.ctrlKey||event.metaKey;if(event.originalEvent.altKey){$.datepicker._adjustDate(event.target,(event.ctrlKey?-$.datepicker._get(inst,"stepBigMonths"):-$.datepicker._get(inst,"stepMonths")),"M")}break;case 38:if(event.ctrlKey||event.metaKey){$.datepicker._adjustDate(event.target,-7,"D")}handled=event.ctrlKey||event.metaKey;break;case 39:if(event.ctrlKey||event.metaKey){$.datepicker._adjustDate(event.target,(isRTL?-1:+1),"D")}handled=event.ctrlKey||event.metaKey;if(event.originalEvent.altKey){$.datepicker._adjustDate(event.target,(event.ctrlKey?+$.datepicker._get(inst,"stepBigMonths"):+$.datepicker._get(inst,"stepMonths")),"M")}break;case 40:if(event.ctrlKey||event.metaKey){$.datepicker._adjustDate(event.target,+7,"D")}handled=event.ctrlKey||event.metaKey;break;default:handled=false}}else{if(event.keyCode==36&&event.ctrlKey){$.datepicker._showDatepicker(this)}else{handled=false}}if(handled){event.preventDefault();event.stopPropagation()}},_doKeyPress:function(event){var inst=$.datepicker._getInst(event.target);if($.datepicker._get(inst,"constrainInput")){var chars=$.datepicker._possibleChars($.datepicker._get(inst,"dateFormat"));var chr=String.fromCharCode(event.charCode==undefined?event.keyCode:event.charCode);return event.ctrlKey||(chr<" "||!chars||chars.indexOf(chr)>-1)}},_showDatepicker:function(input){input=input.target||input;if(input.nodeName.toLowerCase()!="input"){input=$("input",input.parentNode)[0]}if($.datepicker._isDisabledDatepicker(input)||$.datepicker._lastInput==input){return}var inst=$.datepicker._getInst(input);var beforeShow=$.datepicker._get(inst,"beforeShow");extendRemove(inst.settings,(beforeShow?beforeShow.apply(input,[input,inst]):{}));$.datepicker._hideDatepicker(null,"");$.datepicker._lastInput=input;$.datepicker._setDateFromField(inst);if($.datepicker._inDialog){input.value=""}if(!$.datepicker._pos){$.datepicker._pos=$.datepicker._findPos(input);$.datepicker._pos[1]+=input.offsetHeight}var isFixed=false;$(input).parents().each(function(){isFixed|=$(this).css("position")=="fixed";return !isFixed});if(isFixed&&$.browser.opera){$.datepicker._pos[0]-=document.documentElement.scrollLeft;$.datepicker._pos[1]-=document.documentElement.scrollTop}var offset={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null;inst.rangeStart=null;inst.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});$.datepicker._updateDatepicker(inst);offset=$.datepicker._checkOffset(inst,offset,isFixed);inst.dpDiv.css({position:($.datepicker._inDialog&&$.blockUI?"static":(isFixed?"fixed":"absolute")),display:"none",left:offset.left+"px",top:offset.top+"px"});if(!inst.inline){var showAnim=$.datepicker._get(inst,"showAnim")||"show";var duration=$.datepicker._get(inst,"duration");var postProcess=function(){$.datepicker._datepickerShowing=true;if($.browser.msie&&parseInt($.browser.version,10)<7){$("iframe.ui-datepicker-cover").css({width:inst.dpDiv.width()+4,height:inst.dpDiv.height()+4})}};if($.effects&&$.effects[showAnim]){inst.dpDiv.show(showAnim,$.datepicker._get(inst,"showOptions"),duration,postProcess)}else{inst.dpDiv[showAnim](duration,postProcess)}if(duration==""){postProcess()}if(inst.input[0].type!="hidden"){inst.input[0].focus()}$.datepicker._curInst=inst}},_updateDatepicker:function(inst){var dims={width:inst.dpDiv.width()+4,height:inst.dpDiv.height()+4};var self=this;inst.dpDiv.empty().append(this._generateHTML(inst)).find("iframe.ui-datepicker-cover").css({width:dims.width,height:dims.height}).end().find("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a").bind("mouseout",function(){$(this).removeClass("ui-state-hover");if(this.className.indexOf("ui-datepicker-prev")!=-1){$(this).removeClass("ui-datepicker-prev-hover")}if(this.className.indexOf("ui-datepicker-next")!=-1){$(this).removeClass("ui-datepicker-next-hover")}}).bind("mouseover",function(){if(!self._isDisabledDatepicker(inst.inline?inst.dpDiv.parent()[0]:inst.input[0])){$(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");$(this).addClass("ui-state-hover");if(this.className.indexOf("ui-datepicker-prev")!=-1){$(this).addClass("ui-datepicker-prev-hover")}if(this.className.indexOf("ui-datepicker-next")!=-1){$(this).addClass("ui-datepicker-next-hover")}}}).end().find("."+this._dayOverClass+" a").trigger("mouseover").end();var numMonths=this._getNumberOfMonths(inst);var cols=numMonths[1];var width=17;if(cols>1){inst.dpDiv.addClass("ui-datepicker-multi-"+cols).css("width",(width*cols)+"em")}else{inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("")}inst.dpDiv[(numMonths[0]!=1||numMonths[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");inst.dpDiv[(this._get(inst,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");if(inst.input&&inst.input[0].type!="hidden"&&inst==$.datepicker._curInst){$(inst.input[0]).focus()}},_checkOffset:function(inst,offset,isFixed){var dpWidth=inst.dpDiv.outerWidth();var dpHeight=inst.dpDiv.outerHeight();var inputWidth=inst.input?inst.input.outerWidth():0;var inputHeight=inst.input?inst.input.outerHeight():0;var viewWidth=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)+$(document).scrollLeft();var viewHeight=(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)+$(document).scrollTop();offset.left-=(this._get(inst,"isRTL")?(dpWidth-inputWidth):0);offset.left-=(isFixed&&offset.left==inst.input.offset().left)?$(document).scrollLeft():0;offset.top-=(isFixed&&offset.top==(inst.input.offset().top+inputHeight))?$(document).scrollTop():0;offset.left-=(offset.left+dpWidth>viewWidth&&viewWidth>dpWidth)?Math.abs(offset.left+dpWidth-viewWidth):0;offset.top-=(offset.top+dpHeight>viewHeight&&viewHeight>dpHeight)?Math.abs(offset.top+dpHeight+inputHeight*2-viewHeight):0;return offset},_findPos:function(obj){while(obj&&(obj.type=="hidden"||obj.nodeType!=1)){obj=obj.nextSibling}var position=$(obj).offset();return[position.left,position.top]},_hideDatepicker:function(input,duration){var inst=this._curInst;if(!inst||(input&&inst!=$.data(input,PROP_NAME))){return}if(inst.stayOpen){this._selectDate("#"+inst.id,this._formatDate(inst,inst.currentDay,inst.currentMonth,inst.currentYear))}inst.stayOpen=false;if(this._datepickerShowing){duration=(duration!=null?duration:this._get(inst,"duration"));var showAnim=this._get(inst,"showAnim");var postProcess=function(){$.datepicker._tidyDialog(inst)};if(duration!=""&&$.effects&&$.effects[showAnim]){inst.dpDiv.hide(showAnim,$.datepicker._get(inst,"showOptions"),duration,postProcess)}else{inst.dpDiv[(duration==""?"hide":(showAnim=="slideDown"?"slideUp":(showAnim=="fadeIn"?"fadeOut":"hide")))](duration,postProcess)}if(duration==""){this._tidyDialog(inst)}var onClose=this._get(inst,"onClose");if(onClose){onClose.apply((inst.input?inst.input[0]:null),[(inst.input?inst.input.val():""),inst])}this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",left:"0",top:"-100px"});if($.blockUI){$.unblockUI();$("body").append(this.dpDiv)}}this._inDialog=false}this._curInst=null},_tidyDialog:function(inst){inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(event){if(!$.datepicker._curInst){return}var $target=$(event.target);if(($target.parents("#"+$.datepicker._mainDivId).length==0)&&!$target.hasClass($.datepicker.markerClassName)&&!$target.hasClass($.datepicker._triggerClass)&&$.datepicker._datepickerShowing&&!($.datepicker._inDialog&&$.blockUI)){$.datepicker._hideDatepicker(null,"")}},_adjustDate:function(id,offset,period){var target=$(id);var inst=this._getInst(target[0]);if(this._isDisabledDatepicker(target[0])){return}this._adjustInstDate(inst,offset+(period=="M"?this._get(inst,"showCurrentAtPos"):0),period);this._updateDatepicker(inst)},_gotoToday:function(id){var target=$(id);var inst=this._getInst(target[0]);if(this._get(inst,"gotoCurrent")&&inst.currentDay){inst.selectedDay=inst.currentDay;inst.drawMonth=inst.selectedMonth=inst.currentMonth;inst.drawYear=inst.selectedYear=inst.currentYear}else{var date=new Date();inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear()}this._notifyChange(inst);this._adjustDate(target)},_selectMonthYear:function(id,select,period){var target=$(id);var inst=this._getInst(target[0]);inst._selectingMonthYear=false;inst["selected"+(period=="M"?"Month":"Year")]=inst["draw"+(period=="M"?"Month":"Year")]=parseInt(select.options[select.selectedIndex].value,10);this._notifyChange(inst);this._adjustDate(target)},_clickMonthYear:function(id){var target=$(id);var inst=this._getInst(target[0]);if(inst.input&&inst._selectingMonthYear&&!$.browser.msie){inst.input[0].focus()}inst._selectingMonthYear=!inst._selectingMonthYear},_selectDay:function(id,month,year,td){var target=$(id);if($(td).hasClass(this._unselectableClass)||this._isDisabledDatepicker(target[0])){return}var inst=this._getInst(target[0]);inst.selectedDay=inst.currentDay=$("a",td).html();inst.selectedMonth=inst.currentMonth=month;inst.selectedYear=inst.currentYear=year;if(inst.stayOpen){inst.endDay=inst.endMonth=inst.endYear=null}this._selectDate(id,this._formatDate(inst,inst.currentDay,inst.currentMonth,inst.currentYear));if(inst.stayOpen){inst.rangeStart=this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay));this._updateDatepicker(inst)}},_clearDate:function(id){var target=$(id);var inst=this._getInst(target[0]);inst.stayOpen=false;inst.endDay=inst.endMonth=inst.endYear=inst.rangeStart=null;this._selectDate(target,"")},_selectDate:function(id,dateStr){var target=$(id);var inst=this._getInst(target[0]);dateStr=(dateStr!=null?dateStr:this._formatDate(inst));if(inst.input){inst.input.val(dateStr)}this._updateAlternate(inst);var onSelect=this._get(inst,"onSelect");if(onSelect){onSelect.apply((inst.input?inst.input[0]:null),[dateStr,inst])}else{if(inst.input){inst.input.trigger("change")}}if(inst.inline){this._updateDatepicker(inst)}else{if(!inst.stayOpen){this._hideDatepicker(null,this._get(inst,"duration"));this._lastInput=inst.input[0];if(typeof(inst.input[0])!="object"){inst.input[0].focus()}this._lastInput=null}}},_updateAlternate:function(inst){var altField=this._get(inst,"altField");if(altField){var altFormat=this._get(inst,"altFormat")||this._get(inst,"dateFormat");var date=this._getDate(inst);dateStr=this.formatDate(altFormat,date,this._getFormatConfig(inst));$(altField).each(function(){$(this).val(dateStr)})}},noWeekends:function(date){var day=date.getDay();return[(day>0&&day<6),""]},iso8601Week:function(date){var checkDate=new Date(date.getFullYear(),date.getMonth(),date.getDate());var firstMon=new Date(checkDate.getFullYear(),1-1,4);var firstDay=firstMon.getDay()||7;firstMon.setDate(firstMon.getDate()+1-firstDay);if(firstDay<4&&checkDate<firstMon){checkDate.setDate(checkDate.getDate()-3);return $.datepicker.iso8601Week(checkDate)}else{if(checkDate>new Date(checkDate.getFullYear(),12-1,28)){firstDay=new Date(checkDate.getFullYear()+1,1-1,4).getDay()||7;if(firstDay>4&&(checkDate.getDay()||7)<firstDay-3){return 1}}}return Math.floor(((checkDate-firstMon)/86400000)/7)+1},parseDate:function(format,value,settings){if(format==null||value==null){throw"Invalid arguments"}value=(typeof value=="object"?value.toString():value+"");if(value==""){return null}var shortYearCutoff=(settings?settings.shortYearCutoff:null)||this._defaults.shortYearCutoff;var dayNamesShort=(settings?settings.dayNamesShort:null)||this._defaults.dayNamesShort;var dayNames=(settings?settings.dayNames:null)||this._defaults.dayNames;var monthNamesShort=(settings?settings.monthNamesShort:null)||this._defaults.monthNamesShort;var monthNames=(settings?settings.monthNames:null)||this._defaults.monthNames;var year=-1;var month=-1;var day=-1;var doy=-1;var literal=false;var lookAhead=function(match){var matches=(iFormat+1<format.length&&format.charAt(iFormat+1)==match);if(matches){iFormat++}return matches};var getNumber=function(match){lookAhead(match);var origSize=(match=="@"?14:(match=="y"?4:(match=="o"?3:2)));var size=origSize;var num=0;while(size>0&&iValue<value.length&&value.charAt(iValue)>="0"&&value.charAt(iValue)<="9"){num=num*10+parseInt(value.charAt(iValue++),10);size--}if(size==origSize){throw"Missing number at position "+iValue}return num};var getName=function(match,shortNames,longNames){var names=(lookAhead(match)?longNames:shortNames);var size=0;for(var j=0;j<names.length;j++){size=Math.max(size,names[j].length)}var name="";var iInit=iValue;while(size>0&&iValue<value.length){name+=value.charAt(iValue++);for(var i=0;i<names.length;i++){if(name==names[i]){return i+1}}size--}throw"Unknown name at position "+iInit};var checkLiteral=function(){if(value.charAt(iValue)!=format.charAt(iFormat)){throw"Unexpected literal at position "+iValue}iValue++};var iValue=0;for(var iFormat=0;iFormat<format.length;iFormat++){if(literal){if(format.charAt(iFormat)=="'"&&!lookAhead("'")){literal=false}else{checkLiteral()}}else{switch(format.charAt(iFormat)){case"d":day=getNumber("d");break;case"D":getName("D",dayNamesShort,dayNames);break;case"o":doy=getNumber("o");break;case"m":month=getNumber("m");break;case"M":month=getName("M",monthNamesShort,monthNames);break;case"y":year=getNumber("y");break;case"@":var date=new Date(getNumber("@"));year=date.getFullYear();month=date.getMonth()+1;day=date.getDate();break;case"'":if(lookAhead("'")){checkLiteral()}else{literal=true}break;default:checkLiteral()}}}if(year==-1){year=new Date().getFullYear()}else{if(year<100){year+=new Date().getFullYear()-new Date().getFullYear()%100+(year<=shortYearCutoff?0:-100)}}if(doy>-1){month=1;day=doy;do{var dim=this._getDaysInMonth(year,month-1);if(day<=dim){break}month++;day-=dim}while(true)}var date=this._daylightSavingAdjust(new Date(year,month-1,day));if(date.getFullYear()!=year||date.getMonth()+1!=month||date.getDate()!=day){throw"Invalid date"}return date},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TIMESTAMP:"@",W3C:"yy-mm-dd",formatDate:function(format,date,settings){if(!date){return""}var dayNamesShort=(settings?settings.dayNamesShort:null)||this._defaults.dayNamesShort;var dayNames=(settings?settings.dayNames:null)||this._defaults.dayNames;var monthNamesShort=(settings?settings.monthNamesShort:null)||this._defaults.monthNamesShort;var monthNames=(settings?settings.monthNames:null)||this._defaults.monthNames;var lookAhead=function(match){var matches=(iFormat+1<format.length&&format.charAt(iFormat+1)==match);if(matches){iFormat++}return matches};var formatNumber=function(match,value,len){var num=""+value;if(lookAhead(match)){while(num.length<len){num="0"+num}}return num};var formatName=function(match,value,shortNames,longNames){return(lookAhead(match)?longNames[value]:shortNames[value])};var output="";var literal=false;if(date){for(var iFormat=0;iFormat<format.length;iFormat++){if(literal){if(format.charAt(iFormat)=="'"&&!lookAhead("'")){literal=false}else{output+=format.charAt(iFormat)}}else{switch(format.charAt(iFormat)){case"d":output+=formatNumber("d",date.getDate(),2);break;case"D":output+=formatName("D",date.getDay(),dayNamesShort,dayNames);break;case"o":var doy=date.getDate();for(var m=date.getMonth()-1;m>=0;m--){doy+=this._getDaysInMonth(date.getFullYear(),m)}output+=formatNumber("o",doy,3);break;case"m":output+=formatNumber("m",date.getMonth()+1,2);break;case"M":output+=formatName("M",date.getMonth(),monthNamesShort,monthNames);break;case"y":output+=(lookAhead("y")?date.getFullYear():(date.getYear()%100<10?"0":"")+date.getYear()%100);break;case"@":output+=date.getTime();break;case"'":if(lookAhead("'")){output+="'"}else{literal=true}break;default:output+=format.charAt(iFormat)}}}}return output},_possibleChars:function(format){var chars="";var literal=false;for(var iFormat=0;iFormat<format.length;iFormat++){if(literal){if(format.charAt(iFormat)=="'"&&!lookAhead("'")){literal=false}else{chars+=format.charAt(iFormat)}}else{switch(format.charAt(iFormat)){case"d":case"m":case"y":case"@":chars+="0123456789";break;case"D":case"M":return null;case"'":if(lookAhead("'")){chars+="'"}else{literal=true}break;default:chars+=format.charAt(iFormat)}}}return chars},_get:function(inst,name){return inst.settings[name]!==undefined?inst.settings[name]:this._defaults[name]},_setDateFromField:function(inst){var dateFormat=this._get(inst,"dateFormat");var dates=inst.input?inst.input.val():null;inst.endDay=inst.endMonth=inst.endYear=null;var date=defaultDate=this._getDefaultDate(inst);var settings=this._getFormatConfig(inst);try{date=this.parseDate(dateFormat,dates,settings)||defaultDate}catch(event){this.log(event);date=defaultDate}inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear();inst.currentDay=(dates?date.getDate():0);inst.currentMonth=(dates?date.getMonth():0);inst.currentYear=(dates?date.getFullYear():0);this._adjustInstDate(inst)},_getDefaultDate:function(inst){var date=this._determineDate(this._get(inst,"defaultDate"),new Date());var minDate=this._getMinMaxDate(inst,"min",true);var maxDate=this._getMinMaxDate(inst,"max");date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);return date},_determineDate:function(date,defaultDate){var offsetNumeric=function(offset){var date=new Date();date.setDate(date.getDate()+offset);return date};var offsetString=function(offset,getDaysInMonth){var date=new Date();var year=date.getFullYear();var month=date.getMonth();var day=date.getDate();var pattern=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;var matches=pattern.exec(offset);while(matches){switch(matches[2]||"d"){case"d":case"D":day+=parseInt(matches[1],10);break;case"w":case"W":day+=parseInt(matches[1],10)*7;break;case"m":case"M":month+=parseInt(matches[1],10);day=Math.min(day,getDaysInMonth(year,month));break;case"y":case"Y":year+=parseInt(matches[1],10);day=Math.min(day,getDaysInMonth(year,month));break}matches=pattern.exec(offset)}return new Date(year,month,day)};date=(date==null?defaultDate:(typeof date=="string"?offsetString(date,this._getDaysInMonth):(typeof date=="number"?(isNaN(date)?defaultDate:offsetNumeric(date)):date)));date=(date&&date.toString()=="Invalid Date"?defaultDate:date);if(date){date.setHours(0);date.setMinutes(0);date.setSeconds(0);date.setMilliseconds(0)}return this._daylightSavingAdjust(date)},_daylightSavingAdjust:function(date){if(!date){return null}date.setHours(date.getHours()>12?date.getHours()+2:0);return date},_setDate:function(inst,date,endDate){var clear=!(date);var origMonth=inst.selectedMonth;var origYear=inst.selectedYear;date=this._determineDate(date,new Date());inst.selectedDay=inst.currentDay=date.getDate();inst.drawMonth=inst.selectedMonth=inst.currentMonth=date.getMonth();inst.drawYear=inst.selectedYear=inst.currentYear=date.getFullYear();if(origMonth!=inst.selectedMonth||origYear!=inst.selectedYear){this._notifyChange(inst)}this._adjustInstDate(inst);if(inst.input){inst.input.val(clear?"":this._formatDate(inst))}},_getDate:function(inst){var startDate=(!inst.currentYear||(inst.input&&inst.input.val()=="")?null:this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));return startDate},_generateHTML:function(inst){var today=new Date();today=this._daylightSavingAdjust(new Date(today.getFullYear(),today.getMonth(),today.getDate()));var isRTL=this._get(inst,"isRTL");var showButtonPanel=this._get(inst,"showButtonPanel");var hideIfNoPrevNext=this._get(inst,"hideIfNoPrevNext");var navigationAsDateFormat=this._get(inst,"navigationAsDateFormat");var numMonths=this._getNumberOfMonths(inst);var showCurrentAtPos=this._get(inst,"showCurrentAtPos");var stepMonths=this._get(inst,"stepMonths");var stepBigMonths=this._get(inst,"stepBigMonths");var isMultiMonth=(numMonths[0]!=1||numMonths[1]!=1);var currentDate=this._daylightSavingAdjust((!inst.currentDay?new Date(9999,9,9):new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));var minDate=this._getMinMaxDate(inst,"min",true);var maxDate=this._getMinMaxDate(inst,"max");var drawMonth=inst.drawMonth-showCurrentAtPos;var drawYear=inst.drawYear;if(drawMonth<0){drawMonth+=12;drawYear--}if(maxDate){var maxDraw=this._daylightSavingAdjust(new Date(maxDate.getFullYear(),maxDate.getMonth()-numMonths[1]+1,maxDate.getDate()));maxDraw=(minDate&&maxDraw<minDate?minDate:maxDraw);while(this._daylightSavingAdjust(new Date(drawYear,drawMonth,1))>maxDraw){drawMonth--;if(drawMonth<0){drawMonth=11;drawYear--}}}inst.drawMonth=drawMonth;inst.drawYear=drawYear;var prevText=this._get(inst,"prevText");prevText=(!navigationAsDateFormat?prevText:this.formatDate(prevText,this._daylightSavingAdjust(new Date(drawYear,drawMonth-stepMonths,1)),this._getFormatConfig(inst)));var prev=(this._canAdjustMonth(inst,-1,drawYear,drawMonth)?'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#'+inst.id+"', -"+stepMonths+", 'M');\" title=\""+prevText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?"e":"w")+'">'+prevText+"</span></a>":(hideIfNoPrevNext?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+prevText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?"e":"w")+'">'+prevText+"</span></a>"));var nextText=this._get(inst,"nextText");nextText=(!navigationAsDateFormat?nextText:this.formatDate(nextText,this._daylightSavingAdjust(new Date(drawYear,drawMonth+stepMonths,1)),this._getFormatConfig(inst)));var next=(this._canAdjustMonth(inst,+1,drawYear,drawMonth)?'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#'+inst.id+"', +"+stepMonths+", 'M');\" title=\""+nextText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?"w":"e")+'">'+nextText+"</span></a>":(hideIfNoPrevNext?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+nextText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?"w":"e")+'">'+nextText+"</span></a>"));var currentText=this._get(inst,"currentText");var gotoDate=(this._get(inst,"gotoCurrent")&&inst.currentDay?currentDate:today);currentText=(!navigationAsDateFormat?currentText:this.formatDate(currentText,gotoDate,this._getFormatConfig(inst)));var controls=(!inst.inline?'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery.datepicker._hideDatepicker();">'+this._get(inst,"closeText")+"</button>":"");var buttonPanel=(showButtonPanel)?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(isRTL?controls:"")+(this._isInRange(inst,gotoDate)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery.datepicker._gotoToday(\'#'+inst.id+"');\">"+currentText+"</button>":"")+(isRTL?"":controls)+"</div>":"";var firstDay=parseInt(this._get(inst,"firstDay"),10);firstDay=(isNaN(firstDay)?0:firstDay);var dayNames=this._get(inst,"dayNames");var dayNamesShort=this._get(inst,"dayNamesShort");var dayNamesMin=this._get(inst,"dayNamesMin");var monthNames=this._get(inst,"monthNames");var monthNamesShort=this._get(inst,"monthNamesShort");var beforeShowDay=this._get(inst,"beforeShowDay");var showOtherMonths=this._get(inst,"showOtherMonths");var calculateWeek=this._get(inst,"calculateWeek")||this.iso8601Week;var endDate=inst.endDay?this._daylightSavingAdjust(new Date(inst.endYear,inst.endMonth,inst.endDay)):currentDate;var defaultDate=this._getDefaultDate(inst);var html="";for(var row=0;row<numMonths[0];row++){var group="";for(var col=0;col<numMonths[1];col++){var selectedDate=this._daylightSavingAdjust(new Date(drawYear,drawMonth,inst.selectedDay));var cornerClass=" ui-corner-all";var calender="";if(isMultiMonth){calender+='<div class="ui-datepicker-group ui-datepicker-group-';switch(col){case 0:calender+="first";cornerClass=" ui-corner-"+(isRTL?"right":"left");break;case numMonths[1]-1:calender+="last";cornerClass=" ui-corner-"+(isRTL?"left":"right");break;default:calender+="middle";cornerClass="";break}calender+='">'}calender+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+cornerClass+'">'+(/all|left/.test(cornerClass)&&row==0?(isRTL?next:prev):"")+(/all|right/.test(cornerClass)&&row==0?(isRTL?prev:next):"")+this._generateMonthYearHeader(inst,drawMonth,drawYear,minDate,maxDate,selectedDate,row>0||col>0,monthNames,monthNamesShort)+'</div><table class="ui-datepicker-calendar"><thead><tr>';var thead="";for(var dow=0;dow<7;dow++){var day=(dow+firstDay)%7;thead+="<th"+((dow+firstDay+6)%7>=5?' class="ui-datepicker-week-end"':"")+'><span title="'+dayNames[day]+'">'+dayNamesMin[day]+"</span></th>"}calender+=thead+"</tr></thead><tbody>";var daysInMonth=this._getDaysInMonth(drawYear,drawMonth);if(drawYear==inst.selectedYear&&drawMonth==inst.selectedMonth){inst.selectedDay=Math.min(inst.selectedDay,daysInMonth)}var leadDays=(this._getFirstDayOfMonth(drawYear,drawMonth)-firstDay+7)%7;var numRows=(isMultiMonth?6:Math.ceil((leadDays+daysInMonth)/7));var printDate=this._daylightSavingAdjust(new Date(drawYear,drawMonth,1-leadDays));for(var dRow=0;dRow<numRows;dRow++){calender+="<tr>";var tbody="";for(var dow=0;dow<7;dow++){var daySettings=(beforeShowDay?beforeShowDay.apply((inst.input?inst.input[0]:null),[printDate]):[true,""]);var otherMonth=(printDate.getMonth()!=drawMonth);var unselectable=otherMonth||!daySettings[0]||(minDate&&printDate<minDate)||(maxDate&&printDate>maxDate);tbody+='<td class="'+((dow+firstDay+6)%7>=5?" ui-datepicker-week-end":"")+(otherMonth?" ui-datepicker-other-month":"")+((printDate.getTime()==selectedDate.getTime()&&drawMonth==inst.selectedMonth&&inst._keyEvent)||(defaultDate.getTime()==printDate.getTime()&&defaultDate.getTime()==selectedDate.getTime())?" "+this._dayOverClass:"")+(unselectable?" "+this._unselectableClass+" ui-state-disabled":"")+(otherMonth&&!showOtherMonths?"":" "+daySettings[1]+(printDate.getTime()>=currentDate.getTime()&&printDate.getTime()<=endDate.getTime()?" "+this._currentClass:"")+(printDate.getTime()==today.getTime()?" ui-datepicker-today":""))+'"'+((!otherMonth||showOtherMonths)&&daySettings[2]?' title="'+daySettings[2]+'"':"")+(unselectable?"":" onclick=\"DP_jQuery.datepicker._selectDay('#"+inst.id+"',"+drawMonth+","+drawYear+', this);return false;"')+">"+(otherMonth?(showOtherMonths?printDate.getDate():"&#xa0;"):(unselectable?'<span class="ui-state-default">'+printDate.getDate()+"</span>":'<a class="ui-state-default'+(printDate.getTime()==today.getTime()?" ui-state-highlight":"")+(printDate.getTime()>=currentDate.getTime()&&printDate.getTime()<=endDate.getTime()?" ui-state-active":"")+'" href="#">'+printDate.getDate()+"</a>"))+"</td>";printDate.setDate(printDate.getDate()+1);printDate=this._daylightSavingAdjust(printDate)}calender+=tbody+"</tr>"}drawMonth++;if(drawMonth>11){drawMonth=0;drawYear++}calender+="</tbody></table>"+(isMultiMonth?"</div>"+((numMonths[0]>0&&col==numMonths[1]-1)?'<div class="ui-datepicker-row-break"></div>':""):"");group+=calender}html+=group}html+=buttonPanel+($.browser.msie&&parseInt($.browser.version,10)<7&&!inst.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':"");inst._keyEvent=false;return html},_generateMonthYearHeader:function(inst,drawMonth,drawYear,minDate,maxDate,selectedDate,secondary,monthNames,monthNamesShort){minDate=(inst.rangeStart&&minDate&&selectedDate<minDate?selectedDate:minDate);var changeMonth=this._get(inst,"changeMonth");var changeYear=this._get(inst,"changeYear");var showMonthAfterYear=this._get(inst,"showMonthAfterYear");var html='<div class="ui-datepicker-title">';var monthHtml="";if(secondary||!changeMonth){monthHtml+='<span class="ui-datepicker-month">'+monthNames[drawMonth]+"</span> "}else{var inMinYear=(minDate&&minDate.getFullYear()==drawYear);var inMaxYear=(maxDate&&maxDate.getFullYear()==drawYear);monthHtml+='<select class="ui-datepicker-month" onchange="DP_jQuery.datepicker._selectMonthYear(\'#'+inst.id+"', this, 'M');\" onclick=\"DP_jQuery.datepicker._clickMonthYear('#"+inst.id+"');\">";for(var month=0;month<12;month++){if((!inMinYear||month>=minDate.getMonth())&&(!inMaxYear||month<=maxDate.getMonth())){monthHtml+='<option value="'+month+'"'+(month==drawMonth?' selected="selected"':"")+">"+monthNamesShort[month]+"</option>"}}monthHtml+="</select>"}if(!showMonthAfterYear){html+=monthHtml+((secondary||changeMonth||changeYear)&&(!(changeMonth&&changeYear))?"&#xa0;":"")}if(secondary||!changeYear){html+='<span class="ui-datepicker-year">'+drawYear+"</span>"}else{var years=this._get(inst,"yearRange").split(":");var year=0;var endYear=0;if(years.length!=2){year=drawYear-10;endYear=drawYear+10}else{if(years[0].charAt(0)=="+"||years[0].charAt(0)=="-"){year=drawYear+parseInt(years[0],10);endYear=drawYear+parseInt(years[1],10)}else{year=parseInt(years[0],10);endYear=parseInt(years[1],10)}}year=(minDate?Math.max(year,minDate.getFullYear()):year);endYear=(maxDate?Math.min(endYear,maxDate.getFullYear()):endYear);html+='<select class="ui-datepicker-year" onchange="DP_jQuery.datepicker._selectMonthYear(\'#'+inst.id+"', this, 'Y');\" onclick=\"DP_jQuery.datepicker._clickMonthYear('#"+inst.id+"');\">";for(;year<=endYear;year++){html+='<option value="'+year+'"'+(year==drawYear?' selected="selected"':"")+">"+year+"</option>"}html+="</select>"}if(showMonthAfterYear){html+=(secondary||changeMonth||changeYear?"&#xa0;":"")+monthHtml}html+="</div>";return html},_adjustInstDate:function(inst,offset,period){var year=inst.drawYear+(period=="Y"?offset:0);var month=inst.drawMonth+(period=="M"?offset:0);var day=Math.min(inst.selectedDay,this._getDaysInMonth(year,month))+(period=="D"?offset:0);var date=this._daylightSavingAdjust(new Date(year,month,day));var minDate=this._getMinMaxDate(inst,"min",true);var maxDate=this._getMinMaxDate(inst,"max");date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear();if(period=="M"||period=="Y"){this._notifyChange(inst)}},_notifyChange:function(inst){var onChange=this._get(inst,"onChangeMonthYear");if(onChange){onChange.apply((inst.input?inst.input[0]:null),[inst.selectedYear,inst.selectedMonth+1,inst])}},_getNumberOfMonths:function(inst){var numMonths=this._get(inst,"numberOfMonths");return(numMonths==null?[1,1]:(typeof numMonths=="number"?[1,numMonths]:numMonths))},_getMinMaxDate:function(inst,minMax,checkRange){var date=this._determineDate(this._get(inst,minMax+"Date"),null);return(!checkRange||!inst.rangeStart?date:(!date||inst.rangeStart>date?inst.rangeStart:date))},_getDaysInMonth:function(year,month){return 32-new Date(year,month,32).getDate()},_getFirstDayOfMonth:function(year,month){return new Date(year,month,1).getDay()},_canAdjustMonth:function(inst,offset,curYear,curMonth){var numMonths=this._getNumberOfMonths(inst);var date=this._daylightSavingAdjust(new Date(curYear,curMonth+(offset<0?offset:numMonths[1]),1));if(offset<0){date.setDate(this._getDaysInMonth(date.getFullYear(),date.getMonth()))}return this._isInRange(inst,date)},_isInRange:function(inst,date){var newMinDate=(!inst.rangeStart?null:this._daylightSavingAdjust(new Date(inst.selectedYear,inst.selectedMonth,inst.selectedDay)));newMinDate=(newMinDate&&inst.rangeStart<newMinDate?inst.rangeStart:newMinDate);var minDate=newMinDate||this._getMinMaxDate(inst,"min");var maxDate=this._getMinMaxDate(inst,"max");return((!minDate||date>=minDate)&&(!maxDate||date<=maxDate))},_getFormatConfig:function(inst){var shortYearCutoff=this._get(inst,"shortYearCutoff");shortYearCutoff=(typeof shortYearCutoff!="string"?shortYearCutoff:new Date().getFullYear()%100+parseInt(shortYearCutoff,10));return{shortYearCutoff:shortYearCutoff,dayNamesShort:this._get(inst,"dayNamesShort"),dayNames:this._get(inst,"dayNames"),monthNamesShort:this._get(inst,"monthNamesShort"),monthNames:this._get(inst,"monthNames")}},_formatDate:function(inst,day,month,year){if(!day){inst.currentDay=inst.selectedDay;inst.currentMonth=inst.selectedMonth;inst.currentYear=inst.selectedYear}var date=(day?(typeof day=="object"?day:this._daylightSavingAdjust(new Date(year,month,day))):this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));return this.formatDate(this._get(inst,"dateFormat"),date,this._getFormatConfig(inst))}});function extendRemove(target,props){$.extend(target,props);for(var name in props){if(props[name]==null||props[name]==undefined){target[name]=props[name]}}return target}function isArray(a){return(a&&(($.browser.safari&&typeof a=="object"&&a.length)||(a.constructor&&a.constructor.toString().match(/\Array\(\)/))))}$.fn.datepicker=function(options){if(!$.datepicker.initialized){$(document).mousedown($.datepicker._checkExternalClick).find("body").append($.datepicker.dpDiv);$.datepicker.initialized=true}var otherArgs=Array.prototype.slice.call(arguments,1);if(typeof options=="string"&&(options=="isDisabled"||options=="getDate")){return $.datepicker["_"+options+"Datepicker"].apply($.datepicker,[this[0]].concat(otherArgs))}if(options=="option"&&arguments.length==2&&typeof arguments[1]=="string"){return $.datepicker["_"+options+"Datepicker"].apply($.datepicker,[this[0]].concat(otherArgs))}return this.each(function(){typeof options=="string"?$.datepicker["_"+options+"Datepicker"].apply($.datepicker,[this].concat(otherArgs)):$.datepicker._attachDatepicker(this,options)})};$.datepicker=new Datepicker();$.datepicker.initialized=false;$.datepicker.uuid=new Date().getTime();$.datepicker.version="1.7.2";window.DP_jQuery=$})(jQuery);;
 _xDisplay = {
displayComments:function(response, p_sIsTypeYesNo){
 var l_sPLK_Final_Template = "";
 var l_sPLKYesTemplate = '';
//get type of comment, yes or no.
 var p_nType = p_sIsTypeYesNo.split(g_sDelimiter);
 //iterate to all comments received in the response
 //Pickup Appropriate div, either yes or no
if(p_nType[2] == 1){
l_sPLKYesTemplate = $('#plk_comments_yes_template').html();
}
if(p_nType[2] == 0){
l_sPLKYesTemplate = $('#plk_comments_no_template').html();
}
//Check if comments exist, addup comments.
if(document._xPluckIsNotPagination){
var l_nTotalComments = parseInt(document._xPluckCommentCount) + parseInt(response.NumberOfComments);
document._xPluckCommentCount = l_nTotalComments;
$('#plck-comment-count').removeClass("plck-comment-count-class").addClass("commentcount");
$('#plck-comment-count').html(l_nTotalComments);
}
 
var i = 0;
for(i = 0; i < response.Comments.length; i++){
var l_sTemplate = '';
var l_sTemplate = l_sPLKYesTemplate.toString();
//get commentData object
var commentData = response.Comments[i];
//Additional css to first comment only
if(i == 0){
 l_sTemplate = l_sTemplate.replace(/~extraclass~/, "comment_first");
 }
 if(i > 0){
 l_sTemplate = l_sTemplate.replace(/~extraclass~/, "");
 }
 
l_sTemplate = l_sTemplate.replace(/~fire-up-id~/, "fireup-"+i);
 //break date time to place in appropriate html
 var l_sPostDateTime = commentData.PostedAtTime;
 var l_aPostDateTime = l_sPostDateTime.split(" ");
 var l_sCommentTime = l_aPostDateTime[1].substring(0, l_aPostDateTime[1].length - 3); 
 l_sTemplate = l_sTemplate.replace(/~byline~/,"By <a href=" + commentData.Author.PersonaUrl + ">" + commentData.Author.DisplayName + "</a> @ <span>" + l_aPostDateTime[0] + "</span> at " + l_sCommentTime +"" + l_aPostDateTime[2].toLowerCase() );
 l_sTemplate = l_sTemplate.replace(/~comment~/,commentData.CommentBody);
 
 //Check if user has already flagged
 if(commentData.CurrentUserHasReportedAbuse == 'True'){
 l_sTemplate = l_sTemplate.replace(/~extraclass-flag-selected~/, "sprite_selected");
 l_sTemplate = l_sTemplate.replace(/~flag-a-tag~/,"<a href='javascript:void(0)' onclick=''/>");
}else{
l_sTemplate = l_sTemplate.replace(/~extraclass-flag-selected~/, "");
l_sTemplate = l_sTemplate.replace(/~flag-a-tag~/,"<a href='javascript:void(0)' onclick='javascript:reportAbuse(\"" + commentData.CommentKey.Key + "\", \"comment\", \"comment\", \"comment\", this);'/>");
 }
 
 //check if user has already recommended
 if(commentData.CurrentUserHasRecommended == 'True'){
 l_sTemplate = l_sTemplate.replace(/~extraclass-fireup-selected~/, "sprite_selected");
 l_sTemplate = l_sTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick=''/>");
 }else{
 l_sTemplate = l_sTemplate.replace(/~extraclass-fireup-selected~/, "");
 l_sTemplate = l_sTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick='javascript:recommend(\"" + commentData.CommentKey.Key + "\", \"comment\", this);'/>");
 }
 
 
 //append current changes to final template
 l_sPLK_Final_Template += l_sTemplate;
}
//select appropriate div and place final template data
 
if(p_nType[2] == 1){
$('#plk_comments_yes_template_final').html(l_sPLK_Final_Template);
}
if(p_nType[2] == 0){
$('#plk_comments_no_template_final').html(l_sPLK_Final_Template);
}
//pagination for comments
if(response.NumberOfComments > 2){
if(parseInt(response.NumberOfComments) > parseInt(response.NumberPerPage)){
 l_aPaginationInfo = _xPagination.modComments(response.OnPage, response.NumberOfComments, response.NumberPerPage, response.ArticleKey.Key, "getComments");
 
l_sPaginationTemplate = $('#plck_pagi_'+p_nType[2]).html();
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-left~/,"<div class= 'mod_pagination_left sprite " + l_aPaginationInfo['left_class'] + "'><a " + l_aPaginationInfo['left_string'] +"><span>Left</span></a></div>"); 
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-right~/,"<div class= 'mod_pagination_right sprite" + l_aPaginationInfo['right_class'] + "'><a " + l_aPaginationInfo['right_string'] + "><span>Right</span></a></div>");
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~page-numbers~/, "" + l_aPaginationInfo['item_display'] + " of <b> " + l_aPaginationInfo['total_count'] + "</b>");
$('#plck_pagi_final_'+p_nType[2]).html(l_sPaginationTemplate);
}
}
},
BeTheFirstToComment:function(response, p_sIsTypeYesNo){
var p_nType = p_sIsTypeYesNo.split(g_sDelimiter);
if(p_nType[2] == 1){
$('#plk_comments_yes_template_final').html('<div class="no_comments"></div><div class="sprite befirst_comment"><a href="#addcomment"><span>Be the First</span></a></div>');
}
if(p_nType[2] == 0){
$('#plk_comments_no_template_final').html('<div class="no_comments"></div><div class="sprite befirst_comment"><a href="#addcomment"><span>Be the First</span></a></div>');
}
},

displayRecentFeedModule:function(feedActivity){
//initialize templates
var l_sPLKBaseTemplate = '';
var l_sPLKForumPostTemplate = '';
var l_sPLKBlogPostTemplate = '';
var l_sPLKForumDiscussionTemplate = '';
var l_sPLKPhotoTemplate = '';
var l_sVideoTemplate = '';
var l_sPLK_Final_Template = '';
//Pickup base template
l_sPLKBaseTemplate = $('#plck_feeds_base_template').html();
//check for number of activities
var feedIteration = feedActivity.NumberOfActivities
 //handle special case where number of activities per page is greater than the number of activities.
if((feedActivity.NumberPerPage) < (feedActivity.NumberOfActivities)){
//alert("no per page is less than no of activities");
var feedIteration = feedActivity.NumberPerPage;
 }

 for (var i = 0; i < feedActivity.GroupActivities.length; i++) {
//get all group activities from feeds
var activity = feedActivity.GroupActivities[i];
//get base template for each content type
var l_sTemplate = '';
var l_sTemplate = l_sPLKBaseTemplate.toString();
//replace url in image
l_sTemplate = l_sTemplate.replace(/plck-base-image/, activity.LiteUserResponse.ImageUrl);
//replace alt in image
l_sTemplate = l_sTemplate.replace(/~base-image-alt~/, activity.LiteUserResponse.DisplayName);
//accomodate html for different activity types
//calculate time uploaded
l_sTimeUploaded = getActivityTime(activity.ActivityDate); 
switch(activity.ActivityType){

case 'ForumPost':
var l_aTextInfo = { c:'000000',type:'b','bg':'ffffff',tran:true,s:20,t: '"'+activity.Abstract+'"', w:410, 'bb':'9px' }
l_sForumQuote = makeCustomImage(l_aTextInfo);
l_sActivityTitle = activity.Title.replace("Re:", "");
l_sPLKForumPostTemplate = $("#plck_feeds_forum_post_template").html();
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/plck-forum-owner-url/, activity.LiteUserResponse.PersonaUrl);
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/~forum-owner-name~/, activity.LiteUserResponse.DisplayName);
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/~forum-activity~/, activity.ActivityAction);
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/plck-forum-group-url/, "");
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/~forum-group-title~/, l_sActivityTitle);
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/~forum-time~/, l_sTimeUploaded);
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/plck-forum-quote-image-text/, l_sForumQuote);
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/plck-forum-quote-text/, activity.Abstract);
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/plck-forum-url/, "");//activity.TargetKey
l_sPLKForumPostTemplate = l_sPLKForumPostTemplate.replace(/~forum-title~/, l_sActivityTitle);
l_sTemplate = l_sTemplate.replace(/~feeds-template-type~/, l_sPLKForumPostTemplate);
l_sPLK_Final_Template += l_sTemplate;
break;
case 'BlogPost':
var l_aTextInfo = { c:'000000',type:'b','bg':'ffffff',tran:true,s:20,t: '"'+activity.Abstract+'"', w:410, 'bb':'9px' }
l_sBlogQuote = makeCustomImage(l_aTextInfo);
l_sPLKBlogPostTemplate = $("#plck_feeds_blog_post_template").html();
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-blog-owner-url/, activity.LiteUserResponse.PersonaUrl);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~blog-owner-name~/, activity.LiteUserResponse.DisplayName);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~blog-activity~/, activity.ActivityAction);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-blog-group-url/, "");
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~blog-group-title~/, activity.Title);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~blog-time~/, l_sTimeUploaded);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-blog-quote-image-text/,l_sBlogQuote);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-blog-quote-text/,activity.Abstract);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~blog-title~/, activity.Title);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-blog-url/, "/community/blog/"+activity.TargetKey+"/");
l_sTemplate = l_sTemplate.replace(/~feeds-template-type~/, l_sPLKBlogPostTemplate);
l_sPLK_Final_Template += l_sTemplate;
break;
case 'ForumDiscussion':
l_sPLKForumDiscussionTemplate = $("#plck_feeds_discussion_template").html();
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/plck-discussion-owner-url/, activity.LiteUserResponse.PersonaUrl);
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/~discussion-owner-display-name~/, activity.LiteUserResponse.DisplayName);
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/~discussion-activity~/, activity.ActivityAction);
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/plck-discussion-group-url/, "");
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/~discussion-group-title~/, activity.Title);
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/~discussion-time~/, l_sTimeUploaded);
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/plck-discussion-url/, "");
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/~discussion-title~/, activity.Title);
l_sPLKForumDiscussionTemplate = l_sPLKForumDiscussionTemplate.replace(/~discussion-description~/, activity.Abstract);
l_sTemplate = l_sTemplate.replace(/~feeds-template-type~/, l_sPLKForumDiscussionTemplate);
l_sPLK_Final_Template += l_sTemplate;
break;
case 'Photo':
 l_sPLKPhotoTemplate = $("#plck_feeds_photo_template").html();
//_xCore.getPhotoDetail(activity.TargetKey);
//get gallery description
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-owner-url/, activity.LiteUserResponse.PersonaUrl);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photo-owner-display-name~/, activity.LiteUserResponse.DisplayName);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photo-activity~/, activity.ActivityAction);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-group-url/, "");
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photo-group-title~/, activity.Title);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photo-time~/, l_sTimeUploaded);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-thumbnail/, activity.Image.Medium);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-url-tnholder/, "/community/photo/"+activity.TargetKey+"/");
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-url/, "/community/photo/"+activity.TargetKey+"/");
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photo-title~/, activity.Title );
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photo-description~/, activity.Abstract);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photos-in-gallery~/, "");
l_sTemplate = l_sTemplate.replace(/~feeds-template-type~/, l_sPLKPhotoTemplate);
l_sPLK_Final_Template += l_sTemplate;
break;
case 'Video':
l_sPLKVideoTemplate = $("#plck_feeds_video_template").html();
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-owner-url/, activity.LiteUserResponse.PersonaUrl);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-owner-display-name~/, activity.LiteUserResponse.DisplayName);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-activity~/, activity.ActivityAction);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-group-url/, "");
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-group-title~/, activity.Title);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-time~/, l_sTimeUploaded);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-thumbnail/, activity.Image.Small);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-url-tnholder/, "/community/video/"+activity.TargetKey+"/");
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-url/, "/community/video/"+activity.TargetKey+"/");
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-title~/, activity.Title );
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-description~/, activity.Abstract);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-duration~/, "");
l_sTemplate = l_sTemplate.replace(/~feeds-template-type~/, l_sPLKVideoTemplate);
l_sPLK_Final_Template += l_sTemplate;
break;
case 'Event':
l_sEventTime = _xUtils.displayModifiedDate(activity.ActivityDate);
l_sPLKEventTemplate = $("#plck_feeds_events_template").html();
l_sPLKEventTemplate = l_sPLKEventTemplate.replace(/plck-events-owner-url/, activity.LiteUserResponse.PersonaUrl);
l_sPLKEventTemplate = l_sPLKEventTemplate.replace(/~events-owner-name~/, activity.LiteUserResponse.DisplayName);
l_sPLKEventTemplate = l_sPLKEventTemplate.replace(/~events-activity~/, activity.ActivityAction);
l_sPLKEventTemplate = l_sPLKEventTemplate.replace(/~events-time~/, l_sTimeUploaded);
l_sPLKEventTemplate = l_sPLKEventTemplate.replace(/~events-title~/, activity.Title);
l_sPLKEventTemplate = l_sPLKEventTemplate.replace(/~events-description~/, activity.Abstract);
l_sTemplate = l_sTemplate.replace(/~feeds-template-type~/, l_sPLKEventTemplate);
l_sPLK_Final_Template += l_sTemplate;
break;
case 'Comment':
l_sEventTime = _xUtils.displayModifiedDate(activity.ActivityDate);
l_sPLKCommentTemplate = $("#plck_feeds_comments_template").html();
l_sPLKCommentTemplate = l_sPLKCommentTemplate.replace(/plck-comments-owner-url/, activity.LiteUserResponse.PersonaUrl);
l_sPLKCommentTemplate = l_sPLKCommentTemplate.replace(/~comments-owner-name~/, activity.LiteUserResponse.DisplayName);
l_sPLKCommentTemplate = l_sPLKCommentTemplate.replace(/~comments-activity~/, activity.ActivityAction);
l_sPLKCommentTemplate = l_sPLKCommentTemplate.replace(/~comments-time~/, l_sTimeUploaded);
l_sPLKCommentTemplate = l_sPLKCommentTemplate.replace(/comments-description/, activity.Abstract);
l_sPLKCommentTemplate = l_sPLKCommentTemplate.replace(/~comments-title~/, activity.Title);
l_sTemplate = l_sTemplate.replace(/~feeds-template-type~/, l_sPLKCommentTemplate);
l_sPLK_Final_Template += l_sTemplate;
break;
}
}
 
$('#plck_feeds_template_final').html(l_sPLK_Final_Template); 
if((parseInt(feedActivity.NumberOfActivities)) > (parseInt(feedActivity.NumberPerPage))){
l_sPaginationTemplate = _xPagination.tallNumRecentFeed(feedActivity.OnPage, feedActivity.NumberOfActivities, feedActivity.NumberPerPage, feedActivity.CommunityGroupKey.Key, "_xCommunity.getRecentActivityFeedModule", 10);
$('#plck-pagination-final').html(l_sPaginationTemplate);
 }
}, 
displayNoContentImage: function(l_sDivId){
$('#'+l_sDivId).addClass("no_content");
switch(l_sDivId){
 case 'home_no_content':
 $('#plck-no-content-links').css("padding-left", "28px").html(
'<div class="be_first_photo sprite"><a href="javascript:void(0)" onclick="_xTruebox.makePopup(\'upload\',\'image\')"><span>Add Your Photos!</span></a></div>'+
'<div class="be_first_video sprite"><a href="javascript:void(0)" onclick="_xTruebox.makePopup(\'upload\',\'video\')"><span>Add Your Videos!</span></a></div>'+
'<div class="be_first_blog sprite"><a href="javascript:void(0)" onclick="_xTruebox.makePopup(\'create\',\'blog\')"><span>Create Your Blog!</span></a></div>'+
'<div class="be_first_event sprite"><a href="javascript:void(0)" onclick="_xTruebox.makePopup(\'create\',\'event\')"><span>Create an Event!</span></a></div>');
 break;
 case 'plck_picture_page_template_final':
 $('#plck-no-content-links').css("padding-left", "240px").html('<div class="be_first_photo sprite"><a href="javascript:void(0)" onclick="_xTruebox.makePopup(\'upload\',\'image\')"><span>Add Your Photos!</span></a></div>');
 break;
 case 'plck_video_page_template_final':
 $('#plck-no-content-links').css("padding-left", "240px").html('<div class="be_first_video sprite"><a href="javascript:void(0)" onclick="_xTruebox.makePopup(\'upload\',\'video\')"><span>Add Your Videos!</span></a></div>');
 break;
 case 'plck_events_page_template_upcoming_events_final':
 $('#plck-no-content-links').css("padding-left", "240px").html('<div class="be_first_event sprite"><a href="javascript:void(0)" onclick="_xTruebox.makePopup(\'create\',\'event\')"><span>Create an Event!</span></a></div>');
 break;
 case 'plck_blog_page_template_final':
 $('#plck-no-content-links').css("padding-left", "240px").html('<div class="be_first_blog sprite"><a href="javascript:void(0)" onclick="_xTruebox.makePopup(\'create\',\'blog\')"><span>Create Your Blog!</span></a></div>');
 break;
 
}
},

displayCommunityTabModule:function(l_sImageURL, l_sGroupTitle, l_sGroupDescription, l_sCommunityKey, l_sMembershipTier){
//imagify group title:
var l_aTextInfo = { c:'FFFFFF',type:'b','bg':'0F0F0F',tran:true,s:20,t: l_sGroupTitle, w:410, 'bb':'9px' }
l_sGroupTitleImage = makeCustomImage(l_aTextInfo);
//get grouptabmodule template
l_sPLKTabModuleTemplate = $('#plck_groups_tab_module_template').html();
//replace with data.
l_sPLKTabModuleTemplate = l_sPLKTabModuleTemplate.replace(/plck-groups-hero-img/, l_sImageURL.replace("Small", "Large"));
l_sPLKTabModuleTemplate = l_sPLKTabModuleTemplate.replace(/plck-generated-image-title/, l_sGroupTitleImage);
l_sPLKTabModuleTemplate = l_sPLKTabModuleTemplate.replace(/plck-group-title/, l_sGroupTitle);
l_sPLKTabModuleTemplate = l_sPLKTabModuleTemplate.replace(/~plck-group-description~/, l_sGroupDescription);
//jam into html

if(l_sMembershipTier == "NonMember"){
//get cookie, if cookie exists, get userkey
var l_sCurrentCookie = _xValidate.getCookie("at");
if(l_sCurrentCookie){
//get userkey from cookie
l_aCookieInfo = l_sCurrentCookie.split("%26");
l_aUserKey = l_aCookieInfo[0].split("=");
l_sUserKeyInfo = l_aUserKey[1];
l_sUserKeySplit = l_sUserKeyInfo.split("%3D");
l_sUserKey = l_sUserKeySplit[1];
l_sPLKTabModuleTemplate = l_sPLKTabModuleTemplate.replace(/~plck-join-button-div~/, "<div id = 'plck_jointhisgroup' class = 'sprite btn_jointhisgroup'><a onclick= 'javascript:_xCore.requestCommunityGroupMembership(\"" + l_sCommunityKey + "\", \"" + l_sUserKey + "\");'><span>Join This Group</span></a></div>");
} else{
l_sPLKTabModuleTemplate = l_sPLKTabModuleTemplate.replace(/~plck-join-button-div~/,"");
}
}else{
 l_sPLKTabModuleTemplate = l_sPLKTabModuleTemplate.replace(/~plck-join-button-div~/,"");
}
$('#plck_groups_tab_module_template_final').html(l_sPLKTabModuleTemplate);
},
displayCommunityBadgeModule:function(l_nMemberCount, l_sType){
var l_sPLKBadgeModuleTemplate = '';
var l_sGroupBadgeCount = '';
//get badge template:
l_sPLKBadgeModuleTemplate = $('#plck-badge-count-template').html();
l_aMemberCount = l_nMemberCount.split("");
//l_sGroupBadgeCount = l_sPLKBadgeModuleTemplate.replace(/~group-badge-count-image~/, "<img src='/image/groups_badge_num_" + l_aMemberCount[i] + ".gif?v=213)' alt='"+ l_aMemberCount[i] + "' />"
if(l_aMemberCount.length == 0){
 l_sGroupBadgeCount += "<img src='/image/groups_badge_num_0.gif?v=213)' alt='0' />";
}else{
for(i = 0; i < l_aMemberCount.length; i++){
l_sGroupBadgeCount += "<img src='/image/groups_badge_num_" + l_aMemberCount[i] + ".gif?v=213)' alt='"+ l_aMemberCount[i] + "' />";
}
}
l_sPLKBadgeModuleTemplate = l_sPLKBadgeModuleTemplate.replace(/~group-badge-count-image~/, l_sGroupBadgeCount);

$('#plck-badge-count-template-final').html(l_sPLKBadgeModuleTemplate);
}, 

displayGroupPreviousEvents: function(response){
var l_sPLKEventsPageTemplate = '';
var l_sPLKFinalEventsPageTemplate = '';
var l_sPaginationTemplate = '';
l_sPLKTitleEventsPageTemplate = $('#plck_events_page_template_title').html();
l_sPLKTitleEventsPageTemplate = l_sPLKTitleEventsPageTemplate.replace(/~events-title~/, "<div class='hr'></div><div class='gap40'></div><div class='txt_recentevents txt'>Recent Events</div>");
$('#plck_events_page_template_upcoming_events_title_final').html(l_sPLKTitleEventsPageTemplate);
//loop thru response
for(i = 0; i < response.Events.length; i++){
 var eventData = response.Events[i];
//alert("start date"+
//get events template
l_sPLKEventsPageTemplate = $('#plck_events_page_template').html();
//replace events template with pluck data
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/plck-base-image/, eventData.Author.ImageUrl);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~base-image-alt~/, eventData.Author.DisplayName);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/plck-events-owner-url/, "");
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-owner-name~/, eventData.Author.DisplayName);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-owner-name~/, eventData.Author.DisplayName);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/plck-events-group-url/, "");
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-group-title~/, eventData.Author.DisplayName);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-title~/, eventData.Title);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-start-date~/, eventData.StartDate_UTC);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-end-date~/, eventData.EndDate_UTC);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-description~/, eventData.Description);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~event-location~/, eventData.Location);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/event-bookmark-url/, eventData.BookmarkUrl);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~event-bookmark-name~/, eventData.BookmarkName);
l_sPLKFinalEventsPageTemplate += l_sPLKEventsPageTemplate;
}
//jam it into html
$('#plck_events_page_template_upcoming_events_final').html('');
$('#plck_events_page_template_upcoming_events_final').html(l_sPLKFinalEventsPageTemplate);
if((parseInt(response.NumberOfEvents)) > (parseInt(response.NumberPerPage))){
l_sPaginationTemplate = _xPagination.tallNum(response.OnPage, response.NumberOfEvents, response.NumberPerPage, response.EventSetKey.Key, "_xCommunityEvents.getRecentEventsModule", 10);
$('#plck-pagination-final-upcoming-events').html(l_sPaginationTemplate);
 } else{
$('#plck-pagination-final-upcoming-events').html('');
 }
 
},
displayGroupUpcomingEvents: function(response){
var l_sPLKEventsPageTemplate = '';
var l_sPLKFinalEventsPageTemplate = '';
var l_sPaginationTemplate = '';
l_sPLKTitleEventsPageTemplate = $('#plck_events_page_template_title').html();
l_sPLKTitleEventsPageTemplate = l_sPLKTitleEventsPageTemplate.replace(/~events-title~/, "<div class='hr'></div><div class='gap40'></div><div class='txt_upcomingevents txt'>Upcoming Events</div>");
$('#plck_events_page_template_upcoming_events_title_final').html(l_sPLKTitleEventsPageTemplate);
//loop thru response
for(i = 0; i < response.Events.length; i++){
 var eventData = response.Events[i];
//get events template
l_sPLKEventsPageTemplate = $('#plck_events_page_template').html();
//replace events template with pluck data
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/plck-base-image/, eventData.Author.ImageUrl);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~base-image-alt~/, eventData.Author.DisplayName);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/plck-events-owner-url/, "");
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-owner-name~/, eventData.Author.DisplayName);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-owner-name~/, eventData.Author.DisplayName);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/plck-events-group-url/, "");
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-group-title~/, eventData.Author.DisplayName);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-title~/, eventData.Title);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-start-date~/, eventData.StartDate_UTC);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-end-date~/, eventData.EndDate_UTC);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~events-description~/, eventData.Description);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~event-location~/, eventData.Location);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/event-bookmark-url/, eventData.BookmarkUrl);
l_sPLKEventsPageTemplate = l_sPLKEventsPageTemplate.replace(/~event-bookmark-name~/, eventData.BookmarkName);
l_sPLKFinalEventsPageTemplate += l_sPLKEventsPageTemplate;
}
//jam it into html
$('#plck_events_page_template_upcoming_events_final').html('');
$('#plck_events_page_template_upcoming_events_final').html(l_sPLKFinalEventsPageTemplate);
if((parseInt(response.NumberOfEvents)) > (parseInt(response.NumberPerPage))){
l_sPaginationTemplate = _xPagination.tallNum(response.OnPage, response.NumberOfEvents, response.NumberPerPage, response.EventSetKey.Key, "_xCommunityEvents.getUpcomingEventsModule", 10);
$('#plck-pagination-final-upcoming-events').html(l_sPaginationTemplate);
 }else{
$('#plck-pagination-final-upcoming-events').html('');
 }
 
},
displayCommunityGroupPictures: function(response){
var l_sPLKPicturesTemplate = '';
var l_sPLKFinalPicturesTemplate = '';
for(i = 0; i < response.Photos.length; i++){
var photoData = response.Photos[i];
//get picture tamplate
l_sPLKPicturesTemplate = $('#plck_picture_page_template').html();
//replace with pluck data
l_sPLKPicturesTemplate = l_sPLKPicturesTemplate.replace(/plck-picture-tn/, photoData.Image.Medium);
l_sPLKPicturesTemplate = l_sPLKPicturesTemplate.replace(/plck-picture-alt-title/, photoData.Title);
l_sPLKPicturesTemplate = l_sPLKPicturesTemplate.replace(/~plck-picture-title~/, photoData.Title);
l_sPLKPicturesTemplate = l_sPLKPicturesTemplate.replace(/plck-picture-detail-url/, "/community/photo/"+photoData.PhotoKey.Key+"/");
l_sPLKPicturesTemplate = l_sPLKPicturesTemplate.replace(/plck-photo-tn-url/, "/community/photo/"+photoData.PhotoKey.Key+"/");
l_sPLKPicturesTemplate = l_sPLKPicturesTemplate.replace(/~plck-picture-timestamp~/, photoData.CreatedOn);
l_sPLKFinalPicturesTemplate += l_sPLKPicturesTemplate;
}
$('#plck_picture_page_template_final').html(l_sPLKFinalPicturesTemplate);
if((parseInt(response.NumberOfPhotos)) > (parseInt(response.NumberPerPage))){
l_sPaginationTemplate = _xPagination.tallNum(response.OnPage, response.NumberOfPhotos, response.NumberPerPage, response.GalleryKey.Key, "_xCommunityPhotos.getPhotosModule", 10);
$('#plck-pagination-final').html(l_sPaginationTemplate);
}
},
displayCommunityGroupVideos: function(response){
 var l_sPLKVideosTemplate = '';
 var l_sPLKFinalVideosTemplate = '';
 
 for(i = 0; i < response.Videos.length; i++){
var videoData = response.Videos[i];
var l_sVideoCreated = videoData.CreatedOn;
var l_aVideoTimeStamp = l_sVideoCreated.split(" ");
var l_sVideoDate = l_aVideoTimeStamp[0];
//get videos template
 l_sPLKVideosTemplate = $('#plck_video_page_template').html();
 //replace with pluck data:
 l_sPLKVideosTemplate = l_sPLKVideosTemplate.replace(/plck-video-tn/, videoData.VideoThumbnail);
 l_sPLKVideosTemplate = l_sPLKVideosTemplate.replace(/plck-video-alt-title/, videoData.Title);
 l_sPLKVideosTemplate = l_sPLKVideosTemplate.replace(/~plck-video-title~/, videoData.Title);
 l_sPLKVideosTemplate = l_sPLKVideosTemplate.replace(/plck-video-detail-url/, "/community/video/"+videoData.VideoKey.Key+"/");
 l_sPLKVideosTemplate = l_sPLKVideosTemplate.replace(/video-tn-url/, "/community/video/"+videoData.VideoKey.Key+"/");
 l_sPLKVideosTemplate = l_sPLKVideosTemplate.replace(/~plck-video-timestamp~/, l_sVideoDate);
 l_sPLKFinalVideosTemplate += l_sPLKVideosTemplate;
 }
 
 $('#plck_video_page_template_final').html(l_sPLKFinalVideosTemplate);
 
if((parseInt(response.NumberOfVideos)) > (parseInt(response.NumberPerPage))){
l_sPaginationTemplate = _xPagination.tallNum(response.OnPage, response.NumberOfVideos, response.NumberPerPage, response.GalleryKey.Key, "_xCommunityVideos.getVideosModule", 10);
$('#plck-pagination-final').html(l_sPaginationTemplate);
}
}, 

displayCommunityGroupBlogs: function(response){
var l_sPLKBlogsTemplate = '';
var l_sPLKFinalBlogsTemplate = '';
for(i = 0; i < response.BlogPosts.length; i++){
 
 var blogData = response.BlogPosts[i];
 l_sTimeUploaded = getActivityTime(blogData.PostDate);
 l_sPLKBlogsTemplate = $('#plck_blog_page_template').html();
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~group-blog-title~/, blogData.PostTitle);
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/plck-blog-url/, "/community/blog/"+blogData.BlogPostKey.Key+"/");
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~group-blog-description~/, blogData.PostBody);
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~group-blog-author~/, blogData.PostAuthor.DisplayName);
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/plck-group-blog-author-url/, blogData.PostAuthor.ImageUrl);
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/plck-group-blog-author-persona-url/, blogData.PostAuthor.PersonaUrl);
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/plck-group-blog-author-display-name/, blogData.PostAuthor.DisplayName);
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~plck-blog-post-date~/, l_sTimeUploaded);
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~plck-blog-tags~/, blogData.PostTags);
 //Number of comments will have to be pulled from the article comments as comments for any content type are tied to an article.
 //l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~plck-blog-number-of-comments~/, blogData.NumberOfComments);
 if(blogData.CurrentUserHasRecommended == 'True'){
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~extraclass-fireup-selected~/, "sprite_selected");
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick=''/>");
}else{
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~extraclass-fireup-selected~/, "");
 l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick='javascript:recommend(\"" + blogData.BlogPostKey.Key + "\", \"blog-post\", this);'/>");
 }
 
 l_sPLKFinalBlogsTemplate += l_sPLKBlogsTemplate;
}
$('#plck_blog_page_template_final').html(l_sPLKFinalBlogsTemplate);
if((parseInt(response.NumberOfBlogPosts)) > (parseInt(response.NumberPerPage))){
l_sPaginationTemplate = _xPagination.tallNum(response.OnPage, response.NumberOfBlogPosts, response.NumberPerPage, response.BlogKey.Key, "_xCommunityBlogs.getBlogsModule", 10);
$('#plck-pagination-final').html(l_sPaginationTemplate);
 }
},

displayCommunityGroupPageAggregate: function(response){
 var l_sPLKGroupAggregateTemplate = '';
 var l_sPLKFinalGroupAggregateTemplate = '';
 
for(i = 0; i < response.CommunityGroups.length; i++){
 var groupData = response.CommunityGroups[i];
 var groupTitle = groupData.Title;
 if(groupTitle.length > 30){
groupTitle = groupTitle.substring(0, 300);
groupTitle = groupTitle.replace(/\w+$/, '');
groupTitle = groupTitle + "...";
 }
 var groupDescription = groupData.Description;
 if(groupDescription.length > 300){
groupDescription = groupDescription.substring(0, 300);
groupDescription = groupDescription.replace(/\w+$/, '');
groupDescription = groupDescription + "...";
 }
 var l_sSmallAvatarImage = groupData.AvatarImageUrl;
 var l_sMediumAvatarImage = l_sSmallAvatarImage.replace("Small", "Medium"); 
 var l_sCreatedDate = groupData.CreatedDate.split(" ");
 var l_sEstablished = l_sCreatedDate[0]; 
 
 l_sPLKGroupAggregateTemplate = $('#plck_group_aggregate_template').html();
 l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/plck-group-aggregate-link/, "/community/group/" + groupData.CommunityGroupKey.Key + "/");
 l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/plck-group-aggregate-link-title/, "/community/group/" + groupData.CommunityGroupKey.Key + "/");
 l_sPLKGroupAggregateTemplate =l_sPLKGroupAggregateTemplate.replace(/plck-group-aggregate-image/, l_sMediumAvatarImage);
 l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/~plck-group-aggregate-title~/, groupTitle);
 l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/plck-group-aggregate-title/, groupTitle);
 l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/~plck-group-aggregate-description~/, groupDescription);
 l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/~plck-group-aggregate-fire-count~/, groupData.NumberOfRecommendations);
 l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/~plck-group-aggregate-established~/, l_sEstablished);
 
 if((i % 2) == 0){
l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/~div-class-clear~/, ""); 
 }else{
l_sPLKGroupAggregateTemplate = l_sPLKGroupAggregateTemplate.replace(/~div-class-clear~/, '<div class = "clear"></div>');
 }
 
 l_sPLKFinalGroupAggregateTemplate += l_sPLKGroupAggregateTemplate; 
}
l_sPLKFinalGroupAggregateTemplate += '<div class="clear"></div>';
$('#plck-group-aggregate-template-final').css('height','auto');
$('#plck-group-aggregate-template-final').html(l_sPLKFinalGroupAggregateTemplate);
 if((parseInt(response.NumberOfCommunityGroups)) > (parseInt(response.NumberPerPage))){
l_sPaginationTemplate = _xPagination.tallNumAggregate(response.NumberOfCommunityGroups, response.NumberPerPage, response.OnPage, "All", response.Sort, "_xCommunity.getGroupPageAggregateModule");
$('#plck-pagination-final').html(l_sPaginationTemplate);
}

},
displayUserActivity: function(response, l_sDivId){
 var l_nVideos = 0;
 var l_nPhotos = 0;
 var l_nComments = 0;
 var l_nBlogPosts = 0;
 var l_nDiscussions = 0;
 
 for(var i = 0; i < response.length; i ++){
if(response[i].Video){
 l_nVideos += 1;
 }
 if(response[i].Photo){
 l_nPhotos += 1;
 }
 if(response[i].BlogPosts){
 l_nBlogPosts += 1;
 }
 if(response[i].Comments){
 l_nComments += 1;
 }
 if(response[i].Discussions){
 l_nDiscussions += 1;
 }
}
 
l_sRecentActivityTemplate = 
"<div class='txtholder' style='float:right'>"+
"<b>Recent Activity</b>"+
"<p>"+l_nVideos+" Videos | "+l_nPhotos+" Photos | "+l_nBlogPosts+" Posts</p>"+
"<p>"+l_nComments+" Comments | "+l_nDiscussions+" Discussions</p>"+
 "</div>";
 
 $('#'+l_sDivId).html(l_sRecentActivityTemplate);
},
 

 displayDiscoverContentGroupLandingModule: function(discoveredContent){
var p_aContentType = new Array("PublicVideo", "BlogPost", "PublicPhoto", "CommunityGroup" , "Persona", "Discussion");
for(var x = 0; x < discoveredContent.Responses.length; x++){
var init_response = discoveredContent.Responses[x];
var init_discoveredResponse = init_response.DiscoverContentAction.DiscoveredContent;
var l_sStyleWidth = init_discoveredResponse.length*208;
 
switch(p_aContentType[x]){
case "PublicVideo":
$('#video_reel_inner').css('width', l_sStyleWidth); 
break;
case "BlogPost":
$('#blogposts_reel_inner').css('width', init_discoveredResponse.length*600); 
break;
case "PublicPhoto":
//TODO: Vishal: figure out why the width calculation is not accurate for photos
$('#photo_reel_inner').css('width', (l_sStyleWidth + 208)); 
break;
case "CommunityGroup":
$('#group_reel_inner').css('width', l_sStyleWidth); 
break;
case "Persona":
$('#member_reel_inner').css('width', l_sStyleWidth); 
break;
case "Discussion":
 $('#discussion_reel_inner').css('width', l_sStyleWidth); 
break;
}
 
}

for(var i = 0; i < discoveredContent.Responses.length; i++){
 var response = discoveredContent.Responses[i];
var discoveredResponse = response.DiscoverContentAction.DiscoveredContent;
 if(discoveredResponse.length != 0){
 switch(p_aContentType[i]){
 case "PublicVideo":
 
$('#plck-videos-pagination').html(_xPagination.createcommunitylandingmod( 1, discoveredResponse.length,3,'videos' ) )
var l_sPLK_Final_Video_Template = '';
for(var j = 0; j < discoveredResponse.length; j++){
 if(discoveredResponse[j].AssociatedCommunityGroupKey){ 
var l_sPLKVideoTemplate = '';
l_sTimeUploaded = getActivityTime(discoveredResponse[j].CreatedOn);
l_sPLKVideoTemplate = $("#plck_landing_video_holder_template").html();
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-set-width/, discoveredResponse.length);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-holder-url/, "/community/video/" +discoveredResponse[j].VideoKey.Key+"/");
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-holder-url-title/, "/community/video/" +discoveredResponse[j].VideoKey.Key+"/");
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-title/, discoveredResponse[j].Title);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-title-alt/, discoveredResponse[j].Title);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~plk-video-title~/, discoveredResponse[j].Title);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/plck-video-thumbnail/, discoveredResponse[j].VideoThumbnail);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/video-author-url/, discoveredResponse[j].Author.PersonaUrl);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-author-display-name~/, discoveredResponse[j].Author.DisplayName);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/~video-created-on~/, l_sTimeUploaded);
l_sPLKVideoTemplate = l_sPLKVideoTemplate.replace(/video-group-url/, "/community/group/" +discoveredResponse[j].AssociatedCommunityGroupKey.Key+"/");
l_sPLK_Final_Video_Template += l_sPLKVideoTemplate;
 }
}
$('#plck_landing_video_holder_template_final').html(l_sPLK_Final_Video_Template);

 break;
 case "BlogPost":
$('#plck-blog-pagination').html(_xPagination.createcommunitylandingmod( 1, discoveredResponse.length,1,'blog' ) )
 var l_sPLK_Final_BlogPost_Template = '';
 for(var j = 0; j < discoveredResponse.length; j++){
 var l_sPLKBlogPostTemplate = '';
l_sPLKBlogPostTemplate = $("#plck_landing_blogpost_holder_template").html();
l_sTimeUploaded = getActivityTime(discoveredResponse[j].PostDate);
var l_sAbstractText = discoveredResponse[j].PostBody;
//strip html tags if any
l_sAbstractText = l_sAbstractText.replace(/<\S[^><]*>/g, '');
//Limit body count to 150 characters
if(l_sAbstractText.length > 150){
l_sAbstractText = l_sAbstractText.substring(0, 150);
} else {
l_sAbstractText = l_sAbstractText.substring(0);
}
l_sAbstractText = l_sAbstractText.toUpperCase() + "...";
var l_aTextInfo = { c:'666666',type:'b','bg':'0F0F0F',tran:true,s:20,lh:6,t: '"'+l_sAbstractText+'"', w:600, 'bb':'9px'}
l_sAbstractImage = makeCustomImage(l_aTextInfo);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-image-url/, l_sAbstractImage);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-abstract-text/, l_sAbstractText);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-blogpost-author-url/, discoveredResponse[j].PostAuthor.PersonaUrl);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-blog-post-user-avatar-img-url/, discoveredResponse[j].PostAuthor.ImageUrl);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~plck-blogpost-author-name~/, discoveredResponse[j].PostAuthor.DisplayName);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~plck-blogpost-title~/, discoveredResponse[j].PostTitle);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/plck-blogpost-url/, discoveredResponse[j].Url);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~plck-time-posted~/, l_sTimeUploaded);

//Check if blog post has been made to group or persona
if(discoveredResponse[j].AssociatedCommunityGroupKey){
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/blog-post-url/, "/community/blog/"+discoveredResponse[j].BlogPostKey.Key+"/");
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/blog-post-url-name/, "/community/blog/"+discoveredResponse[j].BlogPostKey.Key+"/");
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~blog-location~/, "a group blog");
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/blog-group-url/, "/community/group/" +discoveredResponse[j].AssociatedCommunityGroupKey.Key+"/blogs/");
 } else {
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/blog-post-url/, discoveredResponse[j].Url);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/blog-post-url-name/, discoveredResponse[j].Url);
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/~blog-location~/, "their profile blog");
l_sPLKBlogPostTemplate = l_sPLKBlogPostTemplate.replace(/blog-group-url/, discoveredResponse[j].Url);
}
 
l_sPLK_Final_BlogPost_Template += l_sPLKBlogPostTemplate;
 
}
$('#plck_landing_blogpost_holder_template_final').html(l_sPLK_Final_BlogPost_Template);
 break;
 case "PublicPhoto":
$('#plck-photos-pagination').html(_xPagination.createcommunitylandingmod( 1, discoveredResponse.length,3,'photos' ) )
var l_sPLK_Final_Photo_Template = '';
for(var j = 0; j < discoveredResponse.length; j++){
if(discoveredResponse[j].AssociatedCommunityGroupKey){
var l_sPLKPhotoTemplate = '';
l_sTimeUploaded = getActivityTime(discoveredResponse[j].CreatedOn);
l_sPLKPhotoTemplate = $("#plck_landing_photo_holder_template").html();
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-holder-url/, "/community/photo/" +discoveredResponse[j].PhotoKey.Key+"/");
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-title/, discoveredResponse[j].Title);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-title-alt/, discoveredResponse[j].Title);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~plk-photo-title~/, discoveredResponse[j].Title);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/plck-photo-thumbnail/, discoveredResponse[j].Image.Medium);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/photo-author-url/, discoveredResponse[j].Author.PersonaUrl);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photo-author-display-name~/, discoveredResponse[j].Author.DisplayName);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/~photo-created-on~/, l_sTimeUploaded);
l_sPLKPhotoTemplate = l_sPLKPhotoTemplate.replace(/photo-group-url/, "/community/group/" +discoveredResponse[j].AssociatedCommunityGroupKey.Key+"/");
l_sPLK_Final_Photo_Template += l_sPLKPhotoTemplate;
}
}
$('#plck_landing_photo_holder_template_final').html(l_sPLK_Final_Photo_Template);
 break;
 case "Discussion":
$('#plck-discussions-pagination').html(_xPagination.createcommunitylandingmod( 1, discoveredResponse.length,3,'discussions' ) )
 
var l_sPLK_Final_Discussion_Template = '';
for(var j = 0; j < discoveredResponse.length; j++){
l_sTimeUploaded = getActivityTime(discoveredResponse[j].LastPostDate);
var l_sPLKDiscussionTemplate = '';
l_sPLKDiscussionTemplate = $("#plck_landing_discussion_holder_template").html();
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/~plck-discussion-title~/, discoveredResponse[j].DiscussionTitle);
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/~plck-discussion~/, discoveredResponse[j].DiscussionBody);
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/plck-discussion-author-url-image/, discoveredResponse[j].LiteUser.ImageUrl);
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/plck-discussion-author-url/, discoveredResponse[j].LiteUser.PersonaUrl);
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/~plck-discussion-author-name~/, discoveredResponse[j].LiteUser.DisplayName);
if(discoveredResponse[j].ForumDiscussionKey.Key.match(/CommGroup/)){
//Discussion belongs to community forums
 l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/~discussion-source~/, "a group");
 l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/plck-discussion-group-url/,"/community/group/"+discoveredResponse[j].AssociatedCommunityGroupKey.Key+"/forum/?slPage=showDiscussion&slGroupKey="+discoveredResponse[j].AssociatedCommunityGroupKey.Key+"&slForumDiscussionKey="+discoveredResponse[j].ForumKey.Key+"&slonPage=1");
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/plck-discussion-url/, "/community/group/"+discoveredResponse[j].AssociatedCommunityGroupKey.Key+"/forum/?slPage=showDiscussionPost&slGroupKey="+discoveredResponse[j].AssociatedCommunityGroupKey.Key+"&slForumPostKey="+discoveredResponse[j].ForumDiscussionKey.Key+"&slonPage=1");
} else{
//Discussion belongs to MessageBoards
 l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/~discussion-source~/, "a message board");
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/plck-discussion-url/, "/community/forums/?plckForumPage=ForumDiscussion&plckDiscussionId="+discoveredResponse[j].ForumDiscussionKey.Key+"");
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/plck-discussion-group-url/, "/community/forums/?plckForumPage=Forum&plckForumId="+discoveredResponse[j].ForumKey.Key+"");
}
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/~plck-discussion-author-displayname~/, discoveredResponse[j].LiteUser.DisplayName);
l_sPLKDiscussionTemplate = l_sPLKDiscussionTemplate.replace(/~discussion-created-date~/, l_sTimeUploaded);

l_sPLK_Final_Discussion_Template += l_sPLKDiscussionTemplate;
}

$('#plck_landing_discussion_holder_template_final').html(l_sPLK_Final_Discussion_Template);
 break;
 case "Persona":
$('#plck-persona-pagination').html(_xPagination.createcommunitylandingmod( 1, discoveredResponse.length,4,'persona' ) )
var l_sPLK_Final_Member_Template = '';
for(var j = 0; j < discoveredResponse.length; j++){
var l_sPLKMemberTemplate = '';
l_sPLKMemberTemplate = $("#plck_landing_member_holder_template").html();
l_sPLKMemberTemplate = l_sPLKMemberTemplate.replace(/plck-member-url/, discoveredResponse[j].ImageUrl);
l_sPLKMemberTemplate = l_sPLKMemberTemplate.replace(/plck-member-image-url/, discoveredResponse[j].ImageUrl);
l_sPLKMemberTemplate = l_sPLKMemberTemplate.replace(/~plck-member-display-name~/, discoveredResponse[j].DisplayName);
l_sPLKMemberTemplate = l_sPLKMemberTemplate.replace(/group-member-joined/, discoveredResponse[j].LastUpdated);
l_sPLKMemberTemplate = l_sPLKMemberTemplate.replace(/~joined-group-display-name~/, "");
l_sPLKMemberTemplate = l_sPLKMemberTemplate.replace(/~date-member-joined~/, "");
l_sPLKMemberTemplate = l_sPLKMemberTemplate.replace(/plck-member-persona-url/, discoveredResponse[j].PersonaUrl);
l_sPLK_Final_Member_Template += l_sPLKMemberTemplate;
}
$('#plck_landing_member_holder_template_final').html(l_sPLK_Final_Member_Template);
 break;
 case "CommunityGroup":
$('#plck-groups-pagination').html(_xPagination.createcommunitylandingmod( 1, discoveredResponse.length,3,'groups' ) )
var l_sPLK_Final_Group_Template = '';
for(var j = 0; j < discoveredResponse.length; j++){
if(discoveredResponse[j].CommunityGroupKey){
var l_sPLKGroupTemplate = '';
l_sTimeUploaded = getActivityTime(discoveredResponse[j].CreatedDate);
var l_sSmallAvatarImage = discoveredResponse[j].AvatarImageUrl;
var l_sMediumAvatarImage = l_sSmallAvatarImage.replace("Small", "Medium"); 
l_sPLKGroupTemplate = $("#plck_landing_group_holder_template").html();
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/plck-group-url-image/, "/community/group/"+discoveredResponse[j].CommunityGroupKey.Key+ "/");
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/plck-group-url-group/, "/community/group/"+discoveredResponse[j].CommunityGroupKey.Key+ "/");
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/~plck-group-display-name~/, discoveredResponse[j].Title);
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/plck-group-title-img/, discoveredResponse[j].CommunityGroupUrl);
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/plck-group-img-src/, l_sMediumAvatarImage);
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/plck-group-url-title/, discoveredResponse[j].CommunityGroupUrl);
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/plck-group-title-title/, discoveredResponse[j].Title);
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/~plck-group-title~/, discoveredResponse[j].Title);
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/~plck-group-owner-display-name~/, "");
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/plck-group-owner-url/, "");
l_sPLKGroupTemplate = l_sPLKGroupTemplate.replace(/~plck-created-date~/, l_sTimeUploaded);
l_sPLK_Final_Group_Template += l_sPLKGroupTemplate;
}
}
$('#plck_landing_group_holder_template_final').html(l_sPLK_Final_Group_Template);
 break;
 }
 }
}
}, 
displayArticleDetail:function(articleData){
var l_sPLKArticleDetailMetaTemplate = '';
l_sPLKArticleDetailMetaTemplate = $('#article-detail-meta-template').html();
if(l_sPLKArticleDetailMetaTemplate != null){
l_sPLKArticleDetailMetaTemplate = l_sPLKArticleDetailMetaTemplate.replace(/plck-fire-count/, "firecount" );
l_sPLKArticleDetailMetaTemplate = l_sPLKArticleDetailMetaTemplate.replace(/~plck-number-of-recommendations~/, articleData.Article.Recommendations.NumberOfRecommendations);
$('#article-detail-meta-template-final').html(l_sPLKArticleDetailMetaTemplate);
}
var l_sPLKArticleDetailFireUpTemplate = '';
var l_sPLKArticleDetailFireUpTemplate = $('#article-detail-fireup-template').html();
if(l_sPLKArticleDetailFireUpTemplate != null){
if(articleData.Article.Recommendations.CurrentUserHasRecommended == 'True'){
 l_sPLKArticleDetailFireUpTemplate = l_sPLKArticleDetailFireUpTemplate.replace(/~extraclass-fireup-selected~/, "sprite_selected");
 l_sPLKArticleDetailFireUpTemplate = l_sPLKArticleDetailFireUpTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick=''/>");
}else{
 l_sPLKArticleDetailFireUpTemplate = l_sPLKArticleDetailFireUpTemplate.replace(/~extraclass-fireup-selected~/, "");
 l_sPLKArticleDetailFireUpTemplate = l_sPLKArticleDetailFireUpTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick='javascript:recommend(\"" + articleData.Article.ArticleKey.Key + "\", \"article\", this);'/>");
}
$('#article-detail-fireup-template-final').html(l_sPLKArticleDetailFireUpTemplate);
}
}, 
displayCommunityGroupPictureDetail:function(photoData){
var l_sPLKPhotoDetailImageTemplate = '';
l_sPLKPhotoDetailImageTemplate = $('#photo-detail-image-template').html();
var l_sPLKPhotoDetailImageTemplate = l_sPLKPhotoDetailImageTemplate.replace(/plck-photo-detail-image/, photoData.Image.Large);
$('#photo-detail-image-template-final').html(l_sPLKPhotoDetailImageTemplate);
var l_sPLKPhotoDetailMetaTemplate = '';
var l_sPLKPhotoDetailMetaTemplate = $('#photo-detail-meta-template').html();
var l_aTextInfo = { c:'000000',type:'bl','bg':'E1E1E1',tran:true,s:22,t: ''+photoData.Title.toUpperCase()+'', w:375, lh:6 }
l_sAbstractImage = makeCustomImage(l_aTextInfo);
 l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/plck-photo-detail-title-image/, l_sAbstractImage);
l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/plck-photo-detail-title-text/, photoData.Title.toUpperCase());
l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/~plck-photo-created~/, photoData.CreatedOn);
l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/plck-fire-count/, "firecount" );
l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/~plck-number-of-recommendations~/, photoData.NumberOfRecommendations);
l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/~plck-comment-count~/, '<div id = "plck-comment-count" class="plck-comment-count-class"><span></span></div>');
l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/~plck-photo-detail-description~/, photoData.Description);
l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/~plck-user-added-display-name~/, photoData.Author.DisplayName);
l_sPLKPhotoDetailMetaTemplate = l_sPLKPhotoDetailMetaTemplate.replace(/plck-user-added-url/, photoData.Author.PersonaUrl);
$('#photo-detail-meta-template-final').html(l_sPLKPhotoDetailMetaTemplate);

var l_sPLKPhotoDetailFireUpTemplate = '';
var l_sPLKPhotoDetailFireUpTemplate = $('#photo-detail-fireup-template').html();
if(photoData.CurrentUserHasRecommended == 'True'){
 l_sPLKPhotoDetailFireUpTemplate = l_sPLKPhotoDetailFireUpTemplate.replace(/~extraclass-fireup-selected~/, "sprite_selected");
 l_sPLKPhotoDetailFireUpTemplate = l_sPLKPhotoDetailFireUpTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick=''/>");
}else{
 l_sPLKPhotoDetailFireUpTemplate = l_sPLKPhotoDetailFireUpTemplate.replace(/~extraclass-fireup-selected~/, "");
 l_sPLKPhotoDetailFireUpTemplate = l_sPLKPhotoDetailFireUpTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick='javascript:recommend(\"" + photoData.PhotoKey.Key + "\", \"photo\", this);'/>");
}
$('#photo-detail-fireup-template-final').html(l_sPLKPhotoDetailFireUpTemplate);
}, 
displayCommunityGroupVideoDetail:function(videoData){
//video player
var flashvars = {p_sURL:videoData.VideoUrl};
var params = { menu:false, wmode:'transparent', bgcolor:'000000', allowFullScreen:true};
var attributes = {};
swfobject.embedSWF("/_site/swf/VersusVideoPlayer.swf", "videoplayer-detail", "614", "368", "9.0.0","_site/swf/expressInstall.swf", flashvars, params, attributes);
//video metadata
var l_sPLKVideoDetailMetaTemplate = '';
var l_sPLKVideoDetailMetaTemplate = $('#video-detail-meta-template').html();
var l_aTextInfo = { c:'000000',type:'bl','bg':'E1E1E1',tran:true,s:22,t: ''+videoData.Title.toUpperCase()+'', w:375, lh:6 }
l_sAbstractImage = makeCustomImage(l_aTextInfo);
 l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/plck-video-detail-title-image/, l_sAbstractImage);
l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/plck-video-detail-title-text/, videoData.Title.toUpperCase());
l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/~plck-photo-created~/, videoData.CreatedOn);
l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/plck-fire-count/, "firecount" );
l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/~plck-number-of-recommendations~/, videoData.NumberOfRecommendations);
l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/~plck-comment-count~/, '<div id = "plck-comment-count" class="plck-comment-count-class"><span></span></div>');
l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/~plck-video-detail-description~/, videoData.Description);
l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/~plck-user-added-display-name~/, videoData.Author.DisplayName);
l_sPLKVideoDetailMetaTemplate = l_sPLKVideoDetailMetaTemplate.replace(/plck-user-added-url/, videoData.Author.PersonaUrl);
 
$('#video-detail-meta-template-final').html(l_sPLKVideoDetailMetaTemplate);

var l_sPLKVideoDetailFireUpTemplate = '';
var l_sPLKVideoDetailFireUpTemplate = $('#video-detail-fireup-template').html();

if(videoData.CurrentUserHasRecommended == 'True'){
 l_sPLKVideoDetailFireUpTemplate = l_sPLKVideoDetailFireUpTemplate.replace(/~extraclass-fireup-selected~/, "sprite_selected");
 l_sPLKVideoDetailFireUpTemplate = l_sPLKVideoDetailFireUpTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick=''/>");
 }else{
 l_sPLKVideoDetailFireUpTemplate = l_sPLKVideoDetailFireUpTemplate.replace(/~extraclass-fireup-selected~/, "");
 l_sPLKVideoDetailFireUpTemplate = l_sPLKVideoDetailFireUpTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick='javascript:recommend(\"" + videoData.VideoKey.Key + "\", \"video\", this);'/>");
}
$('#video-detail-fireup-template-final').html(l_sPLKVideoDetailFireUpTemplate);
},
displayCommunityBlogDetail:function(blogData){
var l_sBlogAuthorDisplayName = blogData.PostAuthor.DisplayName.toUpperCase()+"'s Blog";
var l_aTextInfo = {c:'000000',type:'b', 'bg':'FCB316','tran':true, s:14, t:l_sBlogAuthorDisplayName, w:410, 'bb':'9px'};
var l_sImageUrl = makeCustomImage(l_aTextInfo); 
l_sPLKBlogsTemplate = $('#plck-blog-detail-template').html();
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/plck-blog-author-name-image/, l_sImageUrl);
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~group-blog-title~/, blogData.PostTitle);
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~group-blog-description~/, blogData.PostBody);
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/group-blog-author/, blogData.PostAuthor.DisplayName);
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~group-blog-post-date~/, blogData.PostDate);
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/plck-group-blog-author-url/, blogData.PostAuthor.ImageUrl);
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/plck-group-blog-author-persona-url/, blogData.PostAuthor.PersonaUrl);
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/plck-group-blog-author-display-name/, blogData.PostAuthor.DisplayName);
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~plck-blog-tags~/, blogData.PostTags);
var l_sPLKBlogDetailFireUpTemplate = '';
var l_sPLKBlogDetailFireUpTemplate = $('#blog-detail-fireup-template').html();
if(blogData.CurrentUserHasRecommended == 'True'){
 l_sPLKBlogDetailFireUpTemplate = l_sPLKBlogDetailFireUpTemplate.replace(/~extraclass-fireup-selected~/, "sprite_selected");
 l_sPLKBlogDetailFireUpTemplate = l_sPLKBlogDetailFireUpTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick=''/>");
 }else{
 l_sPLKBlogDetailFireUpTemplate= l_sPLKBlogDetailFireUpTemplate.replace(/~extraclass-fireup-selected~/, "");
 l_sPLKBlogDetailFireUpTemplate = l_sPLKBlogDetailFireUpTemplate.replace(/~fireup-a-tag~/,"<a href='javascript:void(0)' onclick='javascript:recommend(\"" + blogData.BlogPostKey.Key + "\", \"blog-post\", this);'/>");
}
l_sPLKBlogsTemplate = l_sPLKBlogsTemplate.replace(/~blog-detail-fireup-template-final~/, l_sPLKBlogDetailFireUpTemplate);
$('#plck-blog-detail-template-final').html(l_sPLKBlogsTemplate);
}
};

_xDisplayMiniModules = {
displayModeratorModule:function(userData){
var l_sPLKMiniModeratorTemplate = '';
var l_sPLKFinalMiniModeratorTemplate = '';
l_sPLKMiniModeratorTemplate = $('#plck-moderator-info-template').html();
l_sPLKMiniModeratorTemplate = l_sPLKMiniModeratorTemplate.replace(/plck-moderator-image/, userData.AvatarPhotoUrl); 
l_sPLKMiniModeratorTemplate = l_sPLKMiniModeratorTemplate.replace(/~plck-moderator-display-name~/, userData.DisplayName);
l_sPLKMiniModeratorTemplate = l_sPLKMiniModeratorTemplate.replace(/plck-user-url/, userData.PersonaUrl);
$('#plck-moderator-info-template_final').html(l_sPLKMiniModeratorTemplate);
},
displayCommunityTitleandYear:function(l_sTitle, l_sYear){
l_aMonths = new Array("Zero", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
l_sYearSplit = l_sYear.split("/");
l_sPluckMonth = l_sYearSplit[0];
l_sMonth = l_aMonths[l_sPluckMonth];
l_sPluckYearTime = l_sYearSplit[2].split(" ");
l_sYear = l_sPluckYearTime[0];
l_sGroupStartedString = "Started on "+ l_sYearSplit[1] +" "+ l_sMonth +", "+ l_sYear +"";
$('#plck_date_started').html(l_sGroupStartedString);
var l_sPLKTitleYearTemplate = '';
var l_sPLKFinalTitleYearTemplate = '';
l_sPLKTitleYearTemplate = $('#plck-moderation-info-group-template').html();
l_sPLKTitleYearTemplate = l_sPLKTitleYearTemplate.replace(/~plck-group-name~/, l_sTitle); 
l_sPLKTitleYearTemplate = l_sPLKTitleYearTemplate.replace(/~plck-group-year-founded~/, l_sYear);
$('#plck-moderation-info-group-template_final').html(l_sPLKTitleYearTemplate);
}, 
displaySimilarContent:function(l_sThumbnailUrl, l_sTitle, l_nMemberCount, l_sGroupURL){
 var l_sPLKFinal_SimilarGroupsTemplate = '';
 var l_sStyleWidth = l_sGroupURL.length*140;
 $('#similar_groups_reel_inner').css('width', l_sStyleWidth); 
 $('#plck-discovery-pagination').html(_xPagination.createcommunitylandingmod( 1, l_sGroupURL.length,2,'discovery' ) )
 
 if(l_sGroupURL.length > 0){
 for(var i = 0; i < l_sGroupURL.length; i ++){
var l_sPLKSimilarGroupsTemplate = '';
l_sPLKSimilarGroupsTemplate = $('#plck-similar-groups-template').html();
l_sPLKSimilarGroupsTemplate = l_sPLKSimilarGroupsTemplate.replace(/plck-group-url-image/, l_sThumbnailUrl[i]); 
l_sPLKSimilarGroupsTemplate = l_sPLKSimilarGroupsTemplate.replace(/plck-group-url/, "/community/group/"+l_sGroupURL[i]+ "/");
l_sPLKSimilarGroupsTemplate = l_sPLKSimilarGroupsTemplate.replace(/~plck-group-title~/, l_sTitle[i]);
l_sPLKSimilarGroupsTemplate = l_sPLKSimilarGroupsTemplate.replace(/~plck-no-of-members~/, l_nMemberCount[i]);
l_sPLKSimilarGroupsTemplate = l_sPLKSimilarGroupsTemplate.replace(/~plck-no-of-members~/, l_nMemberCount[i]);
l_sPLKFinal_SimilarGroupsTemplate += l_sPLKSimilarGroupsTemplate; 
}
$('#mod_group_groupslikethis').removeClass("plk_always_hide").addClass("mod_group_groupslikethis");
$('#plck-similar-groups-template-final').html(l_sPLKFinal_SimilarGroupsTemplate);
 }
}, 
displayEventsMiniModule: function(response){
 var l_sPLKMemberships_Template_Final = '';
 for(var i = 0; i < response.Events.length; i++){
var EventsData = '';
var EventsData = response.Events[i];
var l_sSplitDateTime = EventsData.StartDate_UTC.split(" ");
var l_nFinalDate = l_sSplitDateTime[1];
var l_sFinalMonth = l_sSplitDateTime[2];
var l_sDatePrintTemplate = '';
for(var j = 0; j < l_nFinalDate.length; j++){
l_sDatePrintTemplate += "<img src='/image/groups_cal_num_" + l_nFinalDate[j] + ".gif?v=213)' alt='"+ l_nFinalDate[j] + "' />";
}
 
l_sMonthNameImage = generateImageFromText(l_sFinalMonth, '940005', 'FFFFFF');
l_nDateNumber = i + 1; 
var l_sPLKDateHolderTemplate = '';
l_sPLKDateHolderTemplate = $('#plck_date_holder_template').html();
l_sPLKDateHolderTemplate = l_sPLKDateHolderTemplate.replace(/plck-datenumber/, "date date"+l_nDateNumber); 
l_sPLKDateHolderTemplate = l_sPLKDateHolderTemplate.replace(/plck-generated-image-month/, l_sMonthNameImage); 
l_sPLKDateHolderTemplate = l_sPLKDateHolderTemplate.replace(/plck-text-month/, l_sFinalMonth);
l_sPLKDateHolderTemplate = l_sPLKDateHolderTemplate.replace(/~date~/, l_sDatePrintTemplate);
l_sPLKDateHolderTemplate = l_sPLKDateHolderTemplate.replace(/~event-title~/, EventsData.Title);
l_sPLKDateHolderTemplate = l_sPLKDateHolderTemplate.replace(/~event-location~/, EventsData.Location);
$('#plck_date_holder_template_'+i).html(l_sPLKDateHolderTemplate);
}
 if((parseInt(response.NumberOfEvents)) > (parseInt(response.NumberPerPage))){
l_aPaginationInfo = _xPagination.mod(response.OnPage, response.NumberOfEvents, response.NumberPerPage, response.EventSetKey.Key, "_xCommunityEvents.getRecentEventsMiniModule", response.Sort);
l_sPaginationTemplate = $('#plck_pagi_moderation').html();
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-left~/,"<div class= 'mod_pagination_left sprite " + l_aPaginationInfo['left_class'] + "'><a " + l_aPaginationInfo['left_string'] +"><span>Left</span></a></div>"); 
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-right~/,"<div class= 'mod_pagination_right sprite" + l_aPaginationInfo['right_class'] + "'><a " + l_aPaginationInfo['right_string'] + "><span>Right</span></a></div>");
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~page-numbers~/, "" + l_aPaginationInfo['item_display'] + " of <b> " + l_aPaginationInfo['total_count'] + "</b>");
$('#plck_pagi_final_events').html(l_sPaginationTemplate);
}
},
 displayGroupMemberships: function(response){
 
 var l_sPLKMemberships_Template_Final = '';
 for(var i = 0; i < response.CommunityGroupMemberships.length; i++){
var l_sPLKMemberships_Template = '';
 var l_sPLKMemberships_Template = $('#plck-group-memberships-template').html();
 var membershipData = '';
var membershipData = response.CommunityGroupMemberships[i];
var l_sPlkJoinedDate = membershipData.CreatedDate_UTC;
var l_sPLkJoinedDateSplit = l_sPlkJoinedDate.split(" ");
var l_sJoinString = "Joined on "+l_sPLkJoinedDateSplit[0]+" "+l_sPLkJoinedDateSplit[1]+" "+l_sPLkJoinedDateSplit[2]+" "+l_sPLkJoinedDateSplit[3]+"";
if(i == 0){
l_sPLKMemberships_Template = l_sPLKMemberships_Template.replace(/~memberfirst~/, "member_first");
l_sPLKMemberships_Template = l_sPLKMemberships_Template.replace(/~plck-membership-activity~/, '<div id = "plck_membership_user_activity_1"></div>');
//get activitues for first user
_xCore.getActivitiesForUserMembershipOne(membershipData.User.UserKey.Key);
}
if(i == 1){
l_sPLKMemberships_Template = l_sPLKMemberships_Template.replace(/~plck-membership-activity~/, '<div id = "plck_membership_user_activity_2"></div>');
//get activities for second user
_xCore.getActivitiesForUserMembershipTwo(membershipData.User.UserKey.Key);
}
 
l_sPLKMemberships_Template = l_sPLKMemberships_Template.replace(/user-image-url/, membershipData.User.ImageUrl);
l_sPLKMemberships_Template = l_sPLKMemberships_Template.replace(/~plck-join-date~/, l_sJoinString);
l_sPLKMemberships_Template = l_sPLKMemberships_Template.replace(/user-url/, membershipData.User.PersonaUrl);
l_sPLKMemberships_Template = l_sPLKMemberships_Template.replace(/~plck-user-display-name~/, membershipData.User.DisplayName);
l_sPLKMemberships_Template_Final += l_sPLKMemberships_Template;
}
$('#plck-group-memberships-template-final').html(l_sPLKMemberships_Template_Final);
 if((parseInt(response.NumberOfCommunityGroupMemberships)) > (parseInt(response.NumberPerPage))){
l_aPaginationInfo = _xPagination.mod(response.OnPage, response.NumberOfCommunityGroupMemberships, response.NumberPerPage, response.Key.CommunityGroupKey.Key, "_xCore.getGroupMembershipPage", response.Sort);
l_sPaginationTemplate = $('#plck_pagi_moderation').html();
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-left~/,"<div class= 'mod_pagination_left sprite " + l_aPaginationInfo['left_class'] + "'><a " + l_aPaginationInfo['left_string'] +"><span>Left</span></a></div>"); 
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-right~/,"<div class= 'mod_pagination_right sprite" + l_aPaginationInfo['right_class'] + "'><a " + l_aPaginationInfo['right_string'] + "><span>Right</span></a></div>");
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~page-numbers~/, "" + l_aPaginationInfo['item_display'] + " of <b> " + l_aPaginationInfo['total_count'] + "</b>");
$('#plck_pagi_final_moderation').html(l_sPaginationTemplate);
}
},
 displayGroupAdminMemberships: function(response){
// $('#group-members-link').addClass("plk_always_hide");
// $('#banned-members-link').removeClass("plk_always_hide");
var l_sPLKAdminMemberships_Template_Final = '';
 for(var i = 0; i < response.CommunityGroupMemberships.length; i++){
var l_sPLKAdminMemberships_Template = '';
 var l_sPLKAdminMemberships_Template = $('#plck-groupmemberdir').html();
 var membershipData = '';
var membershipData = response.CommunityGroupMemberships[i];
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/plck-admin-member-image-url/, membershipData.User.ImageUrl);
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/plck-admin-member-membership-tier/, membershipData.MembershipTier);
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/plck-admin-member-persona-url/, membershipData.User.PersonaUrl);
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-admin-member-display-name~/, membershipData.User.DisplayName);
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/plck-admin-member-number-of-friends/, membershipData.User.NumberOfFriends +" Friends");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-admin-member-display-name~/, membershipData.User.DisplayName);
l_sCommunityGroupKey = $('#plck-group-key-set').html();
if(membershipData.MembershipTier == "Member"){
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-promote-members~/, "<a onclick='javascript:_xCore.updateCommunityGroupMembership(\""+l_sCommunityGroupKey+"\", \""+membershipData.User.UserKey.Key+"\", \"Manager\", false, this);'>Promote Member</a>");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-ban-members~/, "<a onclick='javascript:_xCore.updateCommunityGroupMembership(\""+l_sCommunityGroupKey+"\", \""+membershipData.User.UserKey.Key+"\", \"Member\", true, this);'>Ban Member</a>");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-admin-tools~/, "Admin Tools");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~space~/, "|");
}
if(membershipData.MembershipTier == "Manager"){
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-promote-members~/, "<a onclick='javascript:_xCore.updateCommunityGroupMembership(\""+l_sCommunityGroupKey+"\", \""+membershipData.User.UserKey.Key+"\", \"Member\", false, this);'>Demote Member</a>");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-ban-members~/, "<a onclick='javascript:_xCore.updateCommunityGroupMembership(\""+l_sCommunityGroupKey+"\", \""+membershipData.User.UserKey.Key+"\", \"Member\", true, this);'>Ban Member</a>");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-admin-tools~/, "Admin Tools");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~space~/, "|");
}
if(membershipData.MembershipTier == "GroupAdmin"){
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-promote-members~/, "");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-ban-members~/, "");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-admin-tools~/, "");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~space~/, "");
}


l_sPLKAdminMemberships_Template_Final += l_sPLKAdminMemberships_Template;
}

$('#plck-groupmemberdir-final').html(l_sPLKAdminMemberships_Template_Final);
if((parseInt(response.NumberOfCommunityGroupMemberships)) > (parseInt(response.NumberPerPage))){
l_aPaginationInfo = _xPagination.mod(response.OnPage, response.NumberOfCommunityGroupMemberships, response.NumberPerPage, response.Key.CommunityGroupKey.Key, "_xCore.getGroupMembershipAdminPage", response.Sort);
l_sPaginationTemplate = $('#plck_pagi_admin_membership').html();
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-left~/,"<div class= 'mod_pagination_left sprite " + l_aPaginationInfo['left_class'] + "'><a " + l_aPaginationInfo['left_string'] +"><span>Left</span></a></div>"); 
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-right~/,"<div class= 'mod_pagination_right sprite" + l_aPaginationInfo['right_class'] + "'><a " + l_aPaginationInfo['right_string'] + "><span>Right</span></a></div>");
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~page-numbers~/, "" + l_aPaginationInfo['item_display'] + " of <b> " + l_aPaginationInfo['total_count'] + "</b>");
$('#plck_pagi_admin_membership_final').html(l_sPaginationTemplate);
} else{
$('#plck_pagi_admin_membership_final').html("");
}

_xTruebox.makeMemberDirectory($('#memberdirectory_template').html());

},
 displayGroupBannedMemberships: function(response){
// $('#banned-members-link').addClass("plk_always_hide");
// $('#group-members-link').removeClass("plk_always_hide");
 var l_sPLKAdminMemberships_Template_Final = '';
 for(var i = 0; i < response.BannedUsers.length; i++){
var l_sPLKAdminMemberships_Template = '';
 var l_sPLKAdminMemberships_Template = $('#plck-groupmemberdir').html();
 var membershipData = '';
var membershipData = response.BannedUsers[i];
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/plck-admin-member-image-url/, membershipData.UserResponse.ImageUrl);
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/plck-admin-member-membership-tier/, "Banned");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/plck-admin-member-persona-url/, membershipData.UserResponse.PersonaUrl);
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-admin-member-display-name~/, membershipData.UserResponse.DisplayName);
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/plck-admin-member-number-of-friends/, membershipData.UserResponse.NumberOfFriends+ " Friends");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-admin-member-display-name~/, membershipData.UserResponse.DisplayName);
l_sCommunityGroupKey = $('#plck-group-key-set').html();
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-promote-members~/, "");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-ban-members~/, "<a onclick='javascript:_xCore.updateCommunityGroupMembership(\""+l_sCommunityGroupKey+"\", \""+membershipData.UserResponse.UserKey.Key+"\", \"Member\", false, this);'>Unban Member</a>");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~plck-admin-tools~/, "");
l_sPLKAdminMemberships_Template = l_sPLKAdminMemberships_Template.replace(/~space~/, "");
l_sPLKAdminMemberships_Template_Final += l_sPLKAdminMemberships_Template;
}

$('#plck-groupmemberdir-final').html(l_sPLKAdminMemberships_Template_Final);
if((parseInt(response.NumberOfCommunityGroupBannedUsers)) > (parseInt(response.NumberPerPage))){
l_aPaginationInfo = _xPagination.mod(response.OnPage, response.NumberOfCommunityGroupMemberships, response.NumberPerPage, response.Key.CommunityGroupKey.Key, "_xCore.getGroupMembershipAdminPage", response.Sort);
l_sPaginationTemplate = $('#plck_pagi_admin_membership').html();
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-left~/,"<div class= 'mod_pagination_left sprite " + l_aPaginationInfo['left_class'] + "'><a " + l_aPaginationInfo['left_string'] +"><span>Left</span></a></div>"); 
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-right~/,"<div class= 'mod_pagination_right sprite" + l_aPaginationInfo['right_class'] + "'><a " + l_aPaginationInfo['right_string'] + "><span>Right</span></a></div>");
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~page-numbers~/, "" + l_aPaginationInfo['item_display'] + " of <b> " + l_aPaginationInfo['total_count'] + "</b>");
$('#plck_pagi_admin_membership_final').html(l_sPaginationTemplate);
} else{
 $('#plck_pagi_admin_membership_final').html("");
}

_xTruebox.makeMemberDirectory($('#memberdirectory_template').html());

},
displayGroupNoMemberships:function(){
alert("display group no memberships!");
$('#plck-groupmemberdir-final').html("No users yet");
_xTruebox.makeMemberDirectory($('#memberdirectory_template').html());

}
};

 
 
 
 

 _xInit = {
initYesNoComments:function(l_sArticleKey, l_sArticleKeyYes, l_sArticleKeyNo, l_nNoPerPage, l_nOnPage, l_sSortBy, l_sDataSource){
document._xPluckCommentCount = 0;
_xCore.getComments(l_sArticleKeyYes, l_nNoPerPage, l_nOnPage, l_sSortBy, "", "article", true, l_sDataSource);
_xCore.getComments(l_sArticleKeyNo, l_nNoPerPage, l_nOnPage, l_sSortBy, "", "article", true, l_sDataSource);
},
initGroupTemplate:function(l_sCommunityKey){
 _xCommunity.getGroupTabModule(l_sCommunityKey);
},
initGroupHome:function(l_sCommunityKey){
 _xCommunity.getRecentActivityFeedModule(l_sCommunityKey, 1, 10);
 _xCore.getStats(l_sCommunityKey, "community");
},
initGroupEvents:function(l_sEventSetKey){
_xCommunityEvents.getEventsBadgeModule(l_sEventSetKey, 3, 1);
_xCommunityEvents.getUpcomingEventsModule(l_sEventSetKey, 3, 1);

},
initGroupForums:function(l_sForumKey){
 _xCommunityForums.getForumsModule(l_sForumKey, 10, 1, 'TimeStampDescending');
},
initGroupPictures:function(l_sGalleryKey){
 _xCommunityPhotos.getPhotosModule(l_sGalleryKey, 10, 1, 'TimeStampDescending');
},
initGroupVideos:function(l_sVideoKey){
 //getStats(l_sVideoKey, "video");
 _xCommunityVideos.getVideosModule(l_sVideoKey, 10, 1, 'TimeStampDescending');
},
initGroupBlogs:function(l_sBlogKey){
_xCommunityBlogs.getBlogsModule(l_sBlogKey, 10, 1, 'TimeStampDescending'); 
//getStats(l_sBlogKey, "blog");
}, 
initCommunityLanding:function(){
_xCommunity.getDiscoverContentForLanding();
},
initCommunityAggregate:function(){
_xCommunity.getGroupPageAggregateModule(10, 1, 'All', 'TimeStampDescending');
},
checkIfUserExists: function(l_sUserKey){
_xCore.checkUser(l_sUserKey);
},
checkIfForumDiscussionExists:function(l_sDiscussionKey){
_xCore.checkIfDiscussionExists(l_sDiscussionKey);
},
initGroupVideoDetailPage: function(l_sVideoKey){
_xCore.getVideoDetail(l_sVideoKey);
},
initGroupPhotoDetailPage: function(l_sPhotoKey){
_xCore.getPhotoDetail(l_sPhotoKey);
}, 
initBlogDetailPage: function(l_sBlogKey){
_xCore.getBlogDetail(l_sBlogKey);
},
initArticle:function(l_sArticleKey){
}


};
 
 
 

 
_xCore = {
 getStats: function(p_sKey, p_sType){
 switch(p_sType){
case 'community':
var p_sStatKey = new CommunityGroupKey(p_sKey);
break;
case 'events':
var p_sStatKey = new EventSetKey(p_sKey);
break;
case 'forum':
var p_sStatKey = new ForumKey(p_sKey);
break;
case 'photo':
var p_sStatKey = new GalleryKey(p_sKey);
break;
case 'video':
var p_sStatKey = new GalleryKey(p_sKey);
break;
case 'blog':
 var p_sStatKey = new BlogKey(p_sKey);
break;
}
sendToServer(p_sStatKey, callbackGroupStatsModule);
 },
 getUserInfo:function(p_sUserKey){
var p_sUserKeyAction = new UserKey(p_sUserKey);
return p_sUserKeyAction;
 }, 
 
 ///////////////Search/////////////////////////
/////////////////////////////////////////////
discoverContent:function(p_sSections, p_sCategories, p_sActivity, p_sContentType, p_nAge, p_nNumItemsToGet){
var l_aSearchSections = p_sSections;
if(p_sCategories.indexOf(",") == -1){
var l_aSearchCategories = new Category(p_sCategories);
}
else{
p_aCategories = p_sCategories.split(",");
var l_aSearchCategories = new Array();
for(var i = 0; i < p_aCategories.length; i++){
l_aSearchCategories[i] = new Category(p_aCategories[i]);
}
 
}
var l_aSearchContributors = new Array();
l_aSearchContributors[0] = new UserTier("Standard");
l_aSearchContributors[1] = new UserTier("Staff");
l_aSearchContributors[2] = new UserTier("Editor");
var l_sActivity = new Activity(p_sActivity);
var l_sContentType = new ContentType(p_sContentType);
var l_nAge = p_nAge;
var l_nNumItemsToGet = p_nNumItemsToGet; 

var discoveryAction = new DiscoverContentAction(l_aSearchSections,
l_aSearchCategories,
l_aSearchContributors,
l_sActivity,
l_sContentType,
l_nAge,
l_nNumItemsToGet);
return discoveryAction;
},
 
 pageRedirect: function(l_sSlug){
 window.location.href = l_sSlug;
 },
 
 updateCommunityGroup: function(l_sCommunityGroupKey){
if(_xValidate.validateCreateGroupForm()){
if(l_sCommunityGroupKey != "null"){
var groupKey = l_sCommunityGroupKey;
}else{
var groupKey = null;
}
var title = $('#title').val();
var description = $('#desc').val();
var tags = $('#tags').val();

if($('#group_section_list').val() == "Own"){
var section = $('#user_own_section_text').val();
}else{
var section = $('#group_section_list:selected').text(); 
}
var photoKey = $('#avatarphotokey').html();
var createGroupAction = updateCommunityGroup(groupKey, title, description, tags, "Public", "bookmark", section, photoKey);
sendToServer(createGroupAction, callbackUpdateCommunityGroup);
}
}, 
 updateCommunityBlog: function(l_sBlogKey){
 if(_xValidate.validateBlogForm()){ 
var title = $('#title').val();
var description = $('#desc').val();
var tags = $('#tags').val();
var published = $('#create_blog_list').val();
var updateBlogAction = updateBlogPost(l_sBlogKey,title,description,tags,published, "new");
sendToServer(updateBlogAction, callbackUpdateBlog);
 }
 }, 
 
 updateGroupEvent: function(l_sEventKey){
if(_xValidate.validateEventForm()){
var l_sTitle = $('#title').val();
var l_sDescription = $('#desc').val();
var l_sLocation = $('#loc').val();
var l_sStartDate = $('#start_time_picker').val();
var l_sEndDate = $('#end_time_picker').val();
var l_sStartTime = $('#start_time_entry').val();
var l_sEndTime = $('#end_time_entry').val();
var l_sBookmarkname = $('#name').val();
var l_sBookmarklink = $('#url').val();
var l_sStartDateTime = ""+l_sStartDate+" "+l_sStartTime+" GMT";
var l_sEndDateTime = ""+l_sEndDate+" "+l_sEndTime+" GMT";
var UTCOffset = 0;
var updateEventAction = updateEvent(l_sEventKey, l_sTitle, l_sDescription, l_sLocation, l_sBookmarkname,l_sBookmarklink, l_sStartDateTime, l_sEndDateTime, "new");
sendToServer(updateEventAction, callbackUpdateGroupSubModuleEvents);
}
 }, 
 
 checkUser: function(l_sUserKey){
var l_sUserInstKey = new UserKey(l_sUserKey);
sendToServer(l_sUserInstKey, callbackUserExists);
 }, 
 
 getActivitiesForUser: function(p_sUserKey){
 var userActivityAction = new RecentUserActivity(new UserKey(p_sUserKey));
 sendToServer(userActivityAction, callbackUserActivityModeration);
 },
 
 getActivitiesForUserMembershipOne: function(p_sUserKey){
 var userActivityAction = new RecentUserActivity(new UserKey(p_sUserKey));
 sendToServer(userActivityAction, callbackUserActivityMembershipOne);
 },
 
 getActivitiesForUserMembershipTwo: function(p_sUserKey){
 var userActivityAction = new RecentUserActivity(new UserKey(p_sUserKey));
 sendToServer(userActivityAction, callbackUserActivityMembershipTwo);
 },
 
 
 
 getGroupMembershipPage: function(l_sCommunityKey, l_sNumberPerPage, l_sOnPage, l_sSortBy){
 var membershipAction = new CommunityGroupMembershipPage(new CommunityGroupKey(l_sCommunityKey), l_sNumberPerPage, l_sOnPage, l_sSortBy);
 sendToServer(membershipAction, callbackCommunityUserMembership);
 }, 
 
 getGroupMembershipAdminPage: function(l_sCommunityKey, l_sNumberPerPage, l_sOnPage, l_sSortBy){
 var membershipAction = new CommunityGroupMembershipPage(new CommunityGroupKey(l_sCommunityKey), l_sNumberPerPage, l_sOnPage, l_sSortBy);
 sendToServer(membershipAction, callbackCommunityUserAdminMembership);
 }, 
 
 getGroupMembershipBannedPage: function(l_sCommunityKey, l_sNumberPerPage, l_sOnPage, l_sSortBy){
 var membershipAction = new CommunityGroupBannedUserPage(new CommunityGroupKey(l_sCommunityKey), l_sNumberPerPage, l_sOnPage, l_sSortBy);
 sendToServer(membershipAction, callbackCommunityUserBannedMembership);
 }, 
 
 requestCommunityGroupMembership: function(p_sCommunityKey, p_sUserKey){
 // send the request via ajax to our local server (Aleks 5/17/10)
var p_sCallbackFunctionName = 'callbackJoinedGroup';
BaseAjax._xArgs.data = 'a=AssociateUserWithGroup';
BaseAjax._xArgs.data += '&CommunityKey='+p_sCommunityKey;
BaseAjax._xArgs.data+= '&CallbackFunctionName='+p_sCallbackFunctionName;
//Tempoararily commented out newsletter checkbox.
//BaseAjax._xArgs.data += '&newsletter=0';
BaseAjax._xArgs.requestType = "POST";
BaseAjax._xArgs.returnDiv = '#returndiv';
BaseAjax.makeAjaxCall(AJAX_URL);
}, 
 requestCommunityGroupMembershipOnRegistration: function(p_sCommunityKey, p_sUserKey){
var inviteAction = new RequestCommunityGroupMembershipAction(new CommunityGroupKey(p_sCommunityKey),new UserKey(p_sUserKey));
sendToServer(inviteAction, callbackGeneric);
}, 

getVideoDetail: function(p_sVideoKey){
var videoKeyAction = new VideoKey(p_sVideoKey);
sendToServer(videoKeyAction, callbackVideoDetail);
}, 
getPhotoDetail: function(p_sPhotoKey){
var photoKeyAction = new PhotoKey(p_sPhotoKey);
sendToServer(photoKeyAction, callbackPhotoDetail);
},
getBlogDetail: function(p_sBlogKey){
var blogKeyAction = new BlogPostKey(p_sBlogKey);
sendToServer(blogKeyAction, callbackBlogDetail);
},
getComments:function(p_nKey, p_nNoPerPage, p_nOnPage, p_sSortType, p_sFindCommentKey, p_sKeyType, p_bNotPagination, p_sDataSource){
if(p_bNotPagination == true){
document._xPluckIsNotPagination = true;
}else{
document._xPluckIsNotPagination = false;
}
switch (p_sKeyType){
case 'article':
var commentKey = new ArticleKey(p_nKey);
break;
case 'gallery':
var commentKey = new GalleryKey(p_nKey);
break;
case 'photo':
var commentKey = new PhotoKey(p_nKey);
break;
case 'video':
var commentKey = new VideoKey(p_nKey);
break;
case 'blogpost':
var commentKey = new BlogPostKey(p_nKey);
break;
}
var commentPageAction = new CommentPage(commentKey, p_nNoPerPage, p_nOnPage, p_sSortType,p_sFindCommentKey);
if(p_sKeyType == "article"){
if(p_sDataSource == g_sDataSourceCMS){
sendToServer(commentPageAction, callbackCMSCommentsYesNo);
}else{
sendToServer(commentPageAction, callbackPluckCommentsYesNo);
}
}else{
sendToServer(commentPageAction, callbackComments);
}
},
checkIfArticleExists: function(p_sArticleKey){
 var articleAction = new ArticleKey(p_sArticleKey);
sendToServer(articleAction, callbackArticleExists);
},
updateArticle: function(p_sArticleKey, p_nOnPageUrl, p_nOnPageTitle, p_sSection, p_sCategories){
if(p_sCategories.indexOf(",") == -1){
var l_aArticleCategories = new Category(p_sCategories);
}else{
l_aCategories = p_sCategories.split(",");
var l_aArticleCategories = new Array();
for(var i = 0; i < l_aCategories.length; i++){
l_aArticleCategories[i] = new Category(l_aCategories[i]);
}
}
 
var updateArticleAction = new UpdateArticleAction(new ArticleKey(p_sArticleKey), p_nOnPageUrl, p_nOnPageTitle, new Section(p_sSection),l_aArticleCategories);
sendToServer(updateArticleAction, callbackGeneric);
},
getYesNoCommentIds: function(l_sArticleId, l_sCMSItemType){
 
//TODO:Obfuscate the Article Keys as they are too transparent and can cause security issues.
var l_sConstructArticleKey = ""+l_sArticleId+""+g_sDelimiter+""+l_sCMSItemType+""+g_sDelimiter+"";
var l_sConstructYesKey = ""+l_sArticleId+""+g_sDelimiter+""+l_sCMSItemType+""+g_sDelimiter+""+ g_sYesKey +"";
var l_sConstructNoKey = ""+l_sArticleId+""+g_sDelimiter+""+l_sCMSItemType+""+g_sDelimiter+""+ g_sNoKey +"";
var l_aYesNoCommentIds = new Array();
l_aYesNoCommentIds["article_key"] = l_sConstructArticleKey;
l_aYesNoCommentIds["yes"] = l_sConstructYesKey;
l_aYesNoCommentIds["no"] =l_sConstructNoKey;
 
return l_aYesNoCommentIds;
 
},
updateCommunityGroupMembership: function(l_sCommunityKey, l_sUserKey, l_sMembershipTier, l_sIsBanned, f){
document._xMembership = f;
 var updateGroupMembershipAction = new UpdateCommunityGroupMembershipAction(new CommunityGroupKey(l_sCommunityKey), new UserKey(l_sUserKey), new MembershipTier(l_sMembershipTier), l_sIsBanned);
 sendToServer(updateGroupMembershipAction, callbackUpdateCommunityGroupMembership);
},
getBlogInfoAfterUpload: function(p_sBlogKey){
var blogKeyAction = new BlogPostKey(p_sBlogKey);
sendToServer(blogKeyAction, callbackBlogInfoAfterUpload);
},
sendEmailViaPluck: function(){
 //Sample for testing
 //requestBatch.AddToRequest(new EmailContentAction("vishal@codeandtheory.com", "An interesting gallery", "Hello, Joe! One of our users thought you would like this gallery:http://www.newspaper.com/galleries/puppies"));
 var l_sTo = $('#to').val();
 var l_sEmailSplit = l_sTo.split(",");
 for(var i=0; i<l_sEmailSplit.length;i++){
 var l_sToEach = l_sEmailSplit[i];
var l_sSubject = $('#subject').val();
 var l_sUserBody = $('#user_body').val();
 var l_sVersusBody = $('#versus_body').val();
 var l_sBody = l_sVersusBody+"'"+l_sUserBody+"'";
 var emailAction = new EmailContentAction(l_sToEach, l_sSubject, l_sBody);
 sendToServer(emailAction, callbackEmailSent);
 }
},
sendEmailWithUserId: function(l_sUserKey, l_sSubject, l_sBody){
var emailAction = new EmailContentWithUserIDAction(new UserKey(l_sUserKey), l_sSubject, l_sBody);
sendToServer(emailAction, callbackGemeric);
}, 
checkIfDiscussionExists: function(p_sCommunityForumKey){
 var forumsAction = new DiscussionKey(p_sCommunityForumKey); 
// var forumsAction = new ForumDiscussionsPage(l_sCommunityForumKey, 10, 1, "TimeStampAscending");
 sendToServer(forumsAction, callbackForumExists);
}

};

_xServer = {
 
 sendMultipleRequestsToServer: function(l_aRequests){
 for(i = 0; i < l_aRequests.length; i++){
 requestBatch.AddToRequest(l_aRequests[i]);
 }
requestBatch.BeginRequest(g_xServerUrl, l_xCallbackFunction);
 }
}
_xUtils = {
displayModifiedDate: function(p_sDate){
 l_aMonths = new Array("Zero", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
 l_sYear = p_sDate;
 l_sYearSplit = l_sYear.split("/");
 l_sPluckMonth = l_sYearSplit[0];
 l_sMonth = l_aMonths[l_sPluckMonth];
 l_sPluckYearTime = l_sYearSplit[2].split(" ");
 l_sYear = l_sPluckYearTime[0];
 l_sModifiedTime = ""+ l_sYearSplit[1] +" "+ l_sMonth +", "+ l_sYear +"";
return l_sModifiedTime;
}
}

 
function isArray( obj ) {
return toString.call(obj) === "[object Array]";
}

function sendToServer(l_sRequest, l_sCallbackFunction){
var requestBatch = new RequestBatch(); 
requestBatch.AddToRequest(l_sRequest); 
requestBatch.BeginRequest(g_xServerUrl, l_sCallbackFunction);
}


////////////////Forums///////////////////////////
/////////////////////////////////////////////////
function updateForumDiscussion(p_sForumKey, p_sTitle, p_sDesc, p_sIsQuestion, p_sSection, p_sCategory, p_sPoll){
var l_sForumKey = new ForumKey(p_sForumKey);
var l_sTitle = p_sTitle;
var l_sDesc = p_sDesc;
var l_sIsQuestion = p_sIsQuestion;
var l_sSection = p_sSection;
var l_sCategory = p_sCategory;
var l_sPoll = p_sPoll;
var updateForumDiscussionAction = new UpdateForumDiscussionAction(new ForumKey(l_sForumKey), l_sTitle, l_sDesc, l_sIsQuestion, l_sSection, l_sCategory, l_sPoll);
return updateForumDiscussionAction;
}
function addForumDiscussionPost(p_sDiscussionKey, p_sTitle, p_sDesc, p_sIsQuestion){
var l_sDiscussionKey = new DiscussionKey(p_sDiscussionKey);
var l_sTitle = p_sTitle;
var l_sDesc = p_sDesc;
var l_sIsQuestion = p_sIsQuestion;
var addForumPostAction = new UpdateForumPostAction(l_sDiscussionKey, l_sTitle, l_sDesc, l_sIsQuestion)
return addForumPostAction;
}
function updateForumDiscussionPost(p_sForumPostKey, p_sTitle, p_sDesc, p_sIsQuestion){
var l_sForumPostKey = new ForumPostKey(p_sForumPostKey);
var l_sTitle = p_sTitle;
var l_sDesc = p_sDesc;
var l_sIsQuestion = p_sIsQuestion;
var editForumPostAction = new UpdateForumPostAction(l_sForumPostKey, l_sTitle, l_sDesc, l_sIsQuestion)
return editForumPostAction;
}
function getCommunityForumsPage(p_sCommunityForumKey, p_nNoPerPage, p_nOnPage, p_sSort){
var l_sCommunityForumKey = new ForumKey(p_sCommunityForumKey); 
var getForumsAction = new ForumDiscussionsPage(l_sCommunityForumKey, p_nNoPerPage, p_nOnPage, p_sSort);
return getForumsAction;
}

////////////////////Blogs///////////////////////
////////////////////////////////////////////////
function updateBlogPost(p_xBlogKey,p_sTitle,p_sDescription,p_sTags,p_sPublished, p_sActionType){
 if (p_sActionType == "update"){ 
var l_xBlogKey = new BlogPostKey(p_xBlogKey);
 }else{
var l_xBlogKey = new BlogKey(p_xBlogKey);
 }
var l_sTitle = p_sTitle;
var l_sDescription = p_sDescription;
var l_sTags = p_sTags;
var l_sPublished = p_sPublished;
var l_sPostDate = new Date();
var l_sGMTPostDate = l_sPostDate.toGMTString();
var updateBlogPostAction = new UpdateBlogPostAction(l_xBlogKey,l_sTitle,l_sDescription,l_sTags, l_sGMTPostDate, l_sPublished)
return updateBlogPostAction;
}
function getCommunityBlogsPage(p_sCommunityBlogKey, p_nNoPerPage, p_nOnPage, p_sSort){
var l_sCommunityBlogKey = new BlogKey(p_sCommunityBlogKey); 
var getBlogsAction = new BlogPostPage(l_sCommunityBlogKey, p_nNoPerPage, p_nOnPage, p_sSort);
return getBlogsAction;
}
/////////////////Gallery////////////////////////
////////////////////////////////////////////////
function updateGallery(p_sGalleryKey, p_sGalleryType, p_sMediaType, p_sTitle,p_sDesc, p_sTags, p_sSection){
var l_sGalleryKey = new GalleryKey(p_sGalleryKey);
var l_sGalleryType = new GalleryType(p_sGalleryType);
var l_sMediaType = new MediaType(p_sMediaType);
var l_sTitle = p_sTitle;
var l_sDesc = p_sDesc;
var l_sTags = p_sTags;
var l_sSection = new Section(p_sSection);
var updateAction = new UpdateGalleryAction(l_sGalleryKey, l_sGalleryType, l_sMediaType, l_sTitle, l_sDesc, l_sTags, l_sSection);
return updateAction;
}
function publicGalleryPage(p_nNoPerPage, p_nOnPage, p_sMediaType){
var l_nNoPerPage = p_nNoPerPage;
var l_nOnPage = p_nOnPage;
var l_sMediaType = new MediaType(p_sMediaType);
var pageAction = new PublicGalleryPage(l_nNoPerPage, l_nOnPage, l_sMediaType);
return pageAction;
}
////////////////////Videos/////////////////////
//////////////////////////////////////////////
function getCommunityGroupPhotos(p_sGroupPhotoKey, p_nNoPerPage, p_nOnPage, l_sSortBy){
var l_sGroupPhotoKey = new GalleryKey(p_sGroupPhotoKey);
var l_nNoPerPage = p_nNoPerPage;
var l_nOnPage = p_nOnPage;
var photoKeyAction = new PhotoPage(l_sGroupPhotoKey, l_nNoPerPage, l_nOnPage, l_sSortBy);
return photoKeyAction;
}

///////////////////Photos/////////////////////
//////////////////////////////////////////////
function getCommunityGroupVideos(p_sGroupVideoKey, p_nNoPerPage, p_nOnPage, l_sSortBy){
var l_sGroupVideoKey = new GalleryKey(p_sGroupVideoKey);
var l_nNoPerPage = p_nNoPerPage;
var l_nOnPage = p_nOnPage;
var videoKeyAction = new VideoPage(l_sGroupVideoKey, l_nNoPerPage, l_nOnPage, l_sSortBy);
return videoKeyAction;
}
function editPhoto(p_sPhotoKey){
var photoKeyAction = new PhotoKey(p_sPhotoKey);
sendToServer(photoKeyAction, callbackEditPhoto);
}

//////////////////Recommend//////////////////
/////////////////////////////////////////////
function recommend(p_sKey, p_sType, f) {
 if(_xUser.getCookie("")){
 var l_bEnableFireUpCount = true;
 document._xRecommend = f;
switch(p_sType){ 
 case 'blog-post':
var recKey = new BlogPostKey(p_sKey);
 break;
 case 'photo':
 document._xIncrementRecommend = true;
var recKey = new PhotoKey(p_sKey);
 break;
 case 'video':
 document._xIncrementRecommend = true;
var recKey = new VideoKey(p_sKey);
 break;
 case 'comment':
var recKey = new CommentKey(p_sKey);
 break;
 case 'review':
var recKey = new ReviewKey(p_sKey);
 break;
 case 'gallery':
var recKey = new GalleryKey(p_sKey);
 break;
 case 'article':
 if(document._xIncrementRecommend != false){
 document._xIncrementRecommend = true;
 var recKey = new ArticleKey(p_sKey);
 } else {
 l_bEnableFireUpCount = false;
 }
 break;
}
 
 if(l_bEnableFireUpCount){
 var recommendAction = new RecommendAction(recKey);
 sendToServer(recommendAction, callbackRecommend);
 }
 
 }else{
_xTruebox.makeSignupRegister();
 }
 
}
/////////////////////Report Abuse///////////////
////////////////////////////////////////////////
function reportAbuse(p_sKey, p_sReason, p_sDesc, p_sKeyType, f){
document._xAbuse = f;
switch(p_sKeyType){
case 'comment':
var abuseKey = new CommentKey(p_sKey);
break;
case 'community':
var abuseKey = new CommunityGroupKey(p_sKey);
break;
}
 var abuseAction = new ReportAbuseAction(abuseKey, p_sReason, p_sDesc);
 //return abuseAction;
sendToServer(abuseAction, callbackReportAbuse);
}
/////////////////////Comments///////////////////
////////////////////////////////////////////////
function makeComment(p_nKey, p_sPageUrl, p_sPageTitle, p_sCommentBody, p_sKeyType){
 if(_xUser.getCookie("")){
if(!document._nCommentSent){
document._nCommentSent = p_nKey;
var p_sCommentBody = document.getElementById("plck_comment_body").value;
if(p_sCommentBody == "Type your smack here..." || p_sCommentBody == ""){
 return;
}

switch (p_sKeyType){
case 'article':
commentKey = new ArticleKey(p_nKey);
break;
case 'gallery':
commentKey = new GalleryKey(p_nKey);
break;
case 'photo':
commentKey = new PhotoKey(p_nKey);
break;
case 'video':
commentKey = new VideoKey(p_nKey);
break;
case 'blogpost':
commentKey = new BlogPostKey(p_nKey);
break;
}
var commentAction = new CommentAction(commentKey, p_sPageUrl, p_sPageTitle, p_sCommentBody); 
sendToServer(commentAction, callbackActionYesNoComments);
}
}
else{
_xTruebox.makeSignupRegister();
}
}

/////////////////////Community//////////////////
////////////////////////////////////////////////
function updateCommunityGroup(p_xCommunityKey, p_sTitle, p_sDescription, p_sTags, p_sVisibility, p_sBookMarks, p_sSections, p_xPhotoKey){
if(p_xCommunityKey != null){
var l_xCommunityKey = new CommunityGroupKey(p_xCommunityKey);
}else{
var l_xCommunityKey = p_xCommunityKey;
}
var l_sTitle = p_sTitle;
var l_sDescription = p_sDescription;
var l_sTags = p_sTags;
var l_sVisibility = new CommunityGroupVisibility(p_sVisibility);
var l_sBookMarks = new Bookmark(p_sBookMarks);
var l_sSections = new Section(p_sSections);
var l_xPhotoKey = new PhotoKey(p_xPhotoKey);
var updateGroupAction = new UpdateCommunityGroupAction(l_xCommunityKey, l_sTitle, l_sDescription, l_sTags, l_sVisibility, l_sBookMarks, l_sSections, l_xPhotoKey);
return updateGroupAction;
}
function editCommunityGroup(p_sCommunityGroupKey){
formHTML = displayGroupForm();
document.getElementById('thickbox').innerHTML = formHTML;
sendToServer(new CommunityGroupKey(p_sCommunityGroupKey), callbackEditGroup);
}
function getCommunity(p_xCommunityKey){
var l_xCommunityGroupKeyAction = new CommunityGroupKey(p_xCommunityKey);
return l_xCommunityGroupKeyAction;
}
function getCommunityGroupPage(p_nNoPerPage, p_nOnPage, p_sSectionName, p_sSortType){
var l_nNoPerPage = p_nNoPerPage;
var l_nOnPage = p_nOnPage;
var l_sSectionName =p_sSectionName;
var l_sSortType = p_sSortType;
var communityGroupPageAction = new CommunityGroupPage(l_nNoPerPage, l_nOnPage, l_sSortType, l_sSectionName);
return communityGroupPageAction;
}

function recentFeedActivity(_xCommunityGroupKey, p_nOnPage, p_nNoPerPage){
var _xCommunityGroupKey = new CommunityGroupKey(_xCommunityGroupKey);
var l_nOnPage = p_nOnPage;
var l_nNoPerPage = p_nNoPerPage;
var recentMiniFeedActivity = new RecentMiniFeedActivity(_xCommunityGroupKey, l_nOnPage, l_nNoPerPage);
return recentMiniFeedActivity;
}
//Post Edit Community Events:
function updateEvent(p_xEventKey,p_sTitle,p_sDescription,p_sLocation, p_sBookmarkName, p_sBookmarkLink, p_sStartDate,p_sEndDate, p_sActionType){
if (p_sActionType == "update"){ 
var l_xEventKey = new EventKey(p_xEventKey);
}else{
var l_xEventKey = new EventSetKey(p_xEventKey);
}
var l_sTitle = p_sTitle;
var l_sDescription = p_sDescription;
var l_sLocation = p_sLocation;
var l_sBookmarkName = p_sBookmarkName;
var l_sBookmarkLink = p_sBookmarkLink;
var l_sStartDate = p_sStartDate;
var l_sEndDate = p_sEndDate;
var UTCOffset = 0;
var updateEventAction = new UpdateEventAction(l_xEventKey, l_sTitle, l_sDescription, l_sLocation, l_sBookmarkName, l_sBookmarkLink , l_sStartDate, l_sEndDate, UTCOffset);
return updateEventAction;
}
 function searchCommunityGroup(p_sCommunityGroupKey, p_sSearchType, p_sSearchString, p_nNoPerPage, p_nOnPage ){
var l_sCommunityGroupKey = new CommunityGroupKey(p_sCommunityGroupKey); //f0e71460-8b4b-493d-9620-aea11b58c0b6
var l_sSearchType = p_sSearchType;
var l_sSearchString = p_sSearchString; 
var l_nNoPerPage = p_nNoPerPage;
var l_nOnPage = p_nOnPage;
var searchAction = new CommunityGroupSearchAction(l_sCommunityGroupKey, l_sSearchType,l_sSearchString, l_nNoPerPage, l_nOnPage);
return searchAction;
}
function getCommunityGroupStats(p_sCommunityGroupKey){
var l_sCommunityGroupKey = new CommunityGroupKey(p_sCommunityGroupKey); 
var statsAction = l_sCommunityGroupKey; 
return statsAction;
 
}


function getCommunityEventsPage(p_sCommunityEventKey, p_sStartDate, p_sEndDate, p_nNoPerPage, p_nOnPage, p_sSortBy){
var l_sCommunityEventKey = new EventSetKey(p_sCommunityEventKey);
var l_sStartDate = p_sStartDate;
var l_sEndDate = p_sEndDate;
var l_nNoPerPage = p_nNoPerPage;
var l_nOnPage = p_nOnPage;
var getEventsAction = new EventsPage(l_sCommunityEventKey, l_sStartDate, l_sEndDate, l_nNoPerPage, l_nOnPage, p_sSortBy);
return getEventsAction;
}
////////////Forms and Moderation////////////
//////////////////////////////////
//Invite User
function addUserToCommunityGroup(p_sCommunityKey){
formHTML = requestCommunityGroupMembershipForm(p_sCommunityKey);
document.getElementById('thickbox').innerHTML = formHTML;
}

//Report Abuse:
function reportAbuseAction(l_sCommunityKey,p_sType){
formHTML = reportAbuseForm(l_sCommunityKey, p_sType);
document.getElementById('thickbox').innerHTML = formHTML;
}
function reportGroupAbuse(p_sKey, p_sKeyType){
var p_sReason = document.getElementById("reason").value;
var p_sDesc = document.getElementById("description").value;
switch(p_sKeyType){
case 'comment':
var abuseKey = new CommentKey(p_sKey);
break;
case 'community':
var abuseKey = new CommunityGroupKey(p_sKey);
break;
}
 var abuseAction = new ReportAbuseAction(abuseKey, p_sReason, p_sDesc);
 //return abuseAction;
sendToServer(abuseAction, callbackGeneric);
}
function requestGroupDeleteAction(l_sCommunityKey){
formHTML = requestGroupDeleteForm(l_sCommunityKey);
document.getElementById('thickbox').innerHTML = formHTML;
}
function requestGroupDelete(l_sCommunityKey){
var p_sReason = document.getElementById("reason").value;
var requestGroupDeleteAction = RequestDeleteCommunityGroupAction(l_sCommunityKey, p_sReason);
sendToServer(requestGroupDeleteAction, callbackGeneric);
}

function updateGroupAction(l_sCommunityGroupKey){
formHTML = displayGroupForm(l_sCommunityGroupKey);
document.getElementById('thickbox').innerHTML = formHTML;
if(l_sCommunityGroupKey != null){
sendToServer(new CommunityGroupKey(l_sCommunityGroupKey), callbackEditGroup);
}
}

 function generateImageFromText(l_sText, l_sColor, l_sBg){
 var l_aTextInfo = { c:''+l_sColor+'',type:'b','bg':''+l_sBg+'',tran:true,s:20,t:l_sText, js:true }
var l_simagEd = makeCustomImage(l_aTextInfo);
return l_simagEd;
 }

function updateEventAction(l_sEventKey, p_sType){
formHTML = displayEventForm(l_sEventKey, p_sType);
document.getElementById('thickbox').innerHTML = formHTML;
if(p_sType == "update"){
sendToServer(new EventKey(l_sEventKey), callbackEditGroupEvent);
}
}
function updateGroupEvent(l_sEventKey, p_sType){
var l_sPostDate = new Date();
var l_sGMTPostDate = l_sPostDate.toGMTString();
var l_sStartDate = l_sPostDate.toGMTString(); //"Wed, 21 0ct 2009 23:58:42 GMT";
var title = document.getElementById("addevent_title").value;
var description = document.getElementById("addevent_desc").value;
var location = document.getElementById("addevent_location").value;
var bookmarkname = document.getElementById("addevent_bookmarkname").value;
var bookmarklink = document.getElementById("addevent_bookmarklink").value;
var UTCOffset = 0;
var updateEventAction = updateEvent(l_sEventKey, title, description, location, bookmarkname, bookmarklink, l_sStartDate, l_sGMTPostDate, p_sType);
sendToServer(updateEventAction, callbackUpdateGroupSubModuleEvents);
}
 function pageRedirect(p_sKey, p_sUrl){
window.location.href = "" + p_sUrl + "" + p_sKey; 
}
function userOwnSection(){
 if($('#group_section_list').val() == "Own"){
$('#user_own_section').removeClass("plk_always_hide").addClass("plk_show");
} else{
 $('#user_own_section').removeClass("plk_show").addClass("plk_always_hide");
}
}
function getActivityTime(l_sActivity){
 var l_sTodaysDate=new Date();
 l_sTodaysJSTime= l_sTodaysDate.getTime();
l_sDateUploaded = l_sActivity.split("/");
l_sYearSplit = l_sDateUploaded[2].split(" ");
l_sYear = l_sYearSplit[0];
l_sTimeSplit = l_sYearSplit[1];
l_sTime = l_sTimeSplit.split(":");
l_sUploadDate = new Date();
l_sUploadDate.setMonth(l_sDateUploaded[0] - 1);
l_sUploadDate.setDate(l_sDateUploaded[1]);
l_sUploadDate.setYear(l_sYear);
l_sUploadDate.setHours(l_sTime[0]);
l_sUploadDate.setMinutes(l_sTime[1]);
l_sUploadDate.setSeconds(l_sTime[2]);
l_sUploadedJSTime = l_sUploadDate.getTime();
//Subtract time taken
l_sTimeTaken = l_sTodaysJSTime - l_sUploadedJSTime;
//Calculate days taken
var l_nRawDays = l_sTimeTaken/ (1000*60*60*24);
var l_nNumDays = Math.floor(l_nRawDays);
//calculate hrs
if (l_nNumDays <= 0) {
l_sFloorRawDays = Math.floor(l_nRawDays);
l_sSubtractRawDays = l_nRawDays - l_sFloorRawDays;
l_nRawHrs = l_sSubtractRawDays*24;
l_nNumHrs = Math.floor(l_nRawHrs);
} else{
if(l_nNumDays == 1){
l_sReturnDays = ""+l_nNumDays+" day ago.";
} else {
 l_sReturnDays = ""+l_nNumDays+" days ago.";
}
return l_sReturnDays;
}
//calculate minutes
if (l_nNumHrs <= 0 ) {
 l_nRawMins = (l_nRawHrs - Math.floor(l_nNumHrs)) * 60;
 l_nNumMins = Math.floor(l_nRawMins);
} else{
if(l_nNumHrs == 1){
l_sReturnHours = ""+l_nNumHrs+" hour ago.";
} else{
l_sReturnHours = ""+l_nNumHrs+" hours ago.";
}
return l_sReturnHours;
}
//calculate seconds
if (l_nNumMins <= 0 ) {
l_nRawSecs = (l_nRawMins - Math.floor(l_nRawMins)) * 60;
l_nNumSecs = Math.floor(l_nRawSecs);
} else{
if(l_nNumMins == 1){
l_sReturnMinutes = ""+l_nNumMins+" minute ago.";
} else{
l_sReturnMinutes = ""+l_nNumMins+" minutes ago.";
}
return l_sReturnMinutes;
 }
 
 if(l_nNumSecs == 1){
l_nReturnSeconds = ""+l_nNumSecs+" second ago.";
 }else{
 l_nReturnSeconds = ""+l_nNumSecs+" seconds ago.";
 }
 return l_nReturnSeconds;
}









// JavaScript Document

_xForms = {
 displayGroupForm: function(l_sCommunityGroupKey){

 if(_xUser.getCookie("")){
$('#truebox').addClass('truebox_community');
var l_sHtml = "";
l_sHtml += '<div class="png txt txt_creategroup">Create a Group</div>'+
 '<div class="closebtn sprite"><a href="javascript:void" onclick="_xTruebox.closePopup();"><span>X</span></a></div>'+
 '<div id="groupeditor">'+
 '<div id="groupeditor_content" class="groupeditor_content">';
 
l_sHtml +='<form id="uploadassetform" name = "create_group_form" method="post" action="" enctype="multipart/form-data">';
l_sHtml +='<label for="title" class="first_label"> Title*:<span id="invalid_title" class="invalid"></span></label>'+
'<input class="text" type="text" id="title" name="title" />';
l_sHtml += '<label for="desc">Description</label>'+
'<textarea class="cg_textarea" id="desc"></textarea>';
l_sHtml += '<label for="tags">Tags:</label>'+
'<input class="text" type="text" id="tags" name="tags" />';
l_sHtml += '<label for="photoUpload">Upload Photo*<span id="invalid_media" class="invalid"></span><span id="invalid_file_format" class= "invalid_file_format"></span></label>'+
 '<input type="file" id="photoUpload" name="Filedata" onChange="_xValidate.validateAvatarPhoto(this.value)" />'+
 '<div id="avatarphotokey" class="plk_always_hide">null</div>';
 
l_sHtml += '<label for="group_section_list">Sport:</label>';
l_sHtml += "<div class='inputholder_left' id='form'>";
l_sHtml +="<SELECT ID='group_section_list' NAME='group_section_list' onchange='userOwnSection()'>";
l_sHtml += "<OPTION VALUE='NHL'>NHL";
l_sHtml += "<OPTION VALUE='Cycling'>Cycling";
l_sHtml += "<OPTION VALUE='Hunting'>Hunting";
l_sHtml += "<OPTION VALUE='Fishing'>Fishing";
l_sHtml += "<OPTION VALUE='Mixed Martial Arts'>Mixed Martial Arts";
l_sHtml += "<OPTION VALUE='College Football'>College Football";
l_sHtml += "<OPTION VALUE='Indycar'>Indycar";
l_sHtml += "<OPTION VALUE='Bull Riding'>Bull Riding";
l_sHtml += "</SELECT>";
l_sHtml += "</div>";
 
 l_sHtml +='<div id="user_own_section" class="plk_always_hide">'+
'<div class="inputholder_right">'+
'<input class="sm_text" type="text" id="user_own_section_text" name="tags" />'+
'</div>'+
'<div id="error" class="plk_always_hide">false</div>'+
'</div>';
 l_sHtml += '<div class="submitcol">'+
'<div class="createbtn sprite"><a onclick="_xCore.updateCommunityGroup(\'' + l_sCommunityGroupKey + '\')" ><span>Create</span></a></div>'+
'</div>';
l_sHtml += '</form>'+
 '</div></div>'; //end of #groupeditor and .groupeditor_content
l_sHtml += '<div id="thankyou" class="plk_always_hide">'+
'<div class="thankyou_generic"></div>'+
 '<div id="takemetocontent" style="padding-left:140px"></div>'+
'</div>';
 
 $('#truebox').html(l_sHtml);
}else{
_xTruebox.makeSignupRegister();
}
 },
 
 displayThankYouMessage: function(){
var l_sGroupTitle = $('#plck-group-title').html();

var l_sStartText = 'FOR JOINING '+l_sGroupTitle.toUpperCase()+'!';
var l_aTextInfo = { c:'000000',type:'med','bg':'ffffff',tran:true,s:13,w:230,cen:true,t:l_sStartText}
var l_sImageUrl = makeCustomImage(l_aTextInfo);

$('#truebox').addClass('truebox_community');
var l_sHtml = "";
l_sHtml += '<div class="closebtn sprite"><a href="javascript:void" onclick="_xTruebox.closePopup();"><span>X</span></a></div>';
l_sHtml +='<div id = "groupeditor_content" class="groupeditor_content">'+
'<div id = "thankyou">'+
 '<div class = "thankyou_generic"><img class="finishtext" src="'+l_sImageUrl+'" ></div>'+
'</div>'+
'</div>';
$('#truebox').html(l_sHtml);
},
 
 displayGroupBlog: function(l_sType){
 if(_xUser.getCookie("")){
$('#truebox').addClass('truebox_community');
 
if(l_sType == 'post'){
 var l_sBlogKey=$('#plck-group-blog-key-set').html();
}
var l_sHtml = "";
 l_sHtml +='<div class="png txt txt_postblog">Post to Blog</div>'+
'<div class="closebtn sprite"><a href="javascript:void" onclick="_xTruebox.closePopup();"><span>X</span></a></div>'+
 '<div id = "groupeditor">'+
 '<div id = "groupeditor_content" class="groupeditor_content">';
l_sHtml +='<form id="uploadassetform" name = "create_blog_form" method="post" action="" enctype="multipart/form-data">';
l_sHtml += '<label for="title" class="first_label">Title*:<span id="invalid_title" class="invalid"></span></label>'+
 '<input class = "text" type="text" id="title" name="title" />';
l_sHtml += '<label for="desc">Body*:<span id="invalid_desc" class="invalid"></span></label>'+
 '<textarea class="tinymce_textarea" id="desc"></textarea>';
l_sHtml += '<label for="tags">Tags:</label>'+
 '<input class="text" type="text" id="tags" name="tags" />';
 
 l_sHtml += '<label for="create_blog_list">Published: </label>';
 l_sHtml += '<div class="group_secondarytext" id="form">';
 l_sHtml += '<select id="create_blog_list" name="create_blog_list">';
 l_sHtml +='<option value="True">Yes'+
 '<option value="False">No';
 l_sHtml += '</select>'; 
 l_sHtml += '</div>'+
'<div class="gap20"></div>'+
'<div id="error" class="plk_always_hide">false</div>';
 l_sHtml +='<div class="postbtn sprite"><a onclick="_xCore.updateCommunityBlog(\'' + l_sBlogKey + '\')" ><span>Post</span></a></div>'+
'<div class="cancelbtn sprite"><a href="javascript:void" onclick="_xTruebox.closePopup();"><span>Cancel</span></a></div>';
l_sHtml += "</form>";
l_sHtml +="</div></div>";
l_sHtml += '<div id = "thankyou" class = "plk_always_hide">'+
'<div class = "thankyou_generic"></div>'+
 '<div id = "takemetocontent"></div>'+
'</div>';
 
 
 $('#truebox').html(l_sHtml);
// _xFormUtils.initTinyMCE();
// _xFormUtils.loadTinyMCE();
}else{
_xTruebox.makeSignupRegister();
}
 }, 
 
 displayUserBlog: function(){
if(_xUser.getCookie("")){
window.location.href = "/user/?plckPersonaPage=PersonaBlog&plckUserId="+_xUser.getPluckUserInfoFromCookie("", "id")+"&uid="+_xUser.getPluckUserInfoFromCookie("", "id")+"";
}else{
 _xTruebox._sUserGroupBlog = true;
 _xTruebox.makeSignupRegister(); 
}
 },
 
 
 displayGroupEvent: function(l_sType){
if(_xUser.getCookie("")){
 
 $('#truebox').addClass('truebox_community');
 
 if(l_sType == 'post'){
 var l_sEventKey=$('#plck-group-event-set-key-set').html();
}
 
 var l_sHtml = "";
 l_sHtml += '<div class="png txt txt_createevent">Create Event</div>'+
 '<div class="closebtn sprite"><a href="javascript:void" onclick="_xTruebox.closePopup();"><span>X</span></a></div>'+
'<div id = "groupeditor">'+
'<div id = "groupeditor_content" class="groupeditor_content">';
 l_sHtml += '<form id="uploadassetform" name = "create_event_form" method="post" action="" enctype="multipart/form-data">';
 l_sHtml += '<label for="title" class="first_label">Title*:<span id="invalid_title" class="invalid"></span></label>'+
 '<input class = "text" type="text" id="title" name="title" />';
 l_sHtml += '<label for="desc">Description*:<span id="invalid_desc" class="invalid"></span></label>'+
 '<textarea class="ce_textarea" id="desc"></textarea>';
 l_sHtml += '<label for="loc">Location*:<span id="invalid_loc" class="invalid"></span></label><input class="text" id="loc" />';
 l_sHtml += '<label for="start_time_picker">'+
'Start Date/Time:'+
'<span id="invalid_setdate" class="invalid"></span>'+
'<span id="invalid_sdate" class="invalid"></span>'+
'<span id="invalid_stime" class="invalid"></span>'+
'</label>'+
 '<input type="text" id="start_time_picker" class="half_input" />'+
'<input type="text" id="start_time_entry" class="half_input" />'+
'<div class="clear"></div>';
 
 l_sHtml += '<label for="end_time_picker">'+
 'End Date/Time:'+
 '<span id="invalid_edate" class="invalid"></span>'+
 '<span id="invalid_etime" class="invalid"></span>'+
'</label>'+
 '<input type="text" id="end_time_picker" class="half_input" />'+
'<input type="text" id="end_time_entry" class="half_input" />'+
'<div class="clear"></div>';
 
 l_sHtml += '<label for="url">'+
'Enter Url/Name:'+
'<span id="invalid_url" class="invalid"></span>'+
'<span id="invalid_urlname" class="invalid"></span>'+
 '</label>'+
'<input type="text" id="url" class="half_input" />'+
'<input type="text" id="name" class="half_input right_input" />';
 l_sHtml += '<div class="gap20"></div>'+
'<div id="error" class="plk_always_hide">false</div>';
 l_sHtml += '<div class="createbtn sprite"><a onclick="_xCore.updateGroupEvent(\'' + l_sEventKey + '\')" ><span>Create</span></a></div>'+
'<div class="cancelbtn sprite"><a href="javascript:void" onclick="_xTruebox.closePopup();"><span>Cancel</span></a></div>';
 l_sHtml +="</form>";
 l_sHtml +="</div></div>";
 
 l_sHtml += '<div id = "thankyou" class = "plk_always_hide">'+
'<div class = "thankyou_generic"></div>'+
 '<div id = "takemetocontent"></div>'+
'</div>';
 
 $('#truebox').html(l_sHtml);
 
_xFormUtils.outputDatePicker("start_time_picker");
_xFormUtils.outputDatePicker("end_time_picker");
_xFormUtils.outputTimePicker("start_time_entry");
_xFormUtils.outputTimePicker("end_time_entry");
 
}else{
_xTruebox.makeSignupRegister();
} 
}, 

displayEmailForm: function(l_sType, f){
 switch(l_sType){
case 'groupblog':
 var l_sArticleSlug = $(f).parents('.article_inner:first').find('.title').attr('href');
 var l_sArticleUrl = "http://"+g_xVersusBaseDomain+l_sArticleSlug;
 var l_sArticleTitle = $(f).parents('.blog_article_inner:first').find('.title').html();
 var l_sContentType = "blog";
break;
case 'grouppicture':
var l_sArticleTitle = $(f).parents('.detail_meta:first').find('#photo-detail-meta-template-final').find('.customimg').attr('alt');
var l_sArticleUrl = window.location.href;
var l_sContentType = "picture";
break;
case 'groupvideo':
 var l_sArticleTitle = $(f).parents('.detail_meta:first').find('#video-detail-meta-template-final').find('.customimg').attr('alt');
 var l_sArticleUrl = window.location.href;
 var l_sContentType = "video";
break;
case 'picture':
var l_sArticleTitle = $(f).parents('.detail_meta:first').find('.customimg').attr('alt');
var l_sArticleUrl = window.location.href;
var l_sContentType = "picture";
break;
case 'video':
var l_sArticleTitle = $(f).parents('.detail_meta:first').find('.customimg').attr('alt');
var l_sArticleUrl = window.location.href;
var l_sContentType = "video";
break;
case 'gear':
var l_sArticleTitle = $(f).parents('.detail_meta:first').find('.customimg').attr('alt');
var l_sArticleUrl = window.location.href;
var l_sContentType = "gear guide";
break;
case 'blog':
var l_sArticleTitle = $(f).parents('.article_inner:first').find('#article_title').html();
var l_sArticleUrl = window.location.href;
var l_sContentType = "blog";
break;
 }

 
 if(_xUser.getCookie("")){
 l_sUserName = _xUser.getPluckUserInfoFromCookie("", "name");
$('#truebox').addClass('truebox_community');
 
 var l_sHtml = "";
 l_sHtml +='<div class="png txt txt_sendemail">Send Email</div>'+
'<div class="closebtn sprite"><a href="javascript:void" onclick="_xTruebox.closePopup();"><span>X</span></a></div>'+
 '<div id="groupeditor">'+
 '<div id="groupeditor_content" class="groupeditor_content">';
l_sHtml +='<form id="uploadassetform" name="send_email_form" method="post" action="" enctype="multipart/form-data">';
l_sHtml += '<label for="to">To*:<span id="invalid_title" class="invalid"></span></label>'+
 '<input class="text" type="text" id="to" name="to" />'+
 '<div class="gap20 input_comment">Enter Comma Separated</div>';
l_sHtml += '<label for="user_body">Body:<span id="invalid_desc" class="invalid"></span></label>'+
 '<textarea class="tinymce_textarea" id="user_body"></textarea>'+
 '<div class="gap20"></div>';
l_sHtml += '<div class="sendbtn sprite"><a onclick="_xCore.sendEmailViaPluck()"><span>Send</span></a></div>'+
 '<div class="cancelbtn sprite"><a href="javascript:void" onclick="_xTruebox.closePopup();"><span>Cancel</span></a></div>';
 
l_sHtml += '<input class = "plk_always_hide" type="text" id="subject" name="subject" value="'+l_sUserName+' wants you to checkout Versus.com!" />'+ 
 '<input class = "plk_always_hide" type="text" id="versus_body" name="versus_body" value="'+l_sUserName+' just sent you a '+l_sContentType+':'+l_sArticleTitle+'.'+ 
 ' Check it out on Versus.com: '+l_sArticleUrl+' ! This is what '+l_sUserName+' has to say about it...."/>'+
 '<div class="gap20"></div>'+
 '<div id = "error" class = "plk_always_hide">false</div>';
 
l_sHtml += "</form>";
l_sHtml +="</div></div>";
l_sHtml += '<div id = "thankyou" class = "plk_always_hide">'+
'<div class = "thankyou_generic"></div>'+
 '<div id = "takemetocontent"></div>'+
'</div>';
 
$('#truebox').html(l_sHtml);

}else{
_xTruebox.makeSignupRegister();
}
 } 

};
_xFormUtils = {
outputDatePicker :function(l_sInputId){
$('#'+l_sInputId).datepicker({dateFormat: 'D, d M yy'});
},
outputTimePicker :function(l_sInputId){
$(function () {
$('#'+l_sInputId).timeEntry({show24Hours: true, showSeconds: true});
});
},
initTinyMCE : function(){
tinyMCE.init({ mode : "textareas",
theme : "advanced",
theme_advanced_buttons1 : "bold,italic,underline,|,cut,copy,paste,pasteword,|,code,|,spellchecker",
theme_advanced_buttons2 : "justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,image",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom"
});
},
loadTinyMCE :function(){
$('.tinymce_textarea').each( function(){
var l_sId = $(this).attr('id');
var l_sName = "#" + l_sId + " .mceEditorContainer";
var l_sData = "#" + l_sId + " .mceContentBody";
tinyMCE.execCommand('mceAddControl', false, l_sId);

if( $(this).attr('rel') == 'tinymce_row_1'){
$('#'+l_sId+'_toolbar2').hide();
$('#'+l_sId+'_toolbar3').hide();
$('#'+l_sId+'_toolbar4').hide();
$('#'+l_sId+'_toolbar5').hide();
}
if( $(this).attr('config-reset-body')){
var l_xObj = _xUtils.getTinyMCEObject(l_sId).body;
l_xObj.style.color = '#000';
l_xObj.style.width = 'auto';
l_xObj.style.padding = '0px';
l_xObj.style.margin = '0px';
l_xObj.style.backgroundColor = '#fff';
}
if( $(this).attr('config-background-color')){
var l_xObj = _xUtils.getTinyMCEObject(l_sId).body;
l_xObj.style.backgroundColor = $(this).attr('config-background-color');
}
});
},
fixDialogBox:function(l_sBoxClass){
setTimeout(function(){
var l_xElement = $('.'+l_sBoxClass);
$(l_xElement).css('left','0px').css('z-index',10000)
},100);
}

};
//
//function displayBlogForm(p_sBlogKey, p_sType){
//
//var html = "";
//
//html += "<h3>Create/ Update Blog!</h3>"; 
//html +="Enter Title: <input type='text' id='postblog_title' name='postblog_title' /><br/><br/>"; 
//html +="Enter Description: <input type='text' id='postblog_description' name='postblog_description' /><br/><br/>"; 
//html +="Enter Tags: <input type='text' id='postblog_tags' name='postblog_tags' /><br/><br/>"; 
//html +="Published(True, False): <input type='text' id='postblog_published' name='postblog_published' /><br/><br/>"; 
//html += "<p><button id='btnUpload' type='button' onclick='updateGroupBlog(\"" + p_sBlogKey + "\", \"" + p_sType + "\")'>Go</button></p> ";
//
//return html;
//}
//
//
//function displayVideoForm(){
// var html = "";
//
//html += "<div id='submitVideo'>";
//html +="<div id = 'submitVideoStep1'>";
//html +="<h3>Step 1: Upload Video</h3>";
//html +="<p>Click <strong>Browse...</strong> to find and select a video on your computer</p>";
//html +="<form id='uploadVideoForm' method='post' action='' enctype='multipart/form-data'>";
//html +="<input id='galleryKey' type='hidden' name='galleryKey' value='' />";
//html +="<p><input type='file' id='videoUpload' name='Filedata' /></p>";
//html +="</form>";
//html += "<p><button id='btnUpload' type='button' onclick='hideObject(\"submitVideoStep1\");showObject(\"submitVideoStep2\")'>Next</button></p>"; 
//html +="</div>";
//html +="<div id='submitVideoStep2' style='display:none'>";
//html += "<h3>Step 2: Enter Video Details</h3>"; 
//html +="Enter Title:<input type='text' id='video_title' name='video_title' /><br/>";
//html +="Enter Desc:<input type='text' id='video_desc' name='video_desc' /><br/>";
//html += "Enter Tags:<input type='text' id='video_tags' name='video_tags' /><br/>";
//html +="<p><button id='btnUpload' type='button' onclick='hideObject(\"submitVideoStep2\");showObject(\"processingMessage\");uploadVideo()'>Start Upload</button></p>";
//html +="<p><button id='btnUpload' type='button' onclick='hideObject(\"submitVideoStep2\");showObject(\"submitVideoStep1\")'>Previous</button></p>";
//html +="</div>";
//html +="<div id='processingMessage' style='display: none'>";
//html +="<h3>Uploading Video</h3>";
//html +="<h4>Thank You</h4>";
//html +="<p>This video will be available in the <span id='galleryTitle'></span> gallery after it has finished processing.</p>";
//html += "<p><button id='btnUpload' type='button' onclick='hideObject(\"processingMessage\");showObject(\"submitVideoStep1\")'>Upload More Videos</button></p>";
//html +="</div>";
//html +="</div>"
//
//return html;
//}
//
//
//
//function displayPhotoForm(){
// var html = "";
//
//html += "<div id='submitPhoto'>";
//html +="<div id = 'submitPhotoStep1'>";
//html +="<h3>Step 1: Upload Photo</h3>";
//html +="<p>Click <strong>Browse...</strong> to find and select a Photo on your computer</p>";
//html +="<form id='uploadPhotoForm' method='post' action='' enctype='multipart/form-data'>";
//html +="<input id='galleryKey' type='hidden' name='galleryKey' value='' />";
//html +="<p><input type='file' id='photoUpload' name='Filedata' /></p>";
//html +="</form>";
//html += "<p><button id='btnUpload' type='button' onclick='hideObject(\"submitPhotoStep1\");showObject(\"submitPhotoStep2\")'>Next</button></p>"; 
//html +="</div>";
//html +="<div id='submitPhotoStep2' style='display:none'>";
//html += "<h3>Step 2: Enter Photo Details</h3>"; 
//html +="Enter Title:<input type='text' id='photo_title' name='photo_title' /><br/>";
//html +="Enter Desc:<input type='text' id='photo_desc' name='photo_desc' /><br/>";
//html += "Enter Tags:<input type='text' id='photo_tags' name='photo_tags' /><br/>";
//html +="<p><button id='btnUpload' type='button' onclick='hideObject(\"submitPhotoStep2\");showObject(\"processingMessage\");uploadPhoto()'>Start Upload</button></p>";
//html +="<p><button id='btnUpload' type='button' onclick='hideObject(\"submitPhotoStep2\");showObject(\"submitPhotoStep1\")'>Previous</button></p>";
//html +="</div>";
//html +="<div id='processingMessage' style='display: none'>";
//html +="<h3>Uploading Photo</h3>";
//html +="<h4>Thank You</h4>";
//html +="<p>This photo will be available in the <span id='galleryTitle'></span> gallery after it has finished processing.</p>";
//html += "<p><button id='btnUpload' type='button' onclick='hideObject(\"processingMessage\");showObject(\"submitPhotoStep1\")'>Upload More Photos</button></p>";
//html +="</div>";
//html +="</div>"
//
//return html;
//}
//
//function displayAvatarPhotoForm(){
// var html = "";
//
//html += "<div id='submitPhoto'>";
//html +="<div id = 'submitPhotoStep1'>";
//html +="<h3>Step 1: Upload Photo</h3>";
//html +="<p>Click <strong>Browse...</strong> to find and select a Photo on your computer</p>";
//html +="<form id='uploadPhotoForm' method='post' action='' enctype='multipart/form-data'>";
//html +="<p><input type='file' id='photoUpload' name='Filedata' /></p>";
//html +="</form>";
//html += "<p><button id='btnUpload' type='button' onclick='hideObject(\"submitPhotoStep1\");showObject(\"submitPhotoStep2\")'>Next</button></p>"; 
//html +="</div>";
//html +="<div id='submitPhotoStep2' style='display:none'>";
//html += "<h3>Step 2: Enter Photo Details</h3>"; 
//html +="Enter Title:<input type='text' id='photo_title' name='photo_title' /><br/>";
//html +="Enter Desc:<input type='text' id='photo_desc' name='photo_desc' /><br/>";
//html += "Enter Tags:<input type='text' id='photo_tags' name='photo_tags' /><br/>";
//html +="<p><button id='btnUpload' type='button' onclick='hideObject(\"submitPhotoStep2\");showObject(\"processingMessage\");uploadPhoto()'>Start Upload</button></p>";
//html +="<p><button id='btnUpload' type='button' onclick='hideObject(\"submitPhotoStep2\");showObject(\"submitPhotoStep1\")'>Previous</button></p>";
//html +="</div>";
//html +="<div id='processingMessage' style='display: none'>";
//html +="<h3>Uploading Photo</h3>";
//html +="<h4>Thank You</h4>";
//html +="<p>This photo will be available in the <span id='galleryTitle'></span> gallery after it has finished processing.</p>";
//html += "<p><button id='btnUpload' type='button' onclick='hideObject(\"processingMessage\");showObject(\"submitPhotoStep1\")'>Upload More Photos</button></p>";
//html +="</div>";
//html +="</div>"
//
//return html;
//}
//
//functionrequestCommunityGroupMembershipForm(p_sKey){
//alert(p_sKey);
//var html = "";
//html +="<h3>Add User to Group</h3>";
//html +="Enter User Key: <input type='text' id='userkey_adduser' name='userkey_adduser' /><br/>";
//html +="Enter Group Key:<input type='text' id='"+ p_sKey +"' name='"+ p_sKey +"' /><br/>"; 
//html +='<p><button id="btnUpload" type="button" onclick="requestCommunityGroupMembership(\'' + p_sKey + '\')">Go</button></p>';
//
//return html;
//}
//
//function reportAbuseForm(p_sKey, p_sType){
//var html = "";
//html += "<strong>Report Abuse Form</strong><br/>";
//html +="Enter Reason: <input type='text' id='reason' name='reason' /><br/>";
//html +="Enter Description:<input type='text' id='description' name='description' /><br/>"; 
//html +='<p><button id="btnUpload" type="button" onclick="reportGroupAbuse(\'' + p_sKey + '\', \'' + p_sType + '\')">Go</button></p>';
//return html; 
//}
//
//function requestGroupDeleteForm(p_sCommunityKey){
// var html = "";
// html += "<strong>Request Group Delete Form</strong><br/>";
// html +="Enter Reason: <input type='text' id='reason' name='reason' /><br/>";
// html +='<p><button id="btnUpload" type="button" onclick="requestGroupDelete(\'' + p_sCommunityKey + '\')">Go</button></p>';
// return html;
//}
//
//
//

 var l_aValidVideoFileFormats = new Array("mp4", "VOB", "MPG", "3GP", "AVI", "ASF", "WMV", "MOV", "FLV");
var l_aValidPhotoFileFormats = new Array("jpeg", "gif", "png", "jpg", "bmp");
 

function handleErrorsType($p_xType, responseBatch) {
var s = '';
for (var i = 0; i < responseBatch.Messages.length; i++) {
s = s + responseBatch.Messages[i].Message + '\n\n';
}
alert(s);
}
function handleErrors(responseBatch) {
var s = '';
for (var i = 0; i < responseBatch.Messages.length; i++) {
s = s + responseBatch.Messages[i].Message + '\n\n';
}
alert(s);
}
 _xValidate = {
validateAvatarPhoto: function(l_sFileName){
var l_bIsValid = false;
$('#error').html('false');
splitName = l_sFileName.split(".");
fileType = splitName[splitName.length-1];
fileType = fileType.toLowerCase();
for(var i = 0; i < l_aValidPhotoFileFormats.length; i++){
if(fileType == l_aValidPhotoFileFormats[i]){
 l_bIsValid = true;
 $('#error').html('false');
}
}
if(l_bIsValid == false){
$('#invalid_file_format').html("Invalid File Format");
 $('#error').html('true');
}
else{
$('#invalid_file_format').html("");
_xPluckPhoto.uploadAvatarPhoto();
}
},
validateMedia: function(l_sFileName, p_sType){
var l_bIsValid = false;
$('#error').html('false');
splitName = l_sFileName.split(".");
fileType = splitName[splitName.length-1];
fileType = fileType.toLowerCase();
switch(p_sType){
case 'image':
 for(var i = 0; i < l_aValidPhotoFileFormats.length; i++){
 if(fileType == l_aValidPhotoFileFormats[i].toLowerCase()){
l_bIsValid = true;
 $('#error').html('false');
}
}
break;
case 'video':
for(var i = 0; i < l_aValidVideoFileFormats.length; i++){
 if(fileType == l_aValidVideoFileFormats[i].toLowerCase()){
l_bIsValid = true;
 $('#error').html('false');
}
}
break;
}
if(l_bIsValid == false){
 $('#invalid_file_format').html("Invalid File Format");
 $('#error').html('true');
 } else{
 $('#invalid_file_format').html("");
}
}, 
validateCreateGroupForm:function(){
l_aErrors = Array();
var l_bIsValid = false;
$('#error').html('false');
 if($('#title').val()){
 l_bIsValid = true;
$('#invalid_title').html("");
 }else{
 l_aErrors.push("Please Enter Title");
 $('#invalid_title').html("Please enter Title.");
 $('#error').html('true');
 l_bIsValid = false;
 }
 
if($('#group_section_list').val()){
l_bIsValid = true;
 }else{
 l_aErrors.push("Please enter your sport Name.");
 $('#error').html('true');
 l_bIsValid = false;
 }
 
if($('#avatarphotokey').html() == "null"){
 var l_bIsMediaValid = false;
 $('#invalid_media').html("Please Upload Group Image.");
 }else{
 $('#invalid_media').html("");
 l_bIsMediaValid = true;
 }
 
 var l_sAvatarKey = $('#avatarphotokey').html();
 
 if(l_sAvatarKey.indexOf("Anonymous") != -1){
var l_bIsMediaValid = false;
$('#invalid_media').html("Anonymous user is not allowed to upload photos. Please login!");
 }
 
 
 
 if(l_bIsValid && l_bIsMediaValid){
return true;
}else{
 return false;
 }
 
 
 
 
},
validateMediaForm:function(){
l_aErrors = Array();
var l_bIsValid = true;
if($('#title').val()){
$('#invalid_title').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_title').html("Please enter title");
}
 if($('#error').html() == 'true'){
 l_bIsValid = false; 
$('#invalid_file_format').html("Please upload media");
 }else{
 $('#invalid_file_format').html("");
 }
 
 if(l_bIsValid){
 return true;
}else{
 return false;
 }
 
 
 
},
validateBlogForm:function(){
l_aErrors = Array();
var l_bIsValid = true;
if($('#title').val()){
$('#invalid_title').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_title').html("Please enter title.");
 }
 if($('#desc').val()){
$('#invalid_desc').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_desc').html("Please enter post.");
}
 
 if(l_bIsValid){
 return true;
}else{
 return false;
 }
},
validateEventForm:function(){
 l_aErrors = Array();
var l_bIsValid = true;
if($('#title').val()){
$('#invalid_title').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_title').html("Please enter Title");
}
if($('#desc').val()){
$('#invalid_desc').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_desc').html("Please enter Description.");
}
if($('#loc').val()){
$('#invalid_loc').html("");
}else{
 l_bIsValid = false; 
$('#invalid_loc').html("Please enter valid location.");
}
 
if($('#start_time_picker').val()){
$('#invalid_sdate').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_sdate').html("Please enter Start Date.");
}

if($('#start_time_entry').val()){
$('#invalid_stime').html("");
}else{
 l_bIsValid = false;
 $('#invalid_stime').html("Please enter Start Time.");
 }
if($('#end_time_picker').val()){
$('#invalid_edate').html("");
}else{
 l_bIsValid = false; 
$('#invalid_edate').html("Please enter End Date.");
}
//check for valid start and end dates
l_sStartDateJS = new Date($('#start_time_picker').val());
l_sEndDateJS = new Date($('#end_time_picker').val());
if(l_sStartDateJS.getTime() > l_sEndDateJS.getTime()){
 l_bIsValid = false; 
 $('#invalid_setdate').html("Please enter valid Start and End Date.");
}
 if($('#end_time_entry').val()){
$('#invalid_etime').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_etime').html("Please enter End Time.");
}
if($('#url').val()){
$('#invalid_url').html("");
}else{
 l_bIsValid = false;
 $('#invalid_url').html("Please enter valid url.");
 }
 
if($('#name').val()){
$('#invalid_urlname').html("");
}else{
 l_bIsValid = false; 
 $('#invalid_urlname').html("Please enter valid url name.");
}
 
 
 if(l_bIsValid){
 return true;
}else{
return false;
 }
}, 
isEmpty: function(aTextField) {
 if ((aTextField.value.length==0) ||(aTextField.value==null)) {
return true;
 }
 else { return false; }
 },
 
 getCookie:function(name) {
var theCookies = document.cookie.split(/[; ]+/);
for (var i = 0 ; i < theCookies.length; i++) {
var aName = theCookies[i].substring(0,theCookies[i].indexOf('='));
if (aName == name) {
return theCookies[i];
}
}
}, 
validateCookie:function(name){
var theCookies = document.cookie.split(/[; ]+/);
for (var i = 0 ; i < theCookies.length; i++) {
var aName = theCookies[i].substring(0,theCookies[i].indexOf('='));
if (aName == name) {
return theCookies[i];
}
}
}
 
 }
_xPagination = {
tallNum: function(l_nResponseOnPage, l_nTotalCount, l_nNumberOfItemsPerPage, l_nResponseKey, l_sCallbackFunction, l_nPaginationRange){
var l_nPaginationRange = 10;
l_sHref ='href="javascript:void(0)"';
l_nTotalPages =Math.ceil(parseInt(l_nTotalCount)/parseInt(l_nNumberOfItemsPerPage));
if(l_nTotalPages <= 1)
return ;
// PAGINATION RULES.Digg Style
// Set Initial 
if(parseInt(l_nResponseOnPage) < l_nPaginationRange){
l_nRangeStart = 1;
}else{ 
l_nRangeStart = Math.floor(parseInt(l_nResponseOnPage) - l_nPaginationRange/2);
}
l_nRangeEnd = (l_nRangeStart + l_nPaginationRange) - 1;
// Check ranges to keep it within Total Range
if(l_nRangeEnd > l_nTotalPages )
l_nRangeEnd = l_nTotalPages;
if((l_nRangeEnd - l_nRangeStart) < l_nPaginationRange)
l_nRangeStart = (l_nRangeEnd - l_nPaginationRange) + 1;
if(l_nRangeStart < 1)
l_nRangeStart = 1;
// Figure out Start & End Page Booleans
if (l_nRangeStart != 1){
l_bStartPage = true;
}else{
l_bStartPage = false;
}
if(l_nRangeEnd != l_nTotalPages){
l_bEndPage = true;
}else{
 l_bEndPage = false;
}
if((l_bStartPage) && (2 != l_nRangeStart)){
l_bStartEllipses = true;
}else{
l_bStartEllipses = false;
}
if((l_bEndPage) && ((l_nRangeEnd+1) != l_nTotalPages)){
l_bEndEllipses = true;
}else{
l_bEndEllipses = false;
}
l_sPaginationHtml = '<div class="tallnum_pagination">'+
'<div class="pagi_holder">'+
'<div class="hr_holder_left">&nbsp;<div class="hr_left"></div></div>';
if(l_nResponseOnPage != 1){
l_sPaginationHtml += '<a class="inline_arrow" href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + (l_nResponseOnPage - 1) + '\')"; ><img width="13" height="9" class="png arrow" src="/_site/image/btn_tallnum_pagination_left.png?v=213)" /><img width="13" height="9" class="png arrow_hover" src="/_site/image/btn_tallnum_pagination_left_hover.png?v=213)" /></a>';
}
if(l_bStartPage){
l_sPaginationHtml += '<a href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + 1 + '\')"; class="digit">1</a>';
}
if(l_bStartEllipses){
l_sPaginationHtml += '<div class="digit_ellipses digit">...</div>';
}
for(i=l_nRangeStart; i <=l_nRangeEnd; i++){
if(l_nResponseOnPage == i ){
l_sPaginationHtml +='<div class="digit current_digit">' + i + '</div>';
}
else{
l_sPaginationHtml += '<a href="javascript:void(0)" class="digit" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + i + '\')" >' + i + '</a>';
}
}
if(l_bEndEllipses){
l_sPaginationHtml += '<div class="digit_ellipses digit">...</div>';
}
if(l_bEndPage){
l_sPaginationHtml += '<a href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + l_nTotalPages + '\')" class="digit">' + l_nTotalPages +'</a>';
}

 if(l_nResponseOnPage < l_nTotalPages){
l_sPaginationHtml +='<a class="inline_arrow" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + (l_nResponseOnPage + 1) + '\')"><img width="13" height="9" class="png arrow" src="/_site/image/btn_tallnum_pagination_right.png?v=213)" /><img width="13" height="9" class="png arrow_hover" src="/_site/image/btn_tallnum_pagination_right_hover.png?v=213)" /></a>';
} 
l_sPaginationHtml +='<div class="hr_holder_right">&nbsp;<div class="hr_right"></div></div>'+
'</div>'+
'</div>';

return l_sPaginationHtml;
},
//special case for recent feeds
tallNumRecentFeed: function(l_nResponseOnPage, l_nTotalCount, l_nNumberOfItemsPerPage, l_nResponseKey, l_sCallbackFunction, l_nPaginationRange){
var l_nPaginationRange = 10;
l_sHref ='href="javascript:void(0)"';
l_nTotalPages =Math.ceil(parseInt(l_nTotalCount)/parseInt(l_nNumberOfItemsPerPage));
if(l_nTotalPages <= 1)
return ;
// PAGINATION RULES.Digg Style
// Set Initial 
if(parseInt(l_nResponseOnPage) < l_nPaginationRange){
l_nRangeStart = 1;
}else{ 
l_nRangeStart = Math.floor(parseInt(l_nResponseOnPage) - l_nPaginationRange/2);
}
l_nRangeEnd = (l_nRangeStart + l_nPaginationRange) - 1;
// Check ranges to keep it within Total Range
if(l_nRangeEnd > l_nTotalPages )
l_nRangeEnd = l_nTotalPages;
if((l_nRangeEnd - l_nRangeStart) < l_nPaginationRange)
l_nRangeStart = (l_nRangeEnd - l_nPaginationRange) + 1;
if(l_nRangeStart < 1)
l_nRangeStart = 1;
// Figure out Start & End Page Booleans
if (l_nRangeStart != 1){
l_bStartPage = true;
}else{
l_bStartPage = false;
}
if(l_nRangeEnd != l_nTotalPages){
l_bEndPage = true;
}else{
 l_bEndPage = false;
}
if((l_bStartPage) && (2 != l_nRangeStart)){
l_bStartEllipses = true;
}else{
l_bStartEllipses = false;
}
if((l_bEndPage) && ((l_nRangeEnd+1) != l_nTotalPages)){
l_bEndEllipses = true;
}else{
l_bEndEllipses = false;
}
l_sPaginationHtml = '<div class="tallnum_pagination">'+
'<div class="pagi_holder">'+
'<div class="hr_holder_left">&nbsp;<div class="hr_left"></div></div>';
if(l_nResponseOnPage != 1){
l_sPaginationHtml += '<a class="inline_arrow" href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + (l_nResponseOnPage - 1) + '\', \'' + l_nNumberOfItemsPerPage + '\')"; ><img width="13" height="9" class="png arrow" src="/_site/image/btn_tallnum_pagination_left.png?v=213)" /><img width="13" height="9" class="png arrow_hover" src="/_site/image/btn_tallnum_pagination_left_hover.png?v=213)" /></a>';
}
if(l_bStartPage){
l_sPaginationHtml += '<a href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + (l_nResponseOnPage - 1) + '\', \'' + l_nNumberOfItemsPerPage + '\')"; class="digit">1</a>';
}
if(l_bStartEllipses){
l_sPaginationHtml += '<div class="digit_ellipses digit">...</div>';
}
for(i=l_nRangeStart; i <=l_nRangeEnd; i++){
if(l_nResponseOnPage == i ){
l_sPaginationHtml +='<div class="digit current_digit">' + i + '</div>';
}
else{
l_sPaginationHtml += '<a href="javascript:void(0)" class="digit" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + i + '\', \'' + l_nNumberOfItemsPerPage + '\')" >' + i + '</a>';
}
}
if(l_bEndEllipses){
l_sPaginationHtml += '<div class="digit_ellipses digit">...</div>';
}
if(l_bEndPage){
l_sPaginationHtml += '<a href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nTotalPages + '\', \'' + l_nNumberOfItemsPerPage + '\')" class="digit">' + l_nTotalPages +'</a>';
}

 if(l_nResponseOnPage < l_nTotalPages){
l_sPaginationHtml +='<a class="inline_arrow" onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + (l_nResponseOnPage + 1) + '\', \'' + l_nNumberOfItemsPerPage + '\')"><img width="13" height="9" class="png arrow" src="/_site/image/btn_tallnum_pagination_right.png?v=213)" /><img width="13" height="9" class="png arrow_hover" src="/_site/image/btn_tallnum_pagination_right_hover.png?v=213)" /></a>';
} 
l_sPaginationHtml +='<div class="hr_holder_right">&nbsp;<div class="hr_right"></div></div>'+
'</div>'+
'</div>';

return l_sPaginationHtml;
},
tallNumAggregate: function(l_nTotalCount, l_nNumberOfItemsPerPage, l_nResponseOnPage, l_sSection, l_sSortBy, l_sCallbackFunction){
var l_nPaginationRange = 10;
l_sHref ='href="javascript:void(0)"';
l_nTotalPages =Math.ceil(parseInt(l_nTotalCount)/parseInt(l_nNumberOfItemsPerPage));
if(l_nTotalPages <= 1)
return ;
// PAGINATION RULES.Digg Style
// Set Initial 
if(parseInt(l_nResponseOnPage) < l_nPaginationRange){
l_nRangeStart = 1;
}else{ 
l_nRangeStart = Math.floor(parseInt(l_nResponseOnPage) - l_nPaginationRange/2);
}
l_nRangeEnd = (l_nRangeStart + l_nPaginationRange) - 1;
// Check ranges to keep it within Total Range
if(l_nRangeEnd > l_nTotalPages )
l_nRangeEnd = l_nTotalPages;
if((l_nRangeEnd - l_nRangeStart) < l_nPaginationRange)
l_nRangeStart = (l_nRangeEnd - l_nPaginationRange) + 1;
if(l_nRangeStart < 1)
l_nRangeStart = 1;
// Figure out Start & End Page Booleans
if (l_nRangeStart != 1){
l_bStartPage = true;
}else{
l_bStartPage = false;
}
if(l_nRangeEnd != l_nTotalPages){
l_bEndPage = true;
}else{
 l_bEndPage = false;
}
if((l_bStartPage) && (2 != l_nRangeStart)){
l_bStartEllipses = true;
}else{
l_bStartEllipses = false;
}
if((l_bEndPage) && ((l_nRangeEnd+1) != l_nTotalPages)){
l_bEndEllipses = true;
}else{
l_bEndEllipses = false;
}
l_sPaginationHtml = '<div class="tallnum_pagination">'+
'<div class="pagi_holder">'+
'<div class="hr_holder_left">&nbsp;<div class="hr_left"></div></div>';
if(l_nResponseOnPage != 1){
l_sPaginationHtml += '<a class="inline_arrow" href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nNumberOfItemsPerPage + '\', \'' + (l_nResponseOnPage - 1) + '\', \'' + l_sSection + '\',\'' + l_sSortBy + '\')"; ><img width="13" height="9" class="png arrow" src="/_site/image/btn_tallnum_pagination_left.png?v=213)" /><img width="13" height="9" class="png arrow_hover" src="/_site/image/btn_tallnum_pagination_left_hover.png?v=213)" /></a>';
}
if(l_bStartPage){
l_sPaginationHtml += '<a href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nNumberOfItemsPerPage + '\', \'' + (l_nResponseOnPage - 1) + '\', \'' + l_sSection + '\',\'' + l_sSortBy + '\')"; class="digit">1</a>';
}
if(l_bStartEllipses){
l_sPaginationHtml += '<div class="digit_ellipses digit">...</div>';
}
for(i=l_nRangeStart; i <=l_nRangeEnd; i++){
if(l_nResponseOnPage == i ){
l_sPaginationHtml +='<div class="digit current_digit">' + i + '</div>';
}
else{
l_sPaginationHtml += '<a href="javascript:void(0)" class="digit" onclick="'+l_sCallbackFunction +'(\'' + l_nNumberOfItemsPerPage + '\', \''+ i + '\', \'' + l_sSection + '\',\'' + l_sSortBy + '\')" >' + i + '</a>';
}
}
if(l_bEndEllipses){
l_sPaginationHtml += '<div class="digit_ellipses digit">...</div>';
}
if(l_bEndPage){
l_sPaginationHtml += '<a href="javascript:void(0)" onclick="'+l_sCallbackFunction +'(\'' + l_nNumberOfItemsPerPage + '\', \'' + l_nTotalPages + '\', \'' + l_sSection + '\',\'' + l_sSortBy + '\')" class="digit">' + l_nTotalPages +'</a>';
}

 if(l_nResponseOnPage < l_nTotalPages){
l_sPaginationHtml +='<a class="inline_arrow" onclick="'+l_sCallbackFunction +'(\'' + l_nNumberOfItemsPerPage + '\', \'' + (l_nResponseOnPage + 1) + '\', \'' + l_sSection + '\',\'' + l_sSortBy + '\')"><img width="13" height="9" class="png arrow" src="/_site/image/btn_tallnum_pagination_right.png?v=213)" /><img width="13" height="9" class="png arrow_hover" src="/_site/image/btn_tallnum_pagination_right_hover.png?v=213)" /></a>';
} 
l_sPaginationHtml +='<div class="hr_holder_right">&nbsp;<div class="hr_right"></div></div>'+
'</div>'+
'</div>';

return l_sPaginationHtml;

},

modComments:function(l_nResponseOnPage, l_nTotalCount, l_nNumberOfItemsPerPage, l_nResponseKey, l_sCallbackFunction){
 var l_nRangeStart = ((parseInt(l_nResponseOnPage) - 1)*(parseInt(l_nNumberOfItemsPerPage)) + 1);
 var l_bIsPagination = false;
 if(l_nNumberOfItemsPerPage<=1){
var l_nRangeEnd = 0;
}else{
var l_nRangeEnd = parseInt(l_nRangeStart) + parseInt(l_nNumberOfItemsPerPage) - 1;
}
if(parseInt(l_nRangeEnd) > parseInt(l_nTotalCount)) {
l_nRangeEnd = l_nTotalCount;
}
var l_sItemDisplay = '<b>' + l_nRangeStart + '</b>';
 
if((l_nRangeEnd) && (parseInt(l_nRangeEnd) != parseInt(l_nRangeStart))){
l_sItemDisplay += '-<b>' + l_nRangeEnd + '</b>';
}else{
l_sItemDisplay += '';
}
if(l_nResponseOnPage != 1)
var l_bClickLeft = true;
else
var l_bClickLeft = false;
if((parseInt(l_nRangeEnd) != parseInt(l_nTotalCount)) && (parseInt(l_nResponseOnPage) != parseInt(l_nTotalCount))){
var l_bClickRight = true;
}
var l_nResponseSubtract = parseInt(l_nResponseOnPage) - 1;
var l_sLeftString = '';
if(l_bClickLeft){
var l_sLeftString = ' onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + l_nResponseSubtract + '\', \'TimeStampDescending\', \'\', \'article\', \'' + l_bIsPagination + '\')"';
}else{
l_sLeftString = ''; 
}
l_sLeftString +='href="javascript:void(0)"';
var l_nResponseAdd = parseInt(l_nResponseOnPage) + 1;
var l_sRightString = '';
var l_sSortByComment = 'TimeStampAscending';
var l_sTypeComment = 'article';
if(l_bClickRight){
var l_sRightString = ' onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + l_nResponseAdd + '\', \'TimeStampDescending\', \'\', \'article\', \'' + l_bIsPagination + '\')"';
}else{
var l_sRightString = ''; 
}
l_sRightString +=' href="javascript:void(0)"';

if(l_bClickLeft){
var l_sLeftClass = '';
}else{
var l_sLeftClass =' sprite_selected ';
}
if(l_bClickRight){
var l_sRightClass = '';
}else{
var l_sRightClass =' sprite_selected ';
}
l_aPaginationInfo = new Array();
l_aPaginationInfo['left_class'] = l_sLeftClass; 
l_aPaginationInfo['left_string'] = l_sLeftString;
l_aPaginationInfo['right_class'] = l_sRightClass; 
l_aPaginationInfo['right_string'] = l_sRightString; 
l_aPaginationInfo['item_display'] = l_sItemDisplay; 
l_aPaginationInfo['total_count'] = l_nTotalCount;
return l_aPaginationInfo;

},
createcommunitylandingmod:function(p_nPage, p_nTotalCount, p_nItemsPerPage,p_sType){
if(p_sType == 'discovery'){
if((parseInt(p_nTotalCount)) > (p_nItemsPerPage)){
l_aPaginationInfo = _xPagination.mod(p_nPage,p_nTotalCount, p_nItemsPerPage, p_nTotalCount, "_xPagination.paginatecommunitylanding", p_sType);
l_sPaginationTemplate = $('#plck_pagi_community').html();
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-left~/,"<div class= 'mod_pagination_left sprite " + l_aPaginationInfo['left_class'] + "'><a " + l_aPaginationInfo['left_string'] +"><span>Left</span></a></div>"); 
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-right~/,"<div class= 'mod_pagination_right sprite" + l_aPaginationInfo['right_class'] + "'><a " + l_aPaginationInfo['right_string'] + "><span>Right</span></a></div>");
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~page-numbers~/, "" + l_aPaginationInfo['item_display'] + " of <b> " + l_aPaginationInfo['total_count'] + "</b>");
return (l_sPaginationTemplate);
}
}else{
if((parseInt(p_nTotalCount)) > (p_nItemsPerPage)){
l_aPaginationInfo = _xPagination.mod(p_nPage,p_nTotalCount, p_nItemsPerPage, p_nTotalCount, "_xPagination.paginatecommunitylanding", p_sType);
l_sPaginationTemplate = $('#plck_pagi_community').html();
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-left~/,"<div class= 'community_landing_pagination_left sprite " + l_aPaginationInfo['left_class'] + "'><a " + l_aPaginationInfo['left_string'] +"><span>Left</span></a></div>"); 
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~mod-pagi-right~/,"<div class= 'community_landing_pagination_right sprite" + l_aPaginationInfo['right_class'] + "'><a " + l_aPaginationInfo['right_string'] + "><span>Right</span></a></div>");
l_sPaginationTemplate = l_sPaginationTemplate.replace(/~page-numbers~/, "" + l_aPaginationInfo['item_display'] + " of <b> " + l_aPaginationInfo['total_count'] + "</b>");
return (l_sPaginationTemplate);
}
}
},

paginatecommunitylanding:function(p_nTotal, p_nPerpage, p_nPageTo,p_sType){
var l_nWidth = '';
var l_sTarget = '';
switch(p_sType){
case 'videos':
l_nWidth = 208; 
l_sTarget = '#video_reel_inner';
break;
case 'photos': 
l_nWidth = 209; 
l_sTarget = '#photo_reel_inner';
break;
case 'blog': 
l_nWidth = 600; 
l_sTarget = '#blogposts_reel_inner';
break;
case 'discussions': 
l_nWidth = 208;
l_sTarget = '#discussion_reel_inner';
break;
case 'groups': 
l_nWidth = 208;
l_sTarget = '#group_reel_inner';
break;
case 'persona': 
l_nWidth = 155; 
l_sTarget = '#member_reel_inner'
break;
case 'discovery':
l_nWidth = 140;
l_sTarget = '#similar_groups_reel_inner';
break;
}
var l_nNewLeft = l_nWidth*p_nPerpage*(p_nPageTo-1)*-1; 
$(l_sTarget).css('left',l_nNewLeft)
$('#plck-'+p_sType+'-pagination').html(_xPagination.createcommunitylandingmod( p_nPageTo, p_nTotal,p_nPerpage,p_sType ) )
},
mod:function(l_nResponseOnPage, l_nTotalCount, l_nNumberOfItemsPerPage, l_nResponseKey, l_sCallbackFunction, l_sSortBy){
 var l_nRangeStart = ((parseInt(l_nResponseOnPage) - 1)*(parseInt(l_nNumberOfItemsPerPage)) + 1);
 if(l_nNumberOfItemsPerPage<=1){
var l_nRangeEnd = 0;
}else{
var l_nRangeEnd = parseInt(l_nRangeStart) + parseInt(l_nNumberOfItemsPerPage) - 1;
}
if(parseInt(l_nRangeEnd) > parseInt(l_nTotalCount)) {
l_nRangeEnd = l_nTotalCount;
}
var l_sItemDisplay = '<b>' + l_nRangeStart + '</b>';
 
if((l_nRangeEnd) && (parseInt(l_nRangeEnd) != parseInt(l_nRangeStart))){
l_sItemDisplay += '-<b>' + l_nRangeEnd + '</b>';
}else{
l_sItemDisplay += '';
}
if(l_nResponseOnPage != 1)
var l_bClickLeft = true;
else
var l_bClickLeft = false;
if((parseInt(l_nRangeEnd) != parseInt(l_nTotalCount)) && (parseInt(l_nResponseOnPage) != parseInt(l_nTotalCount))){
var l_bClickRight = true;
}
var l_nResponseSubtract = parseInt(l_nResponseOnPage) - 1;
var l_sLeftString = '';
if(l_bClickLeft){
var l_sLeftString = ' onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + l_nResponseSubtract + '\', \'' + l_sSortBy + '\')"';
}else{
l_sLeftString = ''; 
}
l_sLeftString +='href="javascript:void(0)"';
var l_nResponseAdd = parseInt(l_nResponseOnPage) + 1;
var l_sRightString = '';
var l_sSortByComment = 'TimeStampAscending';
var l_sTypeComment = 'article';
if(l_bClickRight){
var l_sRightString = ' onclick="'+l_sCallbackFunction +'(\'' + l_nResponseKey + '\', \'' + l_nNumberOfItemsPerPage + '\', \'' + l_nResponseAdd + '\', \'' + l_sSortBy + '\')"';
}else{
var l_sRightString = ''; 
}
l_sRightString +=' href="javascript:void(0)"';

if(l_bClickLeft){
var l_sLeftClass = '';
}else{
var l_sLeftClass =' sprite_selected ';
}
if(l_bClickRight){
var l_sRightClass = '';
}else{
var l_sRightClass =' sprite_selected ';
}
l_aPaginationInfo = new Array();
l_aPaginationInfo['left_class'] = l_sLeftClass; 
l_aPaginationInfo['left_string'] = l_sLeftString;
l_aPaginationInfo['right_class'] = l_sRightClass; 
l_aPaginationInfo['right_string'] = l_sRightString; 
l_aPaginationInfo['item_display'] = l_sItemDisplay; 
l_aPaginationInfo['total_count'] = l_nTotalCount;
return l_aPaginationInfo;

}


};
// JavaScript Document
_xCommunity = {
getRecentActivityFeedModule:function(communityGroupKey, onPage, noPerPage){
var recentMiniFeedActivity = recentFeedActivity(communityGroupKey, onPage, noPerPage)
sendToServer(recentMiniFeedActivity, callbackRecentActivityFeedModule);
},
getGroupStatsModule:function(communityGroupKey){
var groupStats = getStats(communityGroupKey);
sendToServer(groupStats, callbackGroupStatsModule);
},
getGroupTabModule:function(communityGroupKey){
var groupStats = getCommunityGroupStats(communityGroupKey);
sendToServer(groupStats, callbackGroupTabModule);
},
getModeratorInfo:function(userKey){
var userInfoAction = _xCore.getUserInfo(userKey);
sendToServer(userInfoAction, callbackGroupModeratorModule);
},
getSimilarContent:function(l_sCategories, l_sSections, l_aPageType){
 //var l_aCategories = l_sCategories.split(",");
var discoveryContentAction = _xCore.discoverContent(l_sSections, "All", "Recent", "CommunityGroup", 15, 10);
sendToServer(discoveryContentAction, callbackSimilarContent);
}, 
getDiscoverContentForLanding:function(){
var p_aContentType = new Array("PublicVideo", "BlogPost", "PublicPhoto", "CommunityGroup" , "Persona", "Discussion");
var sections = new Array(new Section("All"));
var searchCategories = new Category("All");
var activity = new Activity("Recent");
var age = 60; // maximum age in days
var numItemsToGet = 30; 
var contributors = new Array(); 
contributors[0] = new UserTier("Standard");
contributors[1] = new UserTier("Staff");
contributors[2] = new UserTier("Editor");
var requestBatch = new RequestBatch(); 
for (var i = 0; i < p_aContentType.length; i++) { 
var contentType = new ContentType(p_aContentType[i]);
 // create and send request
var discoveryAction = new DiscoverContentAction(
 sections,
 searchCategories,
 contributors,
 activity,
 contentType,
 age,
 numItemsToGet);
 requestBatch.AddToRequest(discoveryAction);
}
requestBatch.BeginRequest(g_xServerUrl, callbackDiscoverContentGroupLandingModule);
},
getGroupPageAggregateModule:function(p_nNoPerPage, p_nOnPage, p_sSectionName, p_sSortType){
BaseAjax.setInsideLoaderOverlay('#plck-group-aggregate-template-final', 'dark');
 var groupPageAggregateAction = getCommunityGroupPage(p_nNoPerPage, p_nOnPage, p_sSectionName, p_sSortType);
 sendToServer(groupPageAggregateAction, callbackGetCommunityGroupPageAggregate);
}
};

_xCommunityPhotos = {
getPhotosModule:function(l_sPhotoKey, l_nNoPerPage, l_nOnPage, l_sSortBy){
var groupPhotos = getCommunityGroupPhotos(l_sPhotoKey, l_nNoPerPage, l_nOnPage, l_sSortBy);
 sendToServer(groupPhotos, callbackGroupPhotosSubModule);
 }
};
_xCommunityVideos = {
getVideosModule:function(l_sVideoKey, l_nNoPerPage, l_nOnPage, l_sSortBy){
var groupVideos = getCommunityGroupVideos(l_sVideoKey, l_nNoPerPage, l_nOnPage, l_sSortBy);
 sendToServer(groupVideos, callbackGroupVideosSubModule);
}
};
_xCommunityEvents = {
getEventsBadgeModule:function(l_sEventSetKey, l_nNoPerPage, l_nOnPage){
 l_sStartDate = new Date(2001,0,1);
 l_sEndDate =new Date(2099,0,1);
var groupEvents = getCommunityEventsPage(l_sEventSetKey, l_sStartDate, l_sEndDate, l_nNoPerPage, l_nOnPage);
 sendToServer(groupEvents, callbackGroupEventsBadgeModule);
},
getUpcomingEventsModule:function(l_sEventSetKey, l_nNoPerPage, l_nOnPage){
 var l_sTodaysDate = new Date();
 var l_sFutureDate = new Date(l_sTodaysDate.getFullYear(), l_sTodaysDate.getMonth() + 6, l_sTodaysDate.getDate()); 
 var groupEvents = getCommunityEventsPage(l_sEventSetKey, l_sTodaysDate, l_sFutureDate, l_nNoPerPage, l_nOnPage);
 sendToServer(groupEvents, callbackUpcomingEventsModule);
},
getRecentEventsMiniModule:function(l_sEventSetKey, l_nNoPerPage, l_nOnPage, p_sSortBy){
 var l_sTodaysDate = new Date();
 var l_sPastDate = new Date(l_sTodaysDate.getFullYear(), l_sTodaysDate.getMonth() - 6, l_sTodaysDate.getDate());
 var groupEvents = getCommunityEventsPage(l_sEventSetKey, l_sPastDate, l_sTodaysDate, l_nNoPerPage, l_nOnPage, p_sSortBy);
 sendToServer(groupEvents, callbackGroupRecentEventsMiniModule);
},
getRecentEventsModule:function(l_sEventSetKey, l_nNoPerPage, l_nOnPage, p_sSortBy){
 var l_sTodaysDate = new Date();
 var l_sPastDate = new Date(l_sTodaysDate.getFullYear(), l_sTodaysDate.getMonth() - 6, l_sTodaysDate.getDate());
 var groupEvents = getCommunityEventsPage(l_sEventSetKey, l_sPastDate, l_sTodaysDate, l_nNoPerPage, l_nOnPage, p_sSortBy);
 sendToServer(groupEvents, callbackRecentEventsModule);
}

};
_xCommunityBlogs = {
 getBlogsModule:function(l_sBlogKey, l_nNoPerPage, l_nOnPage, l_sSortBy){
var blogs = getCommunityBlogsPage(l_sBlogKey, l_nNoPerPage, l_nOnPage, l_sSortBy);
sendToServer(blogs, callbackSubModuleBlogs); 
 }
};
_xCommunityForums = {
 getForumsModule:function(l_sForumKey, l_nNoPerPage, l_nOnPage, l_sSortBy){
var forums = getCommunityForumsPage(l_sForumKey, l_nNoPerPage, l_nOnPage, l_sSortBy);
sendToServer(forums, callbackSubModuleForums); 
 }
};

//groups
function postGroupPage(){
window.location.href ="/test_pluck/groupform.htm?Page=AddGroup";
 }
function postEditGroupPage(groupKey){
 //var eventSetKey = document.getElementById('eventkey-'+i).innerHTML
 window.location.href ="/test_pluck/groupform.htm?Page=EditGroup&communityGroupKey=" + groupKey;
}
//photos
function postPhotoPage(photoKey){
window.location.href ="/test_pluck/photogallerypage.htm?plckGalleryID=" + photoKey;
 }
//videos
function postVideoPage(videoKey){
window.location.href ="/test_pluck/videogallerypage.htm?plckGalleryID=" + videoKey;
 }
//event forms
function addEventsPage(){
var eventSetKey = document.getElementById('eventkey').innerHTML
window.location.href ="/test_pluck/groupevents.htm?Page=AddEvent&communityEventSetKey=" + eventSetKey;
}
function postEventPage(blogKey){
window.location.href ="/test_pluck/groupevents.htm?Page=AddEvent&communityEventSetKey=" + blogKey;
 }
function editEventsPage(eventSetKey){
 //var eventSetKey = document.getElementById('eventkey-'+i).innerHTML
 window.location.href ="/test_pluck/groupevents.htm?Page=EditEvent&communityEventSetKey=" + eventSetKey;
}
//blog forms
function addBlogPage(){
var blogKey = document.getElementById('blogkey').innerHTML
window.location.href ="/test_pluck/groupblogs.htm?Page=AddBlog&communityBlogKey=" + blogKey;
}
function postBlogPage(blogKey){
window.location.href ="/test_pluck/groupblogs.htm?Page=AddBlog&communityBlogKey=" + blogKey;
 }
function editBlogPage(blogKey){
 //var eventSetKey = document.getElementById('eventkey-'+i).innerHTML
 window.location.href ="/test_pluck/groupblogs.htm?Page=EditBlog&communityBlogKey=" + blogKey;
}
//Photos
function showPhotoInfo(photoKeyString) {
window.location.href = "/test_pluck/photogallerylandingpage.htm?photoKey=" + photoKeyString;
}
//Videos
function showVideoInfo(videoKeyString) {
window.location.href = "/test_pluck/videogallerylandingpage.htm?videoKey=" + videoKeyString;
}
function recommendGroupBlogPost(blogPostKey){
 var recommendAction = recommend(blogPostKey, "blog-post");
 sendToServer(recommendAction, callBackGroups);
}
function recommendGroupPhoto(photoKey){
 var recommendAction = recommend(photoKey, "photo");
 sendToServer(recommendAction, callBackGroups);
}
function recommendGroupVideo(videoKey){
 var recommendAction = recommend(videoKey, "video");
 sendToServer(recommendAction, callBackGroups);
}

function callBackGroups(responseBatch) {
//console.log(responseBatch);
if (responseBatch.Responses.length == 0) {
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') return;
handleErrors(responseBatch);
return;
}
 }
 
 
 
 //for yes/no comments:
 function setNumberOfComments(commentKey){
// var html = "";
 //html += key;
//document.getElementById('plck_number_of_comments').innerHTML = html;
 }
 

 function setGroupSingleEventKey(eventkey){
var html = "";
html += '<button id="btnUpload" type="button" onclick="loadDatePicker();updateEventAction(\'' +eventkey+ '\', \'update\');">Edit</button>';
return html;
 }
 
function setGroupPostToEventKey(eventSetKey){
var html = "";
html += '<button id="btnUpload" type="button" onclick="loadDatePicker();updateEventAction(\'' + eventSetKey + '\', \'create\');"><strong>Post New Event to this group!</strong></button><br/><br/>';
return html;
 }
 
 function setGroupSingleBlogKey(blogKey){
 var html = "";
html += '<button id="btnUpload" type="button" onclick="updateBlogAction(\'' + blogKey+ '\', \'update\');">Edit</button>';
//html += "<button id='btnUpload' type='button' onclick=editBlogPage('"+blogKey+"')>Edit</button>";
return html;
 }
 
 function setGroupPostToBlogKey(blogKey){
var html = "";
html += '<button id="btnUpload" type="button" onclick="updateBlogAction(\'' + blogKey + '\', \'create\');"><strong>Post New Blog to this group!</strong></button><br/><br/>';
//html += "<button id='btnUpload' type='button' onclick=postBlogPage('" + blogKey + "')><strong>Post New Blog to this group!</strong></button><br/><br/>"
return html;
 }
 
 function setGroupPostToPhotoKey(photoKey){
var html = "";
html += "<button id='btnUpload' type='button' onclick=postPhotoPage('" + photoKey + "')><strong>Post New Photo to this group!</strong></button><br/><br/>"
return html;
 }
 
 function setGroupPostToVideoKey(videoKey){
var html = "";
html += "<button id='btnUpload' type='button' onclick=postVideoPage('" + videoKey + "')><strong>Post New Video to this group!</strong></button><br/><br/>"
return html;
 }
 
 function setGroupPostNewGroup(){
var html = "";
html += "<button id='btnUpload' type='button' onclick=postGroupPage()><strong>Create your own group!</strong></button><br/><br/>"
return html;
 }
 
 function setGroupEditGroup(groupKey){
var html = "";
html += "<button id='btnUpload' type='button' onclick=postEditGroupPage('" + groupKey + "')><strong>Edit this group!</strong></button><br/><br/>"
return html;
 }
 
 function editPhotoSinglePhotoKey(photoKey){
var html = "";
var action = new PhotoKey(photoKey);
html += "<button id='btnUpload' type='button' onclick=editPhoto('" + photoKey + "')><strong>Edit Photo</strong></button><br/><br/>"
return html;
}
 



_xPluckPhoto = {
uploadPhoto: function(p_sType){
if(_xValidate.validateMediaForm()){
switch(p_sType){
case 'global':
document.getElementById('uploadassetform').action = g_xPhotoUploadUrl;
// grab the form 
var form = document.getElementById('uploadassetform'); 
// submit the form in an iframe through PORK.iframe 
new iframe(form, {onComplete: function(request) {
updatePhoto(request.responseText); } 
}, uploadFormCounter) 
// increment for uniqueness 
uploadFormCounter++; 
break;
case 'groups':
$('#plck-media-content').addClass('plk_always_hide');
$('#media-loading').removeClass('plk_always_hide').addClass('video_loading');
var galleryKey = document.getElementById("plck-group-photo-gallery-key-set").innerHTML;
document.getElementById('uploadassetform').action = g_xPhotoUploadUrl;
document.getElementById('galleryKey').value = galleryKey;
// grab the form 
var form = document.getElementById('uploadassetform'); 
// submit the form in an iframe through PORK.iframe 
new iframe(form, {onComplete: function(request) {
updatePhoto(request.responseText); } 
}, uploadFormCounter) 
// increment for uniqueness 
uploadFormCounter++; 
break;
}
}
}, 
uploadAvatarPhoto: function(){
if($('#error').html() == 'false'){
document.getElementById('uploadassetform').action = g_xPhotoUploadUrl;
// grab the form 
var form = document.getElementById('uploadassetform'); 
// submit the form in an iframe through PORK.iframe 
new iframe(form, {onComplete: function(request) {
$('#avatarphotokey').html(request.responseText);} 
}, uploadFormCounter) 
// increment for uniqueness 
uploadFormCounter++; 
}
}
};
function updatePhoto(photoKeyString){
$('#media-loading').removeClass('video_loading').addClass('plk_always_hide');
var photoKey = new PhotoKey(photoKeyString);
var title = document.getElementById('title').value;
var desc = document.getElementById('desc').value;
var tags = document.getElementById('tags').value;
var update = new UpdatePhotoAction(photoKey,title,desc,tags);
var requestBatch = new RequestBatch();
requestBatch.AddToRequest(update);
requestBatch.AddToRequest(photoKey);
requestBatch.BeginRequest(g_xServerUrl, photoCallBack);
}
function photoCallBack(responseBatch){
$('#plck-media-content').addClass('plk_always_hide');
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') {
 $('#confirm-thankyou').addClass('image_uploaded');
//updategallery:
photoData = responseBatch.Responses[0].Photo;
if(photoData.GalleryKey.Key && photoData.AssociatedCommunityGroupKey.Key){
//TODO: FIND BETTER WAY OF GETTING GET VALUES FROM URL
 var l_aGet = window.location.href.split("/");
 var l_sType = l_aGet[6];
 switch(l_sType){
 case '':
 //update group feeds with photo
_xCommunity.getRecentActivityFeedModule(photoData.AssociatedCommunityGroupKey.Key, 1, 10);
 break;
 case 'pictures':
 //update Photos tab with photo
_xCommunityPhotos.getPhotosModule(photoData.GalleryKey.Key, 10, 1, 'TimeStampDescending');
 break;
 }
}
}else{
$('#confirm-error').addClass('image_error');
handleErrors(responseBatch);
}
}


_xPluckVideo = {
 uploadVideo: function(p_sType){
if(_xValidate.validateMediaForm()){ 
 switch(p_sType){
 case 'global':
 document.getElementById('uploadassetform').action = g_xVideoUploadUrl;
 var galleryKey = document.getElementById("plck-group-video-gallery-key-set").innerHTML;
 var form = document.getElementById('uploadassetform'); 
 // submit the form in an iframe through PORK.iframe 
 new iframe(form, {onComplete: function(request) {
updateVideo(request.responseText); } 
 }, uploadFormCounter) 
uploadFormCounter++; 
 break;
 case 'groups':
 $('#plck-media-content').addClass('plk_always_hide');
 $('#media-loading').removeClass('plk_always_hide').addClass('video_loading');
 document.getElementById('uploadassetform').action = g_xVideoUploadUrl;
 var galleryKey = document.getElementById("plck-group-video-gallery-key-set").innerHTML;
 document.getElementById('galleryKey').value = galleryKey;
 var form = document.getElementById('uploadassetform'); 
 // submit the form in an iframe through PORK.iframe 
 new iframe(form, {onComplete: function(request) {
updateVideo(request.responseText); } 
 }, uploadFormCounter) 
uploadFormCounter++; 
break;
 }
}
 }
 
};
 function getVideoThumbnail(videoKey){
 var requestBatch = new RequestBatch();
 requestBatch.AddToRequest(videoKey);
 requestBatch.BeginRequest(g_xServerUrl, updateVideoCallBack);
}

function updateVideo(videoKeyString){
var videoKey = new VideoKey(videoKeyString);
var title = document.getElementById('title').value;
var desc = document.getElementById('desc').value;
var tags = document.getElementById('tags').value;
var update = new UpdateVideoAction(videoKey,title,desc,tags);
var requestBatch = new RequestBatch();
requestBatch.AddToRequest(update);
requestBatch.AddToRequest(videoKey);
requestBatch.BeginRequest(g_xServerUrl, updateVideoCallBack);
}
function updateVideoCallBack(responseBatch){
 $('#media-loading').removeClass('video_loading').addClass('plk_always_hide');
if (responseBatch.Messages.length == 1 && responseBatch.Messages[0].Message == 'ok') {
 $('#confirm-thankyou').addClass('video_uploaded');
//refresh the gallery associated with this video here:
videoData = responseBatch.Responses[0].Video;
if(videoData.GalleryKey.Key && videoData.AssociatedCommunityGroupKey.Key){
//TODO: FIND BETTER WAY OF GETTING GET VALUES FROM URL
 var l_aGet = window.location.href.split("/");
 var l_sType = l_aGet[6];
 switch(l_sType){
 case '':
 //update group feeds with photo
_xCommunity.getRecentActivityFeedModule(videoData.AssociatedCommunityGroupKey.Key, 1, 10);
 break;
 case 'videos':
 //update Photos tab with photo
_xCommunityVideos.getVideosModule(videoData.GalleryKey.Key, 10, 1, 'TimeStampDescending');
 break;
 }
}
}else{
$('#confirm-error').addClass('video_error');
handleErrors(responseBatch);
}
 }

var g_xServerUrl = 'http://sitelife.versus.com/ver1.0/Direct/Process';
var g_xPhotoUploadUrl = 'http://sitelife.versus.com/ver1.0/Photo/Upload';
var g_xVideoUploadUrl = 'http://sitelife.versus.com/ver1.0/video/Upload';
var g_xVersusBaseDomain= 'www.versus.com';
var g_sDelimiter = '_';
var g_sYesKey = '1';
varg_sNoKey = '0';
var g_sDataSourceCMS = 'cms';
var g_sDataSourcePluck = 'pluck';
var uploadFormCounter = 10000;
g_aOfficialGroupsArray = new Array();
g_aOfficialGroupsArray["nhl"] = "c272c3d3-4c26-4ded-b3e0-e75d364ecdff";g_aOfficialGroupsArray["cycling"] = "785236ff-2689-4288-b33d-6d23e5d120d6";g_aOfficialGroupsArray["hunting"] = "37ce019d-9952-47b5-bb90-c91f600376c7";g_aOfficialGroupsArray["fishing"] = "c54a9a80-e1a0-4e7a-94f5-1e9be493bbe2";g_aOfficialGroupsArray["mma"] = "a52c812b-196e-475d-a8c6-be655f75bb4e";g_aOfficialGroupsArray["college-football"] = "fb279397-abe4-4c58-88db-c40323a138d0";g_aOfficialGroupsArray["indycar"] = "57a1efe5-ee10-469c-abcb-567f14f86476";g_aOfficialGroupsArray["bull-riding"] = "9756871c-a011-46ef-a09d-49a719b2fa2e";g_aOfficialGroupsArray["default"] = "7a718045-1a87-4e7b-bed6-777f8287b558";
  