Index: /main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js	(revision 27015)
+++ /main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js	(revision 27016)
@@ -36,4 +36,48 @@
 	var _transactions = new Array();
 	
+	var _validAttrList = 
+	{
+		gsf:
+		{
+			"cgi-param":["name"],
+			"collectionText":["args", "name"],
+			"displayItem":["name"],
+			"displayText":["name"],
+			"equivlinkgs3":["name"],
+			"foreach-metadata":["name", "separator"],
+			"icon":["type"],
+			"if-metadata-exists":["name"],
+			"image":["type"],
+			"interfaceText":["name"],
+			"link":["OID", "OIDmetadata", "name", "nodeID", "target", "title", "titlekey", "type"],
+			"metadata":["format", "hidden", "name", "pos", "prefix", "separator", "suffix", "type"],
+			"script":["src"],
+			"style":["src"],
+			"switch":["preprocess", "test", "test-value"]
+		}
+	}
+	
+	var _elemList = 
+	{
+		html:["a", "br", "div", "li", "link", "p", "script", "span", "table", "td", "tr", "ul"],
+		xsl:
+		[
+			"apply-imports", "apply-templates", "attribute", "attribute-set", "call-template", 
+			"choose", "copy", "copy-of", "decimal-format", "element", 
+			"fallback", "for-each", "if", "import", "include",
+			"key", "message", "namespace-alias", "number", "otherwise",
+			"output", "param", "preserve-space", "processing-instruction", "sort",
+			"strip-space", "stylesheet", "template", "text", "transform",
+			"value-of", "variable", "when", "with-param"
+		],
+		gsf:
+		[
+			"cgi-param", "choose-metadata", "collectionText", "displayItem", "displayText",
+			"equivlinkgs3", "foreach-metadata", "icon", "if-metadata-exists", "image",
+			"interfaceText", "link", "meta-value", "metadata", "script",
+			"style", "switch", "template", "text", "variable"
+		]
+	};
+	
 	var _childRestrictions = 
 	{
@@ -199,32 +243,10 @@
 	var populateToolbar = function()
 	{
-		var elemList = 
-		{
-			html:["a", "br", "div", "li", "link", "p", "script", "span", "table", "td", "tr", "ul"],
-			xsl:
-			[
-				"apply-imports", "apply-templates", "attribute", "attribute-set", "call-template", 
-				"choose", "copy", "copy-of", "decimal-format", "element", 
-				"fallback", "for-each", "if", "import", "include",
-				"key", "message", "namespace-alias", "number", "otherwise",
-				"output", "param", "preserve-space", "processing-instruction", "sort",
-				"strip-space", "stylesheet", "template", "text", "transform",
-				"value-of", "variable", "when", "with-param"
-			],
-			gsf:
-			[
-				"cgi-param", "choose-metadata", "collectionText", "displayItem", "displayText",
-				"equivlinkgs3", "foreach-metadata", "icon", "if-metadata-exists", "image",
-				"interfaceText", "link", "meta-value", "metadata", "script",
-				"style", "switch", "template", "text", "variable"
-			]
-		};
-
 		var tabHolder = $("<ul>");
 		_toolboxDiv.append(tabHolder);
 
-		for(var key in elemList)
-		{
-			var currentList = elemList[key];
+		for(var key in _elemList)
+		{
+			var currentList = _elemList[key];
 
 			var tab = $("<li>");
@@ -675,5 +697,5 @@
 		}
 		
-		this.editMode = function()
+		this.editMode = function(editValue)
 		{
 			_editingNodes.push(_thisAttr);
@@ -704,5 +726,12 @@
 			valueCell.append(valueInput);
 
-			nameInput.focus();
+			if(editValue)
+			{
+				valueInput.focus();
+			}
+			else
+			{
+				nameInput.focus();
+			}
 		}
 		
@@ -1022,13 +1051,55 @@
 				_infoDiv.append(attributeTable);
 				
+				var addSelect = $("<select>");
+				addSelect.append("<option>[blank]</option>", {value:"[blank]"});
+				var fullName = _xmlNode.tagName;
+				var namespace;
+				var nodeName;
+				if(fullName.indexOf(":") == -1)
+				{
+					namespace = "no namespace";
+					nodeName = fullName;
+				}
+				else
+				{
+					namespace = fullName.substring(0, fullName.indexOf(":"));
+					nodeName = fullName.substring(fullName.indexOf(":") + 1);
+				}
+				var nameList = _validAttrList[namespace];
+				if(nameList)
+				{
+					var nameList = _validAttrList[namespace];
+					var attrList = nameList[nodeName];
+					if(attrList)
+					{
+						for(var i = 0; i < attrList.length; i++)
+						{
+							addSelect.append($("<option>" + attrList[i] + "</option>", {value:attrList[i]}));
+						}
+					}
+				}
+				
 				var addButton = $("<button>Add attribute</button>");
 				addButton.click(function()
 				{
-					var newAtt = new VEAttribute(null, _xmlNode, "", "");
+					var newAtt;
+					var editModeValue;
+					if(addSelect.find(":selected").val() == "[blank]")
+					{
+						newAtt = new VEAttribute(null, _xmlNode, "", "");
+						editModeValue = false;
+					}
+					else
+					{
+						newAtt = new VEAttribute(null, _xmlNode, addSelect.find(":selected").val(), "");
+						editModeValue = true;
+					}
+ 
 					var row = newAtt.getAsTableRow();
 					attributeTable.append(row);
-					newAtt.editMode();
+					newAtt.editMode(editModeValue);
 					_transactions.push({type:"addAttr", row:row})
 				});
+				_infoDiv.append(addSelect);
 				_infoDiv.append(addButton);
 			}
