// Simons funky cookie functions
		
		function setCookie(name, value, expires, path, domain, secure) {
      var curCookie = name + "=" + escape(value) +
    	  ((expires) ? "; expires=" + expires.toGMTString() : "") +
    	  ((path) ? "; path=" + path : "") +
    	  ((domain) ? "; domain=" + domain : "") +
    	  ((secure) ? "; secure" : "");
      document.cookie = curCookie;
    }
    
    function getCookie(name) {
      var dc = document.cookie;
      var prefix = name + "=";
      var begin = dc.indexOf("; " + prefix);
      if (begin == -1) {
    	begin = dc.indexOf(prefix);
    	if (begin != 0) return null;
      } else
    	begin += 2;
      var end = document.cookie.indexOf(";", begin);
      if (end == -1)
    	end = dc.length;
      return unescape(dc.substring(begin + prefix.length, end));
    }
    
    function deleteCookie(name, path, domain) {
      if (getCookie(name)) {
    	document.cookie = name + "=" + 
    	((path) ? "; path=" + path : "") +
    	((domain) ? "; domain=" + domain : "") +
    	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
      }
    }

    // date - any instance of the Date object
    // * hand all instances of the Date object to this function for "repairs"
    function fixDate(date) {
      var base = new Date(0);
      var skew = base.getTime();
      if (skew > 0)
    	date.setTime(date.getTime() - skew);
    }
		
		///////////////////////////
		// Show Hide Version 2.0 //
		///////////////////////////
		
		var showHideActivated = "";
		var showHideGroupRegistry = "";   
		var showHideWrapperRegistry = "";
		
		// Register (collect) the name of a new show hide group in the page
		// newGroup :: showHide_{groupName}
		
		function showHideRegisterGroup(newGroup){
		  showHideGroupRegistry = showHideGroupRegistry + newGroup + ",";
		}
		
		// Register (collect) the name of a new show hide wrapper in the page
		// newWrapper :: showHide_{groupName}_{groupIndex}
		
		function showHideRegisterWrapper(newWrapper){
		  showHideWrapperRegistry = showHideWrapperRegistry + newWrapper + ",";
		}
		
		// Let showHide know that the page has loaded
		
		function showHideActivate(){
			showHideActivated = "activated";
			showHideDisplayAll();
		}
		
		// Set display of all groups
		
		function showHideDisplayAll(){
  		ASV_showHideGroupRegistry = showHideGroupRegistry.split(",");
		  for(j=0; j<((ASV_showHideGroupRegistry.length)-1); j++){
			  showHideSetDisplay(ASV_showHideGroupRegistry[j]);
			}
		}
		
		// Set showHide cookie to remember the state of this group
		
		function showHide_hide(showHideGroup){
		  // JS_debug("hiding " + showHideGroup);
			// JS_debug("showHideState = " + showHideState);
		  if(showHideActivated == "activated"){
				setCookie("showHide_" + showHideGroup,"none");
			  showHideSetDisplay("showHide_" + showHideGroup);
			}
		}
		
		// Set showHide state cookie of group to show
		
		function showHide_show(showHideGroup){
		  // JS_debug("showing " + showHideGroup);
		  if(showHideActivated == "activated"){
				setCookie("showHide_" + showHideGroup,"");
			  showHideSetDisplay("showHide_" + showHideGroup);
			}
		}
		
		// Loop through groups registry, applying groups show hide setting to each of the groups wrapper
		
		function showHideSetDisplay(showHideGroup){
		
		  showHideState = getCookie(showHideGroup);
			
			if(showHideState == null) { showHideState = ""; }
			if(showHideState == "") { alt_showHideState = "none"; } else { alt_showHideState = ""; }
						
			// JS_debug("showHideGroup = " + showHideGroup);
			// JS_debug("showHideState = " + showHideState);
			// JS_debug("showHideWrapperRegistry = " + showHideWrapperRegistry);
			
		  ASV_showHideWrapperRegistry = showHideWrapperRegistry.split(",");
			// JS_debug("ASV_showHideWrapperRegistry.length = " + ASV_showHideWrapperRegistry.length);
			// JS_debug("");
			for(i=0; i<((ASV_showHideWrapperRegistry.length)-1); i++){
			
				// JS_debug("ASV_showHideWrapperRegistry["+i+"].substr(0,showHideGroup.length) = " + ASV_showHideWrapperRegistry[i].substr(0,showHideGroup.length+1));
				
			    // make sure this element belongs to the group in question
				if(ASV_showHideWrapperRegistry[i].substr(0,showHideGroup.length+1) == showHideGroup+"_"){
				
				  // JS_debug("### wrapper = " + ASV_showHideWrapperRegistry[i]);
				  // JS_debug("### showHideState = " + showHideState);
								
  			      target = document.getElementById(ASV_showHideWrapperRegistry[i]);
  			      if (!target) {
  			          continue;
  			      }
    			  target.style.display = showHideState;
					
  				  if(document.getElementById(ASV_showHideWrapperRegistry[i] + "_alt")){
  				      alt_target = document.getElementById(ASV_showHideWrapperRegistry[i] + "_alt");
  					  alt_target.style.display = alt_showHideState;
  				  }
						
				}	
				
			}
			// JS_debug("");
		}
		
		function JS_debug(msg){
		  debug_window = document.getElementById("JS_debug");
			debug_window.value = debug_window.value + msg + "\n";
		}