// Functions for enabling and disabling the form
function accept1() {
    document.benefits1.provider_name.disabled=false;
    document.benefits1.insured_name.disabled=false;
    document.benefits1.insured_dob.disabled=false;
	document.benefits1.patient_name.disabled=false;
    document.benefits1.patient_dob.disabled=false;
	document.benefits1.patient_address.disabled=false;
    document.benefits1.policy_number.disabled=false;
	document.benefits1.insurance_company.disabled=false;
    document.benefits1.benefits_phone.disabled=false;
	document.benefits1.visit_reason.disabled=false;
    document.benefits1.contact_phone.disabled=false;
	document.benefits1.contact_yesno[0].disabled=false;
	document.benefits1.contact_yesno[1].disabled=false;
    document.benefits1.contact_email.disabled=false;
	document.benefits1.Submit.disabled=false;
    document.benefits1.Reset.disabled=false;
}
function declined1() {
    document.benefits1.provider_name.disabled=true;
    document.benefits1.insured_name.disabled=true;
    document.benefits1.insured_dob.disabled=true;
	document.benefits1.patient_name.disabled=true;
    document.benefits1.patient_dob.disabled=true;
	document.benefits1.patient_address.disabled=true;
    document.benefits1.policy_number.disabled=true;
	document.benefits1.insurance_company.disabled=true;
    document.benefits1.benefits_phone.disabled=true;
	document.benefits1.visit_reason.disabled=true;
    document.benefits1.contact_phone.disabled=true;
	document.benefits1.contact_yesno[0].disabled=true;
	document.benefits1.contact_yesno[1].disabled=true;
    document.benefits1.contact_email.disabled=true;
	document.benefits1.Submit.disabled=true;
    document.benefits1.Reset.disabled=true;
}

//****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)+"%)";
}

//****functions for form Validation*****
function Form_Validator(theForm)
{

  if (theForm.provider_name.value == "")
  {
    alert("Please enter a value for the \"Name of Provider\" field.");
    theForm.provider_name.focus();
    return (false);
  }
  if (theForm.insured_name.value == "")
  {
    alert("Please enter a value for the \"Name of Insured\" field.");
    theForm.insured_name.focus();
    return (false);
  }
  if (theForm.insured_dob.value == "")
  {
    alert("Please enter a value for the \"Insured Date of Birth\" field.");
    theForm.insured_dob.focus();
    return (false);
  }
  if (theForm.patient_name.value == "")
  {
    alert("Please enter a value for the \"Name of Patient\" field.");
    theForm.patient_name.focus();
    return (false);
  }
  if (theForm.patient_dob.value == "")
  {
    alert("Please enter a value for the \"Patient Date of Birth\" field.");
    theForm.patient_dob.focus();
    return (false);
  }
  if (theForm.patient_address.value == "")
  {
    alert("Please enter a value for the \"Address of Patient\" field.");
    theForm.patient_address.focus();
    return (false);
  }
  if (theForm.policy_number.value == "")
  {
    alert("Please enter a value for the \"Certificate or Policy Number\" field.");
    theForm.policy_number.focus();
    return (false);
  }
  if (theForm.insurance_company.value == "")
  {
    alert("Please enter a value for the \"Name of Insurance Company\" field.");
    theForm.insurance_company.focus();
    return (false);
  }
  if (theForm.benefits_phone.value == "")
  {
    alert("Please enter a value for the \"Phone Number for Benefits\" field.");
    theForm.benefits_phone.focus();
    return (false);
  }
  if (theForm.visit_reason.value == "")
  {
    alert("Please enter a value for the \"Reason for Visit\" field.");
    theForm.visit_reason.focus();
    return (false);
  }
  if (theForm.contact_email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.contact_email.focus();
    return (false);
  }

  
  return (true);
}



