if (SITELIFE_ENABLED) {
// GET NEEDED VARIABLES
var suKey = gSiteLife.GetParameter('uid');
var diKey = gSiteLife.GetParameter('plckDiscussionId');
var gaKey = gSiteLife.GetParameter('plckGalleryID');

// HELPER TOOLS

// truncates long strings
function truncate(long) {
	var short = '';
   	for(var i=0; i<100; i++) { short += long.charAt(i); }
    if (long.length > 100) { short += "..."}
    return short;
};

// get an array from xml
function getXMLArr(XMLVarName) {
	var XMLVarPair = Array;
	var tag = 0;
	var tagname = '';
	var tagval = '';
	for(var i=0; i<(XMLVarName.length); i++){
		if (XMLVarName.charAt(i) == "<") { tag = 1; }
		else if (XMLVarName.charAt(i) == ">") { tag = 0; }
		else if  (XMLVarName.charAt(i) == "/") { tag = 3; }
		else if (tag == 1) { tagname += XMLVarName.charAt(i); }
		else if (tag == 0) { tagval += XMLVarName.charAt(i); }
		else if (tag == 3) { 
			if (tagname != ''){ 
				XMLVarPair[tagname] = tagval; tagname = ''; tagval = ''; 
			}
		}
	}
	return XMLVarPair;
};


// remove duplicate objects in an array
// THANKS http://www.martienus.com/code/javascript-remove-duplicates-from-array.html
function unique(a) {
   var r = new Array();
   o:for(var i = 0, n = a.length; i < n; i++) {
      for(var x = 0, y = r.length; x < y; x++)
         if(r[x]==a[i]) continue o;
      r[r.length] = a[i];
   }
   return r;
};

// TOGGLE BACKGROUND
function togglebackground(myContainer, childTags) {
	var toggle = document.getElementById(myContainer).getElementsByTagName(childTags);
	for (var i=0; i<toggle.length; i++) {
	if (toggle[i].style.visibility == 'hidden' || toggle[i].style.visibility == null) {
		toggle[i].style.visibility = 'visible';} else {
			toggle[i].style.visibility = 'hidden';
		}
	}
};

/*** Refer me! ***/
function referMe() {
var requestBatch = new RequestBatch();
var sender = document.sendEmailFromProfile.yourname.value;
var senderEmail = document.sendEmailFromProfile.senderEmail.value;
var getters = document.sendEmailFromProfile.email.value;
var subject = sender + " wants you to join Detroit Make it Here";
message = sender + " (" + senderEmail + ") has invited you to join Detroit Make it Here, a community of creative professionals in Southeast Michigan.\r\n\r\n Get started here: http://www.detroitmakeithere.com/register. It only takes a few minutes.";
requestBatch.AddToRequest(new EmailContentAction(getters, subject, message));
//console.dir(requestBatch);
requestBatch.BeginRequest(serverUrl, referCallback);
};

function referCallback(responseBatch) {
if (responseBatch.Messages[0].Message == "ok") {
	alert("Message was sent successfully. Won't you invite another?");
} else {alert(responseBatch.Messages[0].Message); }
};

function recentPersonas(bag) {
	var isEven = function(num) {
  		return !(num % 2);
	};
	
	bag = bag || {}
	var container = bag.container || 0;
	if (!container) { return false; }
	
	var displayCount = bag.displayCount || 5;
	var days = bag.days || 15;
	var retrieveCount = bag.retrieveCount || 10;
		
	var cb = function(r) {
	var recentPersonaHtml = '\
		<div style="display: inline;">\
		<div class="Summary_Container">\
		<table class="Summary_ProfileTable" cellspacing="0" cellpadding="0">\
		<tbody>\
	';
    
	if (r.Responses != "undefined") {
    var content = r.Responses[0].DiscoverContentAction.DiscoveredContent;
    var newContent = [];
    for (i=0;i<content.length;i++) {
        var user = content[i];
        if (user.DisplayName != user.UserKey.Key) {
            newContent.push(user);
        }
    }
    
    for (j=0;j<newContent.length;j++) {
	    var recentUser = newContent[j];
	    recentPersonaHtml += '\
	    	<tr';
	    	if (!isEven(j)) {
		    	recentPersonaHtml += ' class="Summary_ProfileAltTRColor"';
	    	}
	    	recentPersonaHtml += '>\
			<td class="Summary_ProfileTableLeft">\
			<a href="'+recentUser.PersonaUrl+'">\
			<img class="PluckUserAvatar" src="'+recentUser.AvatarPhotoUrl+'"/>\
			</a>\
			</td>\
			<td class="Summary_ProfileTableRight">\
			<div class="Summary_ProfileName">\
			<a href="'+recentUser.PersonaUrl+'">'+recentUser.DisplayName+'</a>\
			</div>\
			<div class="Summary_ProfileTime">'+recentUser.LastUpdated+'</div>\
			</td>\
			</tr>\
		';
		if (j == (displayCount-1)) { break; }
			}
			
	recentPersonaHtml += '</tbody>\
		</table>\
		</div>\
		</div>\
	';
	
	document.getElementById(container).innerHTML = recentPersonaHtml;
		}
	};
	
	var rb = new RequestBatch();
	var searchSections = [];
	var searchCategories = [];
	var activityDisco = new Activity("Recent");
	var contentType = new ContentType("Persona");
	var limit = "All";
	var discoAction = new DiscoverContentAction(searchSections,searchCategories,limit,activityDisco,contentType,displayCount,days);
	rb.AddToRequest(discoAction);
	rb.BeginRequest(serverUrl,cb);
};

// VARIOUS REQUESTS
// EDITOR TOOLS
// Page-specific requests

function doVideoRequests() {
	var requestBatch = new RequestBatch();
	requestBatch.AddToRequest(new VideoKey(gSiteLife.GetParameter('videoKey')));
	requestBatch.BeginRequest(serverUrl, videoCb);
};

function doAllLatestStatusRequest() {
    var statusUpdatesCollection = new CustomCollectionKey("profile_ALL_userStatus");
    var statusUpdatesCollectionPage = new CustomCollectionPage(statusUpdatesCollection, 10, 1, "PositionDescending");
    this.rb = new RequestBatch();
    this.rb.AddToRequest(statusUpdatesCollectionPage);
    return this.rb;
};

function videoCb(responseBatch) {
	var bigVideo = responseBatch.Responses[0].Video;
	 	var html = "";
	 	
	 	// show the video title
	 	var videoTitleHtml = "<a href=\"/section/dm?template=profile&uid=" + bigVideo.Author.UserKey.Key + "&plckPersonaPage=PersonaVideos&videoKey=" + bigVideo.VideoKey.Key + "\">" + bigVideo.Title + "</a>";
		var dmVideoTitle = document.getElementById('dmVideoTitle');
		dmVideoTitle.innerHTML = videoTitleHtml;
		
		// Show the requested video in the big player
		html += "<div class='main-video-container'>";
	    html += "<div class='main-video-title'>By <a href=\"/section/dm?template=profile&uid=" + bigVideo.Author.UserKey.Key + "&plckPersonaPage=PersonaVideos\">" + bigVideo.Author.DisplayName + "</a> (<a href=\"/section/dm?template=profile&uid=" + bigVideo.Author.UserKey.Key + "&plckPersonaPage=PersonaVideos&videoKey=" + bigVideo.VideoKey.Key + "\">more &raquo;</a>)</div>";
		html += "<object width='500' height='375'>";
        html += "<param name='flashVars' value='&file=" + bigVideo.VideoUrl + "&width=500&height=375&autostart=true' />";
        html += "<param name='allowfullscreen' value='true' />";
        html += "<param name='allowscriptaccess' value='always' />";
        html += "<embed src='http://sitelife.detroitmakeithere.com/ver1.0/content/swf/mediaplayer.swf'";
        html += "width='500' height='375'";
        html += "allowfullscreen='true'";
        html += "allowscriptaccess='always'";
        html += "flashvars='&file=" + bigVideo.VideoUrl + "&width=500&height=375&autostart=false' />";
        html += "</object>";
        html += "<div class='main-video-big-desc'>"+bigVideo.Description+"</div>";
        html += "</div>";
        
        var dmVideo1 = document.getElementById('dmVideo1');
        dmVideo1.innerHTML = html;
};

function doPhotoRequests() {
		var photoRb = new RequestBatch();
		var galleryKey = new GalleryKey(gaKey);
		var photoPage = new PhotoPage(galleryKey, 10, 1);
		photoRb.AddToRequest(photoPage);
		photoRb.BeginRequest(serverUrl, photoCb);
	};
	
function photoCb(responseBatch) {
	var photos = responseBatch.Responses[0].PhotoPage.Photos;
	var editorPickPhotosHtml = '';
	for (i=0;i<photos.length;i++) {
		editorPickPhotosHtml += '<div style="float:left;margin:0 5px 0 0;"><img src="' + photos[i].Image.Small + '"><br /><input type="radio"';
		if (i == 0) {
			editorPickPhotosHtml += ' checked="checked"';
		}
		 editorPickPhotosHtml += ' name="editorPickPhotosThumbRadio" value="' + photos[i].PhotoKey.Key + '" onclick="document.forms[\'editorpicks_photogalleries\'].elements[\'editorpicks_photogalleries_thumbnail\'].value=\'' + photos[i].PhotoKey.Key + '\'"></div>';
	}
	document.getElementById('editorPickGalleryThumbs').innerHTML = editorPickPhotosHtml;
	};
	
function doNewsRequests() {
	var editorPickBlogsBizCollection = new CustomCollectionKey("editorpicks_blogs_business");
	var editorPickBlogsCareerCollection = new CustomCollectionKey("editorpicks_blogs_career");
	var editorPickPhotosNewsCollection = new CustomCollectionKey("editorpicks_photogalleries_news");
	
	var newsRb1 = new RequestBatch();
	var newsRb2 = new RequestBatch();
	var newsRb3 = new RequestBatch();
	
	newsRb1.AddToRequest(new CustomCollectionPage(editorPickBlogsBizCollection, 2, 1, "PositionDescending"));
	newsRb2.AddToRequest(new CustomCollectionPage(editorPickBlogsCareerCollection, 2, 1, "PositionDescending"));
	newsRb3.AddToRequest(new CustomCollectionPage(editorPickPhotosNewsCollection, 4, 1, "PositionDescending"));
	newsRb1.BeginRequest(serverUrl, newsCb1);
	newsRb2.BeginRequest(serverUrl, newsCb2);
	//if (console) {console.dir(newsRb3);}
	newsRb3.BeginRequest(serverUrl, newsCb3);
};

function newsCb1(responseBatch) {
	var newsRb4 = new RequestBatch();
	for (i=0;i<responseBatch.Responses.length;i++) {
		var response = responseBatch.Responses[i].CustomCollectionPage.Items;
	for (cIdx=0;cIdx<response.length;cIdx++) {
					var contentArr = getXMLArr(response[cIdx]['CustomItem']['Content']);
					newsRb4.AddToRequest(new BlogPostKey(contentArr['contentid']));
				//	newsRb4.AddToRequest(new BlogKey(contentArr['userid']));
			}
		}
	newsRb4.BeginRequest(serverUrl, newsCb4);
};

function newsCb2(responseBatch) {
	var newsRb5 = new RequestBatch();
	for (i=0;i<responseBatch.Responses.length;i++) {
		var response = responseBatch.Responses[i].CustomCollectionPage.Items;
	for (cIdx=0;cIdx<response.length;cIdx++) {
					var contentArr = getXMLArr(response[cIdx]['CustomItem']['Content']);
					newsRb5.AddToRequest(new BlogPostKey(contentArr['contentid']));
				//	newsRb5.AddToRequest(new BlogKey(contentArr['userid']));
			}
		}
	newsRb5.BeginRequest(serverUrl, newsCb5);
	};

function newsCb3(responseBatch) {
	//if (console) {console.dir(responseBatch); }
	var newsRb6 = new RequestBatch();
	var newsRb7 = new RequestBatch();
	for (i=0;i<responseBatch.Responses.length;i++) {
	var response = responseBatch.Responses[i].CustomCollectionPage.Items;
	for (cIdx=0;cIdx<response.length;cIdx++) {
		var contentArr = getXMLArr(response[cIdx]['CustomItem']['Content']);
		newsRb6.AddToRequest(new GalleryKey(contentArr['contentid']));
		newsRb7.AddToRequest(new PhotoKey(contentArr['editornote0']));
		}
	}

	newsRb6.BeginRequest(serverUrl, newsCb6);
	newsRb7.BeginRequest(serverUrl, newsCb6);
	
	};

function newsCb4(responseBatch) {
	// biz blogs
	var blogItemHtml = "";
	for (i=0;i<responseBatch.Responses.length;i++) {
		var blog = responseBatch.Responses[i].BlogPost;
		blogItemHtml += "<li><a href='"+blog.Url+"'>" + blog.PostAuthor.DisplayName + ": " + blog.PostTitle + "</a></li>";
	}
	document.getElementById('dmEditorPickBusiness').innerHTML = blogItemHtml;
};

function newsCb5(responseBatch) {
	// career blogs
	var blogItemHtml = "";
	for (i=0;i<responseBatch.Responses.length;i++) {
		var blog = responseBatch.Responses[i].BlogPost;
		blogItemHtml += "<li><a href='"+blog.Url+"'>" + blog.PostAuthor.DisplayName + ": " + blog.PostTitle + "</a></li>";
	}
	document.getElementById('dmEditorPickCareer').innerHTML = blogItemHtml;
};

/* FOR TWO GALLERIES
function newsCb6(responseBatch) {
	for (i=0;i<responseBatch.Responses.length;i++) {
		var response = responseBatch.Responses[i];
		if (response.Gallery) {
			var carouselTitle = "carousel-title-" + [i + 3];
			document.getElementById(carouselTitle).innerHTML = '<a href="'+response.Gallery.Permalink+'">From the Community: ' + response.Gallery.Title + '</a>';
			} else if (response.Photo) {
			var carouselItem = "carousel-image-" + [i + 3];
			document.getElementById(carouselItem).innerHTML = '<a href="'+response.Photo.PhotoUrl+'"><img src="/apps/pbcsi.dll/urlget?url='+response.Photo.Image.Large+'&maxw=120"></a>';
		}

		}
	};
*/

// FOR FOUR GALLERIES:
function newsCb6(responseBatch) {
	for (i=0;i<responseBatch.Responses.length - 2;i++) {
		var response = responseBatch.Responses[i];
		if (response.Gallery) {
			var carouselTitle = "carousel-title-" + [i + 3];
			document.getElementById(carouselTitle).innerHTML = '<a href="'+response.Gallery.Permalink+'">From the Community: ' + response.Gallery.Title + '</a>';
			} else if (response.Photo) {
			var carouselItem = "carousel-image-" + [i + 3];
			document.getElementById(carouselItem).innerHTML = '<a href="'+response.Photo.PhotoUrl+'"><img src="/apps/pbcsi.dll/urlget?url='+response.Photo.Image.Large+'&maxw=120"></a>';
		}

		}
	for (j=2;j<responseBatch.Responses.length;j++) {
		var response = responseBatch.Responses[j];
		if (response.Gallery) {
			var carouselTitle = "carousel-title-" + [j + 5];
			document.getElementById(carouselTitle).innerHTML = '<a href="'+response.Gallery.Permalink+'">From the Community: ' + response.Gallery.Title + '</a>';
			} else if (response.Photo) {
			var carouselItem = "carousel-image-" + [j + 5];
			document.getElementById(carouselItem).innerHTML = '<a href="'+response.Photo.PhotoUrl+'"><img src="/apps/pbcsi.dll/urlget?url='+response.Photo.Image.Large+'&maxw=120"></a>';
		}

		}
	};

function doForumRequests() {

// get all links to post author personas on the page
var allLinks = gSiteLife.GetTags('a');
var getAuthors = new Array();
for (i=0;i<allLinks.length;i++) {
	if (allLinks[i].parentNode.className.match('Discussion_UserName')) {
		getAuthors[i] = allLinks[i].href;
	}
}
// put the urls into a nice array
// THANKS Pete as a newspaper http://pkarl.com/blog/articles/5/remove-undefined-and-empty-elements-from-a-javascript-array
var cleanAuthors = new Array();
for (k in getAuthors) {
	if(getAuthors[k]) {
		cleanAuthors.push(getAuthors[k]);
	}
}
// isolate the uid and eliminate dupes
var authorKeys = new Array();
for (p=0;p<cleanAuthors.length;p++) {
	authorKeys.push(cleanAuthors[p].split('&plckUserId=').slice(1));
	authorKeys[p] = authorKeys[p][0];
	}
	authorKeys = unique(authorKeys);
	
// request the author userKeys
var discAuthorRb = new RequestBatch();
for (a=0;a<authorKeys.length;a++) {
discAuthorRb.AddToRequest(new UserKey(authorKeys[a]));
}
discAuthorRb.BeginRequest(serverUrl, discAuthorCb);
};

function discAuthorCb(responseBatch) {
	var discAuthorSelectHtml = '<option value="" selected>Select author</option>';
	for (i=0;i<responseBatch.Responses.length;i++) {
		var author = responseBatch.Responses[i].User;
		discAuthorSelectHtml += '<option value="' + author.UserKey.Key + '">' + author.DisplayName + '</option>';
	}
	document.getElementById('editorpicks_discussions_author1').innerHTML = discAuthorSelectHtml;
	document.getElementById('editorpicks_discussions_author2').innerHTML = discAuthorSelectHtml;
};

// EDITOR SELECTIONS
function myPicks(myCollectionName, myPageId, myUserKey, contentId) {
					var myPageAssignment = document.getElementById(myPageId).value;
					var myCollectionKey = myCollectionName + "_" + myPageAssignment;
	    			var myCollection = new CustomCollectionKey(myCollectionKey);
	    			var myItemKey = myCollectionKey + "_" + contentId;
	    			var myItem = new CustomItemKey(myItemKey);
					var myContentUrl = encodeURIComponent(location.href);
	    			
					var collectionNotes = '';
					for (i=0;i<document.forms[myCollectionName].elements.length - 3;i++) {
						collectionNotes += '<editornote' + i + '>' + document.forms[myCollectionName].elements[i].value + '</editornote' +i + '>';
					}
					var editorPickBatch = new RequestBatch();
					editorPickBatch.AddToRequest(new UpdateCustomItemAction(myItem, myItemKey, myCollectionKey+"_class", "", "<userid>"+myUserKey+"</userid><contentid>"+contentId+"</contentid>"+collectionNotes+"<contenturl>"+myContentUrl+"</contenturl>", false));
					editorPickBatch.AddToRequest(new AddCustomCollectionAction(myCollection, myCollectionKey));
					editorPickBatch.AddToRequest(new InsertIntoCollectionAction(myCollection, myItem, 0));
					editorPickBatch.BeginRequest(serverUrl, myPicksCb);
				};
				
	function myPicksCb(responseBatch) {
	};
	
function dmUsers() {
	var et = new RequestBatch();
	et.AddToRequest(new UserKey());
	if (suKey) {
	et.AddToRequest(new UserKey(suKey));
}
	et.BeginRequest(serverUrl, currentUserCb);
};

function currentUserCb(responseBatch) {
//	console.log("Current users:");
//	console.dir(responseBatch);
	var cu = responseBatch.Responses[0].User;
	if (suKey) {
		var su = responseBatch.Responses[1].User;
	}
	
	
	// EDITOR TOOLS
	if (cu.UserTier == 'Editor') {
		var pickTypes = new Array();
		pickTypes[0] = "home";
		pickTypes[1] = "news";
		pickTypes[2] = "business";
		pickTypes[3] = "career";
		var pickOptionHtml = '';
		for (i=0;i<pickTypes.length;i++) {
			pickOptionHtml += '<option value="' + pickTypes[i] + '"';
			if (i == 1) {
				pickOptionHtml += ' selected';
			}
			pickOptionHtml += '>' + pickTypes[i] + '</option>';
		}
		var etHtml = '<div id="etToggle"> </div>';
		etHtml += '<div id="et" class="et" style="display:none;"><a href="http://sitelife.detroitmakeithere.com/ver1.0/CMW/Overview" target="_new">Community Management Workbench</a>';
			if (su || diKey || gaKey) {
			etHtml += '<div class="etPromote"> Promote: ';
		}
			if (su) {
			//	if (console) { console.dir(su); }
			// promote user
			var suAbout = '';
			if (su.AboutMe = '') {
				suAbout += su.AboutMe;
			}
			etHtml += '<div id="editorPickNoteBox" style="position:absolute;margin-top:15px;z-index:50000;display:none;background:#f5f5f5;border:1px solid black;color:black;">Promote on: <select name="editorPickUserTypes" id="editorPickUserTypes">' + pickOptionHtml + '</select> page<br /><strong>Enter custom text:</strong><br /><form name="editorpicks_members"><textarea name="editorpicks_blogs_note" rows=7 cols=25>'+suAbout+'</textarea><br /><input type="button" value="Finish" onclick="myPicks(\'editorpicks_members\',\'editorPickUserTypes\',\''+su.UserKey.Key+'\',\''+su.UserKey.Key+'\');document.getElementById(\'editorPickNoteBox\').style.display=\'none\';document.getElementById(\'persona-make-editors-pick\').innerHTML=\'User added\';return false;"><input type="reset" value="Undo changes"><input type="button" onclick="document.getElementById(\'editorPickNoteBox\').style.display=\'none\';return false;" value="Cancel"></form></div><span id="persona-make-editors-pick"><a href="#none" onclick="document.getElementById(\'editorPickNoteBox\').style.display=\'block\';return false;">USER</a></span>';
			// promote blog post
			
			if (personaPage == "BlogViewPost") {
				var getBlogPostKey = gSiteLife.GetParameter('plckPostId');
	       		var getBlogPost = getBlogPostKey.replace(/%3a/g, ":");
				etHtml += '<div id="editorPickBlogNoteBox" style="position:absolute;margin-top:15px;z-index:50000;display:none;background:#f5f5f5;border:1px solid black;color:black;">Promote on: <select name="editorPickBlogTypes" id="editorPickBlogTypes">' + pickOptionHtml + '</select> page<br /><strong>Enter custom text:</strong><br /><form name="editorpicks_blogs"><textarea name="editorpicks_blogs_note" rows=7 cols=25></textarea><br /><input type="button" value="Finish" onclick="myPicks(\'editorpicks_blogs\',\'editorPickBlogTypes\',\''+su.UserKey.Key+'\',\''+getBlogPost+'\');document.getElementById(\'editorPickBlogNoteBox\').style.display=\'none\';document.getElementById(\'persona-blog-editors-pick\').innerHTML=\'Blog added\';return false;"><input type="reset" value="Undo changes"><input type="button" onclick="document.getElementById(\'editorPickBlogNoteBox\').style.display=\'none\';return false;" value="Cancel"></form></div><span id="persona-blog-editors-pick"> | <a href="#" onclick="document.getElementById(\'editorPickBlogNoteBox\').style.display=\'block\';return false;">BLOG POST</a></span>';
				}
				
			if (personaPage == "PersonaBlog") {
				etHtml += '<div id="editorPickBlogNoteBox" style="position:absolute;margin-top:15px;z-index:50000;display:none;background:#f5f5f5;border:1px solid black;color:black;">Promote on: <select name="editorPickBlogTypes" id="editorPickBlogTypes">' + pickOptionHtml + '</select> page<br /><strong>Enter custom text:</strong><br /><form name="editorpicks_blogs"><textarea name="editorpicks_blogs_note" rows=7 cols=25></textarea><br /><input type="button" value="Finish" onclick="myPicks(\'editorpicks_blogs\',\'editorPickBlogTypes\',\''+su.UserKey.Key+'\',\''+su.UserKey.Key+'\');document.getElementById(\'editorPickBlogNoteBox\').style.display=\'none\';document.getElementById(\'persona-blog-editors-pick\').innerHTML=\' Blog added\';return false;"><input type="reset" value="Undo changes"><input type="button" onclick="document.getElementById(\'editorPickBlogNoteBox\').style.display=\'none\';return false;" value="Cancel"></form></div><span id="persona-blog-editors-pick"> | <a href="#" onclick="document.getElementById(\'editorPickBlogNoteBox\').style.display=\'block\';return false;">BLOG</a></span>';
					}
			}
			if (diKey) {
	       		diKey = diKey.replace(/%3a/g, ":");
				etHtml += '<div id="editorPickDiscussionNoteBox" style="position:absolute;margin-top:15px;z-index:50000;display:none;background:#f5f5f5;border:1px solid black;color:black;">Promote on: <select name="editorPickDiscTypes" id="editorPickDiscTypes">' + pickOptionHtml + '</select> page<br /><form name="editorpicks_discussions"><strong>Enter post text #1 by </strong><select name="editorpicks_discussions_author1" id="editorpicks_discussions_author1"></select><br /><textarea name="editorpicks_discussions_note1" rows=7 cols=25></textarea><br /><strong>Enter post text #2 by</strong><select name="editorpicks_discussions_author2" id="editorpicks_discussions_author2"></select><br /><textarea name="editorpicks_discussions_note2" rows=7 cols=25></textarea><br /><input type="button" value="Finish" onclick="myPicks(\'editorpicks_discussions\',\'editorPickDiscTypes\',\'\',\''+diKey+'\');document.getElementById(\'editorPickDiscussionNoteBox\').style.display=\'none\';document.getElementById(\'discussion-editors-pick\').innerHTML=\'Discussion added\';return false;"><input type="reset" value="Undo changes"><input type="button" onclick="document.getElementById(\'editorPickDiscussionNoteBox\').style.display=\'none\';return false;" value="Cancel"></form></div><span id="discussion-editors-pick"> | <a href="#none" onclick="document.getElementById(\'editorPickDiscussionNoteBox\').style.display=\'block\';return false;">DISCUSSION</a></span>';
				doForumRequests();
				}
				
			if (gaKey) {
	       		gaKey = gaKey.replace(/%3a/g, ":");
				etHtml += '<div id="editorPickGalleriesNoteBox" style="position:absolute;margin-top:15px;z-index:50000;display:none;background:#f5f5f5;border:1px solid black;color:black;">Promote on: <select name="editorPickDiscTypes" id="editorPickGalleryTypes">' + pickOptionHtml + '</select> page<br />Choose thumbnail:<br /><div id="editorPickGalleryThumbs"></div><form name="editorpicks_photogalleries"><input type="hidden" name="editorpicks_photogalleries_thumbnail" value=""><strong>Enter custom text: </strong><br /><textarea name="editorpicks_photogalleries_note" rows=7 cols=25></textarea><br /><input type="button" value="Finish" onclick="myPicks(\'editorpicks_photogalleries\',\'editorPickGalleryTypes\',\'\',\''+gaKey+'\');document.getElementById(\'editorPickGalleriesNoteBox\').style.display=\'none\';document.getElementById(\'photogalleries-editors-pick\').innerHTML=\'Photo gallery added\';return false;"><input type="reset" value="Undo changes"><input type="button" onclick="document.getElementById(\'editorPickGalleriesNoteBox\').style.display=\'none\';return false;" value="Cancel"></form></div><span id="photogalleries-editors-pick"> | <a href="#none" onclick="document.getElementById(\'editorPickGalleriesNoteBox\').style.display=\'block\';return false;">PHOTO GALLERY</a></span>';
				doPhotoRequests();
				}
			
				
			if (su || diKey || gaKey) {
			etHtml += '</div>';
		}
			etHtml += '</div>';
			
			document.getElementById('dmEt').innerHTML = etHtml;
			
			// TOGGLE
				jQuery("#etToggle").click(function () {
					  jQuery("#et").slideToggle("fast");
				});
		
		}

	// welcome bar
	
	var currentUserMsgHtml = '';
	if (cu.DisplayName == "anonymous") {
		currentUserMsgHtml += 'Welcome, Guest! Please <a href="https://home.detroitmakeithere.com/clickshare/pluckAuth.do">Log in</a> or <a href="https://home.detroitmakeithere.com/clickshare/pluckAuth.do">register</a>.';} else {
		currentUserMsgHtml += 'Logged in as <a href="/section/dm?template=profile&uid=' + cu.UserKey.Key + '&plckPersonaPage=PersonaProfile">'+cu.DisplayName+'</a> |';
		if (cu.NumberOfPendingFriends > 0 ) {
            currentUserMsgHtml += '<span style="font-weight:normal;"> <a href="/section/dm?template=profile&uid=' + cu.UserKey.Key + '&plckSubPage=PendingFriends">' + cu.NumberOfPendingFriends + ' friendship request';
            if (cu.NumberOfPendingFriends > 1) {
	            currentUserMsgHtml += 's';}
	        currentUserMsgHtml += '</a></span> | ';
            }
		currentUserMsgHtml += ' <span style="font-weight:normal;"><a href="https://home.detroitmakeithere.com/clickshare/logout.do">Log out</a></span>';
		}
	document.getElementById('dmCurrentUser').innerHTML = currentUserMsgHtml;
	
	// menu
	
	var currentUserMenuMsgHtml = '';
	if (cu.DisplayName == 'anonymous') {
			currentUserMenuMsgHtml += '<li><a href="https://home.detroitmakeithere.com/clickshare/pluckAuth.do?CSTargetURL=' + window.location.href + '">Log in / Register</a></li>';
            currentUserMenuMsgHtml += '<li><a href="/section/dm?template=recentprofiles">Recent activity</a></li>';
            currentUserMenuMsgHtml += '<li><a href="/section/dm?template=users">Community Search</a></li>';
            currentUserMenuMsgHtml += '<li><a href="/section/dm?template=topics01">Blogs & Forums</a>';
            currentUserMenuMsgHtml += '<li><a href="/section/dm?template=events">Events</a>';
            } else {
            currentUserMenuMsgHtml += '<li><small>' + cu.DisplayName + ':</small><a href="/section/dm?template=profile&uid=' + cu.UserKey.Key + '&plckPersonaPage=PersonaHome"><img src="/apps/pbcsi.dll/urlget?url=' + cu.AvatarPhotoUrl + '&maxw=40&q=100"></a>';
            currentUserMenuMsgHtml += '</li><li><a href="/section/dm?template=profile&uid=' + cu.UserKey.Key + '&plckPersonaPage=PersonaHome">My profile</a></li>';
            currentUserMenuMsgHtml += '<li><a href="/section/dm?template=recentprofiles">Recent activity</a></li>';
            currentUserMenuMsgHtml += '<li><a href="/section/dm?template=users">Community Search</a></li>';
            currentUserMenuMsgHtml += '<li><a href="/section/dm?template=topics01">Blogs & Forums</a>';
            currentUserMenuMsgHtml += '<li><a href="/section/dm?template=events">Events</a>';
            currentUserMenuMsgHtml += '<li><a href="https://home.detroitmakeithere.com/clickshare/logout.do?CSTargetURL=' + window.location.href + '">Log out</a>';
            }
            currentUserMenuMsgHtml += '</li>';
            
			document.getElementById('currentUserMenuMessage').innerHTML = currentUserMenuMsgHtml;
	// community box
	var currentUserBoxMsgHtml = '';
	if (cu.DisplayName == 'anonymous') {
		currentUserBoxMsgHtml = '<a href="https://home.detroitmakeithere.com/clickshare/pluckAuth.do?CSTargetURL=' + window.location.href + '" class="dmFeaturedMe">Log in / Register</a> | ';
	} else {
		currentUserBoxMsgHtml = '<a href="/section/dm?template=profile&uid=' + cu.UserKey.Key + '&plckPersonaPage=PersonaHome" class="dmFeaturedMe">My profile</a> | ';
        }
    if(document.getElementById('dmHomeFeaturedMe')) {
	    document.getElementById('dmHomeFeaturedMe').innerHTML = currentUserBoxMsgHtml;
    }
};
}