﻿function docbtnOver(img) { img.src = img.src.replace("_off", "_over"); }
function docbtnOut(img) { img.src = img.src.replace("_over", "_off"); }
function getElementsByClass(rootElement, className) {
	var elements = new Array();
	// Return empty array if the root element doesn't exist
	if(rootElement == null) { return elements; }
	// If the root element is a match, add to our list
	if((rootElement.className != null) && (rootElement.className.indexOf(className) >= 0)) {
		elements.push(rootElement);
	} else {
		// Otherwise, check the root element's children and add all of those nodes as well
		if((rootElement.childNodes != null)) {
			for(var i=0; i<rootElement.childNodes.length; i++) {
				var child = rootElement.childNodes[i];
				var childElements = getElementsByClass(child, className);
				for(var j=0; j<childElements.length; j++) {
					elements.push(childElements[j]);
				}
			}
		}
	}
	return elements;
}
function imgOver(img) {
	if(img.src != null) {
		img.src = img.src.replace("_off", "_over"); 
	}
	return true;
}
function imgOut(img) {
	if(img.src != null) {
		img.src = img.src.replace("_over", "_off");
	}
	return true;
}
function matchElement(rootElement, tag, partialID) {
	// Initialize root element if not specified
	if(rootElement==null) { rootElement = document; }
	// Find all specified tags
	var elements = rootElement.getElementsByTagName(tag);
	for(var i=0; i<elements.length; i++) {
		if(elements[i].id != null) {
			if(elements[i].id.indexOf(partialID) >= 0) {
				return elements[i];
			}
		}
	}
	return null;
}
function matchElements(rootElement, tag, partialID) {
	// Initialize root element if not specified
	if(rootElement==null) { rootElement = document; }
	// Find all specified tags
	var elements = rootElement.getElementsByTagName(tag);
	// Assemble all items that contain the given id
	var arr = Array();
	for(var i=0; i<elements.length; i++) {
		if(elements[i].id != null) {
			if(elements[i].id.indexOf(partialID) >= 0) {
				arr.push(elements[i]);
			}
		}
	}
	return arr;
}
function NewWindow(mypage,myname,w,h,scroll){
	var win = null;
	var win_width = Number(w)+10;
	var win_height = Number(w)+29;	

	var winl = (screen.width/2) - (win_width/2);
	var wint = (screen.height/2) - (win_height/2);

	var settings  ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no';
	settings +='resizable=no';
	win=window.open(mypage,myname,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
function openPrintable() {
	var title = document.title;
	if(title != null) {
		// Remove any HTML tags
		title = title.replace(/\<[^\>]*\>/g, " ");
	}
	var url = "/pf.aspx?title=" + title;
	var features = "width=720,height=600,scrollbars=1,menubar=1,resizable=1";
	window.open(url, "", features);
}
function removeElement(element) {
	if(element != null) {
		var elementParent = element.parentNode;
		if(elementParent != null) {
			elementParent.removeChild(element);
		}
	}
}
function removeElementsByClass(rootElement, className) {
	var elements = getElementsByClass(rootElement, className);
	while(elements.length > 0) {
		var elementToRemove = elements.pop();
		removeElement(elementToRemove);
	}
}

