//---------------------------------------------------------------------------
//This function checks for the Empty field.
//---------------------------------------------------------------------------
function IsEmpty(val,name)
{
	
  if(IsBlank(val.value))
  	{
  		alert(name +" cannot be left blank");
  		val.focus();
  		return true;
  	}
  	return false;	
}
//---------------------------------------------------------------------------
//This function checks for the Blank field.
//---------------------------------------------------------------------------

function IsBlank(sGivenString) 
{                           
	var len = sGivenString.length;
	var i;
	for (i = 0;i < len;++i)
    {
	  	if(sGivenString.charAt(i) != " ")
  			return false;
    }  
    return true;
}

//---------------------------------------------------------------------------
//This function checks for the Blank field.
//---------------------------------------------------------------------------

function CheckBlank(sGivenString,Name) 
{                           
	var len = sGivenString.length;
	var i;
	var flag=false;
	for (i = 0;i < len;++i)
	{
		if(sGivenString.charAt(i) != " ")
		flag= true;	
	}  
	if (flag==false)
	{
		alert(Name + " must be entered");
		return false;
	}      
	else
	{
		return true;
	}	
}

//---------------------------------------------------------------------------
//This function checks for the Valid Number
//---------------------------------------------------------------------------

function IsValidNumber(val,name)
{
	if (!(IsEmpty(val,name)))
		{		
			return false;
		}
	if (!(isNumeric(val.value)))
		{		
			return false;
		}
	if (val.value==0)
		{	
			alert("Number of rows cannot be 0");	
			return false;
		}	
	else
		{
			return true;
		}
}	

function Validator()
{
	
	if(checkForBlank())
	{
	//---------------------------------------------------------------------------
	//This function checks for the for numberic entry.
	//-----------------------------------------------------------------------------	
		if(isNaN(document.frmboilerstream.txtBoilerOutput.value))
		{ 
			alert("Please enter the numeric value");
			document.frmboilerstream.txtBoilerOutput.focus();  
			return false;
		}
		
		if(isNaN(document.frmboilerstream.txtBoilerEfficiency.value))
		{ 
			alert("Please enter the numeric value");
			document.frmboilerstream.txtBoilerEfficiency.focus();  
			return false;
		}
		if(isNaN(document.frmboilerstream.txtAnnualhours.value))
			{
			 alert("Please enter the numeric value");
			 document.frmboilerstream.txtAnnualhours.focus();  
			 return false;
			}
		if(document.frmboilerstream.txtAnnualhours.value>=8761)
			{	
			alert("Annual Hours can not exceed 8760");
			document.frmboilerstream.txtAnnualhours.focus();  
			return false;
			}
			
		if(isNaN(document.frmboilerstream.txtFuelCost.value))
		{ 
			alert("Please enter the numeric value");
			document.frmboilerstream.txtFuelCost.focus();  
			return false;
		}
		return true;
	}
	else
		return false;  	
}
	
 function checkForBlank()
 {
	//---------------------------------------------------------------------------
	//This function checks for the Empty field.
	//-----------------------------------------------------------------------------
  	if(IsEmpty(document.frmboilerstream.txtBoilerOutput,"Boiler Output"))
	{
		return(false);
	}
	else
	if(IsEmpty(document.frmboilerstream.txtBoilerEfficiency,"Boiler Efficiency"))
	{
	  return(false);
	}
	else
	if(IsEmpty(document.frmboilerstream.txtFuelCost,"Fuel Cost"))
	{
		return(false);
	}
	else
	if(IsEmpty(document.frmboilerstream.txtAnnualhours,"Annual Hours"))
	{
		return(false);
	}
	
   return(true);	 
 }


