//these functions are 'global' to the application (well almost global)

    function homeMouseOver(cell) {
        cell.style.cursor = 'pointer'
    }

    function homeMouseOut(cell) {
        cell.style.cursor = 'auto'
    }

    function hideLayer(div){
	   switch (strBrowserType) {
	       case "IE" :
		      parent.main.document.all[div.id].style.visibility="hidden"
		      break
	       case "Netscape" :
		      parent.main.document.getElementById[div.id].style.visibility="hidden"
		      break
	   }
    }

    function showLayer(div){
	   switch (strBrowserType) {
	       case "IE" :
		      parent.main.document.all[div.id].style.visibility="visible"
		      break
	       case "Netscape" :
		      parent.main.document.getElementById[div.id].style.visibility="visible"
		      break
	   }
    }

    function printResultsPage(extraframe){
        if (document.form1.strClicked) {
            if (document.form1.strClicked.value == 'Find'){
                if (extraframe=='true')
                {
                    parent.parent.footer.focus()
                    parent.parent.footer.print()
                } else
                {
                    parent.footer.focus()
                    parent.footer.print()
                }
            }else{
                alert("Please click on 'Find' before printing.")
            }
        }
    }

    function checkAccess(strhref, strSecurityLevel, strTarget){
        if (strSecurityLevel == 'Access Denied'){
            alert("You do not have the necessary permissions to open this screen.")
        }else{
            switch (strTarget){
                case "main_layout":
                    parent.main_layout.location.href = strhref
                    break
                case "menu":
                    parent.menu.location.href = strhref
                    break
            }
        }
    }

    function check_Readonly(chkBox){
        if (chkBox.checked == false){
            chkBox.checked = true
        }else{
            chkBox.checked = false
        }
    }

    function allowChars(evt, allowedChars) {
	   evt = (evt) ? evt : event;
	   var charCode = (evt.charCode) ? evt.charCode :
       ((evt.which) ? evt.which : evt.keyCode);
       var valid=(allowedChars.indexOf(String.fromCharCode(charCode))!=-1);
	   var Ret
	   if (parseInt(charCode) < 32) {
		      Ret = true
	   }else{
	       if(!valid){
		      evt.keycode=0;
		      Ret = false
	       }
	   }
	   if (Ret != false){
            promptSave()
	   }
	   return Ret
    }

    function promptSave(){
        
        try
        {
            if (parent.navbar.document)
            {            
                if (document.getElementById("boolReadOnly").value =='False' )
                {        
                    if (document.forms[0].boolHasChanged.value == "false"){
                        parent.navbar.document.forms[0].btnSave.className = "newpromptbuttons"
                        document.forms[0].boolHasChanged.value = true
                    }
                }
            }
        }     
        catch(error)
        {
        }
    }

    function promptBtn(btnName) {
        try {
            if (document.getElementById("boolReadOnly").value == 'False') {
                        btn=document.getElementById(btnName)
                        btn.className = "newpromptbuttons"
                    }                    
            }
        catch (error) {
        }
    }

    function replaceQueryString(strWholeString){
        strWholeString = strWholeString.replace('&', '%26')
        return strWholeString
    }

    function getScreenHeight() {

        var myHeight = 0;
        if (typeof (window.innerWidth) == 'number') {
            //Non-IE             
            myHeight = window.innerHeight;
        } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            //IE 6+ in 'standards compliant mode'             
            myHeight = document.documentElement.clientHeight;
        } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
            //IE 4 compatible             
            myHeight = document.body.clientHeight;
        }

        return myHeight
    }

    // auto save functions to be used in the new pages that need it
    // to use this the form needs hidden variable 'boolReadOnly' and a save button called 'btnSave'
    var intAutoSaveTimerID = 0

    function startAutoSaveTimer() {
        if (intAutoSaveTimerID != 0) {
            clearTimeout(intAutoSaveTimerID);
        }

        if (document.getElementById("boolReadOnly").value == "False") {
            intAutoSaveTimerID = setTimeout("autoPostbackSave();", (1000 * 60 * 19));
        }
    }

    function autoPostbackSave() {
        if (document.getElementById("btnSave")) {
            if (document.getElementById("btnSave").className == "newpromptbuttons") {
                document.getElementById("btnSave").click()
            } else {
                __doPostBack('__Page', '');
            }
        }
    }
    
    // function used to strip out script tags from any text boxes before postback
    // used when event validation is switched off
    function clearHtmlTags() {
        for (var i = 0; i < document.forms[0].elements.length; i++) {
            if (document.forms[0].elements[i].type == "text" || document.forms[0].elements[i].type == "textarea") {
                if (document.forms[0].elements[i].value.indexOf("<") >= 0) {
                    do {
                        document.forms[0][i].value = document.forms[0].elements[i].value.replace("<%", "")
                    }
                    while (document.forms[0].elements[i].value.indexOf("<") >= 0);
                }

                if (document.forms[0].elements[i].value.indexOf(">") >= 0) {
                    do {
                        document.forms[0][i].value = document.forms[0].elements[i].value.replace("%>", "")
                    }
                    while (document.forms[0].elements[i].value.indexOf(">") >= 0);
                }

                if (document.forms[0].elements[i].value.indexOf("&#60") >= 0) {
                    do {
                        document.forms[0][i].value = document.forms[0].elements[i].value.replace("&#60", "")
                    }
                    while (document.forms[0].elements[i].value.indexOf("&#60") >= 0);
                }

                if (document.forms[0].elements[i].value.indexOf("&#62") >= 0) {
                    do {
                        document.forms[0][i].value = document.forms[0].elements[i].value.replace("&#62", "")
                    }
                    while (document.forms[0].elements[i].value.indexOf("&#62") >= 0);
                }

                if (document.forms[0].elements[i].value.indexOf("&#x3C") >= 0) {
                    do {
                        document.forms[0][i].value = document.forms[0].elements[i].value.replace("&#x3C", "")
                    }
                    while (document.forms[0].elements[i].value.indexOf("&#x3C") >= 0);
                }

                if (document.forms[0].elements[i].value.indexOf("&#x3E") >= 0) {
                    do {
                        document.forms[0][i].value = document.forms[0].elements[i].value.replace("&#x3E", "")
                    }
                    while (document.forms[0].elements[i].value.indexOf("&#x3E") >= 0);
                }

            }
        }

        return true;
    }

    window.onbeforeunload = function(e) {

        // this bit I added to check whether or not to prompt
        if ((document.getElementById("btnSave")) && (document.getElementById("hidUnloadPrompt"))) {
            if ((document.getElementById("btnSave").className == "newpromptbuttons") && (document.getElementById("hidUnloadPrompt").value == "True")) {
                /// this bit does the prompt... somehow
                var e = e || window.event;
                // For IE and FireFox
                var value = "You will lose your unsaved changes."
                if (e) {
                    e.returnValue = value;
                }

                // For Safari
                return value;
            }
        }
    }

   function promptUnsaved(CustomMsg) {
       var value = true;
       if (document.getElementById("btnSave")) {
           if (document.getElementById("btnSave").className == "newpromptbuttons") {
               if ((!CustomMsg) || (CustomMsg == "")) {
                   CustomMsg = "Are you sure you want to navigate away from this record?"
               } 
               if (confirm(CustomMsg + "\n\nYou will lose your unsaved changes.\n\nPress OK to continue, or Cancel to stay on the current record.") == false) {
                  value =false;
               }              
           }
       }
       return value;
   }

   function promptDDLUnsaved(DDL, hidIDName) {
       var value = true;
             
       if (document.getElementById("btnSave")) {
           if (document.getElementById("btnSave").className == "newpromptbuttons") {
               if (confirm('Are you sure you want to navigate away from this record?\n\nYou will lose your unsaved changes.\n\nPress OK to continue, or Cancel to stay on the current record.') == false) {
                   value = false;
                   hidID = document.getElementById(hidIDName);
                   DDL.value = hidID.value                    
               }
           }
       }
       return value;
   }

   function addOption(selectbox, text, value) {
       var optn = document.createElement("OPTION");
       optn.text = text;
       optn.value = value;
       selectbox.options.add(optn);
   }

