
window.addEvent('domready', function() {
    Sexy = new SexyAlertBox();
});


function calculate()
{
var roof=document.getElementById('roof').value;
var rain=document.getElementById('rain').value;
var mul=roof*rain
var ans="Water to be collected in tank is : "+mul+" litres"
if(checkValue1() && checkValue2() )
{
//Sexy.info(ans);
alert(ans);
return true;
}
else
{
return false;
}







}

function checkValue1()
{
var roof=document.getElementById('roof').value;

var roof_empty="* Roof field must be filled out.";
var roof_error="* Roof cannot start with space.";

if (roof.length==0 || roof.substring(0,1)==" ")
  	 {
       if(roof.length==0)
       {
  		 document.getElementById('roof1').innerHTML = roof_empty;
  		
       }
        else
        {
		 document.getElementById('roof1').innerHTML = roof_error;
                 
        }
     } 

else
{

 document.getElementById('roof1').innerHTML ="";
 return true;

}


}



function checkValue2()
{

var rain=document.getElementById('rain').value;
var rain_empty="* Rain field must be filled out.";
var rain_error="* Rain cannot start with space.";


if (rain.length==0 || rain.substring(0,1)==" ")
  	 {
       if(rain.length==0)
       {
  		 document.getElementById('rain1').innerHTML = rain_empty;
  		 
       }
        else
        {
		 document.getElementById('rain1').innerHTML = rain_error;
                
        }
     }
  else
   {

   document.getElementById('rain1').innerHTML ="";
   return true;
   }

}


function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 46 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}




