	var edit_window;

	function contentUpdateFinished(page_target) {
		//alert("Test!");
		if(!page_target) { // if we haven't been given an explicit page target
			// refresh the page.
			window.location.reload();
		} else {
			window.location.href = "./index.php?pid=" + page_target;
		}
	}

	function launchEditWindow(url) {
		edit_window = window.open(url, 'name', 'height=620, width=650, scrollbars=yes');
		
		if (window.focus) { 
			edit_window.focus();
		}
	}
	

	$(document).ready(function() {
		// do stuff when DOM is ready

		// Grab all elements with the manage attrib set...
		// Unfortunately this method is deprecated, since it's easier to just inject the link from php
		$("body").find('*[in_manage_mode]').each(function(index) {
			
			// If we're actively managing, do stuff
			if(this.getAttribute("in_manage_mode") == "true") {
				var title = this.getAttribute("title");
				var tpl_id = this.getAttribute("tpl_id");
				var pid = this.getAttribute("pid");
				var field_name = this.getAttribute("db_name");
				var tpl_type = this.getAttribute("tpl_type");

				//alert("Here's one: " + title);

				var content = this.innerHTML;
				var targetURL = "./edit_datum.php?title=" + title + "&field_name=" + field_name + "&pid=" + pid + "&tpl_id=" + tpl_id + "&tpl_type=" + tpl_type;
				var href = "javascript:launchEditWindow('" + targetURL + "');";
				var editLine = "<br /><a class='manageEditLink' href=\"" + href + "\">Edit " + title + "</a>";

				content += editLine;
				this.innerHTML = content;
				

			}
		});
		
	});
