function isNumber( inputVal )
  {	// general purpose function to see if a suspected numberic input
	// is a positive or negative number
	
    oneDecimal = false;
    inputStr =  inputVal.toString();
    for( var i=0 ; i<inputStr.length ; i++ )
    {
	var oneChar = inputStr.charAt( i );
	if( i==0 && oneChar=="-" )
	{
	  continue;
	}
	if( oneChar=="." && !oneDecimal )
	{
	  oneDecimal = true;
	  continue;
	}
	if( oneChar<"0" || oneChar>"9" )
	{
	  return false;
	}
    }
    return true;
  }

  function verifySubmit( form )
  {
    var intWatts = form.txtWatts.value;
    var intHours = form.txtHours.value;
    var intPrice = form.txtPrice.value;
    var intKilo;
    var intKiloHours;

    if( intWatts == "" )
    {
	errForm( "Watts" );
	return;
    }
    if (intWatts && !isNumber(intWatts))
    {
	errNumber ("Watts")
	return;
    }
    if( intHours == "" )
    {
	errForm( "Hours" );
	return;
    }
    if (intHours && !isNumber(intHours))
    {
	errNumber ("Hours")
	return;
    } 
    if( intPrice == "" )
    {
	errForm( "Price" );
	return;
    }
    if (intPrice && !isNumber(intPrice))
    {
	errNumber ("Price")
	return;
    }

    intKilo = intWatts / 1000;
    intKiloHours = intKilo * intHours;
    intAnswer = intKiloHours * (intPrice / 100);
		intAnswer = roundit(intAnswer, 2);

    window.alert("That appliance will cost you approximately $" + intAnswer + " per month");
    form.txtWatts.value = "";
    form.txtHours.value = "";
    form.txtPrice.value = "7.50";
    form.txtWatts.focus();
    return;
  }

	function roundit(Num, Places)
	{
   if (Places > 0)
	 {
      if ((Num.toString().length - Num.toString().lastIndexOf('.')) > (Places + 1))
			{
         var Rounder = Math.pow(10, Places);
         return Math.round(Num * Rounder) / Rounder;
      }
      else return Num;
   }
   else return Math.round(Num);
	} 

  function errForm( fieldName )
  {
    window.alert( "The '" + fieldName + "' field is a required field.\n\nPlease complete all fields before continuing." );
    return;
  }

  function errNumber( fieldName )
  {	 
    window.alert("The '" + fieldName + "' field must contain only numbers." );
    return;
  }