


function formatDetails (Data) {
						  dojo.byId('Detail').innerHTML = Data;
						  dijit.byId("Products").selectChild(dijit.byId("Detail"));
						  dojo.parser.parse('Detail');
						  
}

function setMapDetail () {
						if(dojo.byId('Detail').innerHTML != "") {
							detailLat = document.getElementById("lat").value;
							detailLon = document.getElementById("lon").value;
							setMapParams(detailLat,detailLon,1,17);
							
						}
}
function setMapResults() {
						setMapParams(resultLat,resultLon,0,resultZoom);
}

function queryDetails(evt){
	map.infoWindow.hide();
	map.setMapCursor("wait");
	foundResults = false;
	var identifyTask = new esri.tasks.IdentifyTask(ip + "/ArcGIS/rest/services/HarrisCounty/Harris_Products/MapServer");
	
	var identifyParams = new esri.tasks.IdentifyParameters();
	identifyParams.tolerance = 2;
	identifyParams.returnGeometry = false;
	identifyParams.layerIds = visible;
	identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
	
	map.infoWindow.setTitle("Results");
	
	var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.5]));
	
	identifyParams.geometry = evt.mapPoint;
	identifyParams.mapExtent = map.extent;
	
	startTable();
	
		identifyTask.execute(identifyParams, function(idResults){
			
			addToMap(idResults, evt);
			queryPipe(evt);
			
			
		}, function(){
			queryPipe(evt);
			
		});

	
		
	
}

function queryPipe(evt){
	if (dijit.byId('pipelines').checked == true) {
		var identifyPipeTask = new esri.tasks.IdentifyTask(ip + "/ArcGIS/rest/services/HarrisCounty/Harris_ProdPipelinesMSD/MapServer");
		
		var identifyPipeParams = new esri.tasks.IdentifyParameters();
		identifyPipeParams.tolerance = 1;
		identifyPipeParams.returnGeometry = false;
		identifyPipeParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
		var pipesymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.5]));
		
		identifyPipeParams.geometry = evt.mapPoint;
		identifyPipeParams.mapExtent = map.extent;
		
		identifyPipeTask.execute(identifyPipeParams, function(idResults){
			addToMapPipe(idResults, evt);
			endTable(evt);
			
		});
	} else {
		endTable(evt);
	}
}

function startTable(){
			infoHTML = "";
			dijit.byId('infoWindow').setContent('');
			map.infoWindow.setContent('');
			infoHTML = "<table><tr><td><strong>Company</strong></td><td><strong>Type</strong></td><td></td></tr>";
			
	
}
function endTable(evt){
			infoHTML += "</table>";
			dijit.byId('infoWindow').setContent(infoHTML);
			map.infoWindow.setContent(dijit.byId('infoWindow').domNode);
			map.setMapCursor("default");
			if (foundResults == true) {
				
				map.infoWindow.resize(300, 200);
				map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
				
				
			}
			
	
}
function addToMap(idResults, evt) {	
		if (idResults.length > 0) {
			foundResults = true;
			var layer1results = {
				displayFieldName: null,
				features: []
			};
			var layer2results = {
				displayFieldName: null,
				features: []
			};
			var layer3results = {
				displayFieldName: null,
				features: []
			};
			var layer4results = {
				displayFieldName: null,
				features: []
			};
			
			
			for (var i = 0, il = idResults.length; i < il; i++) {
				var idResult = idResults[i];
				if (idResult.layerId === 0) {  //Biodiesel
				
					infoHTML += "<tr><td>" + idResult.feature.attributes['Name'] + "</td><td>Biodiesel Plant</td><td>";
						var bioDetails = '<script type=\"dojo/method\" event=\"onClick\"> dojo.byId(\"Detail\").innerHTML = \'<br><strong>' + idResult.feature.attributes['Name'] + '</strong><br><br>';
								
						if (idResult.feature.attributes['Misc'] != "") {
							bioDetails += '<a href=\"' + idResult.feature.attributes['Misc'] + '\" target=\"_blank\">Plant Website</a>';
						}
						bioDetails += '<br><br><div dojoType=\"dijit.TitlePane\" title = \"Address\" selected=\"true\">' + idResult.feature.attributes['Name'] + '<br>' + idResult.feature.attributes['Address'] + '<br>' + idResult.feature.attributes['City'] + ', ' + idResult.feature.attributes['State'] + ' ' + idResult.feature.attributes['Zipcode'] + '</div><div dojoType=\"dijit.TitlePane\" title = \"Capacity\">'; 
						bioDetails += '<strong>Current Capacity: </strong>' + idResult.feature.attributes['Capacity'] + ' million gallons of biodiesel per day<br><br><strong>Future Capacity: </strong>' + idResult.feature.attributes['FutureCapa'] + ' million gallons of biodiesel per day</div>';
						
						bioDetails += '<div dojoType=\"dijit.TitlePane\" title = \"Feedstock Type\" selected=\"true\">' + idResult.feature.attributes['Feedstock'] + '</div>';
						bioDetails += '\';dijit.byId("Products").selectChild(dijit.byId("Detail")); dojo.parser.parse(dojo.byId("Detail"));;</script>';
						infoHTML += "<button type='button' dojoType='dijit.form.Button' align='right' >Details " + bioDetails + " </button>";
						infoHTML +="</td></tr>";
					
				}
				
					else 
						if (idResult.layerId === 1) {  //Refinery
							infoHTML += "<tr><td>" + idResult.feature.attributes['Name'] + "</td><td>Refinery</td><td>";
							var refDetails = '<script type=\"dojo/method\" event=\"onClick\"> dojo.byId(\"Detail\").innerHTML = \'<br><strong>' + idResult.feature.attributes['Name'] + '</strong><br><br>';
								
							if (idResult.feature.attributes['Misc'] != "") {
								refDetails += '<a href=\"' + idResult.feature.attributes['Misc'] + '\" target=\"_blank\">Refinery Website</a>';
							}
							refDetails += '<br><br><div dojoType=\"dijit.TitlePane\" title = \"Address\" selected=\"true\">' + idResult.feature.attributes['Name'] + '<br>' + idResult.feature.attributes['Address'] + '<br>' + idResult.feature.attributes['City'] + ', ' + idResult.feature.attributes['State'] + ' ' + idResult.feature.attributes['Zipcode'] + '</div><div dojoType=\"dijit.TitlePane\" title = \"Capacity\">'; 
							refDetails += idResult.feature.attributes['Capacity'] + ' barrels per day</div>';
							refDetails += '\';dijit.byId("Products").selectChild(dijit.byId("Detail")); dojo.parser.parse(dojo.byId("Detail"));;</script>';
							infoHTML += "<button type='button' dojoType='dijit.form.Button' align='right' >Details " + refDetails + " </button>";
							infoHTML +="</td></tr>";
						}
						else 
							if (idResult.layerId === 2) {  //Terminal
								infoHTML += "<tr><td>" + idResult.feature.attributes['Name'] + "</td><td>Terminal</td><td>";
								//var termDetails = '<script type="dojo/method" event"onClick"> dijit.byId("Detail").setContent("./termDetails.html"); </script>';
								var termDetails = '<script type=\"dojo/method\" event=\"onClick\"> dojo.byId(\"Detail\").innerHTML = \'<br><strong>' + idResult.feature.attributes['Name'] + '</strong><br><br>';
								
								if (idResult.feature.attributes['Misc'] != "") {
									termDetails += '<a href=\"' + idResult.feature.attributes['Misc'] + '\" target=\"_blank\">Terminal Website</a>';
								}
								termDetails += '<br><br><div dojoType=\"dijit.TitlePane\" title = \"Address\" selected=\"true\">' + idResult.feature.attributes['Name'] + '<br>' + idResult.feature.attributes['Address'] + '<br>' + idResult.feature.attributes['City'] + ', ' + idResult.feature.attributes['State'] + ' ' + idResult.feature.attributes['Zipcode'] + '</div><div dojoType=\"dijit.TitlePane\" title = \"Products\">'; 
								if (idResult.feature.attributes['Asphalt'] == "Y"){termDetails += "Asphalt, ";}
								if (idResult.feature.attributes['Chemicals'] == "Y"){termDetails += "Chemcials, ";}
								if (idResult.feature.attributes['LNGs'] == "Y"){termDetails += "LNGs, ";}
								if (idResult.feature.attributes['Propane'] == "Y"){termDetails += "Propane, ";}
								if (idResult.feature.attributes['Butane'] == "Y"){termDetails += "Butane, ";}
								if (idResult.feature.attributes['Refined_Pr'] == "Y"){termDetails += "Refined Products, ";}
								if (idResult.feature.attributes['Ethanol'] == "Y"){termDetails += "Ethanol, ";}
								if (idResult.feature.attributes['Biodiesel'] == "Y"){termDetails += "Biodiesel, ";}
								if (idResult.feature.attributes['Crude_Oil'] == "Y"){termDetails += "Crude Oil, ";}
									
								termDetails += '</div><div dojoType=\"dijit.TitlePane\" title = \"Access\"><table width=\"200\" border=\"1\"><tr align=\"center\"><td></td><td height=\"20\"><b>In</b></td><td height=\"20\"><b>Out</b></td></tr><tr align=\"center\" valign=\"middle\"><td><b>Rail</b></td><td>'+ idResult.feature.attributes['Rail_In'] +' </td><td>' + idResult.feature.attributes['Rail_Out'] + '</td></tr><tr align=\"center\" valign=\"middle\"><td><b>Truck</b></td><td>' + idResult.feature.attributes['Truck_In'] + '</td><td>' + idResult.feature.attributes['Truck_Out'] + '</td></tr><tr align=\"center\" valign=\"middle\"><td><b>Marine</b></td><td>' + idResult.feature.attributes['Marine_In'] + '</td><td>' + idResult.feature.attributes['Marine_Out'] + '</td></tr></table><br><strong>Pipeline Access</strong><br><strong>In: </strong>' + idResult.feature.attributes['Pipeline_I'] + '<br><strong>Out: </strong>' + idResult.feature.attributes['Pipeline_O'] + '</div>';
								
								
								
								termDetails += '\';dijit.byId("Products").selectChild(dijit.byId("Detail")); dojo.parser.parse(dojo.byId("Detail"));;</script>';
								infoHTML += '<button type="button" dojoType="dijit.form.Button" align="right" >Details ' + termDetails + '</button>';
								infoHTML +="</td></tr>";
							}
			}
			
	}
	
}

function addToMapPipe(pipeIdResults, evt) {	
		
		if (pipeIdResults.length >0) {
			foundResults = true;
			
			var pipeName = [];
			var pipeSys = [];
				for (var i = 0, il = pipeIdResults.length; i < il; i++) {
					if (!pipelineContained(pipeName,pipeSys,pipeIdResults[i].feature.attributes['OWNER'],pipeIdResults[i].feature.attributes['SYS_NM'])) {
						infoHTML += "<tr><td>" + pipeIdResults[i].feature.attributes['OWNER'] + "</td><td>Pipeline</td><td>";
						var pipeDetails = '<script type=\"dojo/method\" event=\"onClick\"> dojo.byId(\"Detail\").innerHTML = \'<br><strong>' + pipeIdResults[i].feature.attributes['OWNER'] + '</strong><br><br>';
						
						pipeDetails += '<br><br><div dojoType=\"dijit.TitlePane\" title = \"Info\" selected=\"true\">Owner: ' + pipeIdResults[i].feature.attributes['OWNER'] + '<br>Operator: ' + pipeIdResults[i].feature.attributes['OPR_NM'] + '<br>System Name: ' + pipeIdResults[i].feature.attributes['SYS_NM'] + '<br>Subsystem Name: ' + pipeIdResults[i].feature.attributes['SUBSYSNM'] + '</div><div dojoType=\"dijit.TitlePane\" title = \"Pipeline Detail\">Commodity: '; 
						switch (pipeIdResults[i].feature.attributes['CMDTY']) {
							case 'HG':
								pipeDetails += 'Hydrogen Gas';
								break;
							case 'CRD':
								pipeDetails += 'Crude Oil';
								break;
							case 'LPG':
								pipeDetails += 'Liquified Petroleum Gas';
								break;
							case 'NG':
								pipeDetails += 'Natural Gas';
								break;
							case 'PRD':
								pipeDetails += 'Product';
								break;
							case 'AA':
								pipeDetails += 'Anhydrous Ammonia';
								break;
							case 'CO2':
								pipeDetails += 'Carbon Dioxide';
								break;
							case 'NGL':
								pipeDetails += 'Natural Gas Liquids';
								break;
							case 'HVL':
								pipeDetails += 'Highly Volatile Liquid';
								break;
							case 'EMT':
								pipeDetails += 'Empty';
								break;
							case 'Refine':
								pipeDetails += 'Product';
								break;
							default:
								pipeDetails += 'Unknown';
														
						}
						
						pipeDetails += '<br>Pipeline System Type: ';
						
						switch(pipeIdResults[i].feature.attributes['SYSTYPE']){
							case 'K':
								pipeDetails+= 'Carbon Dioxide Line';
								break;
							case 'L':
								pipeDetails+= 'Crude Gathering Line';
								break;
							case 'O':
								pipeDetails+= 'Crude Transmission Line';
								break;
							case 'P':
								pipeDetails+= 'Product Line (Not Highly Volatile)';
								break;
							case 'Q':
								pipeDetails+= 'Other Product Line (Highly Volatile)';
								break;
							case 'T':
								pipeDetails+= 'Gas Transmission Line';
								break;
							case 'G':
								pipeDetails+= 'Gas Gathering Line';
								break;
							default:
								pipeDetails += 'Unknown';
							
						}
						pipeDetails += '<br>Pipeline Diameter (inches): '+ pipeIdResults[i].feature.attributes['DIA_IN'] + '</div>';
						pipeDetails += '\';dijit.byId("Products").selectChild(dijit.byId("Detail")); dojo.parser.parse(dojo.byId("Detail"));;</script>';
						infoHTML += "<button type='button' dojoType='dijit.form.Button' align='right' >Details " + pipeDetails + " </button>";
						infoHTML +="</td></tr>";
						
						
						pipeName[i] = pipeIdResults[i].feature.attributes['OWNER'];
						pipeSys[i] = pipeIdResults[i].feature.attributes['SYS_NM'];
					} else {
						pipeName[i] = "";
						pipeSys[i] = "";
					}
					
				}
			
			
		}
	
}

function pipelineContained (pipeName,pipeSys,newpipename,newpipesys){
	for (var i = 0;i<pipeName.length;i++){
		if ((pipeName[i] == newpipename) && (pipeSys[i] == newpipesys)) {
			return true;
		}
	}
	return false;
	
}

function terminalTable(featureSet) {
	
						var html = "";
						for(var h=0; h<featureSet.features.length; h++) {
							var termfeature = featureSet.features[h];
							var termDetails = '<script type=\"dojo/method\" event=\"onClick\"> dojo.byId(\"Detail\").innerHTML = \'<br><strong>' + termfeature.attributes.Name + '</strong><br><br>';
								
								if (termfeature.attributes.Misc != "") {
									termDetails += '<a href=\"' + termfeature.attributes.Misc + '\" target=\"_blank\">Terminal Website</a>';
								}
								termDetails += '<br><br><div dojoType=\"dijit.TitlePane\" title = \"Address\" selected=\"true\">' + termfeature.attributes.Name + '<br>' + termfeature.attributes.Address + '<br>' + termfeature.attributes.City + ', ' + termfeature.attributes.State + ' ' + termfeature.attributes.Zipcode + '</div><div dojoType=\"dijit.TitlePane\" title = \"Products\">'; 
								if (termfeature.attributes.Asphalt == "Y"){termDetails += "Asphalt, ";}
								if (termfeature.attributes.Chemicals == "Y"){termDetails += "Chemicals, ";}
								if (termfeature.attributes.LNGs == "Y"){termDetails += "LNGs, ";}
								if (termfeature.attributes.Propane == "Y"){termDetails += "Propane, ";}
								if (termfeature.attributes.Butane == "Y"){termDetails += "Butane, ";}
								if (termfeature.attributes.Refined_Pr == "Y"){termDetails += "Refined Products, ";}
								if (termfeature.attributes.Ethanol== "Y"){termDetails += "Ethanol, ";}
								if (termfeature.attributes.Biodiesel == "Y"){termDetails += "Biodiesel, ";}
								if (termfeature.attributes.Crude_Oil == "Y"){termDetails += "Crude Oil, ";}
									
								termDetails += '</div><div dojoType=\"dijit.TitlePane\" title = \"Access\"><table width=\"200\" border=\"1\"><tr align=\"center\"><td></td><td height=\"20\"><b>In</b></td><td height=\"20\"><b>Out</b></td></tr><tr align=\"center\" valign=\"middle\"><td><b>Rail</b></td><td>'+ termfeature.attributes.Rail_In +' </td><td>' + termfeature.attributes.Rail_Out + '</td></tr><tr align=\"center\" valign=\"middle\"><td><b>Truck</b></td><td>' + termfeature.attributes.Truck_In + '</td><td>' + termfeature.attributes.Truck_Out + '</td></tr><tr align=\"center\" valign=\"middle\"><td><b>Marine</b></td><td>' + termfeature.attributes.Marine_In + '</td><td>' + termfeature.attributes.Marine_Out + '</td></tr></table><br><strong>Pipeline Access</strong><br><strong>In: </strong>' + termfeature.attributes.Pipeline_I + '<br><strong>Out: </strong>' + termfeature.attributes.Pipeline_O + '</div>';
								termDetails += '\';dijit.byId("Products").selectChild(dijit.byId("Detail")); dojo.parser.parse(dojo.byId(\"Detail\"));;</script>';
								
							html+= "<table width=260 id='termRow" + h + "'><tr><td style='cursor:pointer;' onClick=\'showMyTermInfoWindow(\"" + termfeature.attributes.Name + "\", \"Terminal\", " + termfeature.geometry.x + "," + termfeature.geometry.y + ", " + h + " )\'> <strong>" + termfeature.attributes.Name + "</strong><br>" + termfeature.attributes.Address + "<br>" + termfeature.attributes.City + ", " + termfeature.attributes.State + " " + termfeature.attributes.Zipcode + "</td><td align = 'right'><button type='button' dojoType='dijit.form.Button' align='right' >Details" + termDetails + "</button></td></tr></table>"; 
						}
						dojo.byId('termAcc').innerHTML = html;
						
						dojo.parser.parse('termAcc');
}
function refineryTable(featureSet) {
	
						var html = "";
						for(var h=0; h<featureSet.features.length; h++) {
							var reffeature = featureSet.features[h];
							var refDetails = '<script type=\"dojo/method\" event=\"onClick\"> dojo.byId(\"Detail\").innerHTML = \'<br><strong>' + reffeature.attributes.Name + '</strong><br><br>';
								
							if (reffeature.attributes.Misc != "") {
								refDetails += '<a href=\"' + reffeature.attributes.Misc + '\" target=\"_blank\">Refinery Website</a>';
							}
							refDetails += '<br><br><div dojoType=\"dijit.TitlePane\" title = \"Address\" selected=\"true\">' + reffeature.attributes.Name + '<br>' + reffeature.attributes.Address + '<br>' + reffeature.attributes.City + ', ' + reffeature.attributes.State + ' ' + reffeature.attributes.Zipcode + '</div><div dojoType=\"dijit.TitlePane\" title = \"Capacity\">'; 
							refDetails += reffeature.attributes.Capacity + ' barrels per day</div>';
							refDetails += '\';dijit.byId("Products").selectChild(dijit.byId("Detail")); dojo.parser.parse(dojo.byId("Detail"));;</script>';
								
							html+= "<table width=260 id='refRow" + h + "'><tr><td style='cursor:pointer;' onClick=\'showMyRefInfoWindow(\"" + reffeature.attributes.Name + "\", \"Refinery\", " + reffeature.geometry.x + "," + reffeature.geometry.y + ", " + h + " )\'> <strong>" + reffeature.attributes.Name + "</strong><br>" + reffeature.attributes.Address + "<br>" + reffeature.attributes.City + ", " + reffeature.attributes.State + " " + reffeature.attributes.Zipcode + "</td><td align = 'right'><button type='button' dojoType='dijit.form.Button' align='right' >Details" + refDetails + "</button></td></tr></table>"; 
						}
						dojo.byId('refAcc').innerHTML = html;
						
						dojo.parser.parse('refAcc');
}
function ethanolTable(featureSet) {
	
						var html = "";
						for(var h=0; h<featureSet.features.length; h++) {
							var ethfeature = featureSet.features[h];
							var ethDetails = '<script type=\"dojo/method\" event=\"onClick\"> dojo.byId(\"Detail\").innerHTML = \'<br><strong>' + ethfeature.attributes.Name + '</strong><br><br>';
								
								if (ethfeature.attributes.Misc != "") {
									ethDetails += '<a href=\"' + ethfeature.attributes.Misc + '\" target=\"_blank\">Plant Website</a>';
								}
								ethDetails += '<br><br><div dojoType=\"dijit.TitlePane\" title = \"Address\" selected=\"true\">' + ethfeature.attributes.Name + '<br>' + ethfeature.attributes.Address + '<br>' + ethfeature.attributes.City + ', ' + ethfeature.attributes.State + ' ' + ethfeature.attributes.Zipcode + '</div><div dojoType=\"dijit.TitlePane\" title = \"Capacity\">'; 
								ethDetails += '<strong>Current Capacity: </strong>' + ethfeature.attributes.CurrentCap + ' million gallons of ethanol per day<br><br><strong>Future Capacity: </strong>' + ethfeature.attributes.FutureCapa + ' million gallons of ethanol per day</div>';
								
								ethDetails += '<div dojoType=\"dijit.TitlePane\" title = \"Feedstock Type\" selected=\"true\">' + ethfeature.attributes.Feedstock + '</div>';
								ethDetails += '\';dijit.byId("Products").selectChild(dijit.byId("Detail")); dojo.parser.parse(dojo.byId("Detail"));;</script>';
								
							html+= "<table width=260 id='ethRow" + h + "'><tr><td style='cursor:pointer;' onClick=\'showMyEthInfoWindow(\"" + ethfeature.attributes.Name + "\", \"Ethanol\", " + ethfeature.geometry.x + "," + ethfeature.geometry.y + ", " + h + " )\'> <strong>" + ethfeature.attributes.Name + "</strong><br>" + ethfeature.attributes.Address + "<br>" + ethfeature.attributes.City + ", " + ethfeature.attributes.State + " " + ethfeature.attributes.Zipcode + "</td><td align = 'right'><button type='button' dojoType='dijit.form.Button' align='right' >Details" + ethDetails + "</button></td></tr></table>"; 
						}
						dojo.byId('ethAcc').innerHTML = html;
						
						dojo.parser.parse('ethAcc');
}
function biodieselTable(featureSet) {
	
						var html = "";
						for(var h=0; h<featureSet.features.length; h++) {
							var biofeature = featureSet.features[h];
							var bioDetails = '<script type=\"dojo/method\" event=\"onClick\"> dojo.byId(\"Detail\").innerHTML = \'<br><strong>' + biofeature.attributes.Name + '</strong><br><br>';
								
						if (biofeature.attributes.Misc != "") {
							bioDetails += '<a href=\"' + biofeature.attributes.Misc + '\" target=\"_blank\">Plant Website</a>';
						}
						bioDetails += '<br><br><div dojoType=\"dijit.TitlePane\" title = \"Address\" selected=\"true\">' + biofeature.attributes.Name + '<br>' + biofeature.attributes.Address + '<br>' + biofeature.attributes.City + ', ' + biofeature.attributes.State + ' ' + biofeature.attributes.Zipcode + '</div><div dojoType=\"dijit.TitlePane\" title = \"Capacity\">'; 
						bioDetails += '<strong>Current Capacity: </strong>' + biofeature.attributes.Capacity + ' million gallons of biodiesel per day<br><br><strong>Future Capacity: </strong>' + biofeature.attributes.FutureCapa + ' million gallons of biodiesel per day</div>';
						
						bioDetails += '<div dojoType=\"dijit.TitlePane\" title = \"Feedstock Type\" selected=\"true\">' + biofeature.attributes.Feedstock + '</div>';
						bioDetails += '\';dijit.byId("Products").selectChild(dijit.byId("Detail")); dojo.parser.parse(dojo.byId("Detail"));;</script>';
								
							html+= "<table width=260 id='bioRow" + h + "'><tr><td style='cursor:pointer;' onClick=\'showMyBioInfoWindow(\"" + biofeature.attributes.Name + "\", \"Biodiesel\", " + biofeature.geometry.x + "," + biofeature.geometry.y + ", " + h + " )\'> <strong>" + biofeature.attributes.Name + "</strong><br>" + biofeature.attributes.Address + "<br>" + biofeature.attributes.City + ", " + biofeature.attributes.State + " " + biofeature.attributes.Zipcode + "</td><td align = 'right'><button type='button' dojoType='dijit.form.Button' align='right' >Details" + bioDetails + "</button></td></tr></table>"; 
						}
						dojo.byId('bioAcc').innerHTML = html;
						
						dojo.parser.parse('bioAcc');
}
	

function showMyTermInfoWindow(name,type,x,y,num) {
	if (lastclick != "") {
		dojo.byId(lastclick).style.background = "#FFF";
	}
	dojo.byId('termRow' + num).style.background = "#F2F2F2";
	lastclick = 'termRow' + num;
	var mytermcontent = "<strong>" + name + "</strong>";
	var myPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
	var screenPoint = map.toScreen(myPoint);
	map.infoWindow.setContent(mytermcontent);
	map.infoWindow.setTitle(type);
	
	map.infoWindow.resize(150, 50);
	
	map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
	
}
function showMyAllTermInfoWindow(name,type,x,y,num) {
	if (alllastclick != "") {
		dojo.byId(alllastclick).style.background = "#FFF";
	}
	dojo.byId('allTermRow' + num).style.background = "#F2F2F2";
	alllastclick = 'allTermRow' + num;
	var mytermcontent = "<strong>" + name + "</strong>";
	var myPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
	var screenPoint = map.toScreen(myPoint);
	map.infoWindow.setContent(mytermcontent);
	map.infoWindow.setTitle(type);
	
	map.infoWindow.resize(150, 50);
	
	map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
	
}
 
function showMyRefInfoWindow(name,type,x,y,num) {
	if (lastclick != "") {
		dojo.byId(lastclick).style.background = "#FFF";
	}
	dojo.byId('refRow' + num).style.background = "#F2F2F2";
	lastclick = 'refRow' + num;
	var myrefcontent = "<strong>" + name + "</strong>";
	var myPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
	var screenPoint = map.toScreen(myPoint);
	map.infoWindow.setContent(myrefcontent);
	map.infoWindow.setTitle(type);
	
	map.infoWindow.resize(150, 50);
	
	map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
	
}
function showMyAllRefInfoWindow(name,type,x,y,num) {
	if (alllastclick != "") {
		dojo.byId(alllastclick).style.background = "#FFF";
	}
	dojo.byId('allRefRow' + num).style.background = "#F2F2F2";
	alllastclick = 'allRefRow' + num;
	var myrefcontent = "<strong>" + name + "</strong>";
	var myPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
	var screenPoint = map.toScreen(myPoint);
	map.infoWindow.setContent(myrefcontent);
	map.infoWindow.setTitle(type);
	
	map.infoWindow.resize(150, 50);
	
	map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
	
}
       
function showMyBioInfoWindow(name,type,x,y,num) {
	if (lastclick != "") {
		dojo.byId(lastclick).style.background = "#FFF";
	}
	dojo.byId('bioRow' + num).style.background = "#F2F2F2";
	lastclick = 'bioRow' + num;
	var mybiocontent = "<strong>" + name + "</strong>";
	var myPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
	var screenPoint = map.toScreen(myPoint);
	map.infoWindow.setContent(mybiocontent);
	map.infoWindow.setTitle(type);
	
	map.infoWindow.resize(150, 50);
	
	map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
	
}
function showMyAllBioInfoWindow(name,type,x,y,num) {
	if (alllastclick != "") {
		dojo.byId(alllastclick).style.background = "#FFF";
	}
	dojo.byId('allBioRow' + num).style.background = "#F2F2F2";
	alllastclick = 'allBioRow' + num;
	var mybiocontent = "<strong>" + name + "</strong>";
	var myPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
	var screenPoint = map.toScreen(myPoint);
	map.infoWindow.setContent(mybiocontent);
	map.infoWindow.setTitle(type);
	
	map.infoWindow.resize(150, 50);
	
	map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
	
}

function showMyEthInfoWindow(name,type,x,y,num) {
	if (lastclick != "") {
		dojo.byId(lastclick).style.background = "#FFF";
	}
	dojo.byId('ethRow' + num).style.background = "#F2F2F2";
	lastclick = 'ethRow' + num;
	var myethcontent = "<strong>" + name + "</strong>";
	var myPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
	var screenPoint = map.toScreen(myPoint);
	map.infoWindow.setContent(myethcontent);
	map.infoWindow.setTitle(type);
	
	map.infoWindow.resize(150, 50);
	
	map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
	
} 
function showMyAllEthInfoWindow(name,type,x,y,num) {
	if (alllastclick != "") {
		dojo.byId(alllastclick).style.background = "#FFF";
	}
	dojo.byId('allEthRow' + num).style.background = "#F2F2F2";
	alllastclick = 'allEthRow' + num;
	var myethcontent = "<strong>" + name + "</strong>";
	var myPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
	var screenPoint = map.toScreen(myPoint);
	map.infoWindow.setContent(myethcontent);
	map.infoWindow.setTitle(type);
	
	map.infoWindow.resize(150, 50);
	
	map.infoWindow.show(screenPoint,map.getInfoWindowAnchor(screenPoint));
	
} 
