
/* CONCRETE VOLUME */
function validateConcreteVolumeForm(){
  var cubicFeet = "";
  var cubicYards = "";
  var isValid = true;
  var errorMessage = "";
  var width=document.forms["calculatorConcreteVolume"]["concreteVolumeWidth"].value;
  var length=document.forms["calculatorConcreteVolume"]["concreteVolumeLength"].value;
  var depth=document.forms["calculatorConcreteVolume"]["concreteVolumeDepth"].value;
  document.getElementById("concreteVolumeWidth").setAttribute("class", "");
  document.getElementById("concreteVolumeLength").setAttribute("class", "");
  document.getElementById("concreteVolumeDepth").setAttribute("class", "");
  
  //check width
  if (width==null || width=="" || isNaN(width)){
    errorMessage += "Please enter valid WIDTH in feet.\n";
    document.getElementById("concreteVolumeWidth").setAttribute("class", "invalidFormField");
    document.getElementById("concreteVolumeWidth").focus();
    isValid = false;
  }
  
  // check length
  if (length==null || length=="" || isNaN(length)){
    errorMessage += "Please enter valid LENGTH in feet.\n";
    document.getElementById("concreteVolumeLength").setAttribute("class", "invalidFormField");
    document.getElementById("concreteVolumeLength").focus();
    isValid = false;
  }
  
  // check depth
  if (depth==null || depth=="" || isNaN(depth)){
    errorMessage += "Please enter valid DEPTH in inches.\n";
    document.getElementById("concreteVolumeDepth").setAttribute("class", "invalidFormField");
    document.getElementById("concreteVolumeDepth").focus();
    isValid = false;
  }
  
  // if valid form show result, otherwise show error message
  if (isValid){
    cubicFeet = width * length * (depth/12);
    cubicYards = cubicFeet / 27;
    cubicYards = Math.round(cubicYards*10)/10;
    document.getElementById('concreteVolumeTotal').innerHTML = cubicYards;
    return true;
  } else {
    document.getElementById('concreteVolumeTotal').innerHTML = "";
    alert(errorMessage);
    return false;
  }
}


/* COLUMN VOLUME */
function validateColumnVolumeForm(){
  var cubicFeet = "";
  var cubicYards = "";
  var isValid = true;
  var errorMessage = "";
  var height=document.forms["calculatorColumnVolume"]["columnHeight"].value;
  var diameter=document.forms["calculatorColumnVolume"]["columnDiameter"].value;
  document.getElementById("columnHeight").setAttribute("class", "");
  document.getElementById("columnDiameter").setAttribute("class", "");
  
  //check height
  if (height==null || height=="" || isNaN(height)){
    errorMessage += "Please enter valid HEIGHT in feet.\n";
    document.getElementById("columnHeight").setAttribute("class", "invalidFormField");
    document.getElementById("columnHeight").focus();
    isValid = false;
  }
  
  // check diameter
  if (diameter==null || diameter=="" || isNaN(diameter)){
    errorMessage += "Please enter valid DIAMETER in inches.\n";
    document.getElementById("columnDiameter").setAttribute("class", "invalidFormField");
    document.getElementById("columnDiameter").focus();
    isValid = false;
  }
  
  // if valid form show result, otherwise show error message
  if (isValid){
    var divisor = 4950;
    cubicYards = height * diameter * (diameter / divisor);
    cubicYards = Math.round(cubicYards*10)/10;
    document.getElementById('columnVolumeTotal').innerHTML = cubicYards;
    return true;
  } else {
    document.getElementById('columnVolumeTotal').innerHTML = "";
    alert(errorMessage);
    return false;
  }
}


/* BLOCK QUANTITY */
function validateBlockQuantity(){
  var numberBlocks = "";
  var isValid = true;
  var errorMessage = "";
  var blockWallArea=document.forms["calculatorBlockQuantity"]["blockWallArea"].value;
  document.getElementById("blockWallArea").setAttribute("class", "");
  
  //check blockWallArea
  if (blockWallArea==null || blockWallArea=="" || isNaN(blockWallArea)){
    errorMessage += "Please enter valid BLOCK AREA in square feet.\n";
    document.getElementById("blockWallArea").setAttribute("class", "invalidFormField");
    document.getElementById("blockWallArea").focus();
    isValid = false;
  }
 
  // if valid form show result, otherwise show error message
  if (isValid){
    numberBlocks = Math.round(blockWallArea * 1.125);
    document.getElementById('blockQuantityTotal').innerHTML = numberBlocks;
    return true;
  } else {
    document.getElementById('blockQuantityTotal').innerHTML = "";
    alert(errorMessage);
    return false;
  }
}


/* HOLLANDSTONE PAVER QUANTITY */
function validateHollandstoneQuantity(){
  var numberBlocks = "";
  var isValid = true;
  var errorMessage = "";
  var hollandstoneArea=document.forms["calculatorHollandstoneQuantity"]["hollandstoneArea"].value;
  document.getElementById("hollandstoneArea").setAttribute("class", "");
  
  //check blockWallArea
  if (hollandstoneArea==null || hollandstoneArea=="" || isNaN(hollandstoneArea)){
    errorMessage += "Please enter valid PAVING AREA in square feet.\n";
    document.getElementById("hollandstoneArea").setAttribute("class", "invalidFormField");
    document.getElementById("hollandstoneArea").focus();
    isValid = false;
  }
 
  // if valid form show result, otherwise show error message
  if (isValid){
    numberBlocks = Math.round(hollandstoneArea * 4.8);
    document.getElementById('hollandstoneQuantityTotal').innerHTML = numberBlocks;
    return true;
  } else {
    document.getElementById('hollandstoneQuantityTotal').innerHTML = "";
    alert(errorMessage);
    return false;
  }
}


/* UNI-DECOR PAVER QUANTITY */
function validateUniDecorQuantity(){
  var numberBlocks = "";
  var isValid = true;
  var errorMessage = "";
  var uniDecorArea=document.forms["calculatorUniDecorQuantity"]["uniDecorArea"].value;
  document.getElementById("uniDecorArea").setAttribute("class", "");
  //check blockWallArea
  if (uniDecorArea==null || uniDecorArea=="" || isNaN(uniDecorArea)){
    errorMessage += "Please enter valid PAVING AREA in square feet.\n";
    document.getElementById("uniDecorArea").setAttribute("class", "invalidFormField");
    document.getElementById("uniDecorArea").focus();
    isValid = false;
  }
 
  // if valid form show result, otherwise show error message
  if (isValid){
    numberBlocks = Math.round(uniDecorArea * 3.5);
    document.getElementById('uniDecorQuantityTotal').innerHTML = numberBlocks;
    return true;
  } else {
    document.getElementById('uniDecorQuantityTotal').innerHTML = "";
    alert(errorMessage);
    return false;
  }
}

