//function for message box character counter
function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        
	// trim the extra text
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	} else {
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}
function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
//form Validation for literature request and contact us page
function literature_Validator(theForm){
  if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }
  if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.company.focus();
    return (false);
  }
  if (theForm.address1.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.address1.focus();
    return (false);
  }
  if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.city.focus();
    return (false);
  }
  if (theForm.country.value == "")
  {
    alert("Please enter a value for the \"Country\" field.");
    theForm.country.focus();
    return (false);
  }
  if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.phone.focus();
    return (false);
  }
  if (theForm.fax.value == "")
  {
    alert("Please enter a value for the \"Fax\" field.");
    theForm.fax.focus();
    return (false);
  }
  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();
    return (false);
  }
  return (true);
}
//form Validation for literature request and contact us page
function Blowdown_Validator(theForm){
  if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }
  if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.company.focus();
    return (false);
  }
  if (theForm.address1.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.address1.focus();
    return (false);
  }
  if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.city.focus();
    return (false);
  }
  if (theForm.country.value == "")
  {
    alert("Please enter a value for the \"Country\" field.");
    theForm.country.focus();
    return (false);
  }
  if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.phone.focus();
    return (false);
  }
  if (theForm.fax.value == "")
  {
    alert("Please enter a value for the \"Fax\" field.");
    theForm.fax.focus();
    return (false);
  }
  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();
    return (false);
  }
  if (theForm.boilerdrain.value == "")
  {
    alert("Please enter a value for the \"Boilers to drain\" field.");
    theForm.boilerdrain.focus();
    return (false);
  }
  if (theForm.boiler_op_pres.value == "")
  {
    alert("Please enter a value for the \"Boiler Operating Pressure\" field.");
    theForm.boiler_op_pres.focus();
    return (false);
  }
    if (theForm.fueltype.value == "")
  {
    alert("Please enter a value for the \"Fuel Type\" field.");
    theForm.fueltype.focus();
    return (false);
  }
  if (theForm.costTherm.value == "")
  {
    alert("Please enter a value for the \"Cost per Therm\" field.");
    theForm.costTherm.focus();
    return (false);
  }
  if (theForm.FlashTankPres.value == "")
  {
    alert("Please enter a value for the \"Flash Tank Pressure\" field.");
    theForm.FlashTankPres.focus();
    return (false);
  }
  return (true);
}