// browser detection
var ffox = navigator.userAgent.indexOf("Firefox") != -1
var ie = navigator.userAgent.indexOf("MSIE") != -1
var ie7 = navigator.userAgent.indexOf("MSIE 7.0") != -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

function correctPNG() {
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
			//alert(img.src)
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			var strNewHTML = "<span class=\"pngFix\" " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}
if (ie && !ie7) {
	window.attachEvent("onload", correctPNG);
}

// 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.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';
}

// show & hide a layer
function layerVisibility(layerId) {
	if (ffox || ie || ie7 || 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";
		}
	}
}