var dynPage = {
	DOMavailable : null,

	enable:function() {
		dynPage.DOMavailable = true;
		document.body.className += ' dynamic';

		// load the other functions
		drawers.init();
		tabs.init();
		ph.init();
		aInfo.init();
		ql.init();
		rf.init();
		sBg.init();
		pw.init();
		tl.init();
		pagination.init();
		insPop.init();
	}
}


var insPop = {
	frameWidth : null,
	frameHeight : null,
	scrollPosY : null,
	scrollPosX : null,

	init:function() {
		this.setLinkEvent();
	},
	
	setLinkEvent:function() {
		var aDivs = document.getElementsByTagName( 'div' );
		if (aDivs.length <= 0) return;

		var aInsBlock = [];
		for (var i = 0; i < aDivs.length; i++) {
			if (aDivs[i].className.indexOf('' + 'insBlock' + '') > -1) {
				aInsBlock[aInsBlock.length] = aDivs[i];
				if (aInsBlock.length <= 0) return;

				for (var j = 0; j < aInsBlock.length; j++) {
					var aInsLink = aInsBlock[j].getElementsByTagName( 'a' );
					if (aInsLink.length <= 0) return;

					for (var m = 0; m < aInsLink.length; m++) {
						if (aInsLink[m].className.indexOf('' + 'insLink' + '') > -1) {
							var insLink = aInsLink[m];
							
							insLink.onclick = function() {
								var oParent = this.parentNode;
								while (oParent.className.indexOf('' + 'insBlock' + '') == -1) {
									oParent = oParent.parentNode;
								}
								var aInsurance = oParent.getElementsByTagName( 'div' );
								if (aInsurance.length <= 0) return;

								for (var n = 0; n < aInsurance.length; n++) {
									if (aInsurance[n].className.indexOf('' + 'insurance' + '') > -1) {
										var insurance = aInsurance[n];
										if (insurance.className.indexOf( '' + 'insShow' + '' ) > -1) {
											insurance.className = insurance.className.replace(/insShow/g,'');
										} else { // otherwise add the class
											insurance.className += ' insShow';
							
											var oStyle = insurance.style;
											var oWidth = insurance.clientWidth;
											var oHeight = insurance.clientHeight;
								
											insPop.scrollPosition();
											insPop.windowDims();
											
											var posY = parseInt( ( insPop.frameHeight / 2 ) - ( oHeight / 2 ) + insPop.scrollPosY );
											var posX = parseInt( ( insPop.frameWidth / 2 ) - ( oWidth / 2 ) + insPop.scrollPosX );
											if ( 0 > posY ) posY = 0;
											if ( 0 > posX ) posX = 0;
							
											oStyle.top = posY + 'px';
											oStyle.left = posX + 'px';
										}
									}
								}
								return false;
							};
						}
					}
				}
			}

			if (aDivs[i].className.indexOf('' + 'closeIt' + '') > -1) {
				var closeIt = aDivs[i];
				closeIt.onclick = function() {
					var oParent = this.parentNode;
					while (oParent.className.indexOf('' + 'insurance' + '') == -1) {
						oParent = oParent.parentNode;
					}

					if (oParent.className.indexOf( '' + 'insShow' + '') > -1 ) {
						oParent.className = oParent.className.replace( /insShow/g,'' );
					}
					return false;
				};
			}
		}
	},

	windowDims:function() {
		if (self.innerWidth) {
			this.frameWidth = self.innerWidth;
			this.frameHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientWidth) {
			this.frameWidth = document.documentElement.clientWidth;
			this.frameHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			this.frameWidth = document.body.clientWidth;
			this.frameHeight = document.body.clientHeight;
		}
		return [ this.frameWidth, this.frameHeight ]
	},

	scrollPosition:function() {
		if (window.innerHeight) {
			this.scrollPosY = window.pageYOffset;
			this.scrollPosX = window.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			this.scrollPosY = document.documentElement.scrollTop;
			this.scrollPosX = document.documentElement.scrollLeft;
		} else if (document.body) {
			this.scrollPosY = document.body.scrollTop;
			this.scrollPosX = document.body.scrollLeft;
		}
		return [ this.scrollPosX, this.scrollPosY ];
	}
}


/* Content pagination Functions */
var pagination = {
	rootClassA : 'listFacultyParent',
	rootClassB :'patientCareParent',
	labelClass : 'alphaLinkListP',
	groupClass : 'alphaGroupListP',
	activeClass : 'selected',
	contentClass : 'content', //used if there's tabbed content

	init:function() {
		if(dynPage.DOMavailable) {
			// find all the alphaGroupLists and hide them, except for the first set
			var aDivs = document.getElementsByTagName('div');

			for (var i = 0; i < aDivs.length; i++) {
				if (aDivs[i].className.indexOf('' + this.rootClassA + '') > -1) {
					var oRoot = aDivs[i];
					if (oRoot) {
						var aGroups = oRoot.getElementsByTagName('div');
						if (aGroups.length <= 0) return;

						// Array to hold the alphaGroupLists
						var aGroupClass = [];
						for (var j = 0; j < aGroups.length; j++) {
							if (aGroups[j].className.indexOf('' + this.groupClass + '') > -1) {
								aGroupClass[aGroupClass.length] = aGroups[j];
								if (aGroupClass.length <= 0) return;
								for (var m = 0; m < aGroupClass.length; m++) {
									// set the class on the specified content to 'selected'
									if (m == 0) {
										aGroupClass[0].className += ' ' + this.activeClass;
									}
								}
							}
						}
						this.setLinkListEvent(oRoot);
					}
				}

				if (aDivs[i].className.indexOf('' + this.rootClassB + '') > -1) {
					var oRoot = aDivs[i];
					if (oRoot) {
						var aSubDivs = oRoot.getElementsByTagName('div');
						if (aSubDivs.length <= 0) return;
						for (var j = 0; j < aSubDivs.length; j++) {
							if (aSubDivs[j].className.indexOf('' + this.contentClass + '') > -1) {
								var oContent = aSubDivs[j];
								if (oContent) {
									var aGroups = oContent.getElementsByTagName('div');
									if (aGroups.length <= 0) return;

									// Array to hold the alphaGroupLists
									var aGroupClass = [];
									for (var m = 0; m < aGroups.length; m++) {
										if (aGroups[m].className.indexOf('' + this.groupClass + '') > -1) {
											aGroupClass[aGroupClass.length] = aGroups[m];
											if (aGroupClass.length <= 0) return;
											for (var n = 0; n < aGroupClass.length; n++) {
												// set the class on the specified content to 'selected'
												if (n == 0) {
													aGroupClass[0].className += ' ' + this.activeClass;
												}
											}
										}
									}
									this.setLinkListEvent(oContent);
								}
							}
						}
					}
				}
			}
		}
	},
	
	// set the handle onclick event
	setLinkListEvent:function(oRoot) {
	
		var aUL = oRoot.getElementsByTagName('ul');
		if (aUL.length == 0) return;
	
		for (i = 0; i < aUL.length; i++) {
			if (aUL[i].className.indexOf('' + pagination.labelClass + '') > -1) {
				var linkList = aUL[i];

				if (linkList) {
					var aLinks = linkList.getElementsByTagName('a');
					if (aLinks.length == 0) return;

					for (var j = 0; j < aLinks.length; j++) {
						aLinks[0].parentNode.className += ' ' + this.activeClass;

						// Set the onclick event
						aLinks[j].onclick = function() {
							// Find the parent element and set its class to 'selected'.
							var linkParent = this.parentNode;
							var linkRootUL = linkParent.parentNode;

							// if the class doesn't exist, add it
							if (linkParent.className.indexOf('' + pagination.activeClass + '') <= -1) {
								linkParent.className += ' ' + pagination.activeClass;
							}
							
							// set other tabs back to default
							pagination.resetInactive(linkRootUL, 'li', linkParent);
							
							var iHash = this.href.lastIndexOf('#')+1;
							var linkID = this.href.substring( iHash, this.href.length );
							
							// Find corresponding content element and set its class to 'active'.
							var oGroup = document.getElementById(linkID);
		
							// if the class doesn't exist, add it
							if (oGroup.className.indexOf('' + pagination.activeClass + '') <= -1) {
								oGroup.className += ' ' + pagination.activeClass;
							}
		
							// set the other content drawers back to default
							pagination.resetInactive(oRoot, 'div', oGroup);
		
							// don't follow that link!
							return false;
						}
					}
				}
			}
		}
	},
	
	// reset any open drawers when a new drawer is selected
	resetInactive:function(oRoot,subElem,current) {
		// Find all the sub elements
		var contentContainers = oRoot.getElementsByTagName(subElem);
	
		// Loop through the subElements and close all the listings except the current one
		for (var i = 0; i < contentContainers.length; i++) {
			// If the element is not the currently selected one
			if (contentContainers[i] != current) {
				// ...and it has a class of 'active'
				if (contentContainers[i].className.indexOf('' + pagination.activeClass + '') > -1) {
					// remove it
					contentContainers[i].className = contentContainers[i].className.replace(/selected/g,'');
				}
			}
		}
	}
}


/* Content Drawer Functions */
var drawers = {
	rootClass : 'contentDrawers',
	containerClass : 'content',
	handleClass : 'handle',
	activeClass : 'active',

	// find and initialize all the "drawers" in the document
	init:function() {
		if(dynPage.DOMavailable) {
			var aDivs = document.getElementsByTagName('div');

			for (var i = 0; i < aDivs.length; i++) {
				if (aDivs[i].className.indexOf(''+this.rootClass+'') > -1) {
					var oRoot = aDivs[i];
					if (oRoot) {
						var aContent = oRoot.getElementsByTagName('div');
						if (aContent.length <= 0) return;
		
						for (var j = 0; j < aContent.length; j++) {
							if (aContent[j].className.indexOf(''+this.containerClass+'') > -1) {
								var oContainer = aContent[j];
								this.getHandles(oContainer);							
							}
						}
					}
				}		
			}
		}
	},

	// find and initialize all the drawer handles
	getHandles:function(oRoot) {
		var aHandleElems = oRoot.getElementsByTagName('h3');
		if (aHandleElems.length <= 0) return;
	
		for (var i = 0; i < aHandleElems.length; i++) {
			if (aHandleElems[i].className.indexOf(''+this.handleClass+'') > -1) {
				var oHandle = aHandleElems[i];
				this.createHandle(oHandle);
				this.setHandleEvent(oHandle);
			}
		}
	},

	// create the actual handle link from the text
	createHandle:function(oHandle){
		// hold the text of the handle
		var aText = oHandle.innerHTML;
		// remove the handle text
		oHandle.removeChild(oHandle.firstChild);
		// create the links
		var oLink = document.createElement('a');
		// set the href
		oLink.href = '#';
		// set the tab text
		var oText = document.createTextNode(aText);
		// append it to the link
		oLink.appendChild(oText);
		// append the link to the list item
		oHandle.insertBefore(oLink, oHandle.firstChild);
	},

	// set the handle onclick event
	setHandleEvent:function(oHandle) {
		oHandle.onclick=function() {
			// Find the parent element and set its class to 'active'
			var pNode = this.parentNode;
			// if the class already exists, remove it
			if (pNode.className.indexOf(''+drawers.activeClass+'') > -1) {
				pNode.className = pNode.className.replace(/active/g,'');
			// otherwise add the class
			} else {
				pNode.className += ' '+drawers.activeClass;
			}
			drawers.resetInactive(this,'div',pNode);
			return false;
		}
	},

	// reset any open drawers when a new drawer is selected
	resetInactive:function(oHandle,subElem,pNode) {
		var rootObj = oHandle.parentNode;
	
		while (rootObj.className.indexOf(drawers.rootClass) == -1 && rootObj != 'document.body') {
			rootObj = rootObj.parentNode;
		}
	
		// Find all the sub elements
		var aSubElements = rootObj.getElementsByTagName(subElem);
	
		// Loop through the subElements and close all the drawers except the current one
		for (var i = 0; i < aSubElements.length; i++) {
			// If the element is not the currently selected one
			if (aSubElements[i] != pNode) {
				// ...and it has a class of 'active'
				if (aSubElements[i].className.indexOf(''+drawers.activeClass+'') > -1) {
					// remove it
					aSubElements[i].className = aSubElements[i].className.replace(/active/g,'');
				}
			}
		}
	}
}
/* end Content Drawer Functions*/


/* Content Tabs Functions */
var tabs = {
	rootClass : 'contentTabs',
	containerClass : 'content',
	handleClass : 'handle',
	activeClass : 'active',

	// find and initialize all the "tabs" in the document
	init:function() {
		if(dynPage.DOMavailable) {
			var aDivs = document.getElementsByTagName('div'); // a given

			for (var i = 0; i < aDivs.length; i++) {
				if (aDivs[i].className.indexOf(''+this.rootClass+'') > -1) {
					var oRoot = aDivs[i];
					if (oRoot) {
						oRoot.id = 'tabContainer_' + i;
						var aContent = oRoot.getElementsByTagName('div');

						if (aContent.length <= 0) return;
						// Array to hold the content containers
						var aContainers = [];
		
						for (var j = 0; j < aContent.length; j++) {
							if (aContent[j].className.indexOf(''+this.containerClass+'') > -1) {
								aContainers[aContainers.length] = aContent[j];
		
								for (var m = 0; m < aContainers.length; m++) {
									var oContainer = aContainers[m];
		
									// Set the ID on the sub elements
									oContainer.id = oRoot.id + '_tab_' + m;
									// set the class on the specified content to 'active'
									if (m == 0) {
										oContainer.className += ' '+this.activeClass;
									}
								}
							}
						}
						this.createHandles(oRoot);
						this.setActiveTab(oRoot);
						this.setHandleEvent(oRoot);
					}
				}		
			}
		}
	},

	// create the actual handle link from the text
	createHandles:function(oRoot) {
		// Array to hold the text items for the tabs
		var aText = [];
		var aHandles = oRoot.getElementsByTagName('h3');
		if (aHandles.length <= 0) return;
		// add the text from the handles to the text array
		for (var i=0; i < aHandles.length; i++) {
			if (aHandles[i].className.indexOf(''+this.handleClass+'') > -1)
			{
				aText[aText.length] = aHandles[i].innerHTML;
			}
		}

		// create the tab container
		var oDIV = document.createElement('div');
		// set the class
		oDIV.className = 'tabContainer';
	
		// create the tab list
		var oUL = document.createElement('ul');
		// set the class
		oUL.className = 'tabList';
		
		var oFragment = document.createDocumentFragment();
		
		for (var i=0; i < aText.length; i++) {
			// create the list items
			var oLI = document.createElement('li');
			// create the links
			var oLink = document.createElement('a');
			// set the href
			oLink.href = '#';
			// set an attribute to hold the content ID (used to identify the corresponding content)
			oLink.content = oRoot.id + '_tab_' + i;
			// set the tab text
			var oText = document.createTextNode(aText[i]);
			// append it to the link
			oLink.appendChild(oText);
			// append the link to the list item
			oLI.appendChild(oLink);
			oFragment.appendChild(oLI);
		}
		// add the list items to the list
		oUL.appendChild(oFragment);
		// add the list to the container
		oDIV.appendChild(oUL);
		// append the tab list to the top of the section
		oRoot.insertBefore(oDIV, oRoot.firstChild);
	},

	setActiveTab:function(oRoot) {
		// Find the tab list
		var aUL = oRoot.getElementsByTagName('ul');
		if (aUL.length == 0) return;
		
		for (i = 0; i < aUL.length; i++) {
			// Check that the list is the tab list
			var tabList = aUL[i];
			if (tabList && tabList.className.indexOf(''+'tabList'+'') > -1) {
				// get all the list items
				var arrTabs = tabList.getElementsByTagName('li');
	
				for (j = 0; j < arrTabs.length; j++) {
					// if this is the initial tab to display
					if (j == 0) {
						// set the class to 'active'
						arrTabs[j].className += ' '+this.activeClass;
					}
				}
			}
		}
	},
	
	// set the handle onclick event
	setHandleEvent:function(oRoot) {
	
		var aUL = oRoot.getElementsByTagName('ul');
		if (aUL.length == 0) return;
	
		for (i = 0; i < aUL.length; i++) {
			// Check that the element has been designated as a handle
			var tabList = aUL[i];
			if (tabList && tabList.className.indexOf(''+'tabList'+'') > -1) {
				var aLinks = tabList.getElementsByTagName('a');
	
				for (j = 0; j < aLinks.length; j++) {
					// Set the onclick event
					aLinks[j].onclick = function() {
						// Find the parent element and set its class to 'active'.
						var tabParent = this.parentNode;
						// if the class doesn't exist, add it
						if (tabParent.className.indexOf(''+tabs.activeClass+'') <= -1) {
							tabParent.className += ' '+tabs.activeClass;
						}
						// set other tabs back to default
						tabs.resetInactive(oRoot,'li',tabParent);
	
						// Find corresponding content element and set its class to 'active'.
						var oContent = document.getElementById(this.content);
	
						// if the class doesn't exist, add it
						if (oContent.className.indexOf(''+tabs.activeClass+'') <= -1) {
							oContent.className += ' '+tabs.activeClass;
						}
	
						// set the other content drawers back to default
						tabs.resetInactive(oRoot,'div',oContent);
	
						// don't follow that link!
						return false;
					}
				}
			}
		}
	},
	
	// reset any open drawers when a new drawer is selected
	resetInactive:function(oRoot,subElem,current) {
		// Find all the sub elements
		var contentContainers = oRoot.getElementsByTagName(subElem);
	
		// Loop through the subElements and close all the drawers except the current one
		for (var i = 0; i < contentContainers.length; i++) {
			// If the element is not the currently selected one
			if (contentContainers[i] != current) {
				// ...and it has a class of 'active'
				if (contentContainers[i].className.indexOf(''+tabs.activeClass+'') > -1) {
					// remove it
					contentContainers[i].className = contentContainers[i].className.replace(/active/g,'');
				}
			}
		}
	}
}
/* end Content Tabs Functions*/


// show premier branded box
var ph = {
	init:function() {
		if (dynPage.DOMavailable) {
			// find the list
			var aUL = document.getElementsByTagName('ul');
			
			for (var i = 0; i < aUL.length; i++) {
				if (aUL[i].className.indexOf(''+'premierList'+'') > -1) {
					var oRoot = aUL[i];
					if (oRoot) {
						// get all the LIs
						var cElems = oRoot.getElementsByTagName('li');
						if (cElems.length == 0) return;
			
						// go through all the LIs in the nav and set events
						for (var j = 0; j < cElems.length; j++) {
							// set onmouseover event
							cElems[j].onmouseover = function() {
								// set class
								this.className += ' active';
							}
							// set onmouseout event
							cElems[j].onmouseout = function() {
								// remove class
								this.className = this.className.replace(/active/g,'');
							}
						}
					}
				}
			}
		}
	}
}


/* Additional Info Tooltip Function */
var aInfo = {
	//find and initialize all the list result TABLEs in the document
	init:function() {
		if(dynPage.DOMavailable) {
			var aTables = document.getElementsByTagName('table'); // a given
		
			for (var i = 0; i < aTables.length; i++) {
				if (aTables[i].className.indexOf(''+'listResults'+'') > -1) {
					var oRoot = aTables[i];
					if (oRoot) {
						var aContent = oRoot.getElementsByTagName('div');
						if (aContent.length <= 0) return;
		
						for (var j = 0; j < aContent.length; j++) {
							if (aContent[j].className.indexOf(''+'specialtyContent'+'') > -1) {
								var oContainer = aContent[j];
								aInfo.getInfoLink(oContainer);							
							}
						}
					}
				}		
			}
		}
	},
	
	//get the info link
	getInfoLink:function(oRoot) {
		var aLinks = oRoot.getElementsByTagName('a');
		if (aLinks.length <= 0) return;
	
		for (var i = 0; i < aLinks.length; i++) {
			if (aLinks[i].className.indexOf(''+'info'+'') > -1) {
				var oLink = aLinks[i];
				aInfo.setInfoLinkEvent(oLink);
			}
		}
	},
	
	// set the info link events
	setInfoLinkEvent:function(oLink) {
	
		oLink.onclick=function() {
			return false;
		}
		oLink.onmouseover=function() {
			// Find the parent element and set its class to 'active'
			var pNode = this.parentNode;
			// if the class doesn't already exist, add it
			if (pNode.className.indexOf(''+'active'+'') <= -1) {
				pNode.className += ' active';
			}
		}
		oLink.onmouseout=function() {
			// Find the parent element and set its class to 'active'
			var pNode = this.parentNode;
			// if the class already exists, remove it
			if (pNode.className.indexOf(''+'active'+'') > -1) {
				pNode.className = pNode.className.replace(/active/g,'');
			}
		}
		oLink.onfocus=function() {
			// Find the parent element and set its class to 'active'
			var pNode = this.parentNode;
			// if the class doesn't already exist, add it
			if (pNode.className.indexOf(''+'active'+'') <= -1) {
				pNode.className += ' active';
			}
		}
		oLink.onblur=function() {
			// Find the parent element and set its class to 'active'
			var pNode = this.parentNode;
			// if the class already exists, remove it
			if (pNode.className.indexOf(''+'active'+'') > -1) {
				pNode.className = pNode.className.replace(/active/g,'');
			}
		}
	}
}


/* initialize the quicklinks nav */
var ql = {
	menuOpen : null,

	init:function() {
		if (dynPage.DOMavailable) {
			var oRoot = document.getElementById('qlContainer');
			if (oRoot) {
				var slideMenu = document.getElementById('qlMenu');
				var smTop = slideMenu.offsetTop;
				var smHeight = slideMenu.offsetHeight;
				var handle = document.getElementById('qlHandle');
				var handleHeight = handle.offsetHeight;
				smHeight -= handleHeight; // height of the clickable region
		
				slideMenu.style.top = (smTop-smHeight)+'px';
		
				handle.onclick = function() {
					if (ql.menuOpen == undefined || ql.menuOpen == false) {
						oRoot.className += ' active';
					}
					if (ql.menuOpen == true && oRoot.className.indexOf(''+'active'+'') > -1) {
						oRoot.className = oRoot.className.replace(/active/g,'');
					}
					ql.slideInOut(this);
					return false;
				};
			}
		}
	},


	slideInOut:function(obj) {
		var timer = 50;
		var distance = 0;
		var target = 1;
	
		var handle = obj;
		var handleHeight = obj.offsetHeight;
		var menuContainer = obj.parentNode.parentNode;
		var menu = obj.parentNode;
		var menuHeight = menu.offsetHeight;
		var menuDefault = 0-(menuHeight-handleHeight);
	
		window.slide = function() {
			var currentPosition = parseInt(menu.offsetTop);
			//if the menu is closed, slide it open
			if (ql.menuOpen == undefined || ql.menuOpen == false) {
	
				//set the height of the menu container to accomodate the open menu
				menuContainer.style.height = menuHeight + 'px';
	
				if (currentPosition < 0) {
					distance = Math.floor((target-currentPosition)/2);
					menu.style.top = (currentPosition+distance)+'px';
					setTimeout('slide()', timer);
				} else {
					// if the menu has finished closing, set the variable to true
					ql.menuOpen = true;
					return;
				}
			}
			//if the menu is open, slide it closed
			if (ql.menuOpen == true) {
				if (currentPosition > menuDefault) {
					if (distance == 0) {
						distance = -1;
					}
					distance = Math.floor((menuDefault-currentPosition)/2);
					menu.style.top = (currentPosition+distance)+'px';
					setTimeout('slide()', timer);
				} else {
					// if the menu has finished closing, reset the menu container, and set the variable to false
					menuContainer.style.height = handleHeight + 'px';
					ql.menuOpen = false;
					return;
				}
			}
		};
		slide();
	}
}

/* Reset Form function*/
var rf = {
	// find any "reset" buttons in the document
	init:function() {
		if (dynPage.DOMavailable) {
	
			var aInputs = document.getElementsByTagName('input');
			if (aInputs.length == 0) return;
		
			for (var i = 0; i < aInputs.length; i++) {
				if (aInputs[i].className.indexOf(''+'reset'+'') > -1) {
					aInputs[i].onclick = function() {
						rf.processForm(this);

						return false;
					};
				}		
			}
		}
	},

	// reset the form, and if specified, close the window
	processForm:function(obj) {
		if (confirm('Are you sure that you want to clear this form?')) {
		
			var aForms = document.getElementsByTagName('form');
			if (aForms.length == 0) return;

			for (var i = 0; i < aForms.length; i++) {
				// clear the form
				var theForm = aForms[i];
				var controls = theForm.elements;
	
				for (var j = 0; j < controls.length; j++) {
					var current = controls[j];
					if (current.type == 'text' || current.type == 'textarea') {
						current.value = '';
					}
					else if(current.type == 'checkbox') {
						current.checked = false;
					}
					else if(current.type == 'select-one') {
						current.selectedIndex = 0;
					}
				}
			}
	
			if (obj.className.indexOf(''+'close'+'') > -1) {
				self.close();
			}
		} else {
			return;
		}
	}
}


//init the URL array
var section = new Array(); //comes from bgImageSet.js

/* 
Set the background color
Matches the URL of the page to a list of defined URLs/images
and sets the background image accordingly
*/
var sBg = {
	path:null,

	// Set the background image for the page
	init:function() {
		if(section.length > 0) {
			//get the path
			this.getPath();
		
			//sort the 'section' array by number of slashes (descending)
			section.sort(this.sortBySlashes);
		
			//loop through the array's "url" value looking for a match to the path
			for(var i = 0; i < section.length; i++) {
				//if we find a match
				if(this.path.indexOf(section[i].url) > -1) {
					//set the HTML/BODY elements background image/color
					if(document.documentElement && document.documentElement.style) {
						if(section[i].imgSrc) {
							document.documentElement.style.backgroundImage = 'url(' + escape(section[i].imgSrc) + ')';
						}
						if(section[i].color) {
							document.documentElement.style.backgroundColor = '#' + section[i].color;
						}
					}
					if (document.body && document.body.style) {
						if(section[i].imgSrc) {
							document.body.style.backgroundImage = 'url(' + escape(section[i].imgSrc) + ')';
						}
						if(section[i].color) {
							document.body.style.backgroundColor = '#' + section[i].color;
						}
					}
					break;
				}
			}
		}
	},

	//get the string portion of a URL
	getPath:function() {
		var pathString = window.location.pathname;
		//we don't want to use the path encoded (in case there are spaces)
		pathString = unescape(pathString);
		//we don't want filenames
		if(pathString.indexOf('.') > -1) {
			pathString = pathString.substring(0,pathString.lastIndexOf('/') + 1);
		}
		//set trailing slash
		pathString = this.setTrailingSlash(pathString);
		this.path = pathString;
	},

	//set a trailing slash on a string
	setTrailingSlash:function(str) {
		var lastChar = str.substring(str.length - 1); //last character in the string
		var matchChar = '/'; //character to match
		//if the last character isn't what we're looking for
		if(matchChar != lastChar) {
			//add it
			str += matchChar;
		}
		return str;
	},

	//sort array by number of slashes (descending)
	sortBySlashes:function(a, b) {
		var x = sBg.checkSlashes(a.url);
		var y = sBg.checkSlashes(b.url);
		return ((x > y) ? -1 : ((x < y) ? 1 : 0));
	},

	//check the number of slashes in a given string
	checkSlashes:function(string) {
		var matchChar = '/'; //pattern to match
		var count = 0; //count
		for (var i = 0; i < string.length; i++) {
			if (matchChar == string.substr(i,matchChar.length)) {
				count++;
			}
		}
		return count;
	}
}

/*
Window Popup Function

Usage:
	Adding a class name of 'popWin' to a link will initialize it as a popup window.
	The HREF of the link will be used as the URL of the window.
	There is a default window size set, but that can be overridden by adding dimensions
	as part of the class name.

	Parameter Usage
		popWin[ width ]-[ height ]-[ scrollbar ]-[ resize ]-[ statusbar ]-[ toolbar ]-[ menubar ]-[ location ]

	Example:
		<a class="popWin" href="someURL.html">link</a>
		This will open a popup window at the default size.

	Example(s) with parameters:
		<a class="popWin400-550" href="someURL.html">link</a>
		This will open a popup window that is 400 pixels wide and 550 pixels tall.
		
		<a class="popWin400-550-1-0-1" href="someURL.html">link</a>
		This will open a popup window that is 400 pixels wide, 550 pixels tall, has scrollbars, is not resizable, and has a statusbar.
*/

var pw = {
	init:function() {
		if (dynPage.DOMavailable) {
			//create an array of all the links in the page
			var aLinks = document.getElementsByTagName('a');
			// loop through the links
			for (var i = 0; i < aLinks.length; i++) {
				//if the link has a classname that starts with 'popWin'
				if (aLinks[i].className.indexOf(''+'popWin'+'') > -1) {
					//set the onclick event for the link
					aLinks[i].onclick = function() {
						var param = [];
						//get the parameters from the classname if specified
						var parameters = /popWin?(.\S{5,19})?/.exec(this.className);
						//split the parameters up
						if (parameters[1]) {
							var params = parameters[1].split('-');
							for (var j = 0; j < params.length; j++) {
								param[j] = params[j];
							}
						}
						//open the window
						popup(this.href, param[0], param[1], param[2], param[3], param[4], param[5], param[6], param[7]);
						return false;
					};
				}		
			}
		}
	}
}

/* 
Set the target on external links
*/
var tl = {
	init:function() {
		var dom = document.domain.toString();
		for (var i=0; i<=(document.links.length-1); i++) {
			if( (document.links[i].href.indexOf(dom)==-1) && 
			    (document.links[i].href.indexOf('ftp:\/\/')==-1) &&
			    (document.links[i].href.indexOf('javascript:')==-1) ) {
			document.links[i].target = '_top';
			}
		}
	}
}

// window popup
function popup(url,w,h,sc,r,st,t,m,l) {
	//init variables
	w 	= (!w || w == 'undefined' || w == '') ? 300 : w;
	h 	= (!h || h == 'undefined' || h == '') ? 300 : h;
	sc 	= (!sc || sc == 'undefined' || sc == '') ? 0 : sc;
	r 	= (!r || r == 'undefined' || r == '') ? 0 : r;
	st 	= (!st || st == 'undefined' || st == '') ? 0 : st;
	t 	= (!t || t == 'undefined' || t == '') ? 0 : t;
	m 	= (!m || m == 'undefined' || m == '') ? 0 : m;
	l 	= (!l || l == 'undefined' || l == '') ? 0 : l;

	//open the window
	window.open(url,'','width=' + w + ', height=' + h + ', scrollbars=' + sc + ', resizable=' + r + ', status=' + st + ', toolbar=' + t + ', menubar=' + m + ', location=' + l + ', directories=0');
}


/*
The following is a function originally created by:
Dean Edwards - http://dean.edwards.name/weblog/2006/06/again/
updated by others
Rob Cherny - http://www.cherny.com/webdev/27/domloaded-updated-again
They assist in loading/rendering the dynamic elements of the page as quickly as possible. 
*/

var DomLoaded = {
	onload: [],
	loaded: function()
	{
		if (arguments.callee.done) return;
		arguments.callee.done = true;
		for (i = 0;i < DomLoaded.onload.length;i++) DomLoaded.onload[i]();
	},
	load: function(fireThis)
	{
		this.onload.push(fireThis);
		if (document.addEventListener) 
			document.addEventListener("DOMContentLoaded", DomLoaded.loaded, null);
		if (/KHTML|WebKit/i.test(navigator.userAgent))
		{ 
			var _timer = setInterval(function()
			{
				if (/loaded|complete/.test(document.readyState))
				{
					clearInterval(_timer);
					delete _timer;
					DomLoaded.loaded();
				}
			}, 10);
		}
		/*@cc_on @*/
		/*@if (@_win32)
		var proto = "src='javascript:void(0)'";
		if (location.protocol == "https:") proto = "src=//0";
		document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
		    if (this.readyState == "complete") {
		        DomLoaded.loaded();
		    }
		};
		/*@end @*/
	   window.onload = DomLoaded.loaded;
	}
};

DomLoaded.load(dynPage.enable);


// Functions for browse events search form
function browseEventFBCheck() {
	if (document.browseEventFB.searchFor.value != "") {
		document.browseEventFB.eventType.disabled = false;
		document.browseEventFB.department.disabled = false;
	} else {
		document.browseEventFB.eventType.disabled = true;
		document.browseEventFB.department.disabled = true;
	}
}
function browseEventFBSubmit() {
	if (document.browseEventFB.searchFor.value != "") {
		document.getElementById("eDiv").style.display = "none";
		return true;
	} else {
		document.getElementById("eDiv").style.display = "inline";
		return false;
	}
}

