//these functions are 'global' to the application (well almost global)

var menu_on  = 0
var menu_off = 1

var g_aMenuImages;
g_aMenuImages = new Array(2)

if (navigator.appName.indexOf("Netscape") != -1){
    strBrowserType = 'Netscape'
}else if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1){
    strBrowserType = 'IE'
}

RegisterImage(menu_on,"../../images/menu_over.gif")
RegisterImage(menu_off,"../../images/menu.gif")

function RegisterImage(nIndex,src){
    g_aMenuImages[nIndex] = new Image()
	g_aMenuImages[nIndex].src = src;
}

function SetImageFromCache(e, nIndex){
   e.background = g_aMenuImages[nIndex].src
}

function reimage(sImageURL){
    event.srcElement.src=sImageURL
}

function ButtonMouseOver(button){
    switch (button.className){
        case "buttons":
            button.className = "buttons_over"
            break;
        case "widebuttons":
            button.className = "widebuttons_over"
            break;
        case "extrawidebuttons":
            button.className = "extrawidebuttons_over"
            break;
        case "promptbutton":
            button.className = "promptbutton_over"
            break;
    }
}

function ButtonMouseOut(button){
    switch (button.className){
        case "buttons_over":
            button.className = "buttons"
            break;
        case "widebuttons_over":
            button.className = "widebuttons"
            break;
        case "extrawidebuttons_over":
            button.className = "extrawidebuttons"
            break;
        case "promptbutton_over":
            button.className = "promptbutton"
            break;
    }
}

imgMenu = new Image()
imgMenu.src = "../../images/menu.gif"
imgMenuOver = new Image()
imgMenuOver.src = "../../images/menu_over.gif"

function menuMouseOver(cell){
    cell.className = "menuitemselected"
    cell.style.backgroundImage = 'url(' + imgMenuOver.src + ')'
}

function menuMouseOut(cell){
    cell.className = "menuitem"
    cell.style.backgroundImage = 'url(' + imgMenu.src + ')'
}

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
   }
}

tabnum = new Image();
tabnum.src = "../../images/tabnum.gif";
tabnum_o = new Image();
tabnum_o.src = "../../images/tabnum_o.gif";

tabgraph = new Image();
tabgraph.src = "../../images/tabgraph.gif";
tabgraph_o = new Image();
tabgraph_o.src = "../../images/tabgraph_o.gif";

function TabMouseOver(tab, tabno)
{
    if (document.getElementById("intTabSel").value != tabno)
    {
        //tab.src = eval("tab" + tabno + "_o.src");
        tab.className = "tab_o"        
    }    
}

function TabMouseOut(tab, tabno)
{
    if (document.getElementById("intTabSel").value != tabno)
    {
        //tab.src = eval("tab" + tabno + ".src");
        tab.className = "tab"
    }
}

function printButtonMouseOver(button){                        
    //image.src = '../../images/print_button_o.gif'
    button.className = "tab_o"
    button.style.cursor = 'pointer'
}

function printButtonMouseOut(button){
    //image.src = '../../images/print_button.gif'
    button.className = "tab"
    button.style.cursor = 'auto'
}


function wordButtonMouseOver(button){
    button.className = "tab_o"
    button.style.cursor = 'pointer'
}

function wordButtonMouseOut(button){
    button.className = "tab"
    button.style.cursor = 'auto'
}

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 xButtonMouseOver(button){
    button.className = "tab_o"
    button.style.cursor = 'pointer'
}

function xButtonMouseOut(button){
    button.className = "tab"
     button.style.cursor = 'auto'
}

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(){
    if (parent.navbar.document)
    {
        try
        {
            if (document.forms[0].boolHasChanged.value == "false"){
                parent.navbar.document.forms[0].btnSave.className = "promptbutton"
                document.forms[0].boolHasChanged.value = true
            }
        }
        catch(error){}
    }
}

function replaceQueryString(strWholeString){
    strWholeString = strWholeString.replace('&', '%26')
    return strWholeString
}

if(window.attachEvent)
    window.attachEvent("onload",setListeners);

function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
        inputList[i].attachEvent("onpropertychange",restoreStyles);
        inputList[i].style.backgroundColor = "";
    }

    selectList = document.getElementsByTagName("SELECT");

    for(i=0;i<selectList.length;i++){
        selectList[i].attachEvent("onpropertychange",restoreStyles);
        selectList[i].style.backgroundColor = "";
    }
}

function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
        event.srcElement.style.backgroundColor = "";
}

// name:    homeMouseOver
// purpose: mouse over tab change cursor
function homeMouseOver(cell) {
    try{
        cell.style.cursor = 'pointer'
    }catch(e){
    
    }    
}   

// name:    homeMouseOut
// purpose: mouse out tab change cursor
function homeMouseOut(cell) {
    cell.style.cursor = 'auto'
}