var xmlResponse = "";
/*
$(document).ready(function()
{
  $.ajax({
    type: "GET",
    url: "http://mismo.labuno.com/GenericBoarderIncome.xml",
    dataType: "xml",
    success: parseXML
  });
  // parseXMLString(xmlString);

});
*/
// ----------------------------------------------------------------------------------------
function loadXML(xmlString) {
$('#content').fadeIn();
$('#selectContainer').fadeOut();
if (window.DOMParser)
  {
  parser=new DOMParser();
  xmlDoc=parser.parseFromString(xmlString,"text/xml");
  }
else // Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async="false";
  xmlDoc.loadXML(xmlString);
  }
  parseXML(xmlDoc);
}
// ----------------------------------------------------------------------------------------
function parseXML(xml) {
  xmlResponse = xml;
  populateFields();
}
// ----------------------------------------------------------------------------------------
function printXML() {
		if (window.ActiveXObject) 
			var xmlString = xmlResponse.xml;
		else
			var xmlString = (new XMLSerializer()).serializeToString(xmlResponse);
		//alert(xmlString);
//		alert (xmlString);

		return xmlString;
}
// ------------------------------------------------------------------------------------------
function updateXML(divID) {
	try {
		$("#" + divID + " input ").each(function(n) {
							if (xmlResponse !== '')		
								attrNode = xmlResponse.getElementsByTagName(divID)[0].getAttributeNode(this.name);
								if (attrNode != null) 
									attrNode.nodeValue = this.value;
								//else 
									//alert(divID + " has no attribute " + this.name);
		});

		$("#" + divID + " select ").each(function(n) {
							if (xmlResponse !== '')
								attrNode = xmlResponse.getElementsByTagName(divID)[0].getAttributeNode(this.name);
								if (attrNode != null) 
									attrNode.nodeValue = this.value;
								//else 
									//alert(divID + " has no attribute " + this.name);
										   });
	} catch (ex) {}
			
}
// ------------------------------------------------------------------------------------------------
function populateDiv(divID) {
   	$("#" + divID + " input ").each(function(n) {
				if (xmlResponse !== '')	
								attrNode = xmlResponse.getElementsByTagName(divID)[0].getAttributeNode(this.name);
								if (attrNode != null) 
									this.value = attrNode.nodeValue;
								//else 
									//alert(divID + " has no attribute " + this.name);
		});

		$("#" + divID + " select ").each(function(n) {
							if (xmlResponse !== '')
								attrNode = xmlResponse.getElementsByTagName(divID)[0].getAttributeNode(this.name);
								if (attrNode !== null) 
									this.value = attrNode.nodeValue;
								 //else 
									//alert(divID + " has no attribute " + this.name);
										   });
   }
// ------------------------------------------------------------------------------------------
function populateFields() {
	 $("td div").each(function(n) {
		 	 populateDiv(this.id);

		 });
}
// ------------------------------------------------------------------------------------------


