

function includeJS(file) {
	document.write('<script type="text/javascript" src="' + file + '"></script>');
};



function includeCSS(file) {
	document.write('<link rel="stylesheet" type="text/css" media="screen" href="' + file + '" />');
};


//-- -------------------------------------------
//-- FUNCTION TO CLEAR THE SEARCH BOX TEXT
//-- -------------------------------------------
function clearField(Field,fieldValue) {
	if (Field.value	== fieldValue) {
		Field.value = '';
	}
}





//-- -------------------------------------------
//-- FUNCTION TO RESET THE SEARCH BOX TEXT
//-- -------------------------------------------
function resetField(Field,fieldValue) {
	if (Field.value	== '') {
		Field.value = fieldValue;
	}
}





//-- -------------------------------------------
//-- FUNCTION TO PRINT PAGE
//-- -------------------------------------------
function printpage() {
	if (window.print) { window.print(); }
	else {
		alert ("To print this page please select the 'Print' option from your browser's 'File' menu.")
	}
	return;
}





//-- -------------------------------------------
//-- ADD ON LOAD EVENT
//-- -------------------------------------------
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
		func();
		}
	}
}




function syncDate(sourceObj,target) {
	var sourceValue = sourceObj.options[sourceObj.selectedIndex].value;
	var targetObj = document.getElementById(target);
	targetObj.value = sourceValue;
}





//-- -------------------------------------------
//-- GENERIC ACCESSIBLE POPUP SCRIPT
//-- -------------------------------------------
var _POPUP_FEATURES = 'width=790,height=525,scrollbars=no';

function raw_popup(url, target, features) {
	if (isUndefined(features)) features = _POPUP_FEATURES;
	if (isUndefined(target)) target = '_blank';
	var theWindow = window.open(url, target, features);
	theWindow.focus();
	return theWindow;
}

function link_popup(src, features) {
	return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}


function isUndefined(v) {
	var undef;
	return v===undef;
}








//-- -------------------------------------------
//-- CREATE ROLLOVERS FOR PAGE LIST ITEMS
//-- -------------------------------------------
function pageItemRollovers(parentObject, childObjectType, childObjectClasses, exceptionClass) {
	if (document.getElementById(parentObject)) {
		var theParent = document.getElementById(parentObject);
		var theChildren = theParent.getElementsByTagName(childObjectType);
		for (var i = 0; i < theChildren.length; i++) {
			if (childObjectClasses.length) {

				// Create an array out of the childObjectClasses value(s)
				cObjClasses = new Array();
				if (childObjectClasses.indexOf("|") != -1) {
					cObjClasses = childObjectClasses.split("|");
				}
				else {
					cObjClasses[0] = childObjectClasses;
				}
				theChildren[i].onmouseover = function() {
					for(u=0; u<cObjClasses.length; u++) {
						if (this.className.indexOf(cObjClasses[u]) != -1) {
							if(exceptionClass.length != 0) {
								if (this.className.indexOf(exceptionClass) == -1) {
									this.className += " sfhover";
								}
							}
							else {
								this.className += " sfhover";
							}
						}
					}
				}
				theChildren[i].onmouseout=function() {
					for(u=0; u<cObjClasses.length; u++) {
						if (this.className.indexOf(cObjClasses[u]) != -1) {
							this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
						}
					}
				}
			}
			else {
				theChildren[i].onmouseover = function() {
					this.className += " sfhover";
				}
				theChildren[i].onmouseout=function() {
					this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
	}
}

function initRollovers() {
	pageItemRollovers('cmsFileList','div','Fodd|Feven', '');
	pageItemRollovers('cmsPublicationList','div','Fodd|Feven', '');
	pageItemRollovers('cmsEventList','div','Eodd|Eeven|featuredEvent','');
}









fixImageCaptionWidths = function() {
	if (!document.getElementById) return;
	var allDefLists = document.getElementsByTagName("dl");
	for (var i=0; i<allDefLists.length; i++) {
		var theDefList = allDefLists[i]
		if (hasClass(theDefList, "epImgCaption")) {
			var theImage = theDefList.childNodes[0].childNodes[0];
			if (document.all) {
				var theWidth = theImage.width;
			} else {
				var theWidth = theImage.width + 8;
			}
			theDefList.style.width = theWidth +"px";
			if (hasClass(theDefList, "capright")) {
				removeClass(theDefList, "capright");
				addClass(theDefList, "flRight");
			}
			if (hasClass(theDefList, "capleft")) {
				removeClass(theDefList, "capleft");
				addClass(theDefList, "flLeft");
			}
		}
	}
};






addLoadEvent(initRollovers);
addLoadEvent(fixImageCaptionWidths);


