// JavaScript Document
function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
var mygreen = new Color('#339966');
var myblue = new Color('#3366FF');
var myblack = new Color('#000000');
var mydarkgreen = new Color('#009200');


//  SECTION 1 workplace hazard provison
  one = document.needs.box1.value;
  two = document.needs.box2.value;
  three = document.needs.box3.value; 
  four = document.needs.box4.value; 
  five = document.needs.box5.value; 
  six = document.needs.box6.value; 
  seven = document.needs.box7.value; 
  eight = document.needs.box8.value; 
  nine = document.needs.box9.value;  
  document.needs.SectionOneTotal.value = (one * 1) + (two * 1) + (three * 1) + (four * 1) + (five * 1) + (six * 1)+(seven * 1) + (eight * 1) + (nine * 1);
  
//  SECTION 2 workforec demographics
   ten = document.needs.box10.value;
  eleven = document.needs.box11.value;
  twelve = document.needs.box12.value; 
  thirteen = document.needs.box13.value; 
  fourteen = document.needs.box14.value; 
document.needs.SectionTwoTotal.value = (ten * 1) + (eleven * 1) + (twelve * 1) + (thirteen * 1) + (fourteen * 1);
  
  
//  SECTION 3 workplace working arrangemnets 
fifteen = document.needs.box15.value; 
sixteen = document.needs.box16.value; 
seventeen = document.needs.box17.value; 
eighteen = document.needs.box18.value;  
nineteen = document.needs.box19.value; 
document.needs.SectionThreeTotal.value = (fifteen * 1) + (sixteen* 1) + (seventeen * 1) + (eighteen * 1) + (nineteen * 1);

//  SECTION 4 historical accidents
twenty = document.needs.box20.value; 
twentyone = document.needs.box21.value; 
twentytwo = document.needs.box22.value; 
document.needs.SectionFourTotal.value = (twenty * 1) + (twentyone* 1) + (twentytwo * 1);
 
 
//  SECTION 5 non employyee workplacee provision
 twentythree = document.needs.box23.value; 
//twentyfour = document.needs.box24.value; 
//twentyfive = document.needs.box25.value; 
//document.needs.SectionFiveTotal.value = (twentythree * 1) + (twentyfour* 1) + (twentyfive * 1);

document.needs.SectionFiveTotal.value = (twentythree * 1);
  
  
  
  
  //set totals for firstaiders needed
  AppointedPersion = 5;
  EmergencyFirstAiderAtWork = 25;
  FirstAiderAtWork = 49;
  AppointedPersionTotal = 0;
  EmergencyFirstAiderAtWorkTotal = 0;
  FirstAiderAtWorkTotal = 0;
  MultipleFirstAiderAtWorkTotal = 0;
  MultipleFirstAiderAtWork = 174;
  SectionOneText = " ";
  SectionTwoText = " ";
  SectionThreeText = " ";
  SectionFourText = " ";
  SectionFiveText = " ";
  LargestTotal = 0;
  AbsenceCover = "TBC";
  
//section1  +++++++++++++    TOTALS AND TEXT  +++++++++++++++++   //
  $('SectionOneResult').setStyle('color', myblack);
  
  if ( document.needs.SectionOneTotal.value >= 25 && document.needs.SectionOneTotal.value < 50 ){
  
  EmergencyFirstAiderAtWorkTotal = EmergencyFirstAiderAtWorkTotal+1;
   SectionOneText = "Emergency First Aider At Work";
      $('SectionOneResult').setStyle('color', myblue);
  
  }
  
  else if (document.needs.SectionOneTotal.value >= 49  ) {
  
    FirstAiderAtWorkTotal =   FirstAiderAtWorkTotal + 1;
  SectionOneText = "First Aider At Work";
    $('SectionOneResult').setStyle('color', mygreen);
  }
  
 
  //setText
  //var black = new Color('#000');
//var purple = new Color([255,0,255]);


   document.needs.SectionOneResult.value = SectionOneText;

//END  section1 TOTALS AND TEXT  +++++++++++++++++    //
  
//section2    +++++++++++++    TOTALS AND TEXT  +++++++++++++++++ //
  $('SectionTwoResult').setStyle('color', myblack);
  
     if ( document.needs.SectionTwoTotal.value < 25  && document.needs.SectionTwoTotal.value > 0  ){
  
  AppointedPersionTotal = AppointedPersionTotal+1;
SectionTwoText = "Appointed Person";
   $('SectionTwoResult').setStyle('color', myblack);
  }
  
   if ( document.needs.SectionTwoTotal.value >= 25 && document.needs.SectionTwoTotal.value < 50 ){
  
  EmergencyFirstAiderAtWorkTotal = EmergencyFirstAiderAtWorkTotal+1;
    SectionTwoText = "Emergency First Aider At Work";
	 $('SectionTwoResult').setStyle('color', myblue);
  }
  
  else if (document.needs.SectionTwoTotal.value >= 50  && document.needs.SectionTwoTotal.value <= 99) {
  
    FirstAiderAtWorkTotal =   FirstAiderAtWorkTotal + 1;
  SectionTwoText = "First Aider At Work";
   $('SectionTwoResult').setStyle('color', mygreen);
  }
  
  
  
    else if (document.needs.SectionTwoTotal.value >= 100 ) {
  
    MultipleFirstAiderAtWorkTotal =   MultipleFirstAiderAtWorkTotal + 1;
  SectionTwoText = "Multiple First Aider At Work";
    $('SectionTwoResult').setStyle('color', mydarkgreen);
  }
  
  
    //setText
   document.needs.SectionTwoResult.value = SectionTwoText;
    
//END  section2 TOTALS AND TEXT  +++++++++++++++++     //
 //section3   +++++++++++++    TOTALS AND TEXT  +++++++++++++++++  //
     if ( document.needs.SectionThreeTotal.value < 25  && document.needs.SectionThreeTotal.value > 0  ){
  
  AppointedPersionTotal = AppointedPersionTotal+1;
SectionThreeText = "Appointed Person";
 $('SectionThreeResult').setStyle('color', myblack);
  
  }
  
   if ( document.needs.SectionThreeTotal.value >= 25 && document.needs.SectionThreeTotal.value <= 49 ){
  
  EmergencyFirstAiderAtWorkTotal = EmergencyFirstAiderAtWorkTotal+1;
    SectionThreeText = "Emergency First Aider At Work";
	 $('SectionThreeResult').setStyle('color', myblue);
  }
  
  else if (document.needs.SectionThreeTotal.value >= 50  && document.needs.SectionThreeTotal.value <= 99) {
  
    FirstAiderAtWorkTotal =   FirstAiderAtWorkTotal + 1;
  SectionThreeText = "First Aider At Work";
   $('SectionThreeResult').setStyle('color', mygreen);
  }
  
  
    else if (document.needs.SectionThreeTotal.value >= 100 ) {
  
    MultipleFirstAiderAtWorkTotal =   MultipleFirstAiderAtWorkTotal + 1;
  SectionThreeText = "Multiple First Aider At Work";
    $('SectionThreeResult').setStyle('color', mydarkgreen);
  }
  
    //setText
   document.needs.SectionThreeResult.value = SectionThreeText;
    
 //END  section3 TOTALS AND TEXT  +++++++++++++++++     //
 
//section4 TOTALS AND TEXT  +++++++++++++++++ //
   $('SectionFourResult').setStyle('color', myblack);
     if ( document.needs.SectionFourTotal.value < 5 && document.needs.SectionFourTotal.value > 0  ){
  
  AppointedPersionTotal = AppointedPersionTotal+1;
SectionFourText = "Appointed Person";
  $('SectionFourResult').setStyle('color', myblack);
  
  }
  
   if ( document.needs.SectionFourTotal.value >= 5 && document.needs.SectionFourTotal.value <= 50 ){
  
  EmergencyFirstAiderAtWorkTotal = EmergencyFirstAiderAtWorkTotal+1;
    SectionFourText = "Emergency First Aider At Work";
	  $('SectionFourResult').setStyle('color', myblue);
  }
  
  else if (document.needs.SectionFourTotal.value > 50 && document.needs.SectionFourTotal.value <= 176) {
  
    FirstAiderAtWorkTotal =   FirstAiderAtWorkTotal + 1;
  SectionFourText = "First Aider At Work";
    $('SectionFourResult').setStyle('color', mygreen);
  }
  
  
     else if (document.needs.SectionFourTotal.value > 176 ) {
  
    MultipleFirstAiderAtWorkTotal =   MultipleFirstAiderAtWorkTotal + 1;
  SectionFourText = "Multiple First Aider At Work";
    $('SectionFourResult').setStyle('color', mydarkgreen);
  }
  
    //setText
   document.needs.SectionFourResult.value = SectionFourText;
    
 //END  section4 TOTALS AND TEXT  +++++++++++++++++    //
 
 //section5 TOTALS AND TEXT  +++++++++++++++++  //
  $('SectionFiveResult').setStyle('color', myblack);
     if ( document.needs.SectionFiveTotal.value <= 5  && document.needs.SectionFiveTotal.value > 0  ){
  
  AppointedPersionTotal = AppointedPersionTotal+1;
SectionFiveText = "Appointed Person";
 $('SectionFiveResult').setStyle('color', myblack);
  
  }
  
   if ( document.needs.SectionFiveTotal.value > 5 && document.needs.SectionFiveTotal.value <= 49 ){
  
  EmergencyFirstAiderAtWorkTotal = EmergencyFirstAiderAtWorkTotal+1;
    SectionFiveText = "Emergency First Aider At Work";
	 $('SectionFiveResult').setStyle('color', myblue);
  }
  
  else if (document.needs.SectionFiveTotal.value > 49 && document.needs.SectionFiveTotal.value <= 99) {
  
    FirstAiderAtWorkTotal =   FirstAiderAtWorkTotal + 1;
  SectionFiveText = "First Aider At Work";
   $('SectionFiveResult').setStyle('color', mygreen);
  }
  
  
       else if (document.needs.SectionFiveTotal.value > 99 ) {
  
    MultipleFirstAiderAtWorkTotal =   MultipleFirstAiderAtWorkTotal + 1;
  SectionFiveText = "Multiple First Aider At Work";
    $('SectionFiveResult').setStyle('color', mydarkgreen);
  }
  
    //setText
   document.needs.SectionFiveResult.value = SectionFiveText;
    
 //END  section5 TOTALS AND TEXT  +++++++++++++++++     //
 
//set totals
   document.needs.AppointedPersion.value = AppointedPersionTotal;
  document.needs.EmergencyFirstAiderAtWork.value = EmergencyFirstAiderAtWorkTotal;
  document.needs.FirstAiderAtWork.value = FirstAiderAtWorkTotal;
  document.needs.MultipleFirstAiderAtWork.value = MultipleFirstAiderAtWorkTotal;
  
  
  

  
 
//end main function
}
function stopCalc(){
  clearInterval(interval);
}


