﻿function PressedEnter(e) {
    if (e.keyCode == 13) {
        document.forms[0].submit();
    }
}
function ClearSearchBox(obj, IsFocus) {
    if (((obj.value == 'Search our archive since 1989 for free') || (obj.value == 'Search our archive of 1.5 million stories')) && (IsFocus == 1)) {
        obj.value = '';
    }
    if ((obj.value == '') && (IsFocus == 0)) {
        obj.value = 'Search our archive since 1989 for free';
        //obj.value = 'Search our archive of 1.5 million stories';
    }
}

/* The "nav" functions below cause the top-nav / sub-nav magic to happen */

var DefaultNav = '1';
var TimerIdArray = new Array();
var TimerIdCount = 0;

function ShowDefSubNav() {   //show the default subnav, in one second (sets a timer)
    TimerIdArray[TimerIdCount++] = self.setTimeout("tab(DefaultNav)", 1000);
}
function ClearTimeOuts() {   //because of the <a> tags in the subnav div's, there are multiple "onmouseout" events that fire, and 
    //therefore, multiple timers are set. This keeps track of the potentially multiple "ShowDefSubNav"
    //functions that are waiting to fire off.
    for (var i = 0; i < TimerIdCount; i++) {
        clearTimeout(TimerIdArray[i]);
    }
}
function tab(item) {
    if (document.getElementById) {
        if (arguments.length > 1) {
            DefaultNav = item;
        }
        if (item == 'out') {
            ShowDefSubNav();
        }
        else {
            //first, get rid of any pending "ShowDefSubNav" functions that may be waiting to fire off.
            ClearTimeOuts();

            //now, grab all the <li> tags that are in the "topnav" td
            var NavLis = document.getElementById('navdiv').getElementsByTagName('ul')[0].getElementsByTagName('li');

            //now, loop through them.
            for (var i = 0; i < NavLis.length; i++) {   //if this is the item that was actually moused over... and it's not the "spacer" between main nav and classifieds...
                if (1 == 1) // (i != 13) // removed spacer because there are so many tabs now... want to keep the logic here in case it's needed
                {
                    if (i == (item - 1)) {   //then give it the highlighted style, and show its subnav div.
                        if (NavLis[i].dir != 'ltr')
                            NavLis[i].className = 'on';
                    } else {
                        //check to see if the "off" style is "classifieds red" or not.
                        if (NavLis[i].dir != 'ltr')
                            NavLis[i].className = '';
                    }
                }
            }
        }
    }
}
