 //Programmer:Devdas Kamath.
 //Last Date Modify:25/May/2002.

/*------------------------------------------------------------------------------------*/ 
function window_onunload()
	{	
		document.all.idSteamCost.innerText = "";
		document.all.idSavingCleaver.innerText = "";
	}
/*------------------------------------------------------------------------------------*/ 

function fnReset()
{
	document.all.idSteam4.style.display = "none";
	window.frmboilerstream.txtBoilerOutput.value = "400";
	window.frmboilerstream.txtBoilerEfficiency.value  = "60";
	window.frmboilerstream.txtFuelCost.value = "1.00";
	window.frmboilerstream.txtAnnualhours.value = "";
	window.frmboilerstream.txtAnnualhours.focus();
	document.all.IdAlternateBoiler.style.display = "none";
	document.all.idSteamCostDiff.style.display = "none";

	
	
	 
	
  if(window.frmboilerstream.rdoFueltypeselected(0).checked)
  {  
	window.frmboilerstream.cboOiltype.value = "Light Oil";
	CalculateOil("400","60","1.00",0)
	document.all.idSteam4.style.display = "none";
	document.all.IdCompareAlternateBoiler.style.display = "none";
  }
  else 
  {
	window.frmboilerstream.cbogastype.value = "Natural Gas";
	CalculateGas("400","60","1.00",0)  
	document.all.idSteam4.style.display = "none";
	document.all.IdCompareAlternateBoiler.style.display = "none";
  }	
}

function clearValues()
{
	window.frmboilerstream.rdounits(0).click();
	window.frmboilerstream.rdoFueltypeselected(0).click();
	window.frmboilerstream.txtBoilerOutput.value = "400";
	window.frmboilerstream.txtBoilerEfficiency.value  = "60";
	window.frmboilerstream.cboOiltype.value = "Light Oil";
	window.frmboilerstream.txtFuelCost.value = "1.00";
	window.frmboilerstream.txtAnnualhours.value = "";
	
}

function getValues() 
{
	var minIE4 = (navigator.appName.indexOf("Microsoft") >= 0 &&    parseInt(navigator.appVersion) >= 4)
	var arrQueryResults = new Array();
			
	if (minIE4) 
	{
	// Unescape and strip away leading question mark.
			
		var iQueryString = unescape(location.search.substring(1))
												
		if (iQueryString)
		{
			// Divide long string into array of name/value pairs.
			 var arrQueryResultsSplit = iQueryString.split("&")
			 var arrResult = new Array();
			 		
			 var iCount = 0;				
			 for(var iCntr = 0; iCntr < arrQueryResultsSplit.length; iCntr++) 
			 {	
				// Divide each name/value pair temporarily into a two-entry array.
				arrTempResultArray = arrQueryResultsSplit[iCntr].split("=")
				arrResult[iCount] = arrTempResultArray[1];	
				iCount++;
			 }
			 return arrResult;		
		}
	}
}
/*--------------------------------------------------------------------------------------------------*/
function window_onLoad()
{
	var arrValues = new Array();
	arrValues = getValues();
	
	document.all.idsteamoutputheader.innerText = arrValues[0];
	document.all.idsteamMaxoutputheader.innerText = arrValues[1];
	document.all.idsteamCostoutputheader.innerText = arrValues[2];
	document.all.idMaxBurnRateoutputheader.innerText = arrValues[3];
	
	document.all.idSelectedUnits.innerText = arrValues[4];
	document.all.idFuelType.innerText = arrValues[5];
	document.all.idBoilerOutput.innerText = arrValues[7];
	document.all.idBoilerEfficiency.innerText = arrValues[8];
	
	if(arrValues[6] == 'Heavy Oil' || arrValues[6] == 'Light Oil')
	{
		document.all.idOilGradeText.innerText = "Oil Grade";
	}
	else
	{
		document.all.idOilGradeText.innerText = "Type Of Gas";
	}
		
	document.all.idOilGrade.innerText = arrValues[6];
    document.all.idFuelCosts.innerText = arrValues[10];
    document.all.idFuelCostgaltherm.innerText = arrValues[9];
  	document.all.idAnnualHoursRun.innerText = arrValues[11];
    document.all.idFrom.innerText =arrValues[12]
  	var temp = arrValues[13];
   	var iCnt= temp.indexOf(":");
  	test = temp.substring(0,iCnt + 1);
  	var restVal = temp.substring(iCnt + 1,temp.length);
   	if(temp!="")
  	{
  		document.all.idSteamCost.innerText = "Annual 'Steam Cost' is:" 
  	}
  	document.all.idSteamCost1.innerText = restVal;
	document.all.idAlternateBoilerEfficiency.innerText = arrValues[14];
		
	if(arrValues[13] != "")
	{
		var temp1 = arrValues[15];
		var iCnt= temp1.indexOf(":");
  		test1 = temp1.substring(0,iCnt + 1);
  		var restVal2 = temp1.substring(iCnt + 1,temp1.length);
  		var negativeval = restVal2.indexOf("-");
  		
  		if(negativeval == 0 || restVal2==0)
  		 {
  			document.all.idSavingCleaver.innerText = "'Steam Cost' difference is:";
  			document.all.idSavingCleavers.innerHTML = "<span class='CostDisplayRed'>" + restVal2 + "/ year" + "</span>";
  		 }
  	    else
  		{
   			document.all.idSavingCleaver.innerText = "'Steam Cost' difference is:";
  			document.all.idSavingCleavers.innerHTML = "<span class='CostDisplay'>" + restVal2 + "/ year" + "</span>";
  		}
  
  		
  		document.all.idSteamOutput.innerText = arrValues[16];
		document.all.idMaxOutput.innerText = arrValues[17];
		document.all.idsteamcost.innerText = arrValues[18];
		document.all.idMaxBurnRate.innerText = arrValues[19];
	}else
	{	

		document.all.idSteamOutput.innerText = arrValues[16];
		document.all.idMaxOutput.innerText = arrValues[17];
		document.all.idsteamcost.innerText = arrValues[18];
		document.all.idMaxBurnRate.innerText = arrValues[19];
	}
	
	arrValues = new Array();
}

/*------------------------------------------------------------------------------------*/ 
// sets the window size of BoilerSteamCost.hta
function windowSize()
	{
		window.resizeTo(200,300);
	}

/*------------------------------------------------------------------------------------*/ 
var sDisplayText4Cost;
var chWindow;

function OpenWinPrintPreview()
{
   	var arrValues = new Array();
	var str = "?";
		
	if(document.frmboilerstream.rdounits(0).checked == true)
	{
			str = str + "hId0=Steam Output lbs/hr"+"&";
			str = str + "hId1=Max Output Btu/hr"+"&";
			
			if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
			{
				str = str + "hId2=Steam cost /1000 lbs"+"&";
			}
			else
			{
				str = str + "hId2=Steam cost /1000 lbs"+"&";
			}
				
			if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
			{
				str = str + "hId3=Max Oil burning rate Gal/hr"+"&";
			}
			else
			{
				str = str + "hId3=Max Gas burning rate therm/hr"+"&";
			}	
	}
	else
	{
			str = str + "hId0=Steam Output Kg/hr"+"&";
			str = str + "hId1=Max Output Kg cal/hr"+"&";
			if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
			{
				str = str + "hId2=Steam Cost /1000 kgs"+"&";
			}
			else
			{
				str = str + "hId2=Steam Cost /1000 Kgs"+"&";
			}
				
			if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
			{
				str = str + "hId3=Max Oil burning rate lts/hr"+"&";
			}
			else
			{
				str = str + "hId3=Max Gas burning rate cu m/hr"+"&";
			}	
	}
	
	if(document.frmboilerstream.rdounits(0).checked == true)
	{
		arrValues[0] = "Standard";
	}
	else
	{
		arrValues[0] = "Metric";
	}
	
	str = str +"hId4="+arrValues[0]+"&";
	
	if(document.frmboilerstream.rdoFueltypeselected(0).checked == true)
	{
		str = str +"hId5=Oil"+"&";
		str = str +"hId6="+document.frmboilerstream.cboOiltype.value+"&";
	}
	else
	{
		str = str +"hId5=Gas"+"&";
		str = str +"hId6="+document.frmboilerstream.cbogastype.value+"&";
	}
	
	str = str + "hId7="+document.frmboilerstream.txtBoilerOutput.value+"&";
			
	str = str + "hId8="+document.frmboilerstream.txtBoilerEfficiency.value+"&";
	
	if(document.frmboilerstream.rdoFueltypeselected(0).checked && document.frmboilerstream.rdounits(0).checked)
	{
		str = str + "hId9 =Oil Cost/gal (US $)"+"&";
		str = str +"hId10="+document.frmboilerstream.txtFuelCost.value+"&";
	}
	else if(document.frmboilerstream.rdoFueltypeselected(1).checked && document.frmboilerstream.rdounits(0).checked)
	{
		str = str + "hId9 =Gas Cost/therm (US $)"+"&";
		str = str +"hId10="+document.frmboilerstream.txtFuelCost.value+"&";
	}
	else if(document.frmboilerstream.rdoFueltypeselected(0).checked && document.frmboilerstream.rdounits(1).checked)
	
	{
	   str = str + "hId9 =Oil Cost/lt (US $)"+"&";
	  str = str +"hId10="+document.frmboilerstream.txtFuelCost.value+"&";
	 
	}
	else if(document.frmboilerstream.rdoFueltypeselected(1).checked && document.frmboilerstream.rdounits(1).checked)
	
	{
	  str = str + "hId9 =Gas Cost/cu m (US $)"+"&";
	  str = str +"hId10="+document.frmboilerstream.txtFuelCost.value+"&";
	}
	
	str = str + "hId11="+document.frmboilerstream.txtAnnualhours.value+"&";
	
	if(document.frmboilerstream.rdoFueltypeselected(0).checked && document.frmboilerstream.rdounits(0).checked)	
   	{	
   		str = str + "hid12=From and @ 212 °F"+"&";
   	}
	
   else if(document.frmboilerstream.rdoFueltypeselected(1).checked && document.frmboilerstream.rdounits(0).checked)	
   	
	{   
		str = str + "hid12=From and @ 212 °F"+"&";

	}
	else if(document.frmboilerstream.rdoFueltypeselected(0).checked && document.frmboilerstream.rdounits(1).checked)	
   	{	
   		
		str = str + "hid12=From and @ 100 °C"+"&";
   	}
	
   else if(document.frmboilerstream.rdoFueltypeselected(1).checked && document.frmboilerstream.rdounits(1).checked)	
   	
	{   
		str = str + "hid12=From and @ 100 °C"+"&";

	}
	
	if(document.all.idSteam4.style.display == "")	
 		{
 		str = str + "hId13="+document.all.idCostTD.innerText+"&";
 		}
 	else
 	 {
 	 	str = str + "hId13="+"&";
 	 }
 	 if(document.all.IdAlternateBoiler.style.display == "")
 	 {
 	 			
		str = str +"hId14="+document.frmboilerstream.txtAltBoilerEff.value+"&";
	 }
	else
	{
	   str= str +"hId14="+"&";	 
	}	
		
	if(document.all.IdAlternateBoiler.style.display == "")
	{
		str = str + "hId15="+document.frmboilerstream.hCompareValue.value+"&"; 

	}		
	else
	{
		str = str + "hId15="+"&";
	}
	if(document.all.idSteam1.style.display=="")
	{
		str = str + "hId16="+document.all.idlblsteamoutput.innerText+"&";
		str = str + "hId17="+document.all.idlblmaxoutput.innerText+"&";
	}
	else
	{
		str = str + "hId16="+"&";
		str = str + "hId17="+"&";
	}
	
	if(document.all.idSteam3.style.display=="")
	{
	    str = str + "hId18="+document.all.idperlbs.innerText+"&";
	    str = str + "hId19="+document.all.idlblmaxburnrate.innerText;
    }
	else
	{
		str = str + "hId18="+"&";
	    str = str + "hId19=";
	}
	
	
	var strURL = "EtoolPrintPreview.html" + str;
	chWindow = window.open(strURL,true,'toolbar=no,menubar=no,statusbar=no,width=420,height=600,left=200,top=140')
}

function fndisplaystemdiff()
{
	document.all.idSteamCostDiff.style.display="None";
}
/*------------------------------------------------------------------------------------------------*/
function cmdCompareclick()		//On click of Compare Button.
// compare boiler efficiency of alternate boiler with Oil with cleaver 
{
  	var StrFinalCost
   	var compVal 
	var sign = "";
  
	intBoileroutput = document.frmboilerstream.txtBoilerOutput.value
	intAlterBoilerEfficiency= document.frmboilerstream.txtAltBoilerEff.value
	intAnnualhourrun = document.frmboilerstream.txtAnnualhours.value
	intCostOfoil = document.frmboilerstream.txtFuelCost.value   

	if(IsEmpty(document.frmboilerstream.txtAltBoilerEff," Alternate Boiler Efficiency"))
	{
		document.frmboilerstream.txtAltBoilerEff.focus();
		return(false);
	}
	
	if(document.frmboilerstream.txtAltBoilerEff.value >= 100)
	{
		alert("Boiler Efficiency should be less than 100 %");
		document.frmboilerstream.txtAltBoilerEff.focus();  
		return false;
   }
    if(document.frmboilerstream.txtAltBoilerEff.value == 0)
	{
		alert("Boiler Efficiency should be Greater then 0 %");
		document.frmboilerstream.txtAltBoilerEff.focus();  
		return false;
	}
	if(isNaN(document.frmboilerstream.txtAltBoilerEff.value))
	{ 
		alert("Please enter an appropriate numeric value.");
		document.all.idSteamCostDiff.style.display="None"  
		document.frmboilerstream.txtAltBoilerEff.focus();
		return false;
	}
	
	document.all.idSteamCostDiff.style.display=""
	
   if(document.frmboilerstream.rdounits(0).checked == true)
   {
		if(window.frmboilerstream.rdoFueltypeselected(0).checked)
		{
			var OilGradeVal;
			OilGradeVal = document.frmboilerstream.cboOiltype.options[document.frmboilerstream.cboOiltype.selectedIndex].text
			if(OilGradeVal == "Light Oil")
			{
				IntOilGrade = 142000
						
			}
			if(OilGradeVal == "Heavy Oil")
			{
				IntOilGrade = 150000
			}
			//Apply formala and store the result in local variable.
			intMaxPdsteamPerHrs = intBoileroutput * 34.5
			intMaxOutputperhour = intBoileroutput * 33475
			intBoilerpercentage = intAlterBoilerEfficiency / 100
			intOilBurningRate	= ( intBoileroutput * 33472 )/ ( intBoilerpercentage * IntOilGrade);
			IntConvertInCuft = intOilBurningRate;
 			AnnualFuelCost = intOilBurningRate * intAnnualhourrun * intCostOfoil ;
			//Check for which Boiler is Perfered
					
			if ((AnnualFuelCost) >(OilAnnualFuelCost))
			{
				compVal =(AnnualFuelCost) - (OilAnnualFuelCost)
				sign = "+"	
						
			}
			else if(Math.round(AnnualFuelCost) < Math.round(OilAnnualFuelCost))
			{
				compVal = Math.round(OilAnnualFuelCost) -(AnnualFuelCost)
				sign = "-"
			}
			else
			{
				compVal = Math.round(OilAnnualFuelCost)- Math.round(AnnualFuelCost)
				sign = "";
			}
			// Display text
			InsertComma(compVal,sign);
			displayResult(IntPrintResult, "idVal", "Compare");
		}
		//Compare boiler efficiency of alternate boiler with gas with cleaver
		if(window.frmboilerstream.rdoFueltypeselected(1).checked)
		{
			//BoilerAvgoutput = intBoileroutput * (42/100)
			intPdofSteamperHr = intBoileroutput * 34.5 
			intMaxoutputBtuPerHr = intBoileroutput * 33475
			intBoilerpercentage = intAlterBoilerEfficiency /100
			intMaxGasburnRate  = intBoileroutput * 33472/intBoilerpercentage;
			intTherm = intMaxGasburnRate/100000			
			IntConvertInCuft = intTherm;
			AnnualFuelGascost = IntConvertInCuft * intAnnualhourrun * intCostOfoil
			if ((AnnualFuelGascost) >(GasAnnualFuelCost))
			{
				compVal =(AnnualFuelGascost) - (GasAnnualFuelCost)
				sign = "+"	
			}
			else if(Math.round(AnnualFuelGascost) < Math.round(GasAnnualFuelCost))
			{
				compVal = Math.round(GasAnnualFuelCost) -(AnnualFuelGascost)
				sign = "-"
			}
			else
			{
				compVal = Math.round(GasAnnualFuelCost)- Math.round(AnnualFuelGascost)
				sign = "";
			}
			// Display text
			InsertComma(compVal,sign);
			displayResult(IntPrintResult, "idVal", "Compare");
		}
	}
	else
	{
		if(window.frmboilerstream.rdoFueltypeselected(0).checked)
		  {
			var OilGradeVal;
			OilGradeVal = document.frmboilerstream.cboOiltype.options[document.frmboilerstream.cboOiltype.selectedIndex].text
			if(OilGradeVal == "Light Oil")
			{
				IntOilGrade = 9321
							
			}
			if(OilGradeVal == "Heavy Oil")
			{
				IntOilGrade = 9987
			}
			IntBHP = document.frmboilerstream.txtBoilerOutput.value;
			intBoilerEfficiency = document.frmboilerstream.txtBoilerEfficiency.value;
			IntStreamOutput = IntBHP * 15.6
			IntMaxOutput = (IntBHP * 8436);
			intBoilerpercentage = intAlterBoilerEfficiency / 100
			intOilBurningRate = (IntBHP * 8436)/(intBoilerpercentage * IntOilGrade);
			intAnnualhourrun = document.frmboilerstream.txtAnnualhours.value;
			intCostOfoil = document.frmboilerstream.txtFuelCost.value;
   			AnnualSteamCost = intOilBurningRate * intAnnualhourrun * intCostOfoil
   			FuelCost = (AnnualSteamCost)/(365*24)
			IntFinalresult = (1000 * FuelCost)/IntStreamOutput
			//Check for which Boiler is Perfered
			if ((AnnualSteamCost) >(OilAnnualFuelCost))
			{
				compVal =(AnnualSteamCost) - (OilAnnualFuelCost)
				sign = "+"	
						
			}
			else if(Math.round(AnnualSteamCost) < Math.round(OilAnnualFuelCost))
			{
				compVal = Math.round(OilAnnualFuelCost) -(AnnualSteamCost)
				sign = "-"
			}
			else
			{
				compVal = Math.round(OilAnnualFuelCost)- Math.round(AnnualSteamCost)
				sign = "";
			}
			// Display text
			InsertComma(compVal,sign);
			displayResult(IntPrintResult, "idVal", "Compare");
		}
		//Compare boiler efficiency of alternate boiler with gas with cleaver
		if(window.frmboilerstream.rdoFueltypeselected(1).checked)
		{
			IntBHP = document.frmboilerstream.txtBoilerOutput.value;
			IntStreamOutput = IntBHP * 15.6;
			IntMaxOutput = (IntBHP * 8436);
			intBoilerpercentage = intAlterBoilerEfficiency/100
			intMaxGasburnRate  = (IntBHP * 8436) /intBoilerpercentage
			intTherm = intMaxGasburnRate/8898		
			intAnnualhourrun = document.frmboilerstream.txtAnnualhours.value;
			intCostOfoil = document.frmboilerstream.txtFuelCost.value;
			AnnualSteamCost = intTherm * intAnnualhourrun * intCostOfoil
			FuelCost = (AnnualSteamCost)/(365*24)
			IntFinalresult = (1000 * FuelCost)/IntStreamOutput
			 
	     	if(Math.round(AnnualSteamCost) >Math.round(GasAnnualFuelCost))
			{
				compVal =(AnnualSteamCost) -(GasAnnualFuelCost)
			    sign = "+"
			}
			else if((AnnualSteamCost) < (GasAnnualFuelCost))
			{
				compVal = Math.round(GasAnnualFuelCost) - Math.round(AnnualSteamCost)
				sign = "-"
			}
			else
			{
				compVal = (GasAnnualFuelCost)- (AnnualSteamCost)
				sign = "";
			}
			// Display text
			InsertComma(compVal,sign)
			displayResult(IntPrintResult, "idVal", "Compare"); 
		}
	}	
}	  
 
/*--------------------------------------------------------------------------------*/	
  //Global Variable Declaration
	
  var intMaxOilBurnMetric
  var GasAnnualFuelCost
  var OilAnnualFuelCost
  var intBoileroutput
  var intBoilerEfficiency
  var intAnnualhourrun
  var strGasType
  var intCostOfoil
  var intMaxPdsteamPerHrs
  var intMaxOutputperhour
  var intOilBurningRate
  var intBoilerpercentage
  var intAverageRating 
  var intAnnualhourrun
  var intCostOfgas
  var BoilerAvgoutput 
  var intPdofSteamperHr
  var intMaxoutputBtuPerHr
  var intMaxGasburnRate
  var intTherm
  var AnnualFuelCost
  var AnnualFuelGascost
  var IntOilGrade
  
function CalculateOil(piBoilerOutput,piBoilerEfficiency,piBoilerCost,piAnnualHours)
{	
	
	  //Get values and store it in localVariable
		var OilGradeVal;

		document.frmboilerstream.txtAltBoilerEff.value="";				
		intBoileroutput = piBoilerOutput;
		if((piBoilerOutput <=4 ||piBoilerOutput>2000)) 	
		{
		 	document.all['idSteam4'].style.display="None";
		 	alert("Boiler Output should be between 5 and 2000");
		 	document.frmboilerstream.txtBoilerOutput.focus();
		 	document.frmboilerstream.txtBoilerOutput.select();
		 	return;
		}
		intBoilerEfficiency = piBoilerEfficiency;
		if((piBoilerEfficiency <60 ||piBoilerEfficiency>99)) 	
		{
			document.all['idSteam4'].style.display="None";
			document.all['IdCompareAlternateBoiler'].style.display="None";
			document.all.IdAlternateBoiler.style.display="None";
			document.all.idSteamCostDiff.style.display="None";
			alert("Boiler Efficiency should be between 60% and 99%");
			document.frmboilerstream.txtBoilerEfficiency.focus();
			document.frmboilerstream.txtBoilerEfficiency.select();
			return;
		}		
		intAnnualhourrun = piAnnualHours;
		intCostOfoil = piBoilerCost;
		if (piBoilerCost > 10.00)
		{
		 	alert (" The 'Fuel Cost' can not exceed $10.00. ");
		 	document.frmboilerstream.txtFuelCost.focus();
		 	return;
		}
		OilGradeVal = document.frmboilerstream.cboOiltype.options[document.frmboilerstream.cboOiltype.selectedIndex].text
		if(document.frmboilerstream.rdounits(0).checked == true)
		{
			if(OilGradeVal == "Light Oil")
			{
				IntOilGrade = 142000
										
			}
			if(OilGradeVal == "Heavy Oil")
			{
				IntOilGrade = 150000
			} 
			//Apply formala and store the result in local variable.
			IntBHP = piBoilerOutput;
			intBoilerEfficiency = piBoilerEfficiency;
			IntStreamOutput = IntBHP * 34.5;
			InsertComma(IntStreamOutput,"")
			document.all.idlblsteamoutput.innerText = IntPrintResult + " lbs/hr";
			IntMaxOutput = (IntBHP * 33475);
			InsertComma(IntMaxOutput,"")
			document.all.idlblmaxoutput.innerText = IntPrintResult + " Btu/hr ";
			intBoilerpercentage = intBoilerEfficiency / 100
			intOilBurningRate = (IntBHP * 33472)/(intBoilerpercentage * IntOilGrade);
			IntConvertInCuft = intOilBurningRate
			InsertComma(IntConvertInCuft,"")
   			document.all.idlblmaxburnrate.innerText = IntPrintResult + " Gal/hr ";
   			
   			intMaxOilBurnRate = IntPrintResult
   			
   			intAnnualhourrun = piAnnualHours;
			intCostOfoil = piBoilerCost;
   			OilAnnualFuelCost = intOilBurningRate * intAnnualhourrun * intCostOfoil
   			InsertComma(OilAnnualFuelCost,"")
   			displayResult(IntPrintResult, "idCostTD", "Cost")
   			FuelCost = (OilAnnualFuelCost)/(365*24)
		    var a = (1000 * intMaxOilBurnRate)
		    var b = parseFloat(intCostOfoil)
		    var c = parseInt(IntStreamOutput)
		    IntFinalresult = (a * b)/c
			//IntFinalresult = (1000 * intMaxOilBurnRate * intCostOfoil)/IntStreamOutput
			InsertComma(IntFinalresult,"")
			document.all.idperlbs.innerText = "$" + IntPrintResult + "/1000 lbs of steam";
			window.IdCompareAlternateBoiler.style.display = "";
		}
		else
		{
			if(OilGradeVal == "Light Oil")
			{
				IntOilGrade = 9321
							
			}
			if(OilGradeVal == "Heavy Oil")
			{
				IntOilGrade = 9987
			} 
			 //Apply formala and store the result in local variable.
			IntBHP = piBoilerOutput;
			intBoilerEfficiency = piBoilerEfficiency;
			IntStreamOutput = IntBHP * 15.6;
			InsertComma(IntStreamOutput,"")
			document.all.idlblsteamoutput.innerText = IntPrintResult + " Kg/hr";
			IntMaxOutput = (IntBHP * 8436);
			InsertComma(IntMaxOutput,"")
			document.all.idlblmaxoutput.innerText = IntPrintResult + " Kg cal/hr";
			intBoilerpercentage = intBoilerEfficiency / 100
			intOilBurningRate = (IntBHP * 8436)/(intBoilerpercentage * IntOilGrade);
			IntConvertInCuft = intOilBurningRate
			InsertComma(IntConvertInCuft,"")
   			document.all.idlblmaxburnrate.innerText = IntPrintResult + " lts/hr";
			intAnnualhourrun = piAnnualHours;
			intCostOfoil = piBoilerCost;
   			OilAnnualFuelCost = intOilBurningRate * intAnnualhourrun * intCostOfoil
   			InsertComma(OilAnnualFuelCost,"")
   			displayResult(IntPrintResult, "idCostTD", "Cost")
   			FuelCost = (OilAnnualFuelCost)/(365*24)
   			
   			var a = parseInt(1000 * intOilBurningRate)
   			var b = parseFloat(intCostOfoil)
   			var c = parseInt(IntStreamOutput)
   			
   			IntFinalresult = (a * b)/c
   
   			//IntFinalresult = (1000 * intMaxOilBurnMetric * intCostOfoil)/ IntStreamOutput
			
			InsertComma(IntFinalresult,"")
			document.all.idperlbs.innerText = "$" + IntPrintResult + "/1000 Kgs of steam";
			window.IdCompareAlternateBoiler.style.display = "";
	}	
}
/*-------------------------------------------------------------------------------------------*/	
function displayResult(piResult, psPlaceOfDisplay, psDisplayReference)
{
	var sDisplayText4Cost;
	//sDisplayText4Cost =  "The annual 'Steam Cost' is: $";
	sDisplayText4Cost =  "$";
	//var sDisplayText4Compare = "The 'Steam Cost' difference is:";
	var sDisplayText4Compare = "";
		
	//Display the calculated Result
	if(psDisplayReference == "Cost")
	{	
		costValue = sDisplayText4Cost + piResult;
		document.frmboilerstream.hCostValue.value = costValue;
		document.all(psPlaceOfDisplay).innerText = sDisplayText4Cost + piResult + "/ year";
	}
	else if(psDisplayReference == "Compare")
	{	
		compareCostValue = sDisplayText4Compare + piResult;
		document.frmboilerstream.hCompareValue.value = compareCostValue;
		if(piResult.indexOf("+") >= 0)
			document.all(psPlaceOfDisplay).innerHTML = "" + sDisplayText4Compare + piResult +"/ year";
		else
			document.all(psPlaceOfDisplay).innerHTML = "" + sDisplayText4Compare + "<font color=red>" + piResult + "/ year"  +"</font>";
			//document.all(psPlaceOfDisplay).innerHTML = "" + sDisplayText4Compare + piResult + "/ year";
	}
}
/*--------------------------------------------------------------------------------------------*/ 
function CalculateGas(piBoilerOutput,piBoilerEfficiency,piBoilerCost,piAnnualHours)
 {

	if((piBoilerOutput <=4 ||piBoilerOutput>2000)) 	
	{
		document.all['idSteam4'].style.display="None";
		alert("Boiler output should be between 5 and 2000");
		document.frmboilerstream.txtBoilerOutput.focus();
		document.frmboilerstream.txtBoilerOutput.select();
		return;
	}
	IntBHP = piBoilerOutput;
	intBoilerEfficiency= piBoilerEfficiency
	if((piBoilerEfficiency <60 ||piBoilerEfficiency>99)) 	
	{
		document.all['idSteam4'].style.display="None";
		document.all['IdCompareAlternateBoiler'].style.display="None";
		document.all.IdAlternateBoiler.style.display="None";
		document.all.idSteamCostDiff.style.display="None";
		alert("Boiler Efficiency should be between 60% and 99%");
		document.frmboilerstream.txtBoilerEfficiency.focus();
		document.frmboilerstream.txtBoilerEfficiency.select();
		return;
	}
	if (piBoilerEfficiency >= 100)
	{
		alert("Boiler Efficiency should be less than 100 %");
		document.frmboilerstream.txtBoilerEfficiency.focus();  
		return false;
	}
	intAnnualhourrun = piAnnualHours
	intCostOfoil = piBoilerCost
	if(document.frmboilerstream.rdounits(0).checked == true)
	{
		
		IntStreamOutput = IntBHP * 34.5;
		InsertComma(IntStreamOutput,"")
		document.all.idlblsteamoutput.innerText =  IntPrintResult + " lbs/hr";
		IntMaxOutput = (IntBHP * 33475);
		InsertComma(IntMaxOutput,"")
		document.all.idlblmaxoutput.innerText = IntPrintResult + " Btu/hr ";
		intBoilerpercentage = piBoilerEfficiency /100
		intMaxGasburnRate  = (IntBHP * 33472) /intBoilerpercentage
		intTherm = intMaxGasburnRate/100000			
		InsertComma(intTherm,"")
		document.all.idlblmaxburnrate.innerText = IntPrintResult + " therm/hr ";
		GasAnnualFuelCost = intTherm * intAnnualhourrun * intCostOfoil
		InsertComma(GasAnnualFuelCost,"")     
		displayResult(IntPrintResult, "idCostTD", "Cost")
		FuelCost = (GasAnnualFuelCost)/(365*24)
		IntFinalresult = (1000 * ( GasAnnualFuelCost / intAnnualhourrun)) / IntStreamOutput
		InsertComma(IntFinalresult,"")
		
		if(isNaN(IntPrintResult))
			IntPrintResult = 0;
		document.all.idperlbs.innerText = "$" + IntPrintResult + "/1000 lbs of steam";	
		window.IdCompareAlternateBoiler.style.display = "";
   }
   else
   {
		IntStreamOutput = IntBHP * 15.6;
		InsertComma(IntStreamOutput,"")
		document.all.idlblsteamoutput.innerText =  IntPrintResult + " Kg/hr";
		IntMaxOutput = (IntBHP * 8436);
		InsertComma(IntMaxOutput,"")
		document.all.idlblmaxoutput.innerText = IntPrintResult + " Kg cal/hr";
		intBoilerpercentage = piBoilerEfficiency /100
		intMaxGasburnRate  = (IntBHP * 8436) /intBoilerpercentage
		intTherm = intMaxGasburnRate/8898			
		InsertComma(intTherm,"")
		document.all.idlblmaxburnrate.innerText = IntPrintResult + " cu m/hr";
		intMaxGasBurningRate = IntPrintResult
		GasAnnualFuelCost = intTherm * intAnnualhourrun * intCostOfoil
		InsertComma(GasAnnualFuelCost,"")     
		displayResult(IntPrintResult, "idCostTD", "Cost")
		FuelCost = (GasAnnualFuelCost)/(365*24)
		var a = 1000 * parseInt(intTherm);
		var b = parseFloat(intCostOfoil);
		var c = parseInt(IntStreamOutput);
		IntFinalresult = (a * b)/c 
		if(IntFinalresult>100)
			{
				var intmore = IntFinalresult.toString();
				document.all.idperlbs.innerText = "$" + intmore.substring(0,5) + "/1000 Kgs of steam";
			}
		else
			{
				InsertComma(IntFinalresult,"")
				document.all.idperlbs.innerText = "$" + IntPrintResult + "/1000 Kgs of steam";
			}
	
   } 
}
/*------------------------------------------------------------------------------------*/ 
// Module level variables for the Timers.
	var midTimer1;
	var midTimer2;

//Code To validate fields and calculate the cost result
function cmdCalculateResult() //On click of calculate Button 
{ 
	if(Validator())
	{
		if((document.frmboilerstream.txtBoilerOutput.value <=4 ||document.frmboilerstream.txtBoilerOutput.value>2000)) 	
		{
			document.all['idSteam4'].style.display="None";
		}
		else
		{   
			document.all['idSteam1'].style.display="";
			document.all['idSteam3'].style.display="";
			document.all['idSteam4'].style.display="";
			document.all.IdCompareAlternateBoiler.style.display="";
		}   	
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
		{
			var iBoilerOutput = window.frmboilerstream.txtBoilerOutput.value;
			var iBoilerEfficiency = window.frmboilerstream.txtBoilerEfficiency.value;
			var iBoilerCost = window.frmboilerstream.txtFuelCost.value;
			var iAnnualHours = window.frmboilerstream.txtAnnualhours.value;
			CalculateOil(iBoilerOutput,iBoilerEfficiency,iBoilerCost,iAnnualHours)
		}
		else
		{
			var iBoilerOutput = window.frmboilerstream.txtBoilerOutput.value;
			var iBoilerEfficiency = window.frmboilerstream.txtBoilerEfficiency.value;
			var iBoilerCost = window.frmboilerstream.txtFuelCost.value;
			var iAnnualHours = window.frmboilerstream.txtAnnualhours.value;
			
			CalculateGas(iBoilerOutput,iBoilerEfficiency,iBoilerCost,iAnnualHours);
		}
	}
}
/*------------------------------------------------------------------------------------*/ 
//code which displays alternate boiler effeciency
function Show_AltBoilInfo()
{
	// Displays the Alternate Boiler comparison link 
	document.all['IdAlternateBoiler'].style.display="";
}
/*------------------------------------------------------------------------------------*/ 	
//Code which change to textbox to combo on click of Fuel type radio
function Onclick_DisableFueltype()
{	
	if(window.frmboilerstream.rdoFueltypeselected(0).checked)
	{
		if(document.frmboilerstream.rdounits(0).checked == true)
		{
			document.all.txtAnnualhours.value="";
			document.all.idSteam4.style.display="None";
			window.idfuelcostgal.style.display="";
			window.idfuelcosttherm.style.display="none";
			window.idfuelcostlt.style.display="none";
			window.idfuelcostcum.style.display="none";
		}
		else
		{
			document.all.txtAnnualhours.value="";
			document.all.idSteam4.style.display="None";
			window.idfuelcostgal.style.display="none";
			window.idfuelcosttherm.style.display="none";
			window.idfuelcostlt.style.display="";
			window.idfuelcostcum.style.display="none";
		}	
		window.idfuelOil.style.display = "";
		window.idfuelGas.style.display = "none";
	}
	else if(window.frmboilerstream.rdoFueltypeselected(1).checked)
	{
		if(document.frmboilerstream.rdounits(0).checked == true)
		{
			
			document.all.txtAnnualhours.value="";
			document.all.idSteam4.style.display="None";
			window.idfuelcostgal.style.display="none";
			window.idfuelcosttherm.style.display="";
			window.idfuelcostlt.style.display="none";
			window.idfuelcostcum.style.display="none";
		}
		else
		{
			document.all.txtAnnualhours.value="";
			document.all.idSteam4.style.display="None";
			window.idfuelcostgal.style.display="none";
			window.idfuelcosttherm.style.display="none";
			window.idfuelcostlt.style.display="none";
			window.idfuelcostcum.style.display="";
		}	
		window.idfuelOil.style.display = "none";
		window.idfuelGas.style.display = "";
	}
	CalcuateValuesDynamic();
}
/*------------------------------------------------------------------------------------*/ 	
//Code for click of Increment Decrement images.
function Decrement_imgonclick(pstrTextBox,pobjImage)
{
	document.images(pobjImage).src = "images/arrow_down_11-6.gif";

	switch (pstrTextBox)
	{
		case "txtBoilerOutput":
			iDecrementValue = 5;
		if((document.frmboilerstream.txtBoilerOutput.value)<=5) 	
		{
			alert("'Boiler output'  should be between 5 and 2000"); 
			document.frmboilerstream.txtBoilerOutput.focus();
			document.frmboilerstream.txtBoilerOutput.select();
			return;
		}
		CalcuateValuesDynamic();
		document.frmboilerstream(pstrTextBox).value = Number(document.frmboilerstream(pstrTextBox).value) - iDecrementValue;
		break;
			
		case "txtBoilerEfficiency":
		iDecrementValue = 1;
			
		if((document.frmboilerstream.txtBoilerEfficiency.value) <= 60)
		{
			alert("'Boiler Efficiency' should be  more than 60 % .");
			document.frmboilerstream.txtBoilerEfficiency.focus();
			document.frmboilerstream.txtBoilerEfficiency.select();
			return;
		}	
		document.frmboilerstream(pstrTextBox).value = Number(document.frmboilerstream(pstrTextBox).value) - iDecrementValue;
		CalcuateValuesDynamic();
		break;
			
				
		case "txtgrade":
			iDecrementValue = 1;
			document.frmboilerstream(pstrTextBox).value = Number(document.frmboilerstream(pstrTextBox).value) - iDecrementValue;
		break;
			
		case "txtFuelCost":
			fnDecrement(pstrTextBox);
			CalcuateValuesDynamic();
		break;
	}
	midTimer1 = setTimeout("Decrement_imgonclick('" + pstrTextBox + "', '" + pobjImage + "')",300);
}
/*------------------------------------------------------------------------------------*/ 
function killDecrementTimer(pobjImage)
{
	clearTimeout(midTimer1);
	
	document.images(pobjImage).src = "images/arrow_down_11-6.gif";
}
function killIncrementTimer(pobjImage)
{
	clearTimeout(midTimer1);
	document.images(pobjImage).src = "images/arrow_up_11-6.gif";
}
/*------------------------------------------------------------------------------------*/ 
function Increment_imgonclick(pstrTextBox,pobjImage)
{	
	document.images(pobjImage).src = "images/arrow_up_11-6.gif";
	var iIncrementValue;
	var dotIndex;
	var strTxtVal;
	var strTxtNewVal;
	switch (pstrTextBox)
	{
		case "txtBoilerOutput":
			iIncrementValue = 5;
		if((document.frmboilerstream.txtBoilerOutput.value)>=2000) 	
		{
			alert("'Boiler output' should be between 5 and 2000");
			document.frmboilerstream.txtBoilerOutput.focus();
			document.frmboilerstream.txtBoilerOutput.select();
			return;
		}		
		document.frmboilerstream(pstrTextBox).value = Number(document.frmboilerstream(pstrTextBox).value) + iIncrementValue;
		CalcuateValuesDynamic();
		break;

		case "txtBoilerEfficiency":
			iIncrementValue = 1;
		if((document.frmboilerstream.txtBoilerEfficiency.value) >= 99)
		{
			alert("You can not exceed a 'Boiler Efficiency' of more than 100 %.");
			document.frmboilerstream.txtBoilerEfficiency.focus();
			document.frmboilerstream.txtBoilerEfficiency.select();
			return;
		}
		document.frmboilerstream(pstrTextBox).value = Number(document.frmboilerstream(pstrTextBox).value) + iIncrementValue;
		CalcuateValuesDynamic();
		break;

		case "txtgrade":
			iIncrementValue = 1;
			document.frmboilerstream(pstrTextBox).value = Number(document.frmboilerstream(pstrTextBox).value) + iIncrementValue;
			
		break;
		
		case "txtFuelCost":
			
		if((document.frmboilerstream.txtFuelCost.value)>= 9.99)
		{
			alert("You can not exceed a 'Fuel Cost' of more than $10.00.");
			document.frmboilerstream.txtFuelCost.focus();
			document,frmboilerstream.txtFuelCost.select();
			return
		}
		fnIncrement(pstrTextBox);
		CalcuateValuesDynamic();	
		break;
	}
	midTimer2 = setTimeout("Increment_imgonclick('" + pstrTextBox + "', '" + pobjImage + "')",300);
}
/*------------------------------------------------------------------------------------*/ 
function fnIncrement(pstrTextBox)
{
	var strValue;
	var indexOfDot;
	var firstValue,secondValue,incrValue,newValue;
	
	strValue = document.frmboilerstream(pstrTextBox).value;
	indexOfDot = strValue.indexOf(".");
	if(indexOfDot < 0)
	{
		indexOfDot = 1;
	}
	
	firstValue = strValue.substr(0,indexOfDot);
	secondValue = strValue.substr(indexOfDot,4);
	if(secondValue.length == 0)
	{
		secondValue = ".00";
	}
	incrValue = parseFloat(secondValue) + .01;
	newValue = parseFloat(firstValue) + incrValue;
	
	fnConvert(newValue,pstrTextBox);
}
/*------------------------------------------------------------------------------------*/ 
function fnConvert(newValue,pstrTextBox)
{
	var indexOfDot;
	var firstValue;
	var secondValue;
	var secondDigit;
	var thirdDigit;
	
	newValue = newValue.toString();
	indexOfDot = newValue.indexOf(".");
	firstValue = newValue.substr(0,indexOfDot);
	secondValue = newValue.substr(indexOfDot);
	if(secondValue.length > 3)
	{
		thirdDigit = secondValue.substr(3,1);
		switch(thirdDigit)                           
		{   
			case '0' :
			secondDigit = secondValue.substr(2,1);
			break;
			case '9' :
			secondDigit = parseInt(secondValue.substr(2,1)) + parseInt(1);
			break;
		}	
		newDecimal = newValue.substr(indexOfDot,2) + secondDigit;	
		newValue = firstValue  + newDecimal;
	}
	
	if(indexOfDot > 0)
	{
		document.frmboilerstream(pstrTextBox).value = newValue;
	}
	else
	{
		document.frmboilerstream(pstrTextBox).value = newValue + ".00";
	}	
}
/*------------------------------------------------------------------------------------*/ 

function fnDecrement(pstrTextBox)
{
	var strValue;
	var indexOfDot;
	var firstValue,secondValue,incrValue,newValue;
	
	strValue = document.frmboilerstream(pstrTextBox).value;
	indexOfDot = strValue.indexOf(".");
	if(indexOfDot < 0)
	{
		indexOfDot = 1;
	}
	
	firstValue = strValue.substr(0,indexOfDot);
	secondValue = strValue.substr(indexOfDot,4);
	if(secondValue.length == 0)
	{
		secondValue = ".00";
	}
	incrValue = parseFloat(secondValue) - .01;
	newValue = parseFloat(firstValue) + incrValue;
	
	fnConvert(newValue,pstrTextBox);
}
/*------------------------------------------------------------------------------------*/ 
function killIncrementTimer(pobjImage)
{
	clearTimeout(midTimer2);
	document.images(pobjImage).src = "images/arrow_up_11-6.gif";
}	
/*------------------------------------------------------------------------------------*/ 
//Code To switch the tab	
function onRadioClick(sText)
{
	var src,img
	
	if(sText == 'Standard') 
	{
		document.all.txtAnnualhours.value="";
		document.all.idSteam4.style.display="None";
		document.all.idStdBhp.style.display="";
		document.all.idMtrBhp.style.display="None";
		document.all.StandardUnitsHeader1.style.display="";
		document.all.MetricUnitsHeader1.style.display="None";
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true) 
		{
			document.all.StandardUnitsOil.style.display="";
			document.all.MetricUnitsOil.style.display="None";
			document.all.StandardUnitsGas.style.display="None";
			document.all.MetricUnitsGas.style.display="None";			
		}
		else
		{
			document.all.StandardUnitsGas.style.display="";
			document.all.MetricUnitsGas.style.display="None";
			document.all.StandardUnitsOil.style.display="None";
			document.all.MetricUnitsOil.style.display="None";
		}
		
		src = document.all.ImgEC.src
		img = src.indexOf("efficiency_cal_on_131_18.gif")
		
		if(img > 0)
		{
			IdCCStd.style.display=""
			IdCCMetric.style.display="none"
			IdECMetric.style.display="none"
			idMainControls.style.display="none"
			IdECStd.style.display=""
		}
	}
	if(sText == 'Metric')
	{
		document.all.txtAnnualhours.value="";
		document.all.idSteam4.style.display="None";
		document.all.idStdBhp.style.display="None";
		document.all.idMtrBhp.style.display="";
		document.all.StandardUnitsHeader1.style.display="None";
		document.all.MetricUnitsHeader1.style.display="";
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true) 
		{
			document.all.StandardUnitsOil.style.display="None";
			document.all.MetricUnitsOil.style.display="";
			document.all.StandardUnitsGas.style.display="None";
			document.all.MetricUnitsGas.style.display="None";
		}
		else
		{
			document.all.StandardUnitsGas.style.display="None";
			document.all.MetricUnitsGas.style.display="";
			document.all.StandardUnitsOil.style.display="None";
			document.all.MetricUnitsOil.style.display="None";
		}	
		src = document.all.ImgEC.src
		img = src.indexOf("efficiency_cal_on_131_18.gif")
		
		if(img > 0)
		{
			IdCCStd.style.display="none"
			IdCCMetric.style.display=""
			IdECMetric.style.display=""
			idMainControls.style.display="none"
			IdECStd.style.display="none"
		}
	}
	CalcuateValuesDynamic();
}
/*------------------------------------------------------------------------------------*/ 
function onImgClick(pId)
{
	var src,img,imgEc
	
	if(pId == "ImgEC")
	{
		//document.frmboilerstream.rdounits(1).disabled = false;
		src = document.all[pId].src
		img = src.indexOf("efficiency_cal_off_131_18.gif")

		if(img > 0)
		{
			document.all[pId].src = "Images/efficiency_cal_on_131_18.gif"
			document.all.ImgCC.src = "Images/cost_cal_off_99-18.gif"
			if(window.frmboilerstream.rdounits(1).checked == true)
			{

				document.all.IdCCStd.style.display="none"
				document.all.IdCCMetric.style.display=""
				document.all.IdECMetric.style.display=""
				document.all.IdECStd.style.display="None"
				idMainControls.style.display="none"
			}
			else if(window.frmboilerstream.rdounits(0).checked == true)
			{	
				document.all.IdCCStd.style.display=""
				document.all.IdECMetric.style.display="none"
				document.all.IdECStd.style.display=""
				idMainControls.style.display="none"
			}
		}		
	}
	else if(pId == "ImgCC")
	{
		src = document.all[pId].src
		img = src.indexOf("cost_cal_off_99-18.gif")
		//document.frmboilerstream.rdounits(1).disabled=true;
		document.frmboilerstream.rdounits(0).checked=true;
		if(img > 0)
		{
			document.all[pId].src = "Images/cost_cal_on_99-18.gif"
			document.all.ImgEC.src = "Images/efficiency_cal_off_131_18.gif"
			if(window.frmboilerstream.rdounits(1).checked == true)
			{
				document.all.IdCCStd.style.display="none"
				document.all.IdCCMetric.style.display="none"
				document.all.IdECMetric.style.display="none"
				document.all.IdECStd.style.display="none"
				idMainControls.style.display=""
			}
			else if(window.frmboilerstream.rdounits(0).checked == true)
			{
				document.all.IdCCStd.style.display="none"
				document.all.IdCCMetric.style.display="none"
				document.all.IdECMetric.style.display="none"
				document.all.IdECStd.style.display="none"
				idMainControls.style.display=""
			}
		}
	}
}
/*------------------------------------------------------------------------------------*/ 
function Onclick_SaveAsExcel()
{
	document.frmboilerstream.hAction.value="SaveAsExcel";
	document.frmboilerstream.submit();
}
/*------------------------------------------------------------------------------------*/ 
//Global Variable Declarations

var sString 
var sStringLen 
var sStringLenFound
var sStringRev
var inti
var insretedVal;
function InsertComma(ParamResult,sign)   
{
	var IntResult
 
	IntResult = ParamResult;
	sString = IntResult.toString()
	  
	var indexOfDot
	indexOfDot = sString.indexOf(".");
	if(indexOfDot>0)
	{
		temp = sString.substring(0,indexOfDot+3);
		string1 = temp.substring(0,indexOfDot);
		  
		string2 = temp.substring(indexOfDot+1,indexOfDot+3);
		sStringLenFound = string1.length;
		if(sStringLenFound > 3)
		{
			lastIndex = sStringLenFound - 1;
			firstIndex = 2;
			while(firstIndex < lastIndex)
			{
				noOfChars = lastIndex - firstIndex
				firstSubString = string1.substring(0, noOfChars);
				string1 = firstSubString + "," + string1.substring(noOfChars, sStringLenFound+1);
				sStringFoundLen = string1.length;
				lastIndex = string1.indexOf(",") - 1;
			}
		} 
		IntPrintResult = string1 + "." +string2
		insretedVal = string1 + "." +string2;
	}
	else
	{
		sStringLenFound = sString.length;
		if(sStringLenFound > 3)
		{
			lastIndex = sStringLenFound - 1;
			firstIndex = 2;
			while(firstIndex < lastIndex)
			{
				noOfChars = lastIndex - firstIndex
				firstSubString = sString.substring(0, noOfChars);
				sString = firstSubString + "," + sString.substring(noOfChars, sStringLenFound+1);
				sStringFoundLen = sString.length;
				lastIndex = sString.indexOf(",") - 1;
			}
		} 
		IntPrintResult = sString
		insretedVal = sString
	}
	if(sign != "")
		IntPrintResult = sign + "$" + IntPrintResult;		  
}
 
/*------------------------------------------------------------------------------------*/ 
function OpenWin_boilerCostCalculator()
{
	document.frmboilerstream.txtAltBoilerEff.value="";
	document.frmboilerstream.txtAnnualhours.focus();
	document.frmboilerstream.rdounits(0).checked = true;
	document.frmboilerstream.rdoFueltypeselected(0).checked = true;
	if (window.frmboilerstream.rdounits(0).checked == true)
	{
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
			{
				document.all.StandardUnitsOil.style.display="";
				document.all.MetricUnitsOil.style.display="None";
				document.all.StandardUnitsGas.style.display="None";
				document.all.MetricUnitsGas.style.display="None";
				window.idfuelcostgal.style.display="";
				window.idfuelcosttherm.style.display="none";
				window.idfuelcostlt.style.display="none";
				window.idfuelcostcum.style.display="none";
			}
			else
			{	
				document.all.StandardUnitsGas.style.display="";
				document.all.MetricUnitsGas.style.display="None";
				document.all.StandardUnitsOil.style.display="None";
				document.all.MetricUnitsOil.style.display="None";
				window.idfuelcostgal.style.display="none";
				window.idfuelcosttherm.style.display="";
				window.idfuelcostlt.style.display="none";
				window.idfuelcostcum.style.display="none";
			}
	}
	else
	{
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
			{
				document.all.StandardUnitsOil.style.display="None";
				document.all.MetricUnitsOil.style.display="";
				document.all.StandardUnitsGas.style.display="None";
				document.all.MetricUnitsGas.style.display="None";
				window.idfuelcostgal.style.display="none";
				window.idfuelcosttherm.style.display="none";
				window.idfuelcostlt.style.display="";
				window.idfuelcostcum.style.display="none";
			}
			else
			{	
				document.all.StandardUnitsGas.style.display="None";
				document.all.MetricUnitsGas.style.display="";
				document.all.StandardUnitsOil.style.display="None";
				document.all.MetricUnitsOil.style.display="None";
				window.idfuelcostgal.style.display="none";
				window.idfuelcosttherm.style.display="none";
				window.idfuelcostlt.style.display="none";
				window.idfuelcostcum.style.display="";
			}
	}		
	CalcuateValuesDynamic();
}
/*------------------------------------------------------------------------------------*/ 
function fnMetric()
{
	if(window.idMetric.click)
	{
		idStdBhp.style.display="None";
		idMtrBhp.style.display="";
		
		document.all.StandardUnitsHeader1.style.display="None";
		document.all.MetricUnitsHeader1.style.display="";
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
		{
			document.all.StandardUnitsOil.style.display="None";
			document.all.MetricUnitsOil.style.display="";
			document.all.StandardUnitsGas.style.display="None";
			document.all.MetricUnitsGas.style.display="None";
		}
		else
		{
			document.all.StandardUnitsGas.style.display="None";
			document.all.MetricUnitsGas.style.display="";
			document.all.StandardUnitsOil.style.display="None";
			document.all.MetricUnitsOil.style.display="None";
		}
		window.frmboilerstream.rdounits(1).checked = true;
		window.frmboilerstream.rdounits(0).checked = false;
	}
	CalcuateValuesDynamic();
}
/*------------------------------------------------------------------------------------*/ 
function fnStandard()
{
	if(window.idstandard.click)
	{
		idStdBhp.style.display="";
		idMtrBhp.style.display="None";
		
		document.all.StandardUnitsHeader1.style.display="";
		document.all.MetricUnitsHeader1.style.display="None";
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
		{
			document.all.StandardUnitsOil.style.display="";
			document.all.MetricUnitsOil.style.display="None";
			document.all.StandardUnitsGas.style.display="None";
			document.all.MetricUnitsGas.style.display="None";
		}
		else
		{	
			document.all.StandardUnitsGas.style.display="";
			document.all.MetricUnitsGas.style.display="None";
			document.all.StandardUnitsOil.style.display="None";
			document.all.MetricUnitsOil.style.display="None";
		}
		window.frmboilerstream.rdounits(0).checked = true;
		window.frmboilerstream.rdounits(1).checked = false;
		
	 }
	 CalcuateValuesDynamic();
}
/*------------------------------------------------------------------------------------*/ 

//Open contact window
function win_ContactInformationOpen()
{
	window.open("ContactInformation.html",true,'menubar=no,toolbar=no,statusbar=no,scrollbars=yes,resize=yes,height=500, width=500 top=20 left=200')
  
}
//Open help window
function win_questionOpen()
{
	window.open("HelpInformation.html",true,'menubar=no,toolbar=no,statusbar=no,scrollbars=yes,resize=yes, height=500, width=500 top=20 left=200')
}

//Global Variable Declaration.
/*------------------------------------------------------------------------------------*/ 		
var IntBHP
var IntStreamOutput
var IntMaxOutput 
var IntSteamCostPerLbs
var psDisplayReference
var IntConvertInCuft

function fnHideValues()
{
	document.all['idSteam4'].style.display="None";
	document.all['IdCompareAlternateBoiler'].style.display="None";
	document.all.IdAlternateBoiler.style.display="None";
	document.all.idSteamCostDiff.style.display="None";
	if(document.frmboilerstream.rdounits(0).checked == true &&  window.frmboilerstream.rdoFueltypeselected(1).checked == true)
	{
		document.all.idperlbs.innerText = "$" + 0 + "/1000 Kgs of steam";
	}	
}	

function check4Cond(pObj)
{
	if(pObj.value >2000)
		{
			alert("Boiler Output cannot exceed more than 2000");
			
		}
	else
		{
			CalcuateValuesDynamic()
		}	
}

function CalcuateValuesDynamic()
{
		
	document.all['idSteam4'].style.display="None";
	document.all['IdCompareAlternateBoiler'].style.display="None";
	document.all.IdAlternateBoiler.style.display="None";
	document.all.idSteamCostDiff.style.display="None";
	if (window.frmboilerstream.rdounits(0).checked == true)
	{
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
			{
				document.all.StandardUnitsOil.style.display="";
				document.all.MetricUnitsOil.style.display="None";
				document.all.StandardUnitsGas.style.display="None";
				document.all.MetricUnitsGas.style.display="None";
				window.idfuelcostgal.style.display="";
				window.idfuelcosttherm.style.display="none";
				window.idfuelcostlt.style.display="none";
				window.idfuelcostcum.style.display="none";
			}
			else
			{	
				document.all.StandardUnitsGas.style.display="";
				document.all.MetricUnitsGas.style.display="None";
				document.all.StandardUnitsOil.style.display="None";
				document.all.MetricUnitsOil.style.display="None";
				window.idfuelcostgal.style.display="none";
				window.idfuelcosttherm.style.display="";
				window.idfuelcostlt.style.display="none";
				window.idfuelcostcum.style.display="none";
			}
	}
	else
	{
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
			{
				document.all.StandardUnitsOil.style.display="None";
				document.all.MetricUnitsOil.style.display="";
				document.all.StandardUnitsGas.style.display="None";
				document.all.MetricUnitsGas.style.display="None";
				window.idfuelcostgal.style.display="none";
				window.idfuelcosttherm.style.display="none";
				window.idfuelcostlt.style.display="";
				window.idfuelcostcum.style.display="none";
			}
			else
			{	
				document.all.StandardUnitsGas.style.display="None";
				document.all.MetricUnitsGas.style.display="";
				document.all.StandardUnitsOil.style.display="None";
				document.all.MetricUnitsOil.style.display="None";
				window.idfuelcostgal.style.display="none";
				window.idfuelcosttherm.style.display="none";
				window.idfuelcostlt.style.display="none";
				window.idfuelcostcum.style.display="";
			}
	}		
	if(document.frmboilerstream.rdounits(0).checked == true)
	{
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
		{
			OilGradeVal = document.frmboilerstream.cboOiltype.options[document.frmboilerstream.cboOiltype.selectedIndex].text
			if(OilGradeVal == "Light Oil")
			{
				IntOilGrade = 142000
							
			}
			if(OilGradeVal == "Heavy Oil")
			{
				IntOilGrade = 150000
			}
			
			IntBHP = document.frmboilerstream.txtBoilerOutput.value;
			intBoilerEfficiency = document.frmboilerstream.txtBoilerEfficiency.value;
			IntStreamOutput = IntBHP * 34.5;
			InsertComma(IntStreamOutput,"")
			document.all.idlblsteamoutput.innerText = IntPrintResult + " lbs/hr";
			IntMaxOutput = (IntBHP * 33475);
			InsertComma(IntMaxOutput,"")
			document.all.idlblmaxoutput.innerText = IntPrintResult + " Btu/hr ";
			intBoilerpercentage = intBoilerEfficiency / 100
			intOilBurningRate = (IntBHP * 33472)/(intBoilerpercentage * IntOilGrade);
			IntConvertInCuft = intOilBurningRate
			InsertComma(IntConvertInCuft,"")
   			document.all.idlblmaxburnrate.innerText = IntPrintResult + " Gal/hr ";
   			intMaxOilBurnRate = IntPrintResult
    		intAnnualhourrun = document.frmboilerstream.txtAnnualhours.value;
			intCostOfoil = document.frmboilerstream.txtFuelCost.value;
   			AnnualSteamCost = intOilBurningRate * intAnnualhourrun * intCostOfoil
   			InsertComma(AnnualSteamCost,"")
   			displayResult(IntPrintResult, "idCostTD", "Cost")
   			FuelCost = (AnnualSteamCost)/(365*24)
   		    var a = (1000 * intOilBurningRate)
		    var b = parseFloat(intCostOfoil)
		    var c = parseInt(IntStreamOutput)
		    IntFinalresult = (a * b)/c
			
			//IntFinalresult = (1000 * intMaxOilBurnRate * intCostOfoil)/IntStreamOutput
			InsertComma(IntFinalresult,"")
			document.all.idperlbs.innerText = "$" + IntPrintResult + "/1000 lbs of steam";
		
		}
		else
		{
			// Standard Gas
			IntBHP = document.frmboilerstream.txtBoilerOutput.value;
			IntStreamOutput = IntBHP * 34.5;
			InsertComma(IntStreamOutput,"")
			document.all.idlblsteamoutput.innerText = IntPrintResult + " lbs/hr";
			IntMaxOutput = (IntBHP * 33475);
			InsertComma(IntMaxOutput,"")
			document.all.idlblmaxoutput.innerText = IntPrintResult + " Btu/hr ";
			intBoilerpercentage = document.frmboilerstream.txtBoilerEfficiency.value /100
			intMaxGasburnRate  = (IntBHP * 33472) /intBoilerpercentage
			intTherm = intMaxGasburnRate/100000		
			InsertComma(intTherm,"")
			document.all.idlblmaxburnrate.innerText = IntPrintResult + " therm/hr ";
			intAnnualhourrun = document.frmboilerstream.txtAnnualhours.value;
			intCostOfoil = document.frmboilerstream.txtFuelCost.value;
			AnnualSteamCost = intTherm * intAnnualhourrun * intCostOfoil
			InsertComma(AnnualSteamCost,"")  
			displayResult(IntPrintResult, "idCostTD", "Cost")
   			
   			//FuelCost = (AnnualSteamCost)/(365*24)
			//IntFinalresult = (1000 * ( GasAnnualFuelCost/intAnnualhourrun)) / IntStreamOutput
			
			if(AnnualSteamCost=="0" || AnnualSteamCost=="" || intAnnualhourrun == "0" || intAnnualhourrun=="")
			{
				IntFinalresult = 1000 * 0;
				document.all.idperlbs.innerText = "$" + 0 + "/1000 lbs of steam";
			}
			else
			{
				IntFinalresult = (1000 * (parseInt(AnnualSteamCost) / parseInt(intAnnualhourrun)))/(IntStreamOutput);
				//IntFinalresult = (1000 * (20 / 2))/(5);
				InsertComma(IntFinalresult,"")
				//insretedVal
				document.all.idperlbs.innerText = "$" + insretedVal + "/1000 lbs of steam";
			}
			
		}	
	}
	else
	{
		if(window.frmboilerstream.rdoFueltypeselected(0).checked == true)   
		{
			// Metric Oil
			OilGradeVal = document.frmboilerstream.cboOiltype.options[document.frmboilerstream.cboOiltype.selectedIndex].text
			if(OilGradeVal == "Light Oil")
			{
				IntOilGrade = 9321
							
			}
			if(OilGradeVal == "Heavy Oil")
			{
				IntOilGrade = 9987
			}

			IntBHP = document.frmboilerstream.txtBoilerOutput.value;
			intBoilerEfficiency = document.frmboilerstream.txtBoilerEfficiency.value;
			IntStreamOutput = IntBHP * 15.6
			InsertComma(IntStreamOutput,"")
			document.all.idlblsteamoutput.innerText = IntPrintResult + " Kg/hr";
			IntMaxOutput = (IntBHP * 8436);
			InsertComma(IntMaxOutput,"")
			document.all.idlblmaxoutput.innerText = IntPrintResult + " Kg cal/hr";
			intBoilerpercentage = intBoilerEfficiency / 100
			intOilBurningRate = (IntBHP * 8436)/(intBoilerpercentage * IntOilGrade);
			IntConvertInCuft = intOilBurningRate
			InsertComma(IntConvertInCuft,"")
   			document.all.idlblmaxburnrate.innerText = IntPrintResult + " lts/hr";
   			intMaxOilBurnMetric = IntPrintResult
   			intAnnualhourrun = document.frmboilerstream.txtAnnualhours.value;
			intCostOfoil = document.frmboilerstream.txtFuelCost.value;
   			AnnualSteamCost = intOilBurningRate * intAnnualhourrun * intCostOfoil
   			InsertComma(AnnualSteamCost,"")
   			displayResult(IntPrintResult, "idCostTD", "Cost")
   			FuelCost = (AnnualSteamCost)/(365*24)
   			
   			var a = 1000 * parseFloat(intMaxOilBurnMetric);
			var b = parseFloat(intCostOfoil);
			var c = parseInt(IntStreamOutput);
			IntFinalresult = (a * b)/c;
			//IntFinalresult = (1000 * intMaxOilBurnMetric * intCostOfoil)/ IntStreamOutput
			InsertComma(IntFinalresult,"")
			document.all.idperlbs.innerText = "$" + IntPrintResult + "/1000 Kgs of steam";
		}
		else
		{
			// Metric Gas 
			IntBHP = document.frmboilerstream.txtBoilerOutput.value;
			IntStreamOutput = IntBHP * 15.6;
			InsertComma(IntStreamOutput,"")
			document.all.idlblsteamoutput.innerText = IntPrintResult + " Kg/hr";
			IntMaxOutput = (IntBHP * 8436);
			InsertComma(IntMaxOutput,"")
			document.all.idlblmaxoutput.innerText = IntPrintResult + " Kg cal/hr";
			intBoilerpercentage = document.frmboilerstream.txtBoilerEfficiency.value /100
			intMaxGasburnRate  = (IntBHP * 8436) /intBoilerpercentage
			intTherm = intMaxGasburnRate/8898		
			InsertComma(intTherm,"")
			document.all.idlblmaxburnrate.innerText = IntPrintResult + " cu m/hr";
			intMaxGasBurningRate = IntPrintResult
			intAnnualhourrun = document.frmboilerstream.txtAnnualhours.value;
			intCostOfoil = document.frmboilerstream.txtFuelCost.value;
			AnnualSteamCost = intTherm * intAnnualhourrun * intCostOfoil
			InsertComma(AnnualSteamCost,"")     
			displayResult(IntPrintResult, "idCostTD", "Cost")
   			FuelCost = (AnnualSteamCost)/(365*24)
   			var a = 1000 * parseInt(intTherm);
			var b = parseFloat(intCostOfoil);
			var c = parseInt(IntStreamOutput);
			IntFinalresult = (a * b)/c;
			if(IntFinalresult>100)
			{
			var intmore = IntFinalresult.toString();
			document.all.idperlbs.innerText = "$" + intmore.substring(0,5) + "/1000 Kgs of steam";
			}
			else
			{
			InsertComma(IntFinalresult,"")
			document.all.idperlbs.innerText = "$" + IntPrintResult + "/1000 Kgs of steam";
			}
			
		}	
	}
}
//-->
