// Detects what browser the user has

if (document.all) 					{isIE = 1; isNS6 = 0;}
else if (document.getElementById) 	{isIE = 0; isNS6 = 1;}

function openPicWin(pic, winy, winx, title){
	if (!title) title = "";
	var pictureWindow = window.open("", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=" + winy + ", height=" + winx, winy, winx, pic, title)

	// source variable declared and document.write into the new document/window.
	if (pictureWindow != null) {
		// write this code into it
		var pictureCode = "<html><head><title>" + title + "</title></head>";
		pictureCode += "<body bgcolor=\"#ffffff\" style=\"margin:0px;\">";
		pictureCode += "<div style=\"border: 0; margin: 0; padding: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; text-align:center;\">";
		pictureCode += "<img src='" + pic +"'>";
		pictureCode += "</div>";
		pictureCode += "</body>";
		pictureCode += "</html>";

		pictureWindow.document.open()
		pictureWindow.document.write(pictureCode)
		pictureWindow.document.close()
	}
}

/* Generic functions used throughout the site */

function setClassByObj(obj, newClass) {
	obj.className = newClass;
}

function setClassById(objID, newClass) {
	if (isNS6 || isIE) {
		if (document.getElementById(objID)) {
			document.getElementById(objID).className = newClass;
		}
	}
}

// Takes a row object and applied the trOver class to it
function rowOver(obj) {
	if (obj.className == "trGrey") setObjClass(obj, "trGreyOver");
	else if (obj.className != "trSelected" && obj.className != "trSelectedGrey") setObjClass(obj, "trOver");
}

// Takes a row object and applied the trNorm class to it
function rowOut(obj) {
	if (obj.className == "trGreyOver") setObjClass(obj, "trGrey");
	else if (obj.className != "trSelected" && obj.className != "trSelectedGrey" && obj.className != "trGrey") {
		setObjClass(obj, "trNorm");
	}
}

// Opens the passed link in the current window
function openLink(dest, targetFrame) {
	if (targetFrame) eval("parent."+targetFrame+".location = dest");
	else window.location = dest;
}

function showLayer(layerID) {
	if (isNS6 || isIE) {
		if (document.getElementById(layerID)) {
			document.getElementById(layerID).style.visibility = "visible";
		}
	}
}

function hideLayer(layerID) {
	if (isNS6 || isIE) {
		if (document.getElementById(layerID)) {
			document.getElementById(layerID).style.visibility = "hidden";
		}
	}
}

function moveLayer(layerID, x, y) {
	if (isIE || isNS6) {
		if (document.getElementById(layerID)) {
			document.getElementById(layerID).style.left = x;
			document.getElementById(layerID).style.top = y;
		}
	}
}

function toggleDisplay(layerID){
	if (isNS6 || isIE) {
		if (document.getElementById(layerID)) {
			if (document.getElementById(layerID).style.display == "") {
				document.getElementById(layerID).style.display = "none";
			}
			else {
				document.getElementById(layerID).style.display = "";
			}
		}
	}
}

function setDisplay(layerID, vis){
	if (isNS6 || isIE) {
		if (document.getElementById(layerID)) {
			document.getElementById(layerID).style.display = vis;
		}
	}
}

function findPosition(obj) {
	if (obj.offsetParent) {
		for (var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent) {
			posX += obj.offsetLeft;
			posY += obj.offsetTop;
		}
		return [ posX, posY ];
	} else {
		return [ obj.x, obj.y ];
	}
}


