menu_status = new Array();
function setTertiaryNavState(id){
    if (document.getElementById) {
        var topId = "top" + id;
        var subId = "sub" + id;

        var top = document.getElementById(topId);
        var sub = document.getElementById(subId);
        
        if (top != null) { // does top level exist?
            if (sub != null) { // does sub level exist?
                if (top.className != 'tertMenu_Arrow_on') {
                   top.className = 'tertMenu_Arrow_on';
                } else {
                   top.className = 'tertMenu_Arrow';
                }
                
                if (menu_status[subId] != 'show') {
                   sub.className = 'show';
                   menu_status[subId] = 'show';                   
                } else {
                   sub.className = 'hide';
                   menu_status[subId] = 'hide';
                }
            } else { // No submenu
                if (top.className != 'tertMenu_on') {
                   top.className = 'tertMenu_on';
                } else {
                   top.className = 'tertMenu';
                }
            }
        }
    }
}

var secs
var timerID = null
var timerRunning = false
var delay = 1000
var filename 

function InitializeTimer()
{        
    // Set the length of the timer, in seconds
    secs = 2
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        window.location = filename;
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function fieldAdvance( e, ctrlid, ctrlIdToFocus, ctrlidprev ) 
{
    //event codes values
    //9 = tab
    //16 = shift + tab
    //37 = left arrow
    //39 = right arrow
    //13 = enter button
    //if none of these keys are pressed then go inside the if and proceed
    
    var myKeyCode
    
    if ( e.which != null)
        myKeyCode = e.which;
    else
        myKeyCode = e.keyCode;
    
    if ( myKeyCode != 9 && myKeyCode != 16 && myKeyCode != 37 && myKeyCode != 39)
    {   
        //keycode 8 = backspace
        //if the backsapce was not pressed check the length of the textbox and go forward
        if ( myKeyCode != 8 )
        {
            var ctrlToFocus = document.getElementById( ctrlIdToFocus );       
            if ( document.getElementById( ctrlid ).value.length == document.getElementById( ctrlid ).maxLength ) 
            {
                ctrlToFocus.focus();   
                ctrlToFocus.value = ctrlToFocus.value;         
            }
        }
        //if the backspace was pressed check the lenght of the textbox and go backwards
        else
        {
            var ctrlToFocus = document.getElementById( ctrlidprev ); 
            if ( document.getElementById( ctrlid ).value.length == 0 ) 
            {
                ctrlToFocus.focus();
                ctrlToFocus.value = ctrlToFocus.value;
            }
        }    
    }
}    

function ValidateNumbers(e)
{
    if (e.which != null)
    {
        //mozilla
        //do not allow anything but numbers
        if ( (e.which < 48 || e.which > 57) && e.which != 8 && e.which != 0 && e.which != 13 )
        {
            e.preventDefault(); 
        }
    }
    else
    {
        //ie
        //do not allow anything but numbers
        if ( (e.keyCode < 48 || e.keyCode > 57) && e.keyCode != 13 )
        {       
            e.keyCode = 0;
        }
    }
}