<!-- Hide

//***************************
// Declare global variables

var childWindow = null;
var childWindow_closed = false;
var args = new Array();
var userid_check
var basehref = "http://cip.loc.gov/cipman/";

// Creates new screen after adding "~userid" to URL, for cgi pgms
function new_window(linkhref)
{                            
   linkhref += "~" + args[2];
   window.location=linkhref; 
}

// Creates new screen with known args                                           
function new_window2(linkhref)                                                  
{                                                                               
   window.location=linkhref;                                                    
}                                                                               
                                                                                
// Creates new screen after adding "&userid=..." to URL, for plsql pgms
function new_window_ora(linkhref)
{                            
   linkhref += "&userid=" + args[2];
   window.location=linkhref; 
}
                                                                   
// set new url with userid parameter                               
function next_window(linkhref)                                     
{                                                                  
   var result = linkhref.search(/userid=/);                        
   if (result != -1)                 // function called by plsql   
   {                                                               
     window.location = basehref + linkhref;                        
   }                                                               
   else                              // function called by html    
   {                                                               
     window.location = basehref + linkhref + "?userid=" + args[2]; 
   }
}

function set_userid()
{
/*  2 types of links to extract account from
      1. Chuck's cgi-bin links
         "~account" is 3rd parameter in href substring
      2. ORACLE links
         "?userid=account" is href substring
*/                                                                               
   var query = location.search.substring(1);  // Get query string from href
   var result = query.search(/userid=/);
   if (result != -1)
   {
      args = query.split("=");		// Break query string into separate parameters
	  args = args[1].split("&");	// Break args[1] string into separate parameters
	  args[2] = args[0];			// Move account into args[2]
   }
   else
   {
      args = query.split("~");  	// Break query string into separate parameters
                                	// Account is 3rd parm - will be in args[2]
   }
   var acctexp = /^c[a-z]{2}\d{5}$/;
   if (!(acctexp.test(args[2])) && (args[2] != "cipadmin") && (args[2] != "cipmgt"))                                                                            
   {                                                                            
	  alert("You are not properly signed on!");
	  window.location.replace(basehref);
   }   
}

function update_links()
{
/*  2 types links
      1. Chuck's cgi-bin links
         Add "~account" as 3rd and last argument
      2. ORACLE links
         Add "?userid=account" as last argument
*/
   if (userid_check != "completed")
   {
      userid_check = "completed";
      set_userid();
      for(var i = 0; i < document.links.length; i++)
      { 
		var result = document.links[i].href.search(/\?/);
		if (result != -1)
		{
           	document.links[i].href += "~" + args[2];
       	}
       	else
       	{
			if (document.links[i].hash != "")
			{
				var hrefpath = document.links[i].href.split("#");
				document.links[i].href = hrefpath[0] + "?userid=" + args[2] + "#" + hrefpath[1];
			}
			else { document.links[i].href += "?userid=" + args[2]; }
       	}
      }
   }
}

function load_default()
{
  form = document.forms[0];     
  form.reset();
  form.elements[0].focus();
  var query = location.search.substring(1);
  var arrayQry = new Array();           //array of name and value pairs
  var query_pair = new Array();         //two elements of a pair
  var query_name = new Array();         //array of query names
  var query_value = new Array();        //array of query values

  arrayQry = query.split("&");          	  //array of name and value pairs
  for (var i=0; i < arrayQry.length; i++)     // build name and value arrays
  {
    query_pair = arrayQry[i].split("=");
    if (query_pair[0] == "userid")  {
        args[2] = query_pair[1];              // args[2] is used in other func
                                              // as value of userid
        form.account.value = args[2];
    }

    query_name[i] = query_pair[0];
    query_value[i] = query_pair[1];
  }

   var acctexp = /^c[a-z]{2}\d{5}$/;
   if (!(acctexp.test(args[2])) && (args[2] != "cipadmin") && (args[2] != "cipmgt"))
   {
          alert("You are not properly signed on!");
          window.location.replace(basehref);
   }

  for (var k=0; k < form.elements.length; k++)  //match field name w array
  {
    for (var i=0; i < arrayQry.length; i++)
    if (form.elements[k].name == query_name[i]) {
        form.elements[k].value = unescape(query_value[i]);
	break;
    }
  }
} //load_default()

// **************************************************************
// Window functions

function new_childwin(htmlfile, width_height, field)
{
	close_childwin();
	childWindow = window.open(htmlfile, 'ChildWindow', width_height);
	childWindow.opener = self;
	if (childWindow_closed == true) {
        childWindow_closed = false;
	}
	window.onerror = error_handler;
	childWindow.moveTo(20,20);
}//new_childwin(htmlfile, width_height, field)

function return_new(htmlfile, windowname, width_height)
{
	self.opener.return_new_childwin(htmlfile, windowname, width_height);
	self.close();
}//return_new(htmlfile, windowname, width_height)

function return_new_childwin(htmlfile, windowname, width_height)
{
	childWindow = window.open(htmlfile, windowname, width_height);
	childWindow.opener = self;
	window.onerror = error_handler;
	childWindow.moveTo(20,20);
}//return_new_childwin(htmlfile, windowname, width_height)

function close_childwin()
{
    if (childWindow != null) {
        if (childWindow_closed == false) {
            childWindow_closed = true;
            childWindow.close();
        }
    }
}//close_childwin()

function error_handler()
{	
	return true;
}//error_handler	

// **************************************************************
// Netscape Navigator 4.xx resize fix

function MM_reloadPage(init)
{  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// Unhide -->

