//guess what this does...
function checkBrowser() { //v4.0
	app=navigator.appName

	if ((app.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion.charAt(0)) >= 5)) {
  		return 'netscape6';
  	} else if (app.indexOf('Netscape') != -1) {
  		return 'netscape';
  	} else if (app.indexOf('Microsoft') != -1) {
  		return 'explorer';
  	} else {
  		return 'other';
  	}
}

//returns an object given its name as a string
function findObj(n, d) {
  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;
}

//returns the layer object called in the argument
function findLayer(objName, theDocument){
	if (!theDocument){
		theDocument = document;
	}
	//get the layer objects from the DOM
	if (checkBrowser() == 'netscape') {
		theLayer = theDocument.layers[objName];
	} else if (checkBrowser() == 'netscape6') {
		theLayer = findObj(objName, theDocument).style;
	} else {
		theLayer = theDocument.all[objName].style;
	}
	return theLayer;
}

//this function returns the position of an image
//coordinate should be supplied as 'x' or 'y'
function getImagePosition(imageName, coordinate){
	theImage = document.images[imageName];
	theReturnValue = -1;
	if (checkBrowser() == 'netscape') {
		theReturnValue = eval("theImage." + coordinate);
	} else {
		if (coordinate == 'x'){
			theReturnValue = getIeX(theImage);
		} else {
			theReturnValue = getIeY(theImage);
		}
	}
	//alert(theImage.name);
	return theReturnValue;
}

function getIeX(element) {
    xPos = element.offsetLeft;
    tempElement = element.offsetParent;
    while (tempElement != null) {
        xPos += tempElement.offsetLeft;
        tempElement = tempElement.offsetParent;
    }
    return xPos;
}

function getIeY(element) {
    yPos = element.offsetTop;
    tempElement = element.offsetParent;
    while (tempElement != null) {
        yPos += tempElement.offsetTop;
        tempElement = tempElement.offsetParent;
    }
    return yPos;
}

//returns the browser specific values for a layer being visible or invisible
function visibleString(visible) {
	if (visible) {
		if (checkBrowser() == 'netscape') {
			return 'show';
		} else {
			return 'visible';
		}
	} else {
		if (checkBrowser() == 'netscape') {
			return 'hide';
		} else {
			return 'hidden';
		}
	}
}

//reloads the window if Nav4 resized
function netscapeReload(init) {  
  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();
  }
}
//run this function on any page with layers
netscapeReload(true);
