    /**
     * Functions used by the 'Conference' pages to generate the 'side navigation' area
     * and to manage session state (as needed), especially regarding user (individual homeschoolers,
     * volunteers, and conference speakers/exhibitors) authentications.
     */

    var SethsaCookieName = 'sethsa.org-Exhibitor';
    function getExhibitorCookie(which)
    {
        var start; var end;
        if (document.cookie.length > 0) {
           start = document.cookie.indexOf(which + "=");
           if (start != -1) { 
              start = start + which.length + 1; 
              end = document.cookie.indexOf(";", start);
              if (end == -1) end = document.cookie.length;
              return unescape(document.cookie.substring(start, end));
           } 
        }
        return "";
    }


    function setExhibitorCookie(which, exhibitor, expiredays)
    {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = which + "=" + escape(exhibitor) + ((expiredays == null) ? "" : (";expires=" + exdate.toGMTString()));
    }


    function ifAuthenticated(pgUrl)
    {
        var target = 'exLogin.htm';
        var exhibitor = getExhibitorCookie(SethsaCookieName);
        if (exhibitor != null && exhibitor != '') {
           target = pgUrl;
        }
        return document.location.replace(target);
    }


    function authenticateWith(code)
    {
        var codeIsOK = false;
        var validActivationCodes = 'H24B10U|h24b10u';// coord chgs to codes list with comparison below...
        var exhibitor = document.getElementById(code).value;

        if (exhibitor != null && exhibitor != '') {
           if (validActivationCodes.indexOf('|') != -1 && exhibitor.length >= 5) {
              codeIsOK = (validActivationCodes.match(exhibitor+'|') == exhibitor) || (validActivationCodes.match('|'+exhibitor) == exhibitor);
           } else if (validActivationCodes == exhibitor) {
              codeIsOK = true;
           }
        }

        if (codeIsOK == true) {
           setExhibitorCookie(SethsaCookieName, exhibitor, 180);
           document.location.replace('exInformation.htm');
        } else {
           alert('This is not a recognized activation code.  Please verify and re-enter.');
        }
    }


    function getSpanContentFor(id)  // note: in addition to generating inline, actual/separate invocation of 'includeContent' required initially
    {
        var tn = "script";	// note: cannot inline into following statement w/o causing display/interpretation issues
        return "<span id=\"" + id + "\">&nbsp;</span><" + tn + " language=\"javascript\">includeContent(\"" + id + "\",\"" + id + ".htm\");</" + tn + ">";
    }
    

    function showSideNavFor(navViewAs)
    {
      if (navViewAs != null) {
        var navSideBar = document.getElementById('navSideBar');
        var navChoice  = navViewAs.value;
    
        if (navSideBar == null)
    	    alert('navSideBar not accessible');

        navViewAs.blur();

        if (navChoice == 'attendee') {
	    navSideBar.innerHTML = 
    		"<table width=100%><tr><td>"
    			+ getSpanContentFor("navConf2010") + "</td></tr><tr><td><hr/></td></tr><tr><td>"
    			+ getSpanContentFor("navConf2009") + "</td></tr><tr><td><hr/></td></tr><tr><td>"
    			+ getSpanContentFor("navConf2008") + "</td></tr></table>";
	    includeContent('navConf2010','navConf2010.htm');
	    includeContent('navConf2009','navConf2009.htm');
	    includeContent('navConf2008','navConf2008.htm');
        } else if (navChoice == 'exhibitor') {
	    navSideBar.innerHTML = 
    		"<table width=100%><tr><td>" + getSpanContentFor("navExhConf2010") + "</td></tr></table>";
            var exhibitor = getExhibitorCookie(SethsaCookieName);
            if (exhibitor == null || exhibitor == '')
               includeContent('navExhConf2010','navProspExhConf2010.htm');
            else
	       includeContent('navExhConf2010','navExhConf2010.htm');
        } else if (navChoice != '') {
	    navSideBar.innerHTML = 
    		"No special info available for " + navChoice;
        }
      }
    }


    function showSideNav()
    {
        var navViewAs  = document.getElementById('navViewAs');
        showSideNavFor(navViewAs);
//        showSideNavFor(navViewAs.options[navViewAs.selectedIndex]);
    }