	function doArchiveSwitcher()
	{
		var swObj = $('articleTools');
		if(swObj == null || swObj.nodeName != "UL") { return; }
		
		var btnTxt = ["Post Titles Only", "Full Post"];
		var btnTitle = ["Show me post titles only", "Show me the full post"];
		var btnClass = ["titles", "full"];
		for(var x=0; btnTxt.length>x; x++)
		{
			btnObj = d.createElement("li");
			btnObj.appendChild(d.createTextNode(btnTxt[x]));
			btnObj.title  = btnTitle[x];
			if(btnClass[x] != "") { btnObj.className = btnClass[x]; }
			addEvent(btnObj, "click", function(){ switchView(this.className); });
			addEvent(btnObj, "mouseover", likeLinkOver);
			addEvent(btnObj, "mouseout", likeLinkOut);
			swObj.appendChild(btnObj);
		}
	
	}
		
	function setArchiveCookie(btnClass) 
	{
		setCookie("TGAM-blogArchives", btnClass);
	}
	
	function getArchiveCookie()
	{
		return getCookie("TGAM-blogArchives");
	}
	
	function switchView(btnClass)
	{
		var archivePosts = $('chewy').getElementsByTagName('DIV');
		for(var i=0; i<archivePosts.length; i++) {
			if(archivePosts[i].className.indexOf("blog") == -1) {
				continue;
			} else {
				var postText = archivePosts[i].childNodes[5].childNodes[1];
				var userOpt = archivePosts[i].childNodes[7];
				if(btnClass == "titles") {
					postText.className.indexOf("hide") != -1 ? "" : postText.className += " hide";
					userOpt.style.marginTop = "-10px";
				} else {
					postText.className = "show";
					userOpt.style.marginTop = "0";
				}
			}
		}
		setArchiveCookie(btnClass);
	}
		
	function archiveInit()
	{	
		if(location.href.indexOf("pastWeeks") != -1) 
		{
			doArchiveSwitcher();
			var pref = getArchiveCookie();
			if(pref == null) return; 
			switchView(pref);
		} else {
			return;
		}
	}
		
	function bioInit() {
	  if ($('primaryNav') != null){
		var bios = $A(getElementsByClassName($("primaryNav"),"DIV","blogger-bio"));
		if (bios.length > 0) {
			// get the latest post authour name and display their bio
			var latest_post = getElementsByClassName($("chewy"),"DIV","latest");
			if (latest_post.length > 0) {
				var latest_post_authour = latest_post[0].className.split(" ")[1];
				// if the bio for the latest post author is present and if the bio 
				// has been set to display: none, show it and hide the others			
				if ($("bio-" + latest_post_authour)) {
					bios.each(function(bio, index) {
						bio.id == "bio-" + latest_post_authour ? bio.style.display = "block" : bio.style.display = "none";
					});
				} else {
					// if the latest post authour's bio isn't present 
					//display the first bio
					bios[0].style.display = "block";
				}
			}
			if (bios.length > 1) {			
				var list = $("blogger-bios");
				var items = $A($("blogger-bios").getElementsByTagName("LI"));
				items.each(function(li, index) {
					var objBio = $(bios[index]);
					addEvent(li,"click", function() {
						bios.each(function(bio) {
							$(bio) != objBio ? $(bio).style.display = "none" : $(bio).style.display = "block";
						});	
					});
				});
			// if there's only 1 bio keep the list of bios hidden	
			} else {
				if ($("primaryNav").getElementsByTagName("H4")) {
					$("primaryNav").getElementsByTagName("H4")[0].style.display = "none";
				}
				if ($("blogger-bios")) {
					$("blogger-bios").style.display = "none";
				}
			}
		}
	  }
	}
	
	function getRSS() {
		if ($("feedsAvailable")) { makeRSSLink("feedsAvailable","A"); }
	}
	
	function submitArchive() {
		if ( $F('pastWeeks').indexOf('servlet/story/RTGAM') > 0 ){
			document.blogArchive.action = $F('pastWeeks');
		}
	}
	
	addEvent(window, "load", function() {
		bioInit();
		archiveInit();
		getRSS();
	});
