/* javascript for jexamples.com pages */

var savedAnchorValues;

function removeLineNos() {
   if (savedAnchorValues != null && savedAnchorValues.length > 0) {
       return;
   }
   var anchors = getAnchors();
   //var inputElt;
   savedAnchorValues = new Array(anchors.length);
   for (i = 0; i < anchors.length; i++) {
       if ((anchors[i].className == "ln") || (anchors[i].className == "ln_hit")) {
           savedAnchorValues[i] = anchors[i].firstChild.data;
           anchors[i].removeChild(anchors[i].firstChild); // remove lineNo
       }
   }
}

function restoreLineNos() {
   if (!(savedAnchorValues && savedAnchorValues.length > 0)) {
       return;
   }
   var txt;
   var anchors = getAnchors();
   for (i = 0; i < anchors.length; i++) {
      if ((anchors[i].className == "ln") || (anchors[i].className == "ln_hit")) {
           txt = document.createTextNode(savedAnchorValues[i]);
           anchors[i].appendChild(txt);
       }
   }
   savedAnchorValues = null;
}

function getAnchors() {
    if (navigator.appName.indexOf("Microsoft") != -1)
        return document.anchors;
    else
        return document.getElementsByTagName("a");
}

function cookiesEnabled() {
    document.cookie = "testcookie=val";
    return (document.cookie.indexOf("testcookie") != -1);
}

function checkNotEmpty(field) {
    var fldElt = document.getElementById(field);
    if (fldElt.value == "") {
        document.getElementById("emptyQryMsg").style.display = "inline";
        return false;
    }
    document.getElementById("emptyQryMsg").style.display = "none";
    return true;
}

var _console = null;
function Debug(msg) {
   if ((_console == null) || (_console.closed)) {
       _console = window.open("", "console", "width=600,height=300,resizable");
       _console.document.open("text/plain");
   }
   _console.focus();
   _console.document.writeln(msg);
}
