// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999-2001. Permission granted to reuse and distribute.
// Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
// Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
//					 also added support for IE5.5 Opera4&5 HotJava3 AOLTV
// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, 
//					 correct Opera 5 detection
//					 add support for winME and win2k
//					 synch with browser-type-oo.js
// Revised 26 Mar 01 to correct Opera detection
// Revised 02 Oct 01 to add IE6 detection

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//	 is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
// (2) browser version number:
//	 is_major (integer indicating major version number: 2, 3, 4 ...)
//	 is_minor (float indicating full version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//	 is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
//	 is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
//	 is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
// (4) JavaScript version number:
//	 is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//	 is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
//	 is_os2
//	 is_mac, is_mac68k, is_macppc
//	 is_unix
//	 is_sun, is_sun4, is_sun5, is_suni86
//	 is_irix, is_irix5, is_irix6
//	 is_hpux, is_hpux9, is_hpux10
//	 is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//	 is_linux, is_sco, is_unixware, is_mpras, is_reliant
//	 is_dec, is_sinix, is_freebsd, is_bsd
//	 is_vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when new versions of browsers are released, so
// in conditional code forks, use is_ie5up ("IE 5.0 or greater") 
// is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
// to check version in code which you want to work on future
// versions.

var is_win, is_gecko, is_ie, is_ie4up, is_nav, is_nav6up, is_ie6up;


function ultiSniff()
{
	// convert all characters to lowercase to simplify testing
	var agt=navigator.userAgent.toLowerCase();

	// *** BROWSER VERSION ***
	// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);

	// Note: Opera and WebTV spoof Navigator. We do strict client detection.
	// If you want to allow spoofing, take out the tests for opera and webtv.
	is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
				&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
				&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	var is_nav2 = (is_nav && (is_major == 2));
	var is_nav3 = (is_nav && (is_major == 3));
	var is_nav4 = (is_nav && (is_major == 4));
	var is_nav4up = (is_nav && (is_major >= 4));
	var is_navonly	 = (is_nav && ((agt.indexOf(";nav") != -1) ||
						 (agt.indexOf("; nav") != -1)) );
	var is_nav6 = (is_nav && (is_major == 5));
	 is_nav6up = (is_nav && (is_major >= 5));
	is_gecko = (agt.indexOf('gecko') != -1);


	is_ie	 = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_ie3	= (is_ie && (is_major < 4));
	var is_ie4	= (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
	is_ie4up = (is_ie && (is_major >= 4));
	var is_ie5	= (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
	var is_ie5up = (is_ie && !is_ie3 && !is_ie4);
	var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
	var is_ie6	= (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
	is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

	// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
	// or if this is the first browser window opened. Thus the
	// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
	var is_aol = (agt.indexOf("aol") != -1);
	var is_aol3 = (is_aol && is_ie3);
	var is_aol4 = (is_aol && is_ie4);
	var is_aol5 = (agt.indexOf("aol 5") != -1);
	var is_aol6 = (agt.indexOf("aol 6") != -1);

	var is_opera = (agt.indexOf("opera") != -1);
	var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
	var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
	var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
	var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
	var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

	var is_webtv = (agt.indexOf("webtv") != -1); 

	var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
	var is_AOLTV = is_TVNavigator;

	var is_hotjava = (agt.indexOf("hotjava") != -1);
	var is_hotjava3 = (is_hotjava && (is_major == 3));
	var is_hotjava3up = (is_hotjava && (is_major >= 3));

	// *** JAVASCRIPT VERSION CHECK ***
	var is_js;
	if (is_nav2 || is_ie3) is_js = 1.0;
	else if (is_nav3) is_js = 1.1;
	else if (is_opera5up) is_js = 1.3;
	else if (is_opera) is_js = 1.1;
	else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
	else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
	else if (is_hotjava3up) is_js = 1.4;
	else if (is_nav6 || is_gecko) is_js = 1.5;
	// NOTE: In the future, update this code when newer versions of JS
	// are released. For now, we try to provide some upward compatibility
	// so that future versions of Nav and IE will show they are at
	// *least* JS 1.x capable. Always check for JS version compatibility
	// with > or >=.
	else if (is_nav6up) is_js = 1.5;
	// NOTE: ie5up on mac is 1.4
	else if (is_ie5up) is_js = 1.3

	// HACK: no idea for other browsers; always check for JS version with > or >=
	else is_js = 0.0;

	// *** PLATFORM ***
	is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
	// NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
	//		Win32, so you can't distinguish between Win95 and WinNT.
	var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

	// is this a 16 bit compiled version?
	var is_win16 = ((agt.indexOf("win16")!=-1) || 
			 (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
			 (agt.indexOf("windows 16-bit")!=-1) ); 

	var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
					(agt.indexOf("windows 16-bit")!=-1));

	var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
	var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));

	// NOTE: Reliable detection of Win98 may not be possible. It appears that:
	//	 - On Nav 4.x and before you'll get plain "Windows" in userAgent.
	//	 - On Mercury client, the 32-bit version will return "Win98", but
	//		 the 16-bit version running on Win98 will still return "Win95".
	var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
	var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
	var is_win32 = (is_win95 || is_winnt || is_win98 || 
					((is_major >= 4) && (navigator.platform == "Win32")) ||
					(agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

	var is_os2 = ((agt.indexOf("os/2")!=-1) || 
					(navigator.appVersion.indexOf("OS/2")!=-1) || 
					(agt.indexOf("ibm-webexplorer")!=-1));

	var is_mac	= (agt.indexOf("mac")!=-1);
	// hack ie5 js version for mac
	if (is_mac && is_ie5up) is_js = 1.4;
	var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || 
							 (agt.indexOf("68000")!=-1)));
	var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || 
								(agt.indexOf("powerpc")!=-1)));

	var is_sun = (agt.indexOf("sunos")!=-1);
	var is_sun4 = (agt.indexOf("sunos 4")!=-1);
	var is_sun5 = (agt.indexOf("sunos 5")!=-1);
	var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
	var is_irix = (agt.indexOf("irix") !=-1);	// SGI
	var is_irix5 = (agt.indexOf("irix 5") !=-1);
	var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
	var is_hpux = (agt.indexOf("hp-ux")!=-1);
	var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
	var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
	var is_aix = (agt.indexOf("aix") !=-1);	 // IBM
	var is_aix1 = (agt.indexOf("aix 1") !=-1);	
	var is_aix2 = (agt.indexOf("aix 2") !=-1);	
	var is_aix3 = (agt.indexOf("aix 3") !=-1);	
	var is_aix4 = (agt.indexOf("aix 4") !=-1);	
	var is_linux = (agt.indexOf("inux")!=-1);
	var is_sco = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
	var is_unixware = (agt.indexOf("unix_system_v")!=-1); 
	var is_mpras	= (agt.indexOf("ncr")!=-1); 
	var is_reliant = (agt.indexOf("reliantunix")!=-1);
	var is_dec = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
		 (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
		 (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
	var is_sinix = (agt.indexOf("sinix")!=-1);
	var is_freebsd = (agt.indexOf("freebsd")!=-1);
	var is_bsd = (agt.indexOf("bsd")!=-1);
	var is_unix = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || 
				 is_sco ||is_unixware || is_mpras || is_reliant || 
				 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

	var is_vms = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
}
// end of sniffing code







	function resizeLayers() {

	// do the browser check here too, just to avoid running
	// the delay loop in browsers that are not going to adjust
	// the iFrames anyway.

	var exe = ( is_gecko || is_ie4up )? true : false;
	if (exe)
	{

	// delay slightly before resizing iFrames
	// ie seems to need this delay otherwise things get out of wack

	var timeoutID;
	timeoutID = setTimeout("adjustIFrameSize('thumbs',310,115,1,0,0,115,0)",500);
	}	
	}




// turns on the autoflow for layers when the browser supports it

function initLayerFlow()
{
 var exe = ( is_gecko || is_ie4up )? true : false;

	if (exe)
	{

	 var mdatabox = MM_findObj('mdatabox');
	 mdatabox.style.overflow = 'auto';

	 var thumbs = MM_findObj('thumbs');
	 thumbs.style.overflow = 'auto';

	 for (var i = 0; i < document.totalResults; i++)
		{
		 var myLayer = MM_findObj('rec' + i);
		 myLayer.style.overflow = 'auto';
		}
	}
}


//clears text fields and sets menu items to first option
//used to clear a form that has been filled out automatically
//with data from the previous search.

function clearForm ( theForm )
{
 for (var i=0; i < theForm.length; i++)
	{
	 var e = theForm.elements[i];
	 if (e.type == "text") 
		{
	 e.value = "";
		}
	 else if (e.type == "select-one")
		{
	 e.selectedIndex = 0;
	}
	 }
}

function preBuildBBaction( theForm, winName, type, resultstableForm )
{
 var pagesel = MM_findObj('bbaction');

 if ( pagesel.value == 'check' )
	{
	 checkAllRecords( document.resultstable );
	}
 else if ( pagesel.value == 'uncheck' )
	{
	 clearAllRecords( document.resultstable );
	}
 else if ( pagesel.value == 'bbname' )
	{
	 buildBBaction( theForm, 'namebbag', 'popup', resultstableForm, pagesel.value );
	}
 else if ( pagesel.value == 'remove' )
	{
	 buildBBaction( theForm, 'portfolio', '', resultstableForm, pagesel.value );
	}
 else if ( pagesel.value == 'bbdel' )
	{
	 if (confirm('Permanently delete this portfolio?')) 
	{ 
	 window.close();
	 buildBBaction( theForm, 'bbdel', 'popup', resultstableForm, pagesel.value);
	}
	}

 // deselect the menu item that was just chosen.
 // the selection shouldn't stick once the action has occurred.
 pagesel.options[0].selected = 1;
 
}

// collects data from all search form elements and
// builds a URL for the bbaction form action.

function buildBBaction( theForm, winName, type, resultstableForm, action) 
{
 // uh for "url hold"
 var uh = '';

 // if ( action == 'bbname' )
 //	{
 //	 uh += ";bbaction=";
 //	 uh += action;
 //	}
 // else if ( action == 'bbdel' )
 //	{
 //	 uh += ";bbaction=";
 //	 uh += action;
 //	}
 // else if (action == 'remove' )
 // {
 //	uh += ";bbaction=";
 //	uh += action;
 // }
 // else if ( action == 'bbdel' )
 // {
 //	uh += ";bbaction=";
 //	uh += action;
 // }

 // run through the menu form elements
 for (var i=0; i < theForm.elements.length; i++)
	{
	 // build cgi params
	 var v = ''; //to hold the value
	 if (theForm.elements[i].type == "select-one")
		{
		 var si = theForm.elements[i].selectedIndex; 
		 v = theForm.elements[i].options[si].value;
		}
	 else
		{
		 v = theForm.elements[i].value;
		}

	 v = v.replace(/\s/g, "+");
	 // quotes are not allowed. Perl CGI module doesn't like them.
	 v = v.replace(/\'/g, "");
	 v = v.replace(/\"/g, "");

	 var p = '';		
	 p += "&";
	 p += theForm.elements[i].name;
	 p += "=";
	 p += v;
	 // jump through some hoops to make sure we only get checked
	 // values of radio and checkbox form elements
	 if ((theForm.elements[i].type == 'checkbox') || (theForm.elements[i].type == 'radio'))
		{ 
		 if (theForm.elements[i].checked == true)
	 {
		 uh += p; 
	 }
		}
	 else
		{
	 uh += p;
		}
	}	
 // next, run through the resultstable form to get the selected colls
 // bbidno_checked for all selected colls
 var bbidno_checked = '';
 if (resultstableForm.bbidno.length)
	{
	 for (var i=0; i < resultstableForm.bbidno.length; i++)
	{
	 // p for holding cgi params as we build them
	 var p = '';
	 p += "&";
	 p += resultstableForm.bbidno[i].name;
	 p += "=";
	 p += resultstableForm.bbidno[i].value;
	 // if the image is selected, we add the params to bbidno_checked
	 if (resultstableForm.bbidno[i].checked == true)
		{
		 bbidno_checked += p;
		}
	}
	}
 else if (resultstableForm.bbidno.checked)
	{
	 bbidno_checked += "&" + resultstableForm.bbidno.name + "=" + resultstableForm.bbidno.value;
	} 
 // if there were no selected bbidnos, set uh to '',
 // which is all colls.	
 if ( (bbidno_checked == '') && ( action != 'bbdel' ) )
	{
	 //do nothing, I guess
	}
 else
	{
	 if ( action != 'bbdel' )
	{
	 uh += bbidno_checked;
	}
	 // tack the params on to the end of the url that is in the form's
	 // action and then go to the url.
	 //nn and ie behave differently here. 
	 //theForm.action will be completely empty for ie. 
	 //for nn, it has the cgi url plus parameters that were
	 //passed in to the cgi, which we strip off because we
	 //don't want them. 
	 var u = theForm.action;
	 u = u.replace(/\?.*/g, "");
	 
	 u = u + "?" + uh;
	 
	 if (type == "popup")
	 	{
	 	 popupDiagWindow( u, winName );		
	 	}
	 else
	 	{
	 	 window.open( u, winName);
	 	}
	}


}



//used by index.tpl
function MM_openInfoWindow(theURL,winName) { //v2.0
var infoWindow = 0;
var winY = winavailheight - ( winavailheight - 50 );
var winX = ( winavailwidth - 475 ); 
var winparams = "";

 if (ie4)
 {
	 winparams = 'scrollbars=yes,resizable=yes,location=no,width=455,height=500,left='+winX+',top='+winY;

 }
 else
 {
	 winparams = 'scrollbars=yes,resizable=yes,location=no,width=455,height=500,screenX='+winX+',screenY='+winY;
 }
	if ( infoWindow && !infoWindow.closed )
	{
		infoWindow.focus(); 
	}
	else
	{
	infoWindow = window.open( '', winName, winparams );
		 infoWindow.focus( );	
	}

	// Patch by email from JW:
	// June 8, 2004
	//browser differences make both of the following commands necessary.
	// the first is preferred...
	infoWindow.window.location = theURL;
	// the second is probably on the way out...
	infoWindow.document.location.href = theURL;

 }


// collects data from all search form elements and
// builds a URL for the action.

function formToUrl( theForm, winName, type ) 
{
 // uh for "url hold"
 var uh = '';
 // run through the menu form elements
 for (var i=0; i < theForm.elements.length; i++)
	{
	 // build cgi params
	 var v = ''; //to hold the value
	 if (theForm.elements[i].type == "select-one")
		{
		 var si = theForm.elements[i].selectedIndex; 
		 v = theForm.elements[i].options[si].value;
		}
	 else
		{
		 v = theForm.elements[i].value;
		}
	 // spaces need to be pluses
	 v = v.replace(/\s/g, "+");
	 // quotes are not allowed. Perl CGI module doesn't like them.
	 v = v.replace(/\'/g, "");
	 v = v.replace(/\"/g, "");

	 var p = '';		
	 p += "&";
	 p += theForm.elements[i].name;
	 p += "=";
	 p += v;
	 // jump through some hoops to make sure we only get checked
	 // values of radio and checkbox form elements
	 if ((theForm.elements[i].type == 'checkbox') || (theForm.elements[i].type == 'radio'))
		{ 
		 if (theForm.elements[i].checked == true)
		{
		 uh += p; 
		}
		}
	 else
		 {
	 uh += p;
		 }
	}	
	// tack the params on to the end of the url that is in the form's
	// action and then go to the url.
//	 gotourl( theForm.action + "?" + uh);

// NOTE: ie and nn behave differently in regards to theForm.action values.
// look elsewhere in this file for more info about theForm.action.
	var u = theForm.action + "?" + uh;

//	alert (u);
	if (type == "popup")
	 {
		popupDiagWindow( u, winName );		
	 }
	 else if (type == "notoolbar")
	 {
		MM_openBrWindow(u, winName, 'scrollbars=yes, resizable=yes');	 
	 }
	else
	 {
		window.open( u, winName);
	 }
}


//used by entry.tpl and bbentry.tpl to return to window of results
function focusOnOpener()
{
 var wo = window.opener;
 wo.focus();
}




function display (data, fr)
{

 if ( ! document.currRec )
	{
	 document.currRec = 'rec0';
	}
 show(document.currRec, "hidden");
 document.currRec = data;
 show(document.currRec, "visible");
 if (fr) 
	{
	 adjustIFrameSize(data,0,115,0) 
	}

}

function show(tab, vb) //tab=recnum vb=visibility
{

 if (document.getElementById) //ns6, ie5, ie6
	{
	 var elm=parent.document.getElementById(tab);
	 elm.style.visibility=vb;
	}
 else if (document.all) //ie4
	{
	 var elm=document.all[tab];
	 elm.style.visibility=vb;
	}
 else //ns4
	{
	 document.layers[tab].visibility = vb;
	}
}


// args are in sets of 4
// 1st arg: name/id of layer (in single quotes) OR number of layer (no quotes)
// 2nd arg; pixel location of left side of layer (measured from the left)
// 3rd arg: pixel location of top of layer (measured from top)
// 4th arg: if true, width will be adjusted in addition to height.
// "rec" layer is generally not adjusted in the width.
// "thumbs" layer is adjusted in the width.

// remember args are in sets of 4.
// so if there are 8 args, it means two layers are being adjusted.

function adjustIFrameSize() {

 // only do this function if we're working with a relatively new browser

 var exe = ( is_gecko || is_ie4up )? true : false;

 if (exe){

	var args = arguments;

	// the height and width of the layer needs to be "fixed" / adjusted
	// in some browsers. hFix and wFix can be thought of as compensatory
	// offsets from the bottom and left window edges.
	var hFix = 0;
	var wFix = 0;


	// note that even if similar height parameters are used for the rec/mdatabox and thumbs
	// layers, the bottom edges of the layers may are may not align perfectly depending on
	// the content of the layers. sad as that may be. 

	if (is_nav6up)
	 {
	hFix = -40;
	wFix = -50;
	 }	
	// gecko would include nav6up
	// if we didn't handle it above
	else if (is_gecko)
	 {
	hFix = -40;
	wFix = -30;
	 }
	else if (is_ie4up)
	 {
	hFix = -5;
	wFix = -20;
	 }
	else
	 {
	hFix = -30;
	wFix = -10;
	 }


	for(x=0;x<(args.length);x+=4){
	 var myLayer = (args[x]!=0)? MM_findObj(args[x]) : MM_findObj(document.currRec);	
	 if (myLayer) {
	var winAvailH = getInsideWindowHeight();
	var winAvailW = getInsideWindowWidth();
	myLayer.style.height = winAvailH - (args[x+2] - hFix);

	// only adjust width if final 4th argument is "1"
	if (args[x+3]==1) { myLayer.style.width = winAvailW - (args[x+1] - wFix) }
	 }
	}
 }
}






function gotourl(url)
{
	parent.document.location.href = url;
}


function checkAllRecords(db_form)
{
 // var mydiv = MM_findObj('thumbs');
 // alert (mydiv.elements.length);
	var ele = "";
	for (var i = 0; i < db_form.elements.length; i++) 
	{
		ele = db_form.elements[i];
		if (ele.type == "checkbox")
		{
			ele.checked = true;
 		}
 	}
}


function clearAllRecords(db_form)
{
	var ele = "";
	for (var i = 0; i < db_form.elements.length; i++) 
	{
		ele = db_form.elements[i];
		if (ele.type == "checkbox")
		{
			ele.checked = false;
 		}
 	}
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
 var w = window.open(theURL,winName,features);
 w.focus();
 }

function MM_openTipsWindow(theURL,winName) { //v2.0
var tipsWindow = 0;
var winY = winavailheight - ( winavailheight - 50 );
var winX = ( winavailwidth - 275 ); 
var winparams = "";

 if (ie4)
 {
	 winparams = 'scrollbars=yes,resizable=yes,width=255,height=500,left='+winX+',top='+winY;

 }
 else
 {
	 winparams = 'scrollbars=yes,resizable=yes,width=255,height=500,screenX='+winX+',screenY='+winY;

 }


	if ( tipsWindow && !tipsWindow.closed )
	{
		tipsWindow.focus(); 
	}
	else
	{
	tipsWindow = window.open( '', winName, winparams );
		 tipsWindow.focus( );	
	}

	// Patch by email from JW:
	// June 8, 2004	
	//browser differences make both of the following commands necessary.
	// the first is preferred...
	tipsWindow.window.location = theURL;
	// the second is probably on the way out...
	tipsWindow.document.location.href = theURL;

 }



function buildAction() 
{
 // uh for "url hold"
 var uh = '';
 // run through the search form elements
 for (var i=0; i < document.the_form.elements.length; i++)
	{
	 // build cgi params
	 var v = ''; //to hold the value
	 if (document.the_form.elements[i].type == "select-one")
		{
		 var si = document.the_form.elements[i].selectedIndex; 
		 v = document.the_form.elements[i].options[si].value;
		}
	 else
		{
		 v = document.the_form.elements[i].value;
		}
	 v = v.replace(/\s/, "+");
	 var p = '';		
	 p += "&";
	 p += document.the_form.elements[i].name;
	 p += "=";
	 p += v;
	 // jump through some hoops to make sure we only get checked
	 // values of radio and checkbox form elements
	 if ((document.the_form.elements[i].type == 'checkbox') || (document.the_form.elements[i].type == 'radio'))
		{ 
		 if (document.the_form.elements[i].checked == true)
	 {
		 uh += p; 
	 }
		}
	 else
		{
	 uh += p;
		}
	}	
 // next, run through the colpick form to get the selected colls
 // c_checked for all selected colls
 var c_checked = '';
 // c_unchecked for all unselected colls
 // if no colls are checked, we'll use the unselected colls, 
 // which should be all colls since non were selected.
 var c_unchecked = ''; 
 for (var i=0; i < document.DBselect.c.length; i++)
	{
	// p for holding cgi params as we build them
	var p = '';
	p += "&";
	p += document.DBselect.c[i].name;
	p += "=";
	p += document.DBselect.c[i].value;
	// if the coll is selected, we add the params to c_checked
	if (document.DBselect.c[i].checked == true)
	 {
		c_checked += p;
	 }
	// otherwise we add the params to c_unchecked
	else
	 {
		c_unchecked += p;
	 }
 }

 if (document.DBselect.c.type == 'hidden')
 {
	p += "&";
	p += document.DBselect.c.name;
	p += "=";
	p += document.DBselect.c.value;
	c_checked += p;
 }
 // if there were no selected colls, use the unselected colls,
 // which is all colls.	
 if (c_checked == '')
	{
	 uh += c_unchecked;
	}
 else
	{
	 uh += c_checked;
	}

 // tack the params on to the end of the url that is in the form's
 // action and then go to the url.

 gotourl( document.the_form.action + "?" + uh);
}

 

// these seemingly out of place vars are indeed used.
// or at least some of them are. 
var diagWindow = 0;
var winavailwidth = screen.availWidth;
var winavailheight = screen.availHeight;
var winY = ( winavailheight/8 );
var winX = ( winavailwidth/8 ); 
var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false
var winparams = "";



function popupDiagWindow( URLstr, winName )
{

 if (ie4)
 {
	 winparams = 'scrollbars=yes,resizable=yes,width=625,height=550,left='+winX+',top='+winY;

 }
 else
 {
	 winparams = 'scrollbars=yes,resizable=yes,width=625,height=550,screenX='+winX+',screenY='+winY;

 }


	if ( diagWindow && !diagWindow.closed )
	{
		diagWindow.focus(); 
	}
	else
	{
	diagWindow = window.open( '', "bookbag", winparams );
		 diagWindow.focus( );	
	}

	// Patch by email from JW:
	// June 8, 2004
	//browser differences make both of the following commands necessary.
	// the first is preferred...
	diagWindow.window.location = URLstr;
	// the second is probably on the way out...
	diagWindow.document.location.href = URLstr;

}



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();
}

//start collpick stuff

// -------------- Serves collpick.tpl

function checkAllColls(db_form)
{
	var ele = "";
	for (var i = 0; i < db_form.elements.length; i++) 
	{
		ele = db_form.elements[i];
		if ( (ele.type == "checkbox") && (ele.name == "c") )
		{
			ele.checked = true;
 		}
 	}
 	swapOptions(db_form);
}

function clearAllColls(db_form)
{
	var ele = "";
	for (var i = 0; i < db_form.elements.length; i++) 
	{
		ele = db_form.elements[i];
		if ( (ele.type == "checkbox") && (ele.name == "c") )
		{
			ele.checked = false;
 		}
 	}
		setOptionText('DC');
}

function swapOptions(db_form)
{
	var checkedColls = new Array();
	var ckcount = 0;
	var ele = "";
	
	for (var i = 0; i < db_form.elements.length; i++) 
	{
		ele = db_form.elements[i];
		if ( (ele.type == "checkbox") && (ele.name == "c") )
		{
			if (ele.checked)
			{
				ckcount++;
				checkedColls[checkedColls.length] = db_form.elements[i].value;
			}
		
		}
	
	}
	
	switch(ckcount)
	{
		case 0 :			
		
			setOptionText('DC');

		break
		
		case 1 :			
		
			setOptionText(checkedColls[0]);


		break
		
		
		default :
			setOptionText('DC');

	
		break
		
	}
 
}

//setOptionText
//used by xcoll search form to update rgn select menus
//with xcoll or coll specific category names
//input: CIDname-- coll id

function setOptionText(CIDname)
{
	// determine whether xcoll or coll specific 
	// categs names will be used.
		if (CIDname == '')
		{
			var CollID = 'DC'; //xcoll
		}
		else
		{
			var CollID = eval(CIDname); //coll specific
	}

	var labelArrayName = CIDname + '_lbl';
	var CollID_lbl = eval(labelArrayName);

		// run through all elements of form (is there a better way)
	// and find those that are rgnX


	for (var n=0; n < document.the_form.elements.length; n++)
	{	 
		 var pattern = /rgn/i;
	 if (pattern.test(document.the_form.elements[n].name))
	 {

		//clear the menu
			document.the_form.elements[n].length = 0;
		//	alert (document.the_form.elements[n].length);	
			for (i=0; i < CollID.length; i++)
			{
		 var optiontext = CollID_lbl[i];
		 var selectedIndex = 0;
		 if (CollID[i] == CIDname + '_all')
		{
		 var selectedIndex = i;
		 //		optiontext = "Anywhere in record";
		}

			 document.the_form.elements[n].length++;
			 document.the_form.elements[n].options[i].text = optiontext;
			 document.the_form.elements[n].options[i].value = CollID[i];
			}
			document.the_form.elements[n].options[selectedIndex].selected = true;
		 }
		}

}


// -------------------------------------------

//---- from entry.tpl
function MM_findObj(n, d) { //v4.01
 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;
}



function sniffBrowser()
{
 var ns4 = (document.layers) ? true : false;
 var ie4 = (document.all && !document.getElementById) ? true : false;
 var ie56 = (document.all && document.getElementById) ? true : false;
 var ns6 = (!document.all && document.getElementById) ? true : false;


 // figure out if browser is a netscape browser or an ie browser
 var brwsr = 'ie';
 if ( (ns4) || (ns6) )
	{
	 brwsr = 'ns';
	}

 var platform = "win"; // use as default

 if (navigator.userAgent.indexOf("Mac") != -1)
	{
	 platform = 'mac';
	}	 
 if (navigator.userAgent.indexOf("Win") != -1)
	{
	 platform = 'win';
	}	 

 // alert (platform+' '+brwsr+' '+layersmode);
 // alert (platform+' '+brwsr);
 var ret = new Array(2);
 ret[0] = platform;
 ret[1] = brwsr;
 // ret[2] = layersmode;
 return ret;
}

function MM_showHideLayers() {
	var args = arguments;
	var elm, v;
	for (var i = 0; i < args.length; i++) {
		var arg = args[i];
		if (arg == "show") {
			arg = "visible";
		} else if (arg == "hide") {
			arg = "hidden";
		}
		if (arg == "") {
			//be sure to do nothing
		} else if ((arg == "visible") || (arg == "hidden"))	{
			v = arg;
			if (elm.style){
				elm.style.visibility = v;
				v = "";
			} else if (elm) {
				document.layers[elm].visibility = v;
				v = "";
			} else {
				alert("javascript layers problem in function MM_showHideLayers");
			}
			
			// Make an additional call to show/hideImageTool when the new zoom tool is running
			if ((elm.id == "full-image") 
			&& (typeof(newZoomToolIsRunning) != 'undefined')
			&& newZoomToolIsRunning) {
				if (arg == "visible") {
					showImageTool();
				} else {
					hideImageTool();
				}
			}
			
		} else if ( document.getElementById ) {
			elm = document.getElementById(arg);
		} else if ( document.all ) {
			alert("does this ever happen");
			elm = document.all[arg];
		} else if ( document.layers ) {
			elm = arg;
		} else	{
			v = "";
		}
	}
//MB Extra toevoeging om de statusbar (hourglass!) invisible te maken.
	if (document.getElementById('progressbar')) {
		document.getElementById('progressbar').style.visibility='hidden';
	}
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_nbGroup(event, grpName) { //v3.0
 var i,img,nbArr,args=arguments;
 if (event == "init" && args.length > 2) {
	if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
	 img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
	 if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
	 nbArr[nbArr.length] = img;
	 for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
		if (!img.MM_up) img.MM_up = img.src;
		img.src = img.MM_dn = args[i+1];
		nbArr[nbArr.length] = img;
	} }
 } else if (event == "over") {
	document.MM_nbOver = nbArr = new Array();
	for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
	 if (!img.MM_up) img.MM_up = img.src;
	 img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
	 nbArr[nbArr.length] = img;
	}
 } else if (event == "out" ) {
	for (i=0; i < document.MM_nbOver.length; i++) {
	 img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
 } else if (event == "down") {
	if ((nbArr = document[grpName]) != null)
	 for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
	document[grpName] = nbArr = new Array();
	for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
	 if (!img.MM_up) img.MM_up = img.src;
	 img.src = img.MM_dn = args[i+1];
	 nbArr[nbArr.length] = img;
 } }
}

function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
 var i,j=0,x,a=arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//used for jumping from the popup collinfo window back to the main window
//could be used elsewhere as well
function dlxsLink(url)
{
 var target = url+'?sid='+insTarget;
 wincaller.document.location.href = target;
}

function mainWinLink(url)
{
wincaller.document.location.href = url;
}


/* ***********************************************************
Example 4-3 (DHTMLapi.js)
"Dynamic HTML:The Definitive Reference"
2nd Edition
by Danny Goodman
Published by O'Reilly & Associates ISBN 1-56592-494-0
http://www.oreilly.com
Copyright 2002 Danny Goodman. All Rights Reserved.
************************************************************ */
// DHTMLapi.js custom API for cross-platform
// object positioning by Danny Goodman (http://www.dannyg.com).
// Release 2.0. Supports NN4, IE, and W3C DOMs.


var isCSS, isW3C, isIE4, isNN4, isIE6CSS;
// initialize upon load to let all browsers establish content objects
function initDHTMLAPI() {
	if (document.images) {
		isCSS = (document.body && document.body.style) ? true : false;
		isW3C = (isCSS && document.getElementById) ? true : false;
		isIE4 = (isCSS && document.all) ? true : false;
		isNN4 = (document.layers) ? true : false;
		isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	}
} 


// Return the available content width space in browser window
function getInsideWindowWidth() {
	if (window.innerWidth) {
		return window.innerWidth;
	} else if (isIE6CSS) {
		// measure the html element's clientWidth
		return document.body.parentElement.clientWidth
	} else if (document.body && document.body.clientWidth) {
		return document.body.clientWidth;
	}
	return 0;
}
// Return the available content height space in browser window
function getInsideWindowHeight() {
	if (window.innerHeight) {
		return window.innerHeight;
	} else if (isIE6CSS) {
		// measure the html element's clientHeight
		return document.body.parentElement.clientHeight
	} else if (document.body && document.body.clientHeight) {
		return document.body.clientHeight;
	}
	return 0;
}




// -- moved selected element up or down in a specified list. Takes as args js ref to element
// -- in which moving occurs, the reference to the selected index number, and the desired
// -- direction. 
// -- doNothing is a boolean that is the trigger for the function to run or not. Not
// -- running occurs if the last opt in either direction is selected, or one attempts
// -- to move a box header.
// -- initiated by: clicking the move up or down arrows

function moveSelOpts(elem,currIdx,d,hid) 
{
	var subIdx = 0;
	(d == 'up') ? subIdx = (currIdx-1) : subIdx = (currIdx+1);
	var doNothing = true;
	if (d == 'up')
	{
		(currIdx < 1) ? doNothing = true : doNothing = false;
	}
	
	if (d == 'down')
	{
		(currIdx == elem.options.length-1) ? doNothing = true : doNothing = false;
	}

	if ((doNothing != true) && (currIdx != -1))
	{
	
		var cOpt = new Option(elem.options[currIdx].text,elem.options[currIdx].value);
		var sOpt = new Option(elem.options[subIdx].text,elem.options[subIdx].value);
		elem.options[subIdx].text = "";
		elem.options[subIdx].value = "";
		elem.options[currIdx].text = "";
		elem.options[currIdx].value = "";
		
		//alert(sOpt.value);
		elem.options[subIdx] = cOpt;		
		//alert(elem.options[currIdx-1].value);
		elem.options[currIdx] = sOpt;

		(d == 'up') ? elem.options[subIdx].selected = true : elem.options[currIdx+1].selected = true;
						 

		//DIV ids for record divs have been kept to a simple 'recX' format.
		//in order to relate DIV ids to Record IDs, hidden vars are used
		//in the HTML form. As items are reordered using the select/option form
		//element and the up and down buttons, the hidden input values are
		//also changed in synch. When the form is submitted, only the selected
		//option of the SELECT is submitted, yet all of the hidden inputs are submitted. 
		//this is necessary to allow the cgi to save update the portfolio db with the new order.

		//the following lines were added to this routine by jweise in order to handle the
		//hidden input types.

	 	var hidA_obj = MM_findObj('hrec' + currIdx);
	 	var hidB_obj = MM_findObj('hrec' + subIdx);

		var hold = hidA_obj.value; 

	 	hidA_obj.value = hidB_obj.value;
	 	hidB_obj.value = hold;

		//end of jweise additions

	}

}


