			

// Load import XML file 

function importXML(xmlsource, xmlrecord){
	if (document.implementation && document.implementation.createDocument){
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = createTable;
	}else if (window.ActiveXObject){
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) createTable()
			};
	}else{
		alert('Your browser can\'t handle this script');
		return;
	}
	xmlDoc.load(xmlsource);
}

function createTable(){
	var x = xmlDoc.getElementsByTagName(xmlrecord);
	var newEl = document.createElement('TABLE');
	newEl.setAttribute('cellPadding',1);
	var tmp = document.createElement('TBODY');
	newEl.appendChild(tmp);
	for (i=0;i<x.length;i++){
		var row = document.createElement('TR');
		for (j=0;j<x[i].childNodes.length;j++){
			if (x[i].childNodes[j].nodeType != 1) continue;
				var container = document.createElement('TD');

				// Here is where I am trying to find out with these variables if the next field (child) is empty, but so far with no sucess... 
				///Test if the record field is empty
				//var y = 1,
				var test = x[i].childNodes[j].nodeType;
				// var test1 = x[i].childNodes[j].firstChild.nodeValue;
				// var test0 = x[i].childNodes[j].firstChild.length;
				if (x[i].childNodes[j].length != 0)
					var theData = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);
				else
					var theData = document.createTextNode('');
	
					var theData = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);



					container.appendChild(theData);
					row.appendChild(container);
				}
				tmp.appendChild(row);
		}
			document.getElementById('popupDivSugar').appendChild(newEl);
}

//ethonal
function importXML_E(xmlsource_e, xmlrecord_e){
	if (document.implementation && document.implementation.createDocument){
		xmlDoc1 = document.implementation.createDocument("", "", null);
		xmlDoc1.onload = createTable_E;
	}else if (window.ActiveXObject){
		xmlDoc1 = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc1.onreadystatechange = function () {
			if (xmlDoc1.readyState == 4) createTable_E()
			};
	}else{
		alert('Your browser can\'t handle this script');
		return;
	}
	xmlDoc1.load(xmlsource_e);
}

function createTable_E(){
	var x1 = xmlDoc1.getElementsByTagName(xmlrecord_e);
	var newEl1 = document.createElement('TABLE');
	newEl1.setAttribute('cellPadding',1);
	var tmp1 = document.createElement('TBODY');
	newEl1.appendChild(tmp1);
	for (i=0;i<x1.length;i++){
		var row1 = document.createElement('TR');
		for (j=0;j<x1[i].childNodes.length;j++){
			if (x1[i].childNodes[j].nodeType != 1) continue;
				var container1 = document.createElement('TD');

				// Here is where I am trying to find out with these variables if the next field (child) is empty, but so far with no sucess... 
				///Test if the record field is empty
				//var y = 1,
				var test = x1[i].childNodes[j].nodeType;
				// var test1 = x[i].childNodes[j].firstChild.nodeValue;
				// var test0 = x[i].childNodes[j].firstChild.length;
				if (x1[i].childNodes[j].length != 0)
					var theData1 = document.createTextNode(x1[i].childNodes[j].firstChild.nodeValue);
				else
					var theData1 = document.createTextNode('');
	
					var theData1 = document.createTextNode(x1[i].childNodes[j].firstChild.nodeValue);



					container1.appendChild(theData1);
					row1.appendChild(container1);
				}
				tmp1.appendChild(row1);
		}
			document.getElementById('popupDivEthanol').appendChild(newEl1);
}

//biodoesel
function importXML_B(xmlsource_b, xmlrecord_b){
	if (document.implementation && document.implementation.createDocument){
		xmlDoc2 = document.implementation.createDocument("", "", null);
		xmlDoc2.onload = createTable_B;
	}else if (window.ActiveXObject){
		xmlDoc2 = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc2.onreadystatechange = function () {
			if (xmlDoc2.readyState == 4) createTable_B()
			};
	}else{
		alert('Your browser can\'t handle this script');
		return;
	}
	xmlDoc2.load(xmlsource_b);
}

function createTable_B(){
	var x2 = xmlDoc2.getElementsByTagName(xmlrecord_b);
	var newEl2 = document.createElement('TABLE');
	newEl2.setAttribute('cellPadding',1);
	var tmp2 = document.createElement('TBODY');
	newEl2.appendChild(tmp2);
	for (i=0;i<x2.length;i++){
		var row2 = document.createElement('TR');
		for (j=0;j<x2[i].childNodes.length;j++){
			if (x2[i].childNodes[j].nodeType != 1) continue;
				var container2 = document.createElement('TD');

				// Here is where I am trying to find out with these variables if the next field (child) is empty, but so far with no sucess... 
				///Test if the record field is empty
				//var y = 1,
				var test = x2[i].childNodes[j].nodeType;
				// var test1 = x[i].childNodes[j].firstChild.nodeValue;
				// var test0 = x[i].childNodes[j].firstChild.length;
				if (x2[i].childNodes[j].length != 0)
					var theData2 = document.createTextNode(x2[i].childNodes[j].firstChild.nodeValue);
				else
					var theData2 = document.createTextNode('');
	
					var theData2 = document.createTextNode(x2[i].childNodes[j].firstChild.nodeValue);



					container2.appendChild(theData2);
					row2.appendChild(container2);
				}
				tmp2.appendChild(row2);
		}
			document.getElementById('popupDivBiodiesel').appendChild(newEl2);
}



