//	Javascript file for functions that don't really go anywhere else.

//	open_window_ex_scroll
//		parameters:	url - page to open
//					title - window title
//					top, left, height, width - the top-left corner coordinates and the height and width in pixels
//					iscroll - toggle that controls scrolling
//	yet another open window macro, this one allows scrolling (toggle)
function open_window_ex_scroll(url,title,top,left,height,width, iscroll) {
	void window.open(url,title,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+iscroll+',resizable=1,width='+width+',height='+height+',top='+top+',left='+left);
}

// addBookmark
//		parameters:  none
//	bookmarks current page.
function addBookmark() {
	window.external.AddFavorite(window.location, window.document.title);
}

//	Capturing the mouse position
	// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page
//		function captureMousePosition
//			parameters:	e - event object
//		assigns values of variable on mouse movement
function captureMousePosition(e) {
	if (document.layers) {
		// When the page scrolls in Netscape, the event's mouse position
		// reflects the absolute position on the screen. innerHight/Width
		// is the position from the top/left of the screen that the user is
		// looking at. pageX/YOffset is the amount that the user has
		// scrolled into the page. So the values will be in relation to
		// each other as the total offsets into the page, no matter if
		// the user has scrolled or not.
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
	} else if (document.all) {
		// When the page scrolls in IE, the event's mouse position
		// reflects the position from the top/left of the screen the
		// user is looking at. scrollLeft/Top is the amount the user
		// has scrolled into the page. clientWidth/Height is the height/
		// width of the current page the user is looking at. So, to be
		// consistent with Netscape (above), add the scroll offsets to
		// both so we end up with an absolute value on the page, no
		// matter if the user has scrolled or not.
		xMousePos = window.event.x+document.body.scrollLeft;
		yMousePos = window.event.y+document.body.scrollTop;
		xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
		yMousePosMax = document.body.clientHeight+document.body.scrollTop;
	} else if (document.getElementById) {
		// Netscape 6 behaves the same as Netscape 4 in this regard
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
	}
}

//		function initMouseCapture
//		sets up mouse position functions
function initMouseCapture() {
	if (document.layers) { // Netscape
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = captureMousePosition;
	} else if (document.all) { // Internet Explorer
		document.onmousemove = captureMousePosition;
	} else if (document.getElementById) { // Netcsape 6, others
		document.onmousemove = captureMousePosition;
	}
}

	//	funciton clearForm
	//		clears a form when variables are passed in a Reset no longer works
	//		INPUTS:	f - the form in question
function clearForm(f) {
	var i;
	for (i=0; i<f.elements.length; i++) {
		switch (f.elements[i].type) {
			case "button":
				break;
			case "checkbox":
				f.elements[i].checked = f.elements[i].defaultChecked;
				break;
			case "file":
				break;
			case "hidden":
				break;
			case "password":
				f.elements[i].value = "";
				break;
			case "radio":
				break;
			case "reset":
				break;
			case "select-one":
				f.elements[i].selectedIndex = -1;
				break;
			case "select-multiple":
				f.elements[i].selectedIndex = -1;
				break;
			case "submit":
				break;
			case "text":
				f.elements[i].value = "";
				break;
			case "textarea":
				f.elements[i].value = "";
				break;
		}
	}
}

	//	function showDetail
	//	manages the visibility/invisibility of search detail.
	//		inputs:	name		- element to find*
	//				showhide	- wether to show or hide
	//					*IE currently requires this to be a element with a valid "name" property, a form element
var hide = 1;
function showDetail(name, showhide) {
	var tags = document.getElementsByName(name);
	var prevObj;
	
	var i;
	for (i=0; i<tags.length; i++) {
		//if (tags[i].name == name) {
			if (showhide==1) {
				tags[i].parentNode.style.display = "";
				document.getElementById("show"+name).style.display = "inline";
				document.getElementById("hide"+name).style.display = "none";
			} else {
				tags[i].parentNode.style.display = "none";
				document.getElementById("hide"+name).style.display = "inline";
				document.getElementById("hide"+name).style.display = "none";
			}
		//}
	}
	if (showhide==0) {
		document.getElementById("show"+name).style.display = "inline";
		document.getElementById("hide"+name).style.display = "none";
	} else {
		document.getElementById("hide"+name).style.display = "inline";
		document.getElementById("show"+name).style.display = "none";
	}
	hide = showhide;

	tags = document.getElementById("main-column-content").getElementsByTagName("td");
	for (i=0;i<tags.length; i++) {
		if (((tags[i].getAttribute("class") == "alt-result-title") || (tags[i].className == "alt-result-title")) && (hide == 0)){
			tags[i].setAttribute("class","hidden-result-title");
			tags[i].className = "hidden-result-title";
		} else if (((tags[i].getAttribute("class") == "hidden-result-title") || (tags[i].className == "hidden-result-title")) && (hide == 1)) {
			tags[i].setAttribute("class","alt-result-title");
			tags[i].className = "alt-result-title";
		}
	}
}

	//	function getQSVars()
	//		parses the URL (document.location) for query string arguments
	//		returns assosciative array from "name=value" pairs
function getQSVars() {
	var args = new Object();
	var query = document.location.search.substring(1);
	var pairs = query.split("&");
	
	for (var i=0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		args[argname] = unescape(value);
	}
	return args;
}
	//	function getQSVars5
	//		same as getQSVars, but updated for JavaScript 1.5
function getQSVars5() {
	var args = new Object();
	var query = document.location.search.substring(1);
	var pairs = query.split("&");
	
	for (var i=0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		args[argname] = decodeURIComponent(value);
	}
	return args;
}
	// function getScreenSize
	//		returns the resolution of the monitor
	//	!dependant on javascript version
function getScreenSize() {
	if (_version >= "1.2") {
		width = screen.width;
		height = screen.height;
	} else {
		width = 0;
		height = 0;
	}
	
	var dimensions = new Object;
	dimensions.height = height;
	dimensions.width = width;
	
	return dimensions;
}

	// function tagByID
	//		returns document element with supplied ID attribute;
	//		 -- wraps document.getElementById
function tagByID(tagid) {
	return document.getElementById(tagid);
}