var currentBio = "";
fadeTimeBio = 750;

function startUp()
{
  if ($('.staffEnvelope').length == 1) {
    $('#staff_01').bind('click',{staff: 1},showStaff);
    $('#staff_02').bind('click',{staff: 2},showStaff);
    $('#staff_03').bind('click',{staff: 3},showStaff);
    $('#staff_04').bind('click',{staff: 4},showStaff);
    $('#staff_05').bind('click',{staff: 5},showStaff);
    $('#staff_06').bind('click',{staff: 6},showStaff);
    $('#staff_07').bind('click',{staff: 7},showStaff);
    $('#bio_01').bind('mouseleave',{staff: 0},showStaff);
    $('#bio_02').bind('mouseleave',{staff: 0},showStaff);
    $('#bio_03').bind('mouseleave',{staff: 0},showStaff);
    $('#bio_04').bind('mouseleave',{staff: 0},showStaff);
    $('#bio_05').bind('mouseleave',{staff: 0},showStaff);
    $('#bio_06').bind('mouseleave',{staff: 0},showStaff);
    $('#bio_07').bind('mouseleave',{staff: 0},showStaff);
    $('#bio_01').bind('click',{staff: 0},showStaff);
    $('#bio_02').bind('click',{staff: 0},showStaff);
    $('#bio_03').bind('click',{staff: 0},showStaff);
    $('#bio_04').bind('click',{staff: 0},showStaff);
    $('#bio_05').bind('click',{staff: 0},showStaff);
    $('#bio_06').bind('click',{staff: 0},showStaff);
    $('#bio_07').bind('click',{staff: 0},showStaff);
  }
}


function showStaff(e){
  switch(e.data.staff){
    case 0:
      $(currentBio).css("display","none");
      currentBio = "";
      break;
    case 1:
      $('#bio_01').css("display","block");
      currentBio = "#bio_01";
      break;
    case 2:
      $('#bio_02').css("display","block");
      currentBio = "#bio_02";
      break;
    case 3:
      $('#bio_03').css("display","block");
      currentBio = "#bio_03";
      break;
    case 4:
      $('#bio_04').css("display","block");
      currentBio = "#bio_04";
      break;
    case 5:
      $('#bio_05').css("display","block");
      currentBio = "#bio_05";
      break;
    case 6:
      $('#bio_06').css("display","block");
      currentBio = "#bio_06";
      break;
    case 7:
      $('#bio_07').css("display","block");
      currentBio = "#bio_07";
      break;
  }
}


function getDirections(tf){
  var h = "http://maps.google.ca/maps?f=d&source=s_d&saddr="
  var startString;

  startString = tf.address.value.replace(/\s/g,'+');
  if (startString.length > 0) startString += ",";
  if (tf.city.value.length > 0) startString += tf.city.value.replace(/\s/g,'+') + ",";
  startString += tf.state.options[tf.state.selectedIndex].value.replace(/\s/g,'+');
  h = h + startString + "&daddr=1750+N+Carolina+213,+Marshall,+NC+28753,+USA";
  parent.location.href = h;
  return(false);
}





function generateResponse(page,name){

  var fromPage = "";
  var contact = "";
  var t = "<p>Testing</p>";
  var i = page.indexOf(":");
  if (i < 0) {
    // This is an error output a generic response page.
  }
  fromPage = page.slice(0,i);
  contact = page.slice(i+1,i+2);
  fromPage = fromPage.toLowerCase();
  if (fromPage ==  "onlinepreplan"){
    t = "<h1>On-Line Preplanning Submission</h1>\n";

    t += "<p><b>To: " + name + "</b></p>\n";
    if (contact.toLowerCase() == "n"){
      t += "<p class='responseP'>Thank you for you preplanning submission.  You have requested that we not contact you, so we will file your preplanning information.</p>";
    } else {
      t += "<p class='responseP'>Thank you for you preplanning submission.  We will contact you shortly to discuss the information you have sent.</p>";
    }
  } else if (fromPage == "contactus"){
    t = "<h1>Contact Us Inquiry</h1>\n";
    t += "<p><b>To: " + name + "</b></p>\n";
    t += "<p class='responseP'>Thank you for contacting us using our Contact Us form.  We will contact you shortly with regard to your inquiry.</p>";
  }
  t += "\n<p>Very truly yours,<br />Madison Funeral Home</p>";
  document.writeln(t);
}


function gotoPage(thePage)
{
  location.href = "http://web1.lovinghonors.com/k-o/madisonfh.com/html/" + thePage;
  return(false);
}


$(document).ready(startUp);

