/*
 * Copyright (C) butor.com. All rights reserved.
 *
 * This software is published under the terms of the GNU Library General
 * Public License (GNU LGPL), a copy of which has been included with this
 * distribution in the LICENSE.txt file. 
 */

/*------------------------------------------------------------------*/
/*      JavaScript methods to support accessing the document        */
/*            metadata dialog from the edit pages                   */
/*------------------------------------------------------------------*/

function doProperties() {
	var ff = getElement('editform');
	var uid = ff['uid'].value;
	documentMetadata(uid, propertiesChanged);
}

function showPropertiesDialog(uid)  {
	documentMetadata(uid, propertiesChanged);
}

function propertiesChanged(props) {
	if (props) {
		var span = getElement('page_title_display');
		if (span) {
			if (span.childNodes.length > 0) {
				var textNode = span.childNodes[0];
				var title = props['title'];
				if (title) {
					textNode.nodeValue = title;
				}
				else {
					span.removeChild(textNode);
				}
			}
			else {
				var title = props['title'];
				if (title) {
					span.appendChild(document.createTextNode(title));
				}
				else {
					// ok, just leave it blank
				}
			}		
		}
		
		var propsInit = getElement('propertiesInitialized');
		if (propsInit) {
			propsInit.value = '1';
		}
	}
}
