// COPYRIGHT DENNY WONG PUI CHUNG 2009

// This document requies the use of jsXML_Connect.js, and would refuse to do anything except the file is loaded.
if (typeof ajax_XML_Connect == "function")
{

// -------------------------------------------------------------------------------------------------------------------------
// START OF FUNCTION SET
// -------------------------------------------------------------------------------------------------------------------------

	xml_DOM_NodeList_get_attribute = function (Node, att_name)
										{
											var att_array = Node.attributes;
											
											if (typeof att_array != undefined)
											for (i = 0; i < att_array.length; i++)
											{
												//alert(att_array[i].name + ":" + att_array[i].value);
												if (att_array[i].name == att_name)
												{
													return att_array[i].value;
												}
											}
											return null;
										}
	
	//Check if a node in a NodeList exists
	xml_DOM_NodeList_tag_exists = function (NodeList, node_name)
										{
											return (NodeList.getElementsByTagName(node_name).length != 0);
										}
	
	//Get a sub tag
	xml_DOM_NodeList_get_tag = function (NodeList, node_name)
										{
											return NodeList.getElementsByTagName(node_name);
										}
										
	xml_DOM_Node_get_innerXML = function (Node)
										{
											return Node.childNodes[0].nodeValue;
										}
										
	xml_DOM_NodeList_tag_manager = function (Nodes)
									{
										this.nodes = Nodes;
										this.pointer = 0;
										
										this.length = this.nodes.length;
										
										this.end_of_members = function ()
																	{
																		return this.pointer >= this.nodes.length;
																	}
																	
										this.is_last_member = function ()
																	{
																		return this.pointer == (this.nodes.length-1);
																	}
																	
										this.member_shift = function (amount)
																	{
																		this.pointer+=amount;
																		if (this.pointer <= 0) { this.pointer = 0; }
																		return !this.end_of_members();
																	}
																	
										
																	
										this.next_member = function ()
																	{
																		this.member_shift(1);
																	}
										
										this.prev_member = function ()
																	{
																		this.member_shift(-1);
																	}
																	
										this.first_member = function ()
																	{
																		this.pointer = 0;
																	}
																	
										this.get_attribute = function (att_name)
																	{
																		return xml_DOM_NodeList_get_attribute(this, att_name);
																	}
										
										this.get_value = function (node_name)
																	{
																		var node = xml_DOM_NodeList_get_tag(this.nodes[this.pointer], node_name);
																		
																		if (node.length >0)
																		{
																			return xml_DOM_Node_get_innerXML(node[0]);
																		} else {
																			return undefined;
																		}
																	}
									}
	
	
	

// -------------------------------------------------------------------------------------------------------------------------
// END OF FUNCTION SET
// -------------------------------------------------------------------------------------------------------------------------
} else { alert("FATAL ERROR: AJAX_XML_CONNECT not loaded."); }// Ends the IF condition for the inclusion of jsXML_Connect.js
