function displayAlert(message) {
  if ((typeof message != "undefined") && message.length > 0) alert(message);
}

function isInteger(field, message)
{
  if (/^\d+$/.test(field.value)) return true;
  displayAlert(message);
  return false;
}

function isFloat(field, message)
{
  if (/^\d+\.?\d*$/.test(field.value)) return true;
  displayAlert(message);
  return false;
}

function isEmail(field, message){
  if (/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(field.value)) return true;
  displayAlert(message);
  return false;
} 

function isPhone(field, message){
  with (field) {
    value = value.replace(/(\s|-|\(|\)|\.)/g,"");
    if (/^\d{10}$/.test(value)) return true;
  }
  displayAlert(message);
  return false;
}

function isPostalCode(field, message)
{
  with (field) {
    value = value.toUpperCase().replace(/(\s|-)/g,"");
    if (/[A-Z]\d[A-Z]\d[A-Z]\d/.test(value)) return true;
  }
  displayAlert(message);
  return false;
}

function digitvalidation(entered, min, max, alertbox, datatype)
{
  with (entered)
  {
    checkvalue=parseFloat(value);
    if (datatype) {
	  smalldatatype=datatype.toLowerCase();
      if (smalldatatype.charAt(0)=="i") {
	    checkvalue=parseInt(value); 
		if (value.indexOf(".")!=-1) {
		  checkvalue=checkvalue+1;
		}
      }
    }
    if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue) {
	  displayAlert(alertbox);
	  return false;
	}
  }
  return true;
} 

function isEmpty(field, message)
{
    if (field.value!=null && field.value.length > 0) return false;
	displayAlert(message);
	return true;
} 
