﻿function showSpinner(imageId) {
  if (document.getElementById(imageId) != null) {
    setTimeout('document.getElementById("' + imageId + '").src="images/spinner24.gif";', 100);
  }
}
function disableElement(elementId) {
  if (document.getElementById(elementId) != null) {
    setTimeout('document.getElementById("' + elementId + '").disabled=true;', 100);
  }
}
function showElement(elementId) {
  if (document.getElementById(elementId) != null) {
    document.getElementById(elementId).style.display = "block";
    //document.getElementById(elementId).style.visibility = "visible";
    //setTimeout('document.getElementById("' + elementId + '").style.display = "block";', 100);
    //setTimeout('document.getElementById("' + elementId + '").style.visibility = "visible";', 100);
  }
}
function hideElement(elementId) {
  if (document.getElementById(elementId) != null) {
    //document.getElementById(elementId).style.visibility = "hidden";
    document.getElementById(elementId).style.display = "none";
    //setTimeout('document.getElementById("' + elementId + '").style.display = "none";', 100);
    //setTimeout('document.getElementById("' + elementId + '").style.visibility = "hidden";', 100);
  }
}
function setValue(elementId, value) {
  if (document.getElementById(elementId) != null) {
    document.getElementById(elementId).value = value;
  }
}
function stopTimer(elementId) {
  var element = $find(elementId);
  if (element != null) {
    element._stopTimer();
  }
}
function startTimer(elementId) {
  var element = $find(elementId);
  if (element != null) {
    element._startTimer();
  }
}

function displayWindow(htmlId, width, height) {
  if (document.getElementById(htmlId) != null) {
    var htmlString = document.getElementById(htmlId).innerHTML;
    htmlString = htmlString.replace(/&gt;/g, ">");
    htmlString = htmlString.replace(/&lt;/g, "<");
    htmlString = "<html><body>" + htmlString + "</body></html>";
    myWindow = window.open("", "mywindow", "menubar=no,resizable=yes,toolbar=no,scrollbars=yes,width=" + width + ",height=" + height);
    myWindow.document.write(htmlString);
    myWindow.document.close();
  }
}

function showTyping() {
  changeTyping(false);
  if (document.getElementById('hfShowTyping') != null) {
    document.getElementById('hfShowTyping').value = "1";
  }
}

function hideTyping() {
  changeTyping(true);
  if (document.getElementById('hfShowTyping') != null) {
    document.getElementById('hfShowTyping').value = "0";
  }
}

function loadTyping() {
  if (document.getElementById("hfShowTyping") != null) {
    if (document.getElementById('hfShowTyping').value == "1") {
      changeTyping(false);
    }
    else {
      changeTyping(true);
    }
  }
}

function changeTyping(hide) {
  var inputs = document.getElementsByTagName("input");
  for (var i = 0; i < inputs.length; i++) {
    var id = inputs[i].getAttribute('id');
    if (id != null &&  id.length > 6 ) {
      if ((inputs[i].getAttribute('type') == 'text' && id.substring(0, 6) == "id_tx_") || (inputs[i].getAttribute('type') == 'password' && id.substring(0, 6) == "id_pw_")) {
        var name = inputs[i].getAttribute('name');
        var val = inputs[i].value;
        var idroot = id.substring(6, id.length);
        var cssclass = inputs[i].className;
        pwElement = document.getElementById(id);
        if (hide == true) {
          pwElement.parentNode.innerHTML = "<input type='password' value='" + val + "' id='id_pw_" + idroot + "' name='" + name + "' class='" + cssclass + "'/><a href='javascript:void(0)' onclick='showTyping()' id='hyShow' style='margin-left:10px'>Show Typing</a>"; ;
        }
        else {
          pwElement.parentNode.innerHTML = "<input type='text' value='" + val + "' id='id_tx_" + idroot + "' name='" + name + "' class='" + cssclass + "' /><a href='javascript:void(0)' onclick='hideTyping()' id='hyHide' style='margin-left:10px'>Hide Typing</a>"; ;
        }
      }
    }
  }
}

