
var strConsultantContent = "";

function verify5()
{
	// 0 Object is not initialized
 	// 1 Loading object is loading data
 	// 2 Loaded object has loaded data
 	// 3 Data from object can be worked with
 	// 4 Object completely initialized
 	if (xmlDoc5.readyState != 4)
 	{
   		return false;
 	}
}

function importConsultantInformationXML(processCounty)
{
	//alert("READY");
	county = processCounty;
	var xmlFile = '../XMLData/JCPC/jcpc_consultants.xml';
	//Check if IE(ActiveX) or FireFox
	if (window.ActiveXObject) {
		IE=1;
    xmlDoc5 = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc5.async="false";
    xmlDoc5.onreadystatechange=verify5;
    xmlDoc5.load(xmlFile);
  	xmlObj=xmlDoc5.documentElement;
	} else if (window.XMLHttpRequest) {
		Firefox=1;
  	xmlDoc5 = document.implementation.createDocument("", "", null);
		xmlDoc5.load(xmlFile);
	}
	 if ( !xmlDoc5.load(xmlFile) ) {        
	 	alert ("Failed to load JCPC_Consultant XML data source: ");    
	}
	ConsultantInformation();	
}

function ConsultantInformation() 
{ 
	//Need to set a Time Delay for Firefox
	intTime = 0;
	if (Firefox == 1) intTime = 1000;
	setTimeout("parseConsultantData()",intTime);	 
}

function parseConsultantData()
{	
	strConsultantContent = "";
	var label="";
	var value="";
	var x = xmlDoc5.getElementsByTagName('ROW');
	
	// x is the number of Rows in the XML file
	// loop thru the xml file looking for this County and generate html code
	
	for (i=0;i<x.length;i++) {
	//Loop thru all Child Nodes for the Row and look for County match
		for (j=0;j<x[i].childNodes.length;j++) {
			nodeFound=0;	
			if (x[i].childNodes[j].nodeType == 1) {	
				//Look for the County node
				if (x[i].childNodes[j].nodeName == "County") {
					nodeFound=1;
					strCounty = x[i].childNodes[j].firstChild.nodeValue;
				}
				// If County was found, then continue processing remaining child nodes
				if (strCounty.indexOf(county) >= 0) { 
					//Write out the table tag for District Contact Information
					strConsultantContent = strConsultantContent + '<table width="252" border="0" align="center" cellpadding="0" cellspacing="0">';
          
					// Now read the rest of the ChildNodes until end of Row 
					for (k=j+1;k<x[i].childNodes.length;k++) {
						if (x[i].childNodes[k].nodeType == 1) {	
							label=x[i].childNodes[k].nodeName;
							value="";
							if(x[i].childNodes[k].firstChild) 
								value=x[i].childNodes[k].firstChild.nodeValue;
							//write out the label/value line
							if(value!="(null)" && value!="(none)" && value!="") {
								strConsultantContent = strConsultantContent + '<tr valign="top"><td width="100"><strong>'+label+'</strong></td>';
								strConsultantContent = strConsultantContent + '<td>'+value+'</td></tr>';	
	     				}// End If value
							
						} //End If nodeType = 1
			
					} //End For k
					j=x[i].childNodes.length;
					
				} //End If strCounty = County
				
			} //End If nodeType = 1
						
	    } //End For j
		
		// Set i to the end since the County was found and we only want one Contact person
		if (strCounty.indexOf(county) >= 0) { 
			i = x.length;
			strConsultantContent = strConsultantContent + '</table>';
      strConsultantContent = strConsultantContent + '<br>';
		} // End If

	} //For i End
	
	//Replace jcpcinformation DIV with new strConsultantContent
	var newdiv = document.createElement("div");
	newdiv.innerHTML = strConsultantContent;
	var container = document.getElementById("jcpcconsultantinformation");
	container.appendChild(newdiv);
	
} //Function End

