function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}




//mailwin
function mailwin(theurl) {
	window.open(strWebRoot + "content/global/mailpage.cfm?theurl="+theurl,"mailwin","width=400,height=280,status=no,scrollbars=yes,location=no,toolbar=no,menubar=no,resizable=yes");
}

function IsNumeric(val) {
	var ValidChars = "0123456789.";
	for (i=0; i<val.length; i++) {
		if (ValidChars.indexOf(val.charAt(i)) == -1) return false
	}
	return true
}

function IsEmpty(val) {
	for (i=0; i<val.length; i++) { 
		if (val.charAt(i) != ' ') return false
	}
	return true
}

function IsValidEmail(val) {
	var iLen = val.length;
	if 	((iLen < 6) || (val.indexOf('@') < 1) || ((val.charAt(iLen - 3) != '.') && (val.charAt(iLen - 4) != '.')) ) return false
	return true
}

function NumCBGroupChecked(f,strName){
	var colEl = f.elements;
	var iChecked = 0;
	for (var i=0; i<colEl.length; i++){
		el = colEl[i];
		if (el.name && (el.name == strName) && el.checked) iChecked++;
	}
	return iChecked;
}

function LTrim(s) {
	var whitespace = ' \t\n\r';
	if (s.length == 0) return s;
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++;
		s = s.substring(j, i);
	}
	return s;
}

function RTrim(s) {
	var whitespace = ' \t\n\r';
	if (s.length == 0) return s;
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--;
		s = s.substring(0, i+1);
	}
	return s;
}

function Trim(s) {
   return RTrim(LTrim(s));
}

//===================================================================
function highlight(node) {
	var parent = node.parentElement;
	var sibling = parent.parentElement.firstChild;
	var img = sibling.firstChild;
	if (window.event.type == "mouseover") {
		img.style.display = "";
		sibling.className = "dot-on";
		parent.className = "on";
	} else {
		img.style.display = "none";
		sibling.className = "dot";
		parent.className = "";
	}
}

function filterKeyword(field) {
	var keyword = field;
	var e = window.event;
	if (e.type == "focus" && keyword.value == "search") {
		keyword.value = "";
	} else if (e.type == "blur" && keyword.value == "") {
		keyword.value = "Search";
	}
}



/******************************************************************************
	DHTML Menu Functions
******************************************************************************/
function Browser() {
	var ua, s, i;
	this.version = 0;
	this.ok = false;
	
	ua = ua=navigator.userAgent.toLowerCase();
	
	this.isOpera = ua.indexOf('opera') != -1;
	this.isKonq = ua.indexOf('konqueror') != -1;
	this.isIE = ua.indexOf('msie') != -1;
	if (this.isIE) this.version = parseFloat(ua.substr(ua.indexOf('msie') + 4));
	this.isAol = ua.indexOf('aol') != -1;
	this.isNav = ua.indexOf('netscape6/') != -1;
	if (this.isNav) this.version = parseFloat(ua.substr(ua.indexOf('netscape6/') + 10));
	this.isGecko = ua.indexOf('gecko') != -1;
	if (this.isGecko){
		this.isNav = true;
		this.version = 6.1;
	}
	this.isSafari = ua.indexOf("safari") != -1;
	
	this.isMac = ua.indexOf('mac') != -1;
	this.isWin = ua.indexOf('win') != -1;
	this.isLin = !(this.bMac || this.bWin);
	
	this.isMacIE = this.isIE && this.isMac;
	
	this.ok = 	(this.isIE && this.isWin && this.version >= 4) || 
				(this.isIE && this.isMac && this.version >= 5) || 
				(this.isNavigator && this.version >= 5) || 
				(this.isGecko) || 
				(this.Safari);
	//alert(this.ok);
}

var browser = new Browser();
//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------
var activeButton = null;
function dmRootButtonGo(event, menuId, xOffset, yOffset) {
	var button;
	// Get the target button element.
	if (browser.isIE) button = window.event.srcElement;
	else button = event.currentTarget;
	
	button.blur();		// Blur focus from the link to remove that annoying outline.

	// Associate the named menu to this button if not already done.
	// Additionally, initialize menu display.
	if (button.menu == null) {
		button.menu = document.getElementById(menuId);
		if (button.menu.isInitialized == null) menuInit(button.menu);
	}

	// Set mouseout event handler for the button, if not already done.	
	if (button.onmouseout == null) button.onmouseout = buttonOrMenuMouseout;
	
	// Exit if this button is the currently active one.
	if (button == activeButton) return false;

	// Reset the currently active button, if any.
	if (activeButton != null) dmResetRootButton(activeButton);
	
	// Activate this button, unless it was the currently active one.
	if (button != activeButton) {
		dmDepressRootButton(button, xOffset, yOffset);
		activeButton = button;
	} else activeButton = null;
	
	return false;
}

function dmRootButtonOver(event, menuId, xOffset, yOffset) {
	var button;
	
	if (!browser.ok) return;
	bMouseOut = false;
	
	if(!xOffset) xOffset = 0;
	if(!yOffset) yOffset = 0;
	
	// Activates this button's menu if no other is currently active.
	if (activeButton == null) {
		dmRootButtonGo(event, menuId, xOffset, yOffset);
		return;
	}
	
	// Find the target button element.
	if (browser.isIE) button = window.event.srcElement;
	else button = event.currentTarget;
	
	// If any other button menu is active, make this one active instead.
	if (activeButton != null && activeButton != button) dmRootButtonGo(event, menuId, xOffset, yOffset);
}

function dmDepressRootButton(button, xOffset, yOffset) {
	var x, y;
	// opens the submenu
	
	// Set mouseout event handler for the button, if not already done.
	if (button.onmouseout == null) button.onmouseout = buttonOrMenuMouseout;
	if (button.menu.onmouseout == null) button.menu.onmouseout = buttonOrMenuMouseout;
	
	// Position the associated drop down menu under the button and show it.
	x = getPageOffsetLeft(button) + xOffset;
	y = getPageOffsetTop(button) + button.offsetHeight + yOffset;
	
	button.menu.style.left = x + "px";
	button.menu.style.top  = y + "px";
	button.menu.style.visibility = "visible";
}

function dmResetRootButton(button) {
	// Restore the button's style class.	
	removeClassName(button, "dmRootButtonActive");

	// Hide the button's menu, first closing any sub menus.
	if (button.menu != null) {
		closeSubMenu(button.menu);
		button.menu.style.visibility = "hidden";
	}
}

//----------------------------------------------------------------------------
// Code to handle the menus and sub menus.
//----------------------------------------------------------------------------

function dmMenuMouseover(event) {
	var menu;
	
	bMouseOut = false;
	
	// Find the target menu element.
	if (browser.isIE) menu = getContainerWith(window.event.srcElement, "DIV", "dmMenu");
	else menu = event.currentTarget;
	
	// Close any active sub menu.
	if (menu.activeItem != null) closeSubMenu(menu);
}

function dmMenuItemMouseover(event, menuId) {
	var item, menu, x, y;
	// Find the target item element and its parent menu element.
	
	bMouseOut = false;
		
	if (browser.isIE) item = getContainerWith(window.event.srcElement, "A", "dmMenuItem");
	else item = event.currentTarget;
	menu = getContainerWith(item, "DIV", "dmMenu");

	// Close any active sub menu and mark this one as active.
	if (menu.activeItem != null) closeSubMenu(menu);
	menu.activeItem = item;
	
	// Highlight the item element.
	item.className += " dmMenuItemHighlight";
	
	// Initialize the sub menu, if not already done.
	if (item.subMenu == null) {
		item.subMenu = document.getElementById(menuId);
		if (item.subMenu.isInitialized == null) menuInit(item.subMenu);
	}

	// Set mouseout event handler for the sub menu, if not already done.
	if (item.subMenu.onmouseout == null) item.subMenu.onmouseout = buttonOrMenuMouseout;
		
	// Get position for submenu based on the menu item.
	x = getPageOffsetLeft(item) + item.offsetWidth;
	y = getPageOffsetTop(item);
	
	// Adjust position to fit in view.
	var maxX, maxY;
	
	if (browser.isNav) {
		maxX = window.scrollX + window.innerWidth;
		maxY = window.scrollY + window.innerHeight;
	} else if (browser.isMacIE) {
		maxX = document.body.scrollLeft + document.body.clientWidth;
		maxY = document.body.scrollTop + document.body.clientHeight;
	} else if (browser.isIE) {
		maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
		(document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
		maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
		(document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
	}
	maxX -= item.subMenu.offsetWidth;
	maxY -= item.subMenu.offsetHeight;

	if (x > maxX) x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth + (menu.offsetWidth - item.offsetWidth));
	y = Math.max(0, Math.min(y, maxY));

	// Position and show the sub menu.
	item.subMenu.style.left = x + 5 + "px";
	item.subMenu.style.top  = y + 5 + "px";
	item.subMenu.style.visibility = "visible";

	// Stop the event from bubbling.
	if (browser.isIE) window.event.cancelBubble = true;
	else event.stopPropagation();
}

function closeSubMenu(menu) {
	if (menu == null || menu.activeItem == null) return;
	// Recursively close any sub menus.
	if (menu.activeItem.subMenu != null) {
		closeSubMenu(menu.activeItem.subMenu);
		menu.activeItem.subMenu.style.visibility = "hidden";
		menu.activeItem.subMenu = null;
	}
	removeClassName(menu.activeItem, "dmMenuItemHighlight");
	menu.activeItem = null;
}


var bMouseOut = false;
function buttonOrMenuMouseout(event) {
	var el;
	// If there is no active button, exit.
	if (activeButton == null) return;
	
	// Find the element the mouse is moving to.
	if (browser.isIE) el = window.event.toElement;
	else if (event.relatedTarget != null) el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);
	
	// If the element is not part of a menu, reset the active button.
	if (getContainerWith(el, "DIV", "dmMenu") == null) {
		bMouseOut = true;
		setTimeout('buttonOrMenuMouseout_2();',500);
	}
}

function buttonOrMenuMouseout_2(){
	if (bMouseOut){
		bMouseOut = false;
		dmResetRootButton(activeButton);
		activeButton = null;
	}
}

//----------------------------------------------------------------------------
// Code to initialize menus.
//----------------------------------------------------------------------------
function menuInit(menu) {
	var itemList, spanList;
	var textEl, arrowEl;
	var itemWidth;
	var w, dw;
	var i, j;
	
	// Find the width of a menu item.
	itemList = menu.getElementsByTagName("A");
	if (itemList.length > 0) itemWidth = itemList[0].offsetWidth;
	else return;
	
	if (browser.isIE && browser.isMac){
		itemList[0].style.display = 'inline';
		iMaxItemWidth = itemList[0].offsetWidth;
		for (i=1; i < itemList.length; i++) {
			itemList[i].style.display = 'inline';
			iMaxItemWidth = Math.max(iMaxItemWidth, itemList[i].offsetWidth);
			itemList[i].style.display = 'block';
		}
		for (i=0; i < itemList.length; i++) itemList[i].style.width = iMaxItemWidth;
	} else if (browser.isIE) {
		// Fix IE hover problem by setting an explicit width on first item of the menu.	
		w = itemList[0].offsetWidth;
		itemList[0].style.width = w + "px";
		dw = itemList[0].offsetWidth - w;
		w -= dw;
		itemList[0].style.width = w + "px";
	}
	
	// Mark menu as initialized
	menu.isInitialized = true;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------

function getContainerWith(node, tagName, className) {
	// Starting with the given node, find the nearest containing element with the specified tag name and style class.
	while (node != null) {
		if (node.tagName != null && node.tagName == tagName && hasClassName(node, className)) return node;
		node = node.parentNode;
	}	
	return node;
}

function hasClassName(el, name) {
	var i, list;
	// Return true if the given element currently has the given class name.
	list = el.className.split(" ");
	for (i = 0; i < list.length; i++) if (list[i] == name) return true;
	return false;
}

function removeClassName(el, name) {
	var i, curList, newList;
	if (el.className == null) return;
	// Remove the given class name from the element's className property.
	newList = new Array();
	curList = el.className.split(" ");
	for (i = 0; i < curList.length; i++) if (curList[i] != name) newList[newList.length] = (curList[i]);
	el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {
	var x;
	x = el.offsetLeft;
	if (browser.isSafari && getContainerWith(window.event.srcElement, "DIV", "dmMenu")){
		x -= document.getElementsByTagName('BODY').item(0).offsetLeft;
	} else if (browser.isMacIE && getContainerWith(window.event.srcElement, "DIV", "dmMenu")) {
		x += parseInt(document.body.currentStyle.marginLeft) - 8;
	}
	while (el.offsetParent != null){
		el = el.offsetParent;
		x += el.offsetLeft;
	}
	return x;
}

function getPageOffsetTop(el) {
	var y;
	y = el.offsetTop;
	//alert(el.nodeName+':'+el.offsetTop);
	if (browser.isSafari && getContainerWith(window.event.srcElement, "DIV", "dmMenu")){
		y -= document.getElementsByTagName('BODY').item(0).offsetTop;
	} else if (browser.isMacIE && getContainerWith(window.event.srcElement, "DIV", "dmMenu")) {
		y += parseInt(document.body.currentStyle.marginTop) - 6;
	}
	while (el.offsetParent != null){
		el = el.offsetParent;
		//alert(el.nodeName+':'+el.offsetTop);
		y += el.offsetTop;
	}
	return y;
}
/******************************************************************************
	END OF DHTML Menu Functions
******************************************************************************/


function IsValidEmail(val) {
	var iLen = val.length;
	if 	((iLen < 6) || (val.indexOf('@') < 1) || ((val.charAt(iLen - 3) != '.') && (val.charAt(iLen - 4) != '.')) ) return false
	return true
}

function formVal(formName){
	var msg = "";
	var typeList = "text,password";
	for (var i=0; i<document.form.elements.length; i++){
		tag = document.form.elements[i];
		if (typeList.indexOf(tag.type) >= 0 && tag.getAttribute('required') == 1 && tag.value == "") {
			msg = msg + "<LI>" + tag.title + " </LI>";
		};
		if (tag.name == "email" && tag.value.length != 0) {
			flag = IsValidEmail(tag.value);
			if (!flag) {
				msg = msg + "<LI>Please enter a valid email address</LI>";
			}
		};
		if (tag.type == "password" && tag.value.length > 0  && tag.value.length < 4) {
			msg = msg + "<LI>" + "Password is too short";
		}
		if (tag.name == "password2" && tag.value != "" && tag.value != document.form.password.value)
			msg = msg + "<LI>" + "Password confirmation";
	};
	document.getElementById('err').innerHTML = "";
	if (msg != "") {
		document.getElementById('err').innerHTML = "Those fields are required: <UL>" + msg + "</UL>";
		return false;
	} else {
		return true;
	}
}

function showEmailNotice(){
	var email_notice = 'E-mail Notice\n \nPlease read this notice prior to sending an email to our firm.\n \nSending an e-mail to our firm will not create an attorney-client relationship.  Absent such relationship, any e-mail sent to us will not be considered privileged or confidential.  If you desire to become a client of our firm, you must call our office at the number listed on our "Offices and Contacts" page.\n \nPlease click the OK button to confirm that you have read and understand this notice. \n \n';
	return confirm(email_notice);
}