$(document).ready(function(){
	
	 /* set rounded corners on all hdrbar elements */
		/*$("h2.hdrbar").each(function(){
                if($(this).is(".top")) {
                        $(this).corner("4px top").wrap('<div class="hdr-wrapper"></div>');
                } else {
                        $(this).corner("4px").wrap('<div class="hdr-wrapper"></div>');
                }
        });*/
		
     /* add on-state to menu item */
        $("ul.nav-submenu").find("a").each(function(){
	        if(location.href.indexOf(this.href) != -1) {
	            $(this).addClass("current").click(function() { return false; });
			}
        });
		
	/* set menu section to be closed unless it gets set below in the href search */
        var menuSection = -1;

        $("a.nav-topic").filter(function(index) {
                if ($(this).next("ul.nav-submenu").children("li").children().is("a.current")) {
                        // set the menu to open on this section; see after Accordion below -.activate(index)
                        menuSection = index;
                        return false;
                }
        });
		
	 /* vertical navigation only - accordion plugin */
        if(document.getElementById("nav")) {
            if($("#nav-menu ul.nav-submenu").length != 0) {
                $('#nav-menu').Accordion({
					active:false,
	                header:'.nav-topic',
					speed:'3500',
                    selectedClass:'selected',
					autoheight: false,
	                navigation:false,
					event: 'none',
					autoheight:false
                }).change(function(){
					if($("#nav-menu li a.selected").next("ul.nav-submenu").is(":visible")) {
						$("#nav-menu li a.selected").parent("li").addClass("highlight").siblings("li").removeClass("highlight");
					}
					else {
						$("#nav-menu li a").parent("li").removeClass("highlight");
					}
				}).activate(menuSection);
            }
            
            /*if($(".nav-topic-link").parent().is("#nav-menu")) {
                $("#nav-topic-link").click(function(){
                    if(window.opener && !window.opener.closed){
                        window.opener.focus(); 
                        window.close();
                    } else {
                        window.location = $(this).attr("href");
                    }
                    return false;
                });
            }*/
        }

	 /* generic accordion */
		/*if ($("dl").is(".accordion") && $("dl.accordion").children().length != 0){
			var accObj = $('dl.accordion').Accordion({
				active: '-1',
		        header: 'dt',
		        alwaysOpen: false
			}).filter(".rdcnr").children("dt").children("a").corner("4px top").wrap('<div class="hdr-wrapper"></div>');
		}*/

	 /* site search form box */
		var srchval = $("#searchbox").val();
        $("#searchbox").focus( function() {
                // test value to see if temp instruction text
                $(this).filter(function(){
                        return $(this).val() == srchval;
                }).val("");
                // highlight region bgrd
                $("#hd-srchbox").addClass("infocus");

                $("#searchbox").blur( function() {
                        $(this).filter(function(){
                                return $(this).val().length == 0;
                        }).val(srchval);
                        // restore region bgrd
                        $("#hd-srchbox").removeClass("infocus");
                });
        });
	
	 /* hz menu functions */
		/*function onAnimate(show) {
        	if (show) {
                $(this)
                    .css('visibility', 'hidden').fadeIn("fast")
                    .css('width', $(this).parent().innerWidth() + 20)
                        .hide().css('visibility', 'visible')
                    .fadeIn('normal');
        	} else {
                $(this).fadeOut('fast');
        	}
    	}*/

});