// browser detection
var ffox = navigator.userAgent.indexOf("Firefox") != -1
var ie = navigator.userAgent.indexOf("MSIE") != -1
var ns6 = navigator.userAgent.indexOf("Netscape") != -1
var saf = navigator.userAgent.indexOf("Safari") != -1
var opra = navigator.userAgent.indexOf("Opera") != -1
var camino = navigator.userAgent.indexOf("Camino") != -1

// open a popup centered in user's screen
function popCenter(page, name, w, h, scroll) {
	 var winl = (screen.width - w) / 2;
	 var wint = (screen.height - h) / 2;
	 winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',';
	 win = window.open(page, name, winprops);
	 win.onload=function()
	 {
		 win.document.getElementsByTagName('body')[0].style.background='none';
	 }
	 win.focus();
}

// print the page
function printMe() {
	window.print();
}

// rollover for .gif images (3 states: of, on, in)
function changeGifImage(which) { 
	myImgSrc = document.getElementById(which);
	buttonStatus = myImgSrc.src.substring(myImgSrc.src.length -6, myImgSrc.src.length -4);
	if (buttonStatus == 'of') myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'on.gif';
	else if (buttonStatus == 'in') myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'in.gif';
	else myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'of.gif';
}

// rollover for .jpg images (3 states: of, on, in)
function changeJpgImage(which) { 
	myImgSrc = document.getElementById(which);
	buttonStatus = myImgSrc.src.substring(myImgSrc.src.length -6, myImgSrc.src.length -4);
	if (buttonStatus == 'of') myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'on.jpg';
	else if (buttonStatus == 'in') myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'in.jpg';
	else myImgSrc.src = myImgSrc.src.substring(myImgSrc.src.length -6,0) + 'of.jpg';
}

// show & hide a layer
function layerVisibility(layerId) {
	if (ffox || ie || opra) {
		if (document.all[layerId].style.display == "none") {
			document.all[layerId].style.display = "block";
		}
		else {
			document.all[layerId].style.display = "none";
		}
	}
	if (ns6 || saf || camino) {
		if (document.getElementById([layerId]).style.display == "none") {
			document.getElementById([layerId]).style.display = "block";
		}
		else {
			document.getElementById([layerId]).style.display = "none";
		}
	}
}

//This function return the x or y co-ordinate of an element.(elem)
function getElementLeftTop(elem) {
		xPos = elem.offsetLeft;
		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
		return [xPos,yPos];
}

//This function sets the x or y co-ordinate of an element.(elem)
function setElementLeftTop(elem,leftDim,topDim) {
		elem.style.left=leftDim+80+'px';
		elem.style.top=topDim-160+'px';
}