﻿
function navOver( oDiv, sPageSection, sNavSection ) {
    if ( sPageSection != sNavSection ) {
        oDiv.style.backgroundImage = 'url( "/images/nav/' + sPageSection + '/' + sNavSection + '_overbutton.png" )';
    }
}

function navOut( oDiv, sPageSection, sNavSection ) {
    if ( sPageSection != sNavSection ) {
        oDiv.style.backgroundImage = 'url( "/images/nav/' + sPageSection + '/' + sNavSection + '_button.png" )';
    }
}

function arrowOver( oImg, sName ) {
	oImg.src = '/images/' + sName + '_overarrow.png';
}

function arrowOut( oImg, sName ) {
	oImg.src = '/images/' + sName + '_arrow.png';
}

var SUBNAV_TOP_OFFSET = 32;
var g_iTimeoutId = null;
var g_sPrevSection = "";

$( function() {
    setBackground();
    $( "li.subnav_trig" ).hover( function() {
        $( this ).addClass( "nav_selected" );
        var offset = $( "#nav" ).offset();
        $( "#" + $( this ).attr( "id" ) + "_subnav" ).css( "top", offset.top + SUBNAV_TOP_OFFSET ).css( "left", offset.left ).show();
    }, function() {
        g_sPrevSection = $( this ).attr( "id" );
        g_iTimeoutId = setTimeout( function() {
                $( "#" + g_sPrevSection ).removeClass( "nav_selected" );
                $( "#" + g_sPrevSection + "_subnav" ).hide();
        }, 20 );
    } );
    $( "div.subnav" ).hover( function() {
        clearTimeout( g_iTimeoutId );
    }, function() {
        $( "#" + g_sPrevSection ).removeClass( "nav_selected" );
        $( this ).hide();
    } );
    $( "#q" ).focus( function() {
        if ( $( this ).val() == 'Search AFM' ) {
            $( this ).val( '' );
        }
    } ).blur( function() {
        if ( $( this ).val() == '' ) {
            $( this ).val( 'Search AFM' );
        }
    } );
} );
