function openProductPage(win) {
  newwin = open(win, 'productPage', "width=970, height=600,scrollbars=yes,menubar=no,resizable=1,top=10,screenY=10,left=10,screenX=10");
  newwin.focus();
}
function openPlannerPage(win) {
  newwin = open(win, 'plannerPage', "width=970, height=600,scrollbars=yes,menubar=no,resizable=1,top=10,screenY=10,left=10,screenX=10");
  newwin.focus();
}
function swapHomeLayer(specialtyBusinessId, state) {
  if (state == 'out') {
    document.getElementById('news').style.display='inline';
    document.getElementById(specialtyBusinessId).style.display='none';
  }
  else {
    document.getElementById('news').style.display='none';
    document.getElementById(specialtyBusinessId).style.display='inline';
  }
}
function openTechTable(tableId) {
  if(document.getElementById(tableId).style.display == 'inline') {
    document.getElementById(tableId).style.display = 'none';
  }
  else {
    document.getElementById(tableId).style.display = 'inline';
  }
}
function showModifyMyBathroomOption(formId, linkId) {
  document.getElementById('addForm').style.display = 'none';
  document.getElementById('addBathroom').style.backgroundColor = "";
  document.getElementById('addBathroomLink').style.color = "black";
  document.getElementById('addBathroomListItem').style.color = "black";
  document.getElementById('activeproduct').style.backgroundColor = "#808080";
  document.getElementById('activeBathroomListItem').style.color = "white";
  document.getElementById('activeBathroomLink').style.color = "white";
  if(document.getElementById('modifyForm').style.display == 'inline') {
    document.getElementById('modifyForm').style.display = 'none';
    document.getElementById('modifyBathroom').style.backgroundColor = "";
    document.getElementById('modifyBathroomLink').style.color = "black";
  }
  else {
    document.getElementById('modifyForm').style.display = 'inline';
    document.getElementById('modifyBathroom').style.backgroundColor = "#DCDADA";
  }
}
function showAddMyBathroomOption() {
  if (document.getElementById('modifyForm')) {
    document.getElementById('modifyForm').style.display = "none";
    document.getElementById('modifyBathroom').style.backgroundColor = "";
  }
  if(document.getElementById('addForm').style.display == "inline") {
    document.getElementById('addForm').style.display = "none";
    document.getElementById('addBathroom').style.backgroundColor = "";
    document.getElementById('addBathroomLink').style.color = "black";
    document.getElementById('addBathroomListItem').style.color = "black";
    if (document.getElementById('activeproduct')) {
      document.getElementById('activeproduct').style.backgroundColor = "#808080";
      document.getElementById('activeBathroomListItem').style.color = "white";
      document.getElementById('activeBathroomLink').style.color = "white";
    }
  }
  else {
    document.getElementById('addForm').style.display = "inline";
    document.getElementById('addBathroom').style.backgroundColor = "#DCDADA";
    if (document.getElementById('activeproduct')) {
      document.getElementById('activeproduct').style.backgroundColor = "white";
      document.getElementById('activeBathroomListItem').style.color = "black";
      document.getElementById('activeBathroomLink').style.color = "black";
      document.getElementById('modifyBathroomLink').style.color = "black";
    }
  }
}
function deleteProduct(productId) {
  document.forms['myBathroomForm'].bathroom_action.value = "delete_products";
  document.forms['myBathroomForm'].product_list.value = productId;
  document.forms['myBathroomForm'].submit();
}
function confirmBathroomDelete(bathroomName) {
  var confirmDelete;
  confirmDelete = confirm("Delete " + bathroomName);
  if (confirmDelete == true) {
    document.forms['myBathroomForm'].bathroom_action.value = "delete";
    document.forms['myBathroomForm'].submit();
  }
}
function showForm(showFormId, hideFormId, checkId) {
  document.getElementById(hideFormId).style.display="none";
  document.getElementById(showFormId).style.display="inline";
  document.getElementById(checkId).checked=true;
}
function verifyEmailAddress(formObj) {
  if (formObj.recipient.value.indexOf('@') > 0) {
    return true;
  }
  else {
    alert("Please enter a valid email address for the recipient");
    return false;
  }
}
function addBathroomProduct(bathroomProductFormId, newBathroomFormId, goBtnObj, createBtnId) {
  var bathroomProductFormObj = document.getElementById(bathroomProductFormId);
  if (bathroomProductFormObj.my_bathroom_list.selectedIndex == 0) {
    goBtnObj.style.display = 'none';
    document.getElementById(createBtnId).style.display = 'inline';
    openTechTable(newBathroomFormId);
  }
  else {
    bathroomProductFormObj.mb_bathroom_serialno.value = bathroomProductFormObj.my_bathroom_list[bathroomProductFormObj.my_bathroom_list.selectedIndex].value;
    bathroomProductFormObj.submit();
  }
}
function swapBathroomForm(bathroomListObj, newBathroomFormId, goBtnId, createBtnId) {
  if (bathroomListObj.selectedIndex == 0) {
    document.getElementById(newBathroomFormId).style.display = 'inline';
    document.getElementById(goBtnId).style.display = 'none';
    document.getElementById(createBtnId).style.display = 'inline';
  }
  else {
    document.getElementById(newBathroomFormId).style.display = 'none';
    document.getElementById(goBtnId).style.display = 'inline';
    document.getElementById(createBtnId).style.display = 'none';
  }
}
function swapFormValue(formFieldObj, eventType, formValue) {
  if (eventType == "onblur") {
    if (formFieldObj.value == '') {
      formFieldObj.value = formValue;
    }
  }
  else {
    if (formFieldObj.value == formValue) {
      formFieldObj.value = '';
    }
  }
}
function createBathroomForProduct(newBathroomFormId, bathroomProductFormId, bathroomNameId) {
  var bathroomProductFormObj = document.getElementById(bathroomProductFormId);
  for (var i = 0; i < bathroomList.length; i++) {
    if (bathroomList[i] == document.getElementById(newBathroomFormId).value) {
      alert("Already a bathroom with that name, please use a different name");
      return false;
    }
  }
  if ((document.getElementById(newBathroomFormId).value == '') || (document.getElementById(newBathroomFormId).value == 'Bathroom Name')) {
    alert("Please enter a name for your bathroom");
    return false;
  }
  document.getElementById(bathroomNameId).value = document.getElementById(newBathroomFormId).value;
  return true;
}
function verifyMyBathroom(myBathroomFormObj) {

  if (myBathroomFormObj.bathroom_action.value == 'add') {
    for (var i = 0; i < bathroomList.length; i++) {
      if (bathroomList[i] == myBathroomFormObj.mb_name.value) {
        alert("Already a bathroom with that name, please use a different name");
        return false;
      }
    }
    if ((myBathroomFormObj.mb_name.value == '') || (myBathroomFormObj.mb_name.value == 'Bathroom Name')) {
      alert("Please enter a name for your bathroom");
      myBathroomFormObj.bathroom_action.value = "";
      return false;
    }
  }
  else {
    for (var i = 0; i < bathroomList.length; i++) {
      if (bathroomList[i] == myBathroomFormObj.mod_mb_name.value) {
        alert("Already a bathroom with that name, please use a different name");
        return false;
      }
    }
    if (myBathroomFormObj.mod_mb_name.value == '') {
      alert("Please enter a name for your bathroom");
      myBathroomFormObj.bathroom_action.value = "";
      return false;
    }
  }
  return true;
}
function saveBathroomProduct(bathroomProductFormObj) {
  bathroomProductFormObj.mb_bathroom_serialno.value = bathroomProductFormObj.my_bathroom_list[bathroomProductFormObj.my_bathroom_list.selectedIndex].value;
  return true;
}
function openHelp(helpLayerId) {
  if (document.getElementById(helpLayerId).style.display == 'none') {
    document.getElementById(helpLayerId).style.display = 'inline';
  }
  else {
    document.getElementById(helpLayerId).style.display = 'none';
  }
}