/* ======================================================================
DESC: 		Scripts for "Biblioteca Cantanhede"

PLATFORMS:	All

USAGE NOTES:	NONE
====================================================================== */

reloadPage(true);

/* ======================================================================
FUNCTION: 	reloadPage

INPUT:		init - init the page for the first time (boolean)
RETURNS:		null
DESC:			just to fix a NS4.x BUG!
====================================================================== */
function 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();
}

/* ======================================================================
FUNCTION: 	swapImages

INPUT:		id  - img that called the function
				max - total images to change
RETURNS:		null
DESC:			
====================================================================== */
function swapImages(id, max) {
	img = id.substr(0, 3);
	pic = id.substr(3);

	for(i=1; i<(max+1); i++) {
		if(pic != i) {
			findObj(img + i).src = 'imgs/selectnull.gif';
		} else {
			findObj(img + i).src = 'imgs/select.gif';
		}
	}
}

/* ======================================================================
FUNCTION:	findObj

INPUT:		n - a String to find a Object
RETURNS:		Object
DESC:							
====================================================================== */
function findObj(n, d) { //v4.0
  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=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}