

axe.TextSidePanel = function(inits){
	
	axe.TextSidePanel.superclass.constructor.call(this, sidebar, 'text');
	this.panel = inits["panel"];
	this.sidebar = inits["sidebar"];
	
	this.DOM = this.panel.DOM;
	this.nameBox = document.createElement("div");
	this.nameBox.appendChild(document.createTextNode(this.panel.filename));
	this.HTML.appendChild(this.nameBox);
	
	this.container = document.createElement("div");
	this.container.className = "sideContainer";
	this.HTML.appendChild(this.container);	
	
}
YAHOO.lang.extend(axe.TextSidePanel,axe.SidePanel);
axe.TextSidePanel.prototype.refreshView=function(){
	this.container.parentNode.removeChild(this.container);
	this.container = document.createElement("div");
	this.container.className = "sideContainer";
	this.HTML.appendChild(this.container);
	this.traverseTree(this.DOM.documentElement,this.container);
	//this.container.appendChild(tree);
}
axe.TextSidePanel.prototype.traverseTree = function(node,loc){
	
	var leaf = document.createElement("div");
	leaf.className = "divEle";
	nameSpan = document.createElement("span");
	nameSpan.appendChild(document.createTextNode(node.nodeName));
	killLeaf = document.createElement("span");
	killLeafImg = document.createElement("img");
	killLeafImg.src="./theme/images/icon_audio_delete.png";
	//killLeaf.appendChild(document.createTextNode("X"));
	killLeaf.appendChild(killLeafImg);
	killLeaf.className="killLeaf";
	YAHOO.util.Event.addListener(killLeaf,"click",this.removeNodeClicked,[this,node]);
	//YAHOO.util.Dom.setStyle(killLeaf,"background-color","red");
	YAHOO.util.Dom.setStyle(killLeaf,"display","none");
	
	
	
	
	YAHOO.util.Event.addListener(nameSpan,"click",this.treeNodeClicked,[this,leaf,node]);
	YAHOO.util.Event.addListener(leaf,"mouseover",this.treeNodeMouseOver,[this,leaf,node]);
	YAHOO.util.Event.addListener(leaf,"mouseout",this.treeNodeMouseOut,[this,leaf,node]);
	leaf.appendChild(nameSpan);
	leaf.appendChild(killLeaf);
	loc.appendChild(leaf);
	
	if (node.childNodes.length > 0) {
		var ul = document.createElement("ul");
		for (var i = 0; i < node.childNodes.length; i++) {
			var li = document.createElement("li");
			this.traverseTree(node.childNodes[i],li);
			
			ul.appendChild(li);
		}
		loc.appendChild(ul);	
	}	
}
axe.TextSidePanel.prototype.removeNodeClicked=function(e,obj){
	obj[0].panel.removeTag(obj[1]);
	
}
axe.TextSidePanel.prototype.treeNodeMouseOver = function(e, obj){
	obj[1].className = "tagMouseOver";
	YAHOO.util.Dom.setStyle(obj[1].childNodes[1],"display","inline");	

}
axe.TextSidePanel.prototype.treeNodeMouseOut = function(e, obj){
	obj[1].className = "tagMouseOut";

		YAHOO.util.Dom.setStyle(obj[1].childNodes[1],"display","none");
			
}
axe.TextSidePanel.prototype.treeNodeClicked=function(e,obj){
	
	touched = {obj: obj[2]};
	
	if (!(obj[2].getAttribute("xml:id"))){
		

		obj[2].setAttribute("xml:id",YAHOO.util.Dom.generateId(obj[2],obj[2].nodeName));
	}

	axe.tagClicked.fire({obj: obj[2]});
	obj[0].goToTag(e,obj);
}
axe.TextSidePanel.prototype.goToTag=function(e,obj){
	panel = obj[0].panel;
	
	if (panel.view == "textarea"){
		YAHOO.util.Dom.setStyle(panel.textAreaContent.HTML,"display","none");
		YAHOO.util.Dom.setStyle(panel.tagTree.HTML,"display","block");
		panel.view = "tree";
		panel.tagTree.drawTree(panel.curNode);
	}
	panel.tagTree.selectNode(e,[panel.tagTree,obj[2]]);
	//this.link = new axe.link();
	//axe.sidePanelClick.fire({obj: panel, desktop: panel.desktop, link: this.link});

}
axe.TextPanel = function(inits){
	
 	axe.TextPanel.superclass.constructor.call(this, inits);	
	this.root = inits["root"];
	this.schema = inits["schema"];
	this.filename = inits["filename"];
	this.tagSet = inits["tagSet"];
	this.DOM=null;
	this.schema = inits["schema"];
	//this.filename = "shorttxt.xml";
	this.filename = inits["url"];
	this.importXML(this.filename);
	this.root = this.DOM.documentElement.nodeName;
	this.rootNode = this.DOM.documentElement;

		
	
	this.xmlstring="";
//	this.viewButton = new axe.panelButton("./theme/images/icon_xml.png","view",this.header.HTML,this.showXML,this);



	this.viewButton = new axe.panelButton("./theme/images/icon_xml.png","view",this);
this.header.HTML.insertBefore(this.viewButton.HTML,this.closeButton.HTML);
YAHOO.util.Event.addListener(this.viewButton.HTML,"click",this.showXML,this);
	
	
	this.curNode = this.DOM.documentElement;
	this.path = new axe.Path(this,this.header.HTML,this.root);
	startMode = inits["mode"];
	this.view = startMode;
	this.textAreaContent = new axe.TextAreaContent(this);
	
	this.textAreaContent.textArea.setText(this.xmlstring);

	
	this.tagTree = new axe.TagTreeContent(this,this.root); 
	
	if (startMode == "textarea"){
		YAHOO.util.Dom.setStyle(this.tagTree.HTML,"display","none");
		YAHOO.util.Dom.setStyle(this.textAreaContent.HTML,"display","block");
	}
	else{
		YAHOO.util.Dom.setStyle(this.textAreaContent.HTML,"display","none");
		YAHOO.util.Dom.setStyle(this.tagTree.HTML,"display","block");
	}
	
	this.attributesBox = new axe.attributesBox();
	
	this.content.HTML.appendChild(this.attributesBox.HTML);

	this.attributesBox.hide(null,this.attributesBox);
	this.tagTree.drawTree(this.curNode);
	sideInits = {panel: this,sidebar:this.desktop.sideBar};
	this.sidePanel = new axe.TextSidePanel(sideInits);
	this.desktop.sideBar.addPanel(this.sidePanel);
	this.sidePanel.refreshView();


}
YAHOO.lang.extend(axe.TextPanel,axe.panel);

axe.TextPanel.prototype.getSelection=function(e,obj){
	
	var selection = new Selection(obj.HTML);
	var s = selection.create();
	obj.panel.selection = s;
	
}



axe.TextPanel.prototype.showAttributes = function(e,obj){
	panel = obj[0];
	node = obj[1];

	attBox = panel.attributesBox;
	attBox.show(e,attBox);
	attBox.populateAttributes(node);
	
}
axe.TextPanel.prototype.fillPossible = function(poss){
	this.textAreaContent.possibleBar.clear();
	for (i in poss) {
		if (poss[i].length > 0) {
		
		pt = new axe.possibleTag(this.textAreaContent.possibleBar.container, i, poss[i], this);
	}
	}
}
axe.TextPanel.prototype.showXML = function(e,obj){
	//	alert(getTagForOffset(obj.rootNode,190).parentNode.nodeName);
	xmlout = window.open('','xmlout',''); 
	txt = showXML(obj.DOM.documentElement,obj.filename);
	html = "<textarea rows=500 cols=200>"+txt+"</textarea>";
	xmlout.document.write(html);
	xmlout.document.close();
}
axe.TextPanel.prototype.importXML = function(fn){
	this.xmlstring = phpCall("./text/importXML.php","?fn="+fn,"GET");

	this.DOM = (new DOMParser()).parseFromString(this.xmlstring, "text/xml");
	
}
axe.TextPanel.prototype.getPossibleTags = function(){
	prev = "";
				this.textAreaContent.possibleBar.clear();
	this.textAreaContent.possibleBar.container.appendChild(document.createTextNode("Loading..."));
	if ((this.curNode.parentNode) && (this.curNode.parentNode.nodeName != "#document")) {
	
		parent = this.curNode.parentNode;
		
		sibs = parent.childNodes;
		sibArray = [];
		
		sibArray[0] = "";
		sibArray[1] = "";
		j = 0;
		for (i = 0; i < sibs.length; i++) {
			
			if (sibs[i].nodeName != "#text") {
			
				if (sibs[i] == this.curNode) {
					j = 1
				}
				else {
					sibArray[j] = sibArray[j] + "," + sibs[i].nodeName;
				}
			}
		}
	
		
		
	
		var req = new GetXmlHttpObject();
		sibArray[0]=sibArray[0].substring(1);
		requestLine = './text/getPossible.php?parent=' + parent.nodeName + '&before=' + sibArray[0].toString() + '&after=' + sibArray[1].toString()+"&schema="+this.schema;
		req.open('GET', requestLine, true);
		YAHOO.util.Event.addListener(req, "readystatechange", this.handlePossible, this);
		
		
		req.send(null);
	}
}
axe.TextPanel.prototype.handlePossible = function(e,args){
			
	
   			if (this.readyState == 4)
   			{
			
				resp = this.responseText;
			
				kids = resp.split("\n");
				
    	    	args.fillPossible(kids);
    		
   			}
 		
}
axe.TextPanel.prototype.loadText=function(node){
	
	txt = node.nodeValue.split(",");
	

	offset=txt[0];
	length=txt[1];
	this.xmlstring = loadText(this.filename,offset,length);	
	this.xml = (new DOMParser()).parseFromString(this.xmlstring, "text/xml");
		

}
axe.TextPanel.prototype.loadXML = function(filename){
				
				this.xmlstring = loadFile(filename);	
			
					
				this.xml = (new DOMParser()).parseFromString(this.xmlstring, "text/xml");	
			
					this.DOM.documentElement.appendChild(document.createTextNode(0+","+this.xmlstring.length));
				this.DOM.documentElement.setAttribute("axe_offset",0);
				this.DOM.documentElement.setAttribute("axe_length",this.xmlstring.length);
}


axe.TextPanel.prototype.changeView = function(e,panel){

	if (panel.view == "textarea"){
			YAHOO.util.Dom.setStyle(panel.textAreaContent.HTML,"display","none");
			YAHOO.util.Dom.setStyle(panel.tagTree.HTML,"display","block");
			panel.view = "tree";
			panel.tagTree.drawTree(panel.curNode);
	}
	else{
			textContent = this.xmlstring.replace(/<[^>]+>/g,"");
			this.textAreaContent.textArea.setText(textContent);
	
			YAHOO.util.Dom.setStyle(panel.tagTree.HTML,"display","none");
			YAHOO.util.Dom.setStyle(panel.textAreaContent.HTML,"display","block");
			
			panel.view = "textarea";
	}
}


	

axe.TagTreeContent = function(panel){
	this.HTML = document.createElement("div");
	this.HTML.className="TagTreeContent";	
	

	this.panel = panel;
	this.panel.content.HTML.appendChild(this.HTML);

	//this.drawTree(panel.rootNode);
	
	
	
	
}

axe.TagTreeContent.prototype.drawTree=function(node){
	
	if (this.HTML.firstChild) {
		this.HTML.removeChild(this.HTML.firstChild);
	}
		
	treeBox = document.createElement("div");
	this.rootUL = document.createElement("ul");
	this.rootTagBox = document.createElement("div");
	this.rootTagBox.className="tagBox";
	
	this.rootTagBox.appendChild(document.createTextNode(node.nodeName));
	
	
	
	treeBox.appendChild(this.rootTagBox);
	treeBox.appendChild(this.rootUL);
	this.HTML.appendChild(treeBox);
	if (node.childNodes){
		
		kids=node.childNodes;
		
		for (i=0;i<kids.length;i++){
		
			name = kids[i].nodeName;
	
			li = document.createElement("li");
		
			liDiv = document.createElement("div");
			liDiv.className="tagBox";
			nameSpan = document.createElement("span");
			nameSpan.className = "nameSpan";
				if (name != "#text") {
					nameSpan.appendChild(document.createTextNode(name));
				}
				else {
					var coord = node.firstChild.nodeValue;
					//alert("dude");
					if (coord) {
						offset = coord.substring(0, coord.indexOf(","));
						len = coord.substring(coord.indexOf(",") + 1);
						var content = loadText(this.panel.filename, offset, len);
					}
					else{
						var content = loadFile(this.panel.filename);
					}
					var snip = content.substring(0,20);
					
					nameSpan.appendChild(document.createTextNode("#text:"+ snip+" ..."));
				}
			liDiv.appendChild(nameSpan);
					if (name != "#text") {
						attributeSpan = document.createElement("span");
						attributeSpan.appendChild(document.createTextNode(" Attributes "));
						YAHOO.util.Event.addListener(attributeSpan,"click",this.panel.showAttributes,[this.panel,kids[i]]);
						liDiv.appendChild(attributeSpan);
						
						deleteSpan = document.createElement("span");
						deleteSpan.appendChild(document.createTextNode(" delete "));
						YAHOO.util.Event.addListener(deleteSpan,"click",function(e,obj){
						
							obj["panel"].panel.removeTag(obj["node"]);
							
							},{
							
								panel: this,
								node: kids[i]
							});
						liDiv.appendChild(deleteSpan);
					}
			YAHOO.util.Event.addListener(nameSpan,"click",this.selectNode,[this,kids[i]]);
			li.appendChild(liDiv);
			this.rootUL.appendChild(li);
			
		}
	}
}
axe.TagTreeContent.prototype.selectNode = function(e,obj){
	
	panel = obj[0].panel;
	if (obj[1].nodeName == "#text") {
		
		panel.curNode = obj[1];
		panel.loadText(panel.curNode);
		panel.changeView(e,obj[0].panel);
		panel.getPossibleTags();
	}
	else {
		panel.curNode = obj[1];
		obj[0].drawTree(obj[1]);
	}
	panel.path.updatePath();
}
axe.TextPanel.prototype.tagText = function(e,obj){

	panel = obj.panel;
	
	tagName = obj.tagName;

	offset = panel.selection.start;
	end = panel.selection.end;
	len = end-offset;
	txt = panel.textAreaContent.textArea.HTML.value;
	sTxt = txt.substring(0,offset);
	mTxt = txt.substring(offset,len);
	eTxt = txt.substring(end);
	
	oldOff = obj.panel.curNode.nodeValue.substring(0,obj.panel.curNode.nodeValue.indexOf(","));
	newNode = panel.DOM.createElement(tagName);
	
	
	
	curParent = obj.panel.curNode.parentNode;

		absoluteOffset = parseInt(offset)+parseInt(oldOff);
		
			newNode.setAttribute("axe_offset",absoluteOffset);
			
			newNode.setAttribute("axe_length",len);
			id = YAHOO.util.Dom.generateId(newNode,"textTag");
			newNode.setAttribute("axe_id",id);
			newNode.setAttribute("xml:id",id);
		
			newNode.appendChild(document.createTextNode(absoluteOffset+","+len));
	if (eTxt.length > 0) {
		//create end text

		newEnd = document.createTextNode((parseInt(absoluteOffset)+parseInt(len))+","+eTxt.length);
		curParent.replaceChild(newEnd, panel.curNode);
		
		curParent.insertBefore(newNode,newEnd);
		
		
	}
	else{
		curParent.replaceChild(newNode, obj.panel.curNode);
	}
	if (sTxt.length>0){
	
		newStart = document.createTextNode(oldOff+","+(parseInt(absoluteOffset)-parseInt(oldOff)));
		curParent.insertBefore(newStart,newNode);
	}
	len = parseInt(absoluteOffset)-parseInt(oldOff);
	panel.curNode = curParent;
	panel.changeView(e,panel);
	panel.sidePanel.refreshView();
	saveObj = {tagName: tagName, id: id, offset: absoluteOffset, length: len };
	linkObj = {obj: newNode};
	axe.tagCreated.fire(linkObj);
	obj.panel.saveTag(saveObj);
}
axe.TextPanel.prototype.saveTag=function(obj){
	phpCall("./text/saveTextTag.php","?tagName="+obj["tagName"]+"&id="+id+"&offset="+obj["offset"]+"&length="+obj["length"],"GET");	
}
axe.TextPanel.prototype.deleteTag=function(obj){
	phpCall("./text/delete.php","?id="+id);
}
function collapseTexts(node){

		var kids = node.childNodes;
		
		for (var i=0;i<kids.length;i++){
			
			if (kids[i].nodeName == "#text"){
				first = (kids[i]);
				
				offset = parseInt(first.nodeValue.substring(0,first.nodeValue.indexOf(",")));
				
				length = parseInt(first.nodeValue.substring(first.nodeValue.indexOf(",")+1));
				endoff = length+offset;
				cur=first.nextSibling;
			
				while ((cur)&&(cur.nodeName=="#text")){
					
					newoff = parseInt(cur.nodeValue.substring(0,cur.nodeValue.indexOf(",")));
					newlen = parseInt(cur.nodeValue.substring(cur.nodeValue.indexOf(",")+1));
					
					endoff = newoff+newlen;
				
					old = cur;
					cur = cur.nextSibling;
					old.parentNode.removeChild(old);
					i=i+1;
					
				}
				
				length = endoff-offset;
				newtext = document.createTextNode(offset+","+length);
	
				first.parentNode.replaceChild(newtext,first);
			
			}
			
			
		}
		
}
function getTagForOffset(node,offset){
		var resultString = "";
		var sub = null;
		var kids = node.childNodes;
		
		for (var i in kids){
		
			if (kids[i].nodeName == "#text"){
			//	alert('txt');
				value = kids[i].nodeValue;
				
				o =parseInt(value.substring(0,value.indexOf(",")));
				l = parseInt(value.substring((value.indexOf(",")+1)));
				if ((offset>=o) && (offset<(o+l)))	{
					return kids[i];
				}			
			}
			else{
				//alert("not");
				sub = getTagForOffset(kids[i],offset);
				if (sub){
					return sub;
				}			
			}	
		}
		return null;
	
}
function getTextNodes(node){
		var resultString = "";
		var sub = ""
		var kids = node.childNodes;
		
		for (var i in kids){
			if (kids[i].nodeName == "#text"){
				resultString = resultString+(kids[i].nodeValue)+"|";
			}
			else{
				sub = getTextNodes(kids[i]);
				if (sub.length > 0) {
					resultString = resultString+sub;
				}
			}	
		}
		return resultString;
	
}
axe.TextPanel.prototype.removeTag = function(node){
	offset = 0;
	length = 0;
	
	
	
	allText = getTextNodes(node).split("|");
	
	offset = parseInt(allText[0].substring(0, allText[0].indexOf(",")));
	endIndex = allText.length - 2;
	
	last = allText[endIndex];
	
	if (endIndex != 0) {
	
	endOff = parseInt(last.substring(0, last.indexOf(",")));
	endLen = parseInt(last.substring(last.indexOf(",") + 1));
	
	length = (endOff + endLen);
}
else{
	length = parseInt(last.substring(last.indexOf(",") + 1));
}

	newText = this.DOM.createTextNode(offset+","+length);

	node.parentNode.replaceChild(newText,node);
	collapseTexts(newText.parentNode);
	this.sidePanel.refreshView();
	
}
//--------TextArea View-----------------------
axe.TextAreaContent = function(panel){
	
	this.panel = panel;
	this.HTML = document.createElement("div");
	this.HTML.className = "TextAreaContent";
	panel.content.HTML.appendChild(this.HTML);
	this.textArea = new axe.xmlTextArea(this.HTML,this.panel);
	this.possibleBar = new axe.possibleBar(this.HTML,this.panel);

}
axe.xmlTextArea = function(loc,panel){

	this.id = YAHOO.util.Dom.generateId(this,"textarea");
	this.HTML = document.createElement("textarea");
	this.HTML.className = "xmlTextArea";
	this.panel = panel;

	this.HTML.id = this.id;
	this.HTML.readOnly=true;
	loc.appendChild(this.HTML);
	YAHOO.util.Event.addListener(this.HTML.id,"mouseup",this.panel.getSelection,this);
	this.startOffset = 0;
	this.length = 0;
	
}
axe.xmlTextArea.prototype.setText = function(textObj,offset,length){
	this.HTML.value=textObj;
	this.offset = offset;
	this.length = length;

	this.panel.getPossibleTags();
}
//------PossibleBar-----------
axe.possibleBar = function(loc,panel){
	this.panel = panel;
 	this.HTML = document.createElement("div");
	this.HTML.className = "possibleBar";
	this.id = YAHOO.util.Dom.generateId(this,"possibleBar");
	this.HTML.id = this.id;
	this.container = document.createElement("div");
	this.HTML.appendChild(this.container);
	loc.appendChild(this.HTML);
}

axe.possibleBar.prototype.clear=function(){
	this.HTML.removeChild(this.container);
	this.container = document.createElement("div");
	this.HTML.appendChild(this.container);
	
}
//-------PossibleTag-----------
axe.possibleTag = function(loc, number, tagName, panel){

	this.panel = panel;
	this.HTML = document.createElement("div");
	this.id = YAHOO.util.Dom.generateId(this,"possibleTag");
	this.HTML.id = this.id;
	this.HTML.className = "possibleTag";
	this.tagName = tagName;
	this.number = number;

	text = this.number + ": "+tagName;
	textNode = document.createTextNode(text);
	this.HTML.appendChild(textNode);
	loc.appendChild(this.HTML);
	YAHOO.util.Event.addListener(this.HTML.id,"click",this.panel.tagText,this);
}
//-------------------------------------------

axe.Path = function(panel,loc,initPath){
	this.HTML = document.createElement("span");
	this.HTML.className="path";
	this.id = YAHOO.util.Dom.generateId(this,"path");
	this.panel = panel;
	this.pathNode = document.createElement("span");
	this.HTML.appendChild(this.pathNode);

	loc.appendChild(this.HTML);
	this.updatePath();
}
axe.Path.prototype.updatePath = function(){

	this.HTML.removeChild(this.pathNode);

	this.pathNode = document.createElement("span");
	this.HTML.appendChild(this.pathNode);
	pathString = "";
	index = this.panel.curNode;
	while (index.nodeName != "#document"){
		aNode = document.createElement("span");
		aNode.appendChild(document.createTextNode("/"+index.nodeName));
		YAHOO.util.Event.addListener(aNode,"click",this.pathChange,[this,index]);
		this.pathNode.insertBefore(aNode,this.pathNode.firstChild);
		index=index.parentNode;

	}
	//txtNode = document.createTextNode(pathString);
	//this.HTML.removeChild(this.pathNode.firstChild);
	//this.HTML.appendChild(txtNode);
	}
axe.Path.prototype.pathChange=function(e,obj){
	panel = obj[0].panel;
	node = obj[1];
	if (panel.curNode.nodeName=="#text"){
		panel.changeView(e,panel);
	}
	
	panel.curNode=node;
	panel.tagTree.drawTree(node);
	obj[0].updatePath();
	
}
axe.attributesBox = function(){
	this.id = YAHOO.util.Dom.generateId("attributeBox");
	this.HTML = document.createElement("div");
	this.HTML.className = "attBox"
	this.HTML.id = this.id;
	headerText = document.createTextNode("Attributes");
	this.header = document.createElement("div");
	this.header.className = "attHeader";
	this.header.appendChild(headerText);
	this.HTML.appendChild(this.header);
	this.closeButton = document.createElement("span");
	
	this.closeButton.className = "closeButton";
	this.cbImg= document.createElement("img");
	this.cbImg.src="./theme/images/icon_audio_delete.png";
	this.closeButton.appendChild(this.cbImg);
	//this.closeButton.appendChild(document.createTextNode("X"));
	YAHOO.util.Event.addListener(this.closeButton,"click",this.hide,this);
	this.header.appendChild(this.closeButton);
	this.attBox = document.createElement("div");
	this.attBox.className = "attBoxContent";
	this.HTML.appendChild(this.attBox);	
}
axe.attributesBox.prototype.populateAttributes=function(curNode){
	if (this.attBox.firstChild) {
		this.attBox.removeChild(this.attBox.firstChild);
	}
	allAtts = document.createElement("table");
	
	phpString = phpCall("./text/getAtts.php","?parent="+curNode.nodeName,"GET");
	pieces = phpString.split(".....");
	names = pieces[0].split(",");
	defaults = pieces[1].split(",");
	enums = pieces[2].split(",");

	for (i = 0; i < names.length; i++) {
		attDiv = document.createElement("tr");
		nameSpan = document.createElement("td");
		nameSpan.className = "attNameSpan";
		nameSpan.appendChild(document.createTextNode(names[i]));
		
		valueSpan = document.createElement("td");
		valueSpan.className = "attValueSpan";
		
		if (enums[i]) {
		
			valueBox = document.createElement("select");
			valueBox.className = "attValueOpt";
			poss = enums[i].split("///");
			for (j = 0; j < poss.length; j++) {
				sel = document.createElement("option");
				sel.value = poss[j];
				sel.appendChild(document.createTextNode(poss[j]));
				valueBox.appendChild(sel);
			}
			
			
		}
		else {
		
			valueBox = document.createElement("input");
			valueBox.className = "attValueBox";
		}
		if (curNode.getAttribute(names[i])) {
			
			valueBox.value = curNode.getAttribute(names[i]);
		}
		
		YAHOO.util.Event.addListener(valueBox,"change",function(e,obj){
					
			obj[2].setAttribute(obj[0],obj[1].value);

		},[names[i],valueBox,curNode]
		);
		valueSpan.appendChild(valueBox);
			
		attDiv.appendChild(nameSpan);
		attDiv.appendChild(valueSpan);
	
		allAtts.appendChild(attDiv);
		
	}

	this.attBox.appendChild(allAtts);
}
axe.attributesBox.prototype.show=function(e,obj){

	
	YAHOO.util.Dom.setStyle(obj.HTML,"display","block");
}
axe.attributesBox.prototype.hide=function(e,obj){
	YAHOO.util.Dom.setStyle(obj.HTML,"display","none");
}

