/** 
 * Check Form and Error Messages JS File, for eCalc 1.0
 * by Bruno Augusto
 * (c) 2007 Jack!
 * All rights reserved 
*/

function checkForm()
{
	if( document.getElementById( 'percentual' ).value <= 0 || document.getElementById( 'percentual' ).value >= 100 )
	{
		alert( 'A porcentagem desejada deve estar entre 1% e 99%' );
		
		return false;
	}
	
	else if( document.getElementById( 'units' ).value <= 0 )
	{
		alert( 'Informe a quantidade de soldados existentes para que seja calculada a porcentagem.' );
		
		return false;
	}
	else if( document.getElementById( 'attacks' ).selectedIndex == 0 )
	{
		alert( 'Selecione a quantidade de ataques que serão realizados.' );
		
		return false;
	}
			
	return true;
}

// Funções Auxiliares

function empty(pStrText){
   var   len = pStrText.length;
   var pos;
   var vStrnewtext = "";

   for (pos=0; pos<len; pos++){
      if (pStrText.substring(pos, (pos+1)) != " "){
         vStrnewtext = vStrnewtext + pStrText.substring(pos, (pos+1));
      }
   }

   if (vStrnewtext.length > 0)
      return false;
   else
      return true;
}