/* - - - - - - - - - - - - - - - - - - - - - - -

 JavaScript

 Functions used in township site

 unless otherwise noted,

 copyright 2008 by Lakes Technology Group, Inc.

 - - - - - - - - - - - - - - - - - - - - - - - */



function wsw (txtstring) {

  // function wsw()

  //   wsw = window status write

  // purpose: to write a window status line when a mouse goes over a link

  // inputs: txtstring - string to display on the status line

  // outputs: 'true' - indicates it worked



  window.status = txtstring;

  return true;

}



function changeUpdateButton (sAction) {

  // function changeUpdateButton()

  // purpose: to change the label on the Update button of the form

  // inputs: sAction - string defining the action the user wants:

  //             'Add' - add their name to the list

  //             'Delete' - delete their name from the list

  // outputs: none



  if (sAction == 'Add') {

    document.getElementById("Sub1").value = "Send Updates";

  } else if (sAction == 'Delete') {

    document.getElementById("Sub1").value = "Delete Me";

  }

}



function processEmailRequest (sAction) {

  // function processEmailRequest()

  // purpose: to set a hidden field and then process the form

  // inputs: sAction - string defining the action the user wants:

  //             'Add' - add their name to the list

  //             'Delete' - delete their name from the list

  // outputs: none

  // action taken: submit the form



  if (sAction == 'Add') {

    document.getElementById("emailHid1").value = "Add";

  } else if (sAction == 'Delete') {

    document.getElementById("emailHid1").value = "Delete";

  }

  document.getElementById("emailForm1").submit();

}



function deleteLine (lid, date, sHr, sMin, sAmpm, eHr, eMin, eAmpm, tTime, desc, rate, rType, amount) {

  // function deleteLine ()

  // purpose: to set form fields and submit form on user confirmation

  // inputs: lid - line id

  //         date

  //         sHr - start Hour

  //         sMin - start Minute

  //         sAmpm - start AM/PM

  //         eHr - end Hour

  //         eMin - end Minute

  //         eAmpm - end AM/PM

  //         tTime - end time minus start time

  //         desc - description

  //         rate - pay rate

  //         rType - rate type, "Hourly" or "Flat"

  //         amount - pay = rate * total time

  // outputs: none



  // start by formatting the start and end times for display

  sTime = sHr+":"+sMin+" "+sAmpm

  eTime = eHr+":"+eMin+" "+eAmpm

  if (rType == "Hourly") {

    rType = " per Hour";

  } else {

    rType = " Flat Rate Fee";

  }

  statement = "You are about to delete the following line:\n\r\n\r";

  statement += date+" "+sTime+" - "+eTime+": "+desc+" @ $"+rate+rType+"\n\rTotal Amount: "+amount+"\n\r\n\r";

  statement += "Click \"Yes\" to Delete this line\n\r";

  if (confirm(statement)) {

    // if user confirms they want to delete the line, set fields and submit the form

    document.getElementById("lid").value = lid;

    document.getElementById("action").value = "Delete";

    document.getElementById("entHrs").submit();

  }

}



function changeLine (lid, pid) {

  // function changeLine ()

  // purpose: to set form fields and submit form for changing a line in the database

  // inputs: lid - line id

  //         pid - person id associated with the line

  // outputs: none



  document.getElementById("lid").value = lid;

  document.getElementById("pid").value = pid;

  document.getElementById("action").value = "Modify";

  document.getElementById("entHrs").submit();

}

