xhtml = new WebPage();
window.onload = new Function("xhtml.init();");


/**
* Creates a new WebPage object with methods used by all pages, can be extended to add page specific methods.
*/
function WebPage()
	{
	// Step 1. Define Properties

	this.initialized = 0;
	this.menuTimeout = null;

	// Step 2. Define Methods

	/**
	* Sets up the initial page state and event handlers
	*/
	this.init = function()
		{
		this.processLinks();
		this.dropDownMenus();
		this.initialized = 1;

		// Initialize the scrolling news box on the homepage
		if (document.getElementById('scrollingNewsContent'))
			{
			this.news = new ScrollingNews();
			}
		}


	/**
	* Adds new window handler to "offsite" links, and hides selection marquee around active links
	*/
	this.processLinks = function()
		{
		var links = document.getElementsByTagName('a');
		for(x=0; x<links.length; x++)
			{
			links[x].onfocus = function()
				{
				this.blur();
				}
			if(/\boffsite\b/.exec(links[x].className))
				{
				links[x].onclick = function()
					{
					window.open(this.href,'_blank');
					return false;
					}
				}
			}
		}
	
	this.dropDownMenus = function()
		{
		var headings = new Array('headingPractice','headingRecruiting','headingAbout');
		var menus = new Array('menuPractice','menuRecruiting','menuAbout');

		// Add Event Handlers
		for (var x = 0; x < headings.length; x++)
			{
			// 1. Heading Display Menu
			document.getElementById(headings[x]).onmouseover = function()
				{
				xhtml.dropDownMenusHide();

				this.className += ' over';
				var menuId = this.id.replace(/heading/, 'menu');
				document.getElementById(menuId).style.visibility = 'visible';
				}

			// 2. Heading Hide Menu
			document.getElementById(headings[x]).onmouseout = function()
				{
				xhtml.menuTimeout = setTimeout("xhtml.dropDownMenusHide();", 250);
				}
			
			// 3. Add Menu Items Event Handlers
			var anchors = document.getElementById(menus[x]).getElementsByTagName('a');
			for (var y = 0; y < anchors.length; y++)
				{
				anchors[y].onmouseover = function()
					{
					clearTimeout(xhtml.menuTimeout);
					}
				anchors[y].onmouseout = function()
					{
					clearTimeout(xhtml.menuTimeout);
					xhtml.menuTimeout = setTimeout("xhtml.dropDownMenusHide();", 250);
					}
				}
			}
		}


	this.dropDownMenusHide = function()
		{
		var headings = new Array('headingPractice','headingRecruiting','headingAbout');
		var menus = new Array('menuPractice','menuRecruiting','menuAbout');

		clearTimeout(xhtml.menuTimeout);

		for (var x = 0; x < menus.length; x++)
			{
			document.getElementById(menus[x]).style.visibility = 'hidden';
			document.getElementById(headings[x]).className = document.getElementById(headings[x]).className.replace(/over/, '');
			}
		}


	/**
	* Finds the parent of the element, with of type parentTagName
	*
	* @param		element					The element object to find the parent of
	* @param		parentTagName		The type of parent element to find
	*
	* @return		The element's parent object of the specified type, or null if no parent of that type could be found
	*/
	this.findParent = function(element, parentTagName)
		{
		if (element == null)
			{
			return null;
			}
		else
			{
			if ( element.nodeType == 1 && element.tagName.toLowerCase() == parentTagName.toLowerCase() )
				{
				return element;
				}
			else
				{
				return this.findParent(element.parentNode, parentTagName);
				}
			}
		}

	}



function bioShow(showId)
	{
	for (var x = 1; x < 10; x++)
		{
		if (document.getElementById('bio'+x) != null)
			{
			document.getElementById('bio'+x).style.display = 'none';
			}
		}
	document.getElementById('bio'+showId).style.display = 'block';
	}