/*
***********************************************************
Title:			main.js
Author: 		J. Jackson, JPL
Created: 		12.19.2008
Modified: 		12.19.2008
***********************************************************
*/

jQuery(document).ready(function(){
  jQuery('ul#main_nav').superfish(); // initialize horizontal menu
  jQuery("ul#main_nav ul").append("<span></span>"); // creates & appends span to each sub nav list
  jQuery('input#ctl00_search_input').focus(function() { jQuery(this).select() }); // highlight search value on focus
  if ( jQuery('span#ctl00_TitleLabel').html().length == 0 ) { jQuery('span#ctl00_TitleLabel').css('display','none') } // if .NET generated span is empty, hide it
});

/* function for expand/collapse */

function showHide() {
    function showHide(cid) {
	    var ContentID = cid.replace("yellowBarAccordion","accordionContent");
        if (document.getElementById(ContentID).style.display == "none" || document.getElementById(ContentID).style.display == "") {
  	      document.getElementById(ContentID).style.display = "block";                                  
          document.getElementById(cid).className = "accordion_header_active";
        } else {
			document.getElementById(ContentID).style.display = "none";
            document.getElementById(cid).className = "accordion_header";
        }
    }

	function countContainers(header) {                                    
        i = 0;
        while(document.getElementById(header + i)) { i++; }
        return i;
    }

    var ContainerListeners = countContainers("yellowBarAccordion");
    if (ContainerListeners > 0) {
        var i = 0;
        var arrContainerListners = new Array();

        while(i < ContainerListeners) {
			var temp = document.getElementById('yellowBarAccordion'+i);
			temp.onclick = function() {
				showHide(this.id);
				return false;
    	    }
        	i++;
		}
	}
}

/* fix for ie6-only bug - horizontal menu & select menus */
jQuery(document).ready(function(){
	if ( jQuery.browser.msie && jQuery.browser.version =="6.0" ) {
		
		jQuery("li#nav_agents,li#nav_employers").hover(
			function () { jQuery('#pg_content select').css('visibility','hidden') }, 
			function () { jQuery('#pg_content select').css('visibility','visible') }
		);

	}
});

