// JavaScript Document
// SPRY (for homepage collapsible panel)
// SpryCollapsiblePanel.js - version 0.7 - Spry Pre-Release 1.6.1
//
// Copyright (c) 2006. Adobe Systems Incorporated.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//   * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//   * Neither the name of Adobe Systems Incorporated nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.CollapsiblePanel = function(element, opts)
{
	this.element = this.getElement(element);
	this.focusElement = null;
	this.hoverClass = "CollapsiblePanelTabHover";
	this.openClass = "CollapsiblePanelOpen";
	this.closedClass = "CollapsiblePanelClosed";
	this.focusedClass = "CollapsiblePanelFocused";
	this.enableAnimation = true;
	this.enableKeyboardNavigation = true;
	this.animator = null;
	this.hasFocus = false;
	this.contentIsOpen = true;

	this.openPanelKeyCode = Spry.Widget.CollapsiblePanel.KEY_DOWN;
	this.closePanelKeyCode = Spry.Widget.CollapsiblePanel.KEY_UP;

	Spry.Widget.CollapsiblePanel.setOptions(this, opts);

	this.attachBehaviors();
};

Spry.Widget.CollapsiblePanel.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};

Spry.Widget.CollapsiblePanel.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
		return;
	ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.CollapsiblePanel.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

Spry.Widget.CollapsiblePanel.prototype.hasClassName = function(ele, className)
{
	if (!ele || !className || !ele.className || ele.className.search(new RegExp("\\b" + className + "\\b")) == -1)
		return false;
	return true;
};

Spry.Widget.CollapsiblePanel.prototype.setDisplay = function(ele, display)
{
	if( ele )
		ele.style.display = display;
};

Spry.Widget.CollapsiblePanel.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};

Spry.Widget.CollapsiblePanel.prototype.onTabMouseOver = function(e)
{
	this.addClassName(this.getTab(), this.hoverClass);
	return false;
};

Spry.Widget.CollapsiblePanel.prototype.onTabMouseOut = function(e)
{
	this.removeClassName(this.getTab(), this.hoverClass);
	return false;
};

Spry.Widget.CollapsiblePanel.prototype.open = function()
{
	this.contentIsOpen = true;
	if (this.enableAnimation)
	{
		if (this.animator)
			this.animator.stop();
		this.animator = new Spry.Widget.CollapsiblePanel.PanelAnimator(this, true, { duration: this.duration, fps: this.fps, transition: this.transition });
		this.animator.start();
	}
	else
		this.setDisplay(this.getContent(), "block");

	this.removeClassName(this.element, this.closedClass);
	this.addClassName(this.element, this.openClass);
};

Spry.Widget.CollapsiblePanel.prototype.close = function()
{
	this.contentIsOpen = false;
	if (this.enableAnimation)
	{
		if (this.animator)
			this.animator.stop();
		this.animator = new Spry.Widget.CollapsiblePanel.PanelAnimator(this, false, { duration: this.duration, fps: this.fps, transition: this.transition });
		this.animator.start();
	}
	else
		this.setDisplay(this.getContent(), "none");

	this.removeClassName(this.element, this.openClass);
	this.addClassName(this.element, this.closedClass);
};

Spry.Widget.CollapsiblePanel.prototype.onTabClick = function(e)
{
	if (this.isOpen())
		this.close();
	else
		this.open();

	this.focus();

	return this.stopPropagation(e);
};

Spry.Widget.CollapsiblePanel.prototype.onFocus = function(e)
{
	this.hasFocus = true;
	this.addClassName(this.element, this.focusedClass);
	return false;
};

Spry.Widget.CollapsiblePanel.prototype.onBlur = function(e)
{
	this.hasFocus = false;
	this.removeClassName(this.element, this.focusedClass);
	return false;
};

Spry.Widget.CollapsiblePanel.KEY_UP = 38;
Spry.Widget.CollapsiblePanel.KEY_DOWN = 40;

Spry.Widget.CollapsiblePanel.prototype.onKeyDown = function(e)
{
	var key = e.keyCode;
	if (!this.hasFocus || (key != this.openPanelKeyCode && key != this.closePanelKeyCode))
		return true;

	if (this.isOpen() && key == this.closePanelKeyCode)
		this.close();
	else if ( key == this.openPanelKeyCode)
		this.open();
	
	return this.stopPropagation(e);
};

Spry.Widget.CollapsiblePanel.prototype.stopPropagation = function(e)
{
	if (e.preventDefault) e.preventDefault();
	else e.returnValue = false;
	if (e.stopPropagation) e.stopPropagation();
	else e.cancelBubble = true;
	return false;
};

Spry.Widget.CollapsiblePanel.prototype.attachPanelHandlers = function()
{
	var tab = this.getTab();
	if (!tab)
		return;

	var self = this;
	Spry.Widget.CollapsiblePanel.addEventListener(tab, "click", function(e) { return self.onTabClick(e); }, false);
	Spry.Widget.CollapsiblePanel.addEventListener(tab, "mouseover", function(e) { return self.onTabMouseOver(e); }, false);
	Spry.Widget.CollapsiblePanel.addEventListener(tab, "mouseout", function(e) { return self.onTabMouseOut(e); }, false);

	if (this.enableKeyboardNavigation)
	{
		// XXX: IE doesn't allow the setting of tabindex dynamically. This means we can't
		// rely on adding the tabindex attribute if it is missing to enable keyboard navigation
		// by default.

		// Find the first element within the tab container that has a tabindex or the first
		// anchor tag.
		
		var tabIndexEle = null;
		var tabAnchorEle = null;

		this.preorderTraversal(tab, function(node) {
			if (node.nodeType == 1 /* NODE.ELEMENT_NODE */)
			{
				var tabIndexAttr = tab.attributes.getNamedItem("tabindex");
				if (tabIndexAttr)
				{
					tabIndexEle = node;
					return true;
				}
				if (!tabAnchorEle && node.nodeName.toLowerCase() == "a")
					tabAnchorEle = node;
			}
			return false;
		});

		if (tabIndexEle)
			this.focusElement = tabIndexEle;
		else if (tabAnchorEle)
			this.focusElement = tabAnchorEle;

		if (this.focusElement)
		{
			Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "focus", function(e) { return self.onFocus(e); }, false);
			Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "blur", function(e) { return self.onBlur(e); }, false);
			Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement, "keydown", function(e) { return self.onKeyDown(e); }, false);
		}
	}
};

Spry.Widget.CollapsiblePanel.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler);
	}
	catch (e) {}};

Spry.Widget.CollapsiblePanel.prototype.preorderTraversal = function(root, func)
{
	var stopTraversal = false;
	if (root)
	{
		stopTraversal = func(root);
		if (root.hasChildNodes())
		{
			var child = root.firstChild;
			while (!stopTraversal && child)
			{
				stopTraversal = this.preorderTraversal(child, func);
				try { child = child.nextSibling; } catch (e) { child = null; }
			}
		}
	}
	return stopTraversal;
};

Spry.Widget.CollapsiblePanel.prototype.attachBehaviors = function()
{
	var panel = this.element;
	var tab = this.getTab();
	var content = this.getContent();

	if (this.contentIsOpen || this.hasClassName(panel, this.openClass))
	{
		this.addClassName(panel, this.openClass);
		this.removeClassName(panel, this.closedClass);
		this.setDisplay(content, "block");
		this.contentIsOpen = true;
	}
	else
	{
		this.removeClassName(panel, this.openClass);
		this.addClassName(panel, this.closedClass);
		this.setDisplay(content, "none");
		this.contentIsOpen = false;
	}

	this.attachPanelHandlers();
};

Spry.Widget.CollapsiblePanel.prototype.getTab = function()
{
	return this.getElementChildren(this.element)[0];
};

Spry.Widget.CollapsiblePanel.prototype.getContent = function()
{
	return this.getElementChildren(this.element)[1];
};

Spry.Widget.CollapsiblePanel.prototype.isOpen = function()
{
	return this.contentIsOpen;
};

Spry.Widget.CollapsiblePanel.prototype.getElementChildren = function(element)
{
	var children = [];
	var child = element.firstChild;
	while (child)
	{
		if (child.nodeType == 1 /* Node.ELEMENT_NODE */)
			children.push(child);
		child = child.nextSibling;
	}
	return children;
};

Spry.Widget.CollapsiblePanel.prototype.focus = function()
{
	if (this.focusElement && this.focusElement.focus)
		this.focusElement.focus();
};

/////////////////////////////////////////////////////

Spry.Widget.CollapsiblePanel.PanelAnimator = function(panel, doOpen, opts)
{
	this.timer = null;
	this.interval = 0;

	this.fps = 60;
	this.duration = 500;
	this.startTime = 0;

	this.transition = Spry.Widget.CollapsiblePanel.PanelAnimator.defaultTransition;

	this.onComplete = null;

	this.panel = panel;
	this.content = panel.getContent();
	this.doOpen = doOpen;

	Spry.Widget.CollapsiblePanel.setOptions(this, opts, true);

	this.interval = Math.floor(1000 / this.fps);

	var c = this.content;

	var curHeight = c.offsetHeight ? c.offsetHeight : 0;
	this.fromHeight = (doOpen && c.style.display == "none") ? 0 : curHeight;

	if (!doOpen)
		this.toHeight = 0;
	else
	{
		if (c.style.display == "none")
		{
			// The content area is not displayed so in order to calculate the extent
			// of the content inside it, we have to set its display to block.

			c.style.visibility = "hidden";
			c.style.display = "block";
		}

		// Clear the height property so we can calculate
		// the full height of the content we are going to show.

		c.style.height = "";
		this.toHeight = c.offsetHeight;
	}

	this.distance = this.toHeight - this.fromHeight;
	this.overflow = c.style.overflow;

	c.style.height = this.fromHeight + "px";
	c.style.visibility = "visible";
	c.style.overflow = "hidden";
	c.style.display = "block";
};

Spry.Widget.CollapsiblePanel.PanelAnimator.defaultTransition = function(time, begin, finish, duration) { time /= duration; return begin + ((2 - time) * time * finish); };

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.start = function()
{
	var self = this;
	this.startTime = (new Date).getTime();
	this.timer = setTimeout(function() {self.stepAnimation();}, this.interval);
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.stop = function()
{
	if (this.timer)
	{
		clearTimeout(this.timer);

		// If we're killing the timer, restore the overflow property.

		this.content.style.overflow = this.overflow;
	}

	this.timer = null;
};

Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.stepAnimation = function()
{
	var curTime = (new Date).getTime();
	var elapsedTime = curTime - this.startTime;

	if (elapsedTime >= this.duration)
	{
		if (!this.doOpen)
			this.content.style.display = "none";
		this.content.style.overflow = this.overflow;
		this.content.style.height = this.toHeight + "px";
		if (this.onComplete)
			this.onComplete();
		return;
	}

	var ht = this.transition(elapsedTime, this.fromHeight, this.distance, this.duration);

	this.content.style.height = ((ht < 0) ? 0 : ht) + "px";

	var self = this;
	this.timer = setTimeout(function() {self.stepAnimation();}, this.interval);
};

Spry.Widget.CollapsiblePanelGroup = function(element, opts)
{
	this.element = this.getElement(element);
	this.opts = opts;

	this.attachBehaviors();
};

Spry.Widget.CollapsiblePanelGroup.prototype.setOptions = Spry.Widget.CollapsiblePanel.prototype.setOptions;
Spry.Widget.CollapsiblePanelGroup.prototype.getElement = Spry.Widget.CollapsiblePanel.prototype.getElement;
Spry.Widget.CollapsiblePanelGroup.prototype.getElementChildren = Spry.Widget.CollapsiblePanel.prototype.getElementChildren;

Spry.Widget.CollapsiblePanelGroup.prototype.setElementWidget = function(element, widget)
{
	if (!element || !widget)
		return;
	if (!element.spry)
		element.spry = new Object;
	element.spry.collapsiblePanel = widget;
};

Spry.Widget.CollapsiblePanelGroup.prototype.getElementWidget = function(element)
{
	return (element && element.spry && element.spry.collapsiblePanel) ? element.spry.collapsiblePanel : null;
};

Spry.Widget.CollapsiblePanelGroup.prototype.getPanels = function()
{
	if (!this.element)
		return [];
	return this.getElementChildren(this.element);
};

Spry.Widget.CollapsiblePanelGroup.prototype.getPanel = function(panelIndex)
{
	return this.getPanels()[panelIndex];
};

Spry.Widget.CollapsiblePanelGroup.prototype.attachBehaviors = function()
{
	if (!this.element)
		return;

	var cpanels = this.getPanels();
	var numCPanels = cpanels.length;
	for (var i = 0; i < numCPanels; i++)
	{
		var cpanel = cpanels[i];
		this.setElementWidget(cpanel, new Spry.Widget.CollapsiblePanel(cpanel, this.opts));
	}
};

Spry.Widget.CollapsiblePanelGroup.prototype.openPanel = function(panelIndex)
{
	var w = this.getElementWidget(this.getPanel(panelIndex));
	if (w && !w.isOpen())
		w.open();
};

Spry.Widget.CollapsiblePanelGroup.prototype.closePanel = function(panelIndex)
{
	var w = this.getElementWidget(this.getPanel(panelIndex));
	if (w && w.isOpen())
		w.close();
};

Spry.Widget.CollapsiblePanelGroup.prototype.openAllPanels = function()
{
	var cpanels = this.getPanels();
	var numCPanels = cpanels.length;
	for (var i = 0; i < numCPanels; i++)
	{
		var w = this.getElementWidget(cpanels[i]);
		if (w && !w.isOpen())
			w.open();
	}
};

Spry.Widget.CollapsiblePanelGroup.prototype.closeAllPanels = function()
{
	var cpanels = this.getPanels();
	var numCPanels = cpanels.length;
	for (var i = 0; i < numCPanels; i++)
	{
		var w = this.getElementWidget(cpanels[i]);
		if (w && w.isOpen())
			w.close();
	}
};
// search form clear and recall
function clickclear(thisfield, defaulttext, color) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
		if (!color) {
			color = "999999";
		}
		thisfield.style.color = "#" + color;
	}
}
function clickrecall(thisfield, defaulttext, color) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
		if (!color) {
			color = "999999";
		}
		thisfield.style.color = "#" + color;
	}
}
// template JS
var lightboxMorph = null;
cases = new Array();

cases['Personal Injury and Wrongful Death Claims'] = new Array(
	"Select a Case Type..."
	,"5:Airplane Accidents"
	,"16:Animal Attacks"
	,"162:Asbestos Injuries"
	,"151:Automobile Accidents"
	,"10:Bicycle Accidents"
	,"17:Boating/Swimming"
	,"20:Bus Accidents"
	,"160:Construction Accidents"
	,"129:Libel and Slander"
	,"164:Maritime/Jones Act"
	,"202:Mass Tort Litigation"
	,"11:Motorcycle Accidents"
	,"18:Other Accidents"
	,"21:Pedestrian Accidents"
	,"128:Property Damage"
	,"14:Railroad Accidents"
	,"19:Slips and Falls"
	,"130:Toxic Torts"
	,"22:Truck Accidents"
	,"15:Wrongful Death"
);

cases['Creditor and Debtor Law'] = new Array(
	"Select a Case Type..."
	,"12:Auto Reposessions"
	,"27:Business Workouts"
	,"92:Collection Cases"
	,"28:Credit Card Debt"
	,"13:Credit Problems"
	,"25:Creditors Rights"
	,"29:Eliminate Debts"
	,"236:Loan Modification"
	,"26:Mortgage Foreclosures"
);

cases['Bankruptcy Law'] = new Array(
	"Select a Case Type..."
	,"189:Bankruptcy Litigation"
	,"23:Business Bankruptcy"
	,"24:Consumer Bankruptcy"
	,"30:Transactions"
);

cases['Corporation and Business Law'] = new Array(
	"Select a Case Type..."
	,"31:Business Litigation"
	,"34:Corporations"
	,"36:Franchise Law"
	,"156:Internet Law"
	,"37:Limited Liability Companies"
	,"175:Mergers and Acquisitions"
	,"33:Partnerships"
	,"174:Sports Law"
	,"35:Starting a Business"
);

cases['Gaming Law'] = new Array(
	"Select a Case Type..."
	,"203:Gaming Contracts"
	,"32:Gaming Law, General"
);

cases['Consumer Claims and Protection'] = new Array(
	"Select a Case Type..."
	,"127:Defective Products"
	,"161:Equipment Failures"
	,"39:General Fraud"
	,"97:Guarantees"
	,"199:Harassing Phone Calls"
	,"41:Mail Fraud"
	,"42:Motor Vehicle Fraud"
	,"40:Telephone Fraud"
);

cases['Criminal and Traffic Law'] = new Array(
	"Select a Case Type..."
	,"43:Arrests and Searches"
	,"50:Assault"
	,"44:Burglary"
	,"208:Criminal Defense, General"
	,"51:Domestic Battery"
	,"57:Drug Crimes"
	,"45:Drunk Driving"
	,"52:Embezzlement"
	,"168:Federal Crimes"
	,"58:Gaming Crimes"
	,"46:Juvenile"
	,"53:Murder"
	,"60:Parole & Probation"
	,"157:Post Conviction Relief"
	,"47:Rape"
	,"54:Robbery"
	,"59:Sex Offenses"
	,"169:State Crimes"
	,"48:Tax Evasion"
	,"55:Theft Crimes"
	,"94:Traffic Law"
	,"56:Vehicle Accidents"
	,"49:White Collar Crime"
);

cases['Employment Law and Job Discrimination'] = new Array(
	"Select a Case Type..."
	,"166:Age Discrimination"
	,"102:Americans with Disabilities Act"
	,"103:Civil Rights Law"
	,"62:Discrimination Claims"
	,"61:Harassment Issues"
	,"172:Job Discrimination"
	,"173:Sexual Harassment"
	,"171:Whistleblowers"
);

cases['Workers Compensation'] = new Array(
	"Select a Case Type..."
	,"228:Workers Compensation, Employee"
	,"227:Workers Compensation, Employer"
	,"63:Workers Compensation, General"
);

cases['Copyright and Trademark Law'] = new Array(
	"Select a Case Type..."
	,"115:Art Law"
	,"118:Communications Law"
	,"121:Computer Law"
	,"116:Copyright Law"
	,"119:Internet/Ecommerce"
	,"122:Patent Law"
	,"64:Rights of Publicity"
	,"65:Theatrical"
	,"117:Trade Secrets"
	,"120:Trademark Law"
);

cases['Wills, Trusts, Estate Planning and Probate Matters'] = new Array(
	"Select a Case Type..."
	,"66:Asset Protection"
	,"68:Elder Law"
	,"70:Estates"
	,"154:Guardianships"
	,"69:Probate"
	,"194:Trust and Estate Disputes"
	,"71:Trusts"
	,"67:Wills"
);

cases['Family Law'] = new Array(
	"Select a Case Type..."
	,"72:Adoption Law"
	,"77:Annulments"
	,"82:Child Custody"
	,"73:Child Support"
	,"218:Collaborative Law"
	,"78:Divorce Law"
	,"163:Domestic Mediation"
	,"83:Domestic Violence"
	,"197:Grandparent Rights"
	,"79:Guardianship"
	,"205:Juvenile Representation"
	,"74:Legal Separation"
	,"198:Name Changes"
	,"76:Parental Rights"
	,"155:Paternity"
	,"84:Pre-Nuptial Agreements"
	,"75:Property Division"
	,"80:Restraining Orders"
	,"204:Sexual Abuse Cases"
	,"85:Spousal Support"
	,"196:Surrogacy"
	,"209:Termination of Parental Rights"
	,"81:Visitation Issues"
);

cases['Corporate Finance and Securities Law'] = new Array(
	"Select a Case Type..."
	,"88:Broker Disputes"
	,"90:Commodities Law"
	,"87:Investment Terms"
	,"89:Raising Capital"
	,"193:Securities Fraud"
	,"91:Securities Law"
);

cases['General Practice Law'] = new Array(
	"Select a Case Type..."
	,"124:Arbitration"
	,"126:Civil Lawsuits"
	,"95:Contracts"
	,"93:Legal Remedies"
	,"96:Licenses"
	,"150:Mediation"
	,"125:Small Claims"
	,"98:Suing/Being Sued"
);

cases['Government Law'] = new Array(
	"Select a Case Type..."
	,"99:Agricultural Law"
	,"100:Education Law"
	,"179:FDA Issues"
	,"101:Public Contracts"
);

cases['Military Law'] = new Array(
	"Select a Case Type..."
	,"104:Military Law, General"
);

cases['Immigration and Customs Law'] = new Array(
	"Select a Case Type..."
	,"159:Asylum Cases"
	,"105:Citizenship"
	,"149:Deportation"
	,"167:Employer Sanctions"
	,"106:Permanent Residence"
	,"107:Visas"
);

cases['Insurance Law'] = new Array(
	"Select a Case Type..."
	,"108:Auto Insurance"
	,"111:Business Insurance"
	,"113:Disability Insurance"
	,"109:Health Insurance"
	,"112:Insurance Bad Faith"
	,"114:Life Insurance"
	,"110:Property Insurance"
);

cases['Appellate Practice'] = new Array(
	"Select a Case Type..."
	,"211:Appeals, General"
	,"123:Criminal Appeals"
	,"216:Domestic and Family Law Appeals"
);

cases['Real Estate Law'] = new Array(
	"Select a Case Type..."
	,"131:Buying/Selling a Home"
	,"135:Commercial Real Estate"
	,"138:Condemnation"
	,"152:Development"
	,"237:Foreclosure"
	,"133:Homeowners Associations"
	,"137:Landlord/Tenant"
	,"134:Mortgage Matters and Loan Modification"
	,"139:Real Estate Law, General"
	,"192:Real Estate Litigation"
	,"140:Zoning"
);

cases['Construction Law'] = new Array(
	"Select a Case Type..."
	,"136:Construction Defects"
	,"132:Construction Law, General"
	,"191:Construction Litigation"
);

cases['Taxation Law'] = new Array(
	"Select a Case Type..."
	,"141:Business Tax Law"
	,"144:Discharge of Federal Income Taxes"
	,"147:Estate Tax Law"
	,"142:Gift Tax Law"
	,"145:Income Tax Law"
	,"148:Property Tax Law"
	,"143:Sales and Use Tax Law"
	,"146:State Tax Law"
);

cases['Labor Law'] = new Array(
	"Select a Case Type..."
	,"170:Employment Contracts"
	,"220:Terminating an Employee"
	,"158:Wage Claims"
	,"221:Wrongful Termination"
);

cases['Health Care Law'] = new Array(
	"Select a Case Type..."
	,"180:Antitrust"
	,"181:Bioethics"
	,"182:Credentials/Peer Review"
	,"183:Fraud/Abuse"
	,"207:Health Care Law, General"
	,"184:Licenses/Certification"
	,"185:Mergers/Transactions"
	,"186:Reimbursement"
	,"187:Research Compliance"
);

cases['Social Security Law'] = new Array(
	"Select a Case Type..."
	,"200:Denied Disability Claims"
	,"201:Denied Supplemental Income Claims"
	,"226:Social Security Law, General"
);

cases['Mining Law'] = new Array(
	"Select a Case Type..."
	,"206:Mining Law, General"
);

cases['Environmental Law'] = new Array(
	"Select a Case Type..."
	,"210:Environmental Law, General"
);

cases['Professional Malpractice'] = new Array(
	"Select a Case Type..."
	,"212:Dental Malpractice"
	,"213:Medical Malpractice"
	,"214:Other Malpractice"
);

cases['Water Rights Law'] = new Array(
	"Select a Case Type..."
	,"215:Water Rights Law, General"
);


function addEditList(form, member_id) {
			var cities_serviced = "";
                        var query_string = '';
                        for(var i=0; i<form.elements.length; i++) {
				if(form.elements[i].name == 'city[]' && form.elements[i].options.length > 0) {
					query_string += "cities_serviced="; 
					for(var j=0; j<form.elements[i].options.length; j++)
						if(form.elements[i].options[j].selected) {
							query_string += form.elements[i].options[j].value + ", ";
							cities_serviced += ((cities_serviced != "") ? "," : "") + form.elements[i].options[j].value;
						}
					query_string += "&";
				} else
					query_string += form.elements[i].name + '=' + form.elements[i].value + '&';
			}
			if(document.getElementById('cities_serviced'))
				document.getElementById('cities_serviced').value = cities_serviced;
                        query_string += 'member_id=' + member_id;
			new Request({
				url: 'http://www.attorneyguide.com/addEditList.php',
				method: 'post',
				onSuccess: function(responseText, responseXML) {
				if(responseText == 'success')
					//form.innerHTML = 'Submission Successful!';
                                        form.submit();
				else
					//form.innerHTML = 'Submission Failed.<br />Response: '+responseText;
                                        form.submit();
				},
				onFailure: function(instance) {
					//form.innerHTML = 'Internal Error - Check Security Settings.';
                                        form.submit();
				}
			}).send(query_string);
                        return false;
}

function validateFindAttorney(form) {
    if( (document.getElementById('first_name').value == '(First Name)' || document.getElementById('first_name').value == '') &&
        (document.getElementById('last_name').value == '(Last Name)' || document.getElementById('last_name').value == '') ) {
        alert("Either a first name or last name is required to continue");
        return false;
    }
    if( document.getElementById('first_name').value == '(First Name)' ) {
      document.getElementById('first_name').value = '';
    }
    if( document.getElementById('last_name').value == '(Last Name)' ) {
      document.getElementById('last_name').value = '';
    }
    document.getElementById('temp_keywords').value = (document.getElementById('first_name').value == "")?document.getElementById('last_name').value:document.getElementById('first_name').value + " " + document.getElementById('last_name').value;
    var temp_name = document.getElementById('first_name').value;
    if ( temp_name.indexOf(' ') ){
      var name_split = temp_name.split(" ",2);
      document.getElementById('first_name').value = name_split[0];
      //document.getElementById('initial').value = name_split[1];
    }

			new Request({
				url: 'http://www.attorneyguide.com/index.php/search/check_feature_log',
				method: 'post',
				onSuccess: function(responseText, responseXML) {
				if(responseText == 'success')
                                        form.submit();
				/*else
					alert('Submission Failed. Response: '+responseText);*/
				},
				onFailure: function(instance) {
					//alert('Internal Error - Check Security Settings.');
				}
			}).send('first_name=' + document.getElementById('first_name').value + '&last_name=' + document.getElementById('last_name').value);

    return false;
}
function validateCertAttorney() {
    if( document.getElementById('practice_area').options[document.getElementById('practice_area').selectedIndex].value == "" ||
document.getElementById('case_type').options[document.getElementById('case_type').selectedIndex].value == "" ||
document.getElementById('city').options[document.getElementById('city').selectedIndex].value == "") {
        alert("All criteria is required to continue");
        return false;
    }
    return true;
}
function validateBasicSearch() {
    if( document.getElementById('city2').options[document.getElementById('city2').selectedIndex].value == "" ||
document.getElementById('practice_area2').options[document.getElementById('practice_area2').selectedIndex].value == "" ||
document.getElementById('case_type2').options[document.getElementById('case_type2').selectedIndex].value == "") {
        alert("All criteria is required to continue");
        return false;
    }
    return true;
}
function validateAdvancedSearch() {    
    if((document.getElementById('city').options[document.getElementById('city').selectedIndex].value == "" ||
document.getElementById('practice_area').options[document.getElementById('practice_area').selectedIndex].value == "") &&
(document.getElementById('firm_name').value == "") && (document.getElementById('keywords2').value == "") && (document.getElementById('last_name').value == "" || document.getElementById('last_name').value == "(Last Name)")) {
        alert("Either keywords, a last name, or all other fields are required to continue");
        return false;
    }
    if(document.getElementById('first_name').value == "(First Name)") document.getElementById('first_name').value = "";
    if(document.getElementById('last_name').value == "(Last Name)") document.getElementById('last_name').value = "";
    return true;
}
function updateCases(practice) {
    if (document.images) {
        // get text of actual selection
        var sel = practice.options[practice.selectedIndex].text;

        if (!sel) {
            sel = practice;
        }
        act = cases[sel];
        if (!act) {
            act = new Array("Select a Case Type...");
        }

        //practice.form.category[].length = act.length;
       practice.form.elements["category[]"].length = act.length;
        var subs='';
        for(i = 0; i < act.length; i++) {
            //practice.form.category[].options[i].text = act[i];
            if(act[i] != "Select a Case Type...") {
              var brokenstring = act[i].split(":")
             practice. form.elements["category[]"].options[i].value = brokenstring[0];
             practice. form.elements["category[]"].options[i].text = brokenstring[1];
              subs+=brokenstring[0]+'|';
            }
        }
       subs=subs.substr(0, subs.length-1);
      //practice. form.elements["category[]"].options[0].value = subs;
    } else {
        alert("Your browser does not allow this script to modify the "
            + "cases selection lists. You should update your browser.");
    }
}
function updateCasesWithName(practice) {
    if (document.images) {
        // get text of actual selection
        var sel = practice.options[practice.selectedIndex].text;

        if (!sel) {
            sel = practice;
        }
        act = cases[sel];
        if (!act) {
            act = new Array("Select a Case Type...");
        }

        //practice.form.category[].length = act.length;
       practice.form.elements["category[]"].length = act.length;
        var subs='';
        for(i = 0; i < act.length; i++) {
            //practice.form.category[].options[i].text = act[i];
            if(act[i] != "Select a Case Type...") {
              var brokenstring = act[i].split(":")
             practice. form.elements["category[]"].options[i].value = brokenstring[1];
             practice. form.elements["category[]"].options[i].text = brokenstring[1];
              subs+=brokenstring[1]+', ';
            }
        }
       subs=subs.substr(0, subs.length-2);
      practice.form.elements["category[]"].options[0].value = subs;
    } else {
        alert("Your browser does not allow this script to modify the "
            + "cases selection lists. You should update your browser.");
    }
}
function showLightbox(obj) {
  if(lightboxMorph == null) {
    lightboxMorph = new Fx.Morph('lightbox', { duration: 200, transition: Fx.Transitions.Quad.easeIn, link: "cancel" });
    lightboxMorph.set({'opacity' : 0});
  }
  $('lightbox').innerHTML = '<a onclick="return hideLightbox()" href="/" class="close">Close</a>';
  switch(obj.href.substr(obj.href.lastIndexOf('/')+1)) {
	case 'practice_area':
		$('lightbox').innerHTML += '<strong>Practice Area</strong> - Please select from the drop down list an area of law that matches your issue, for example: Family Law or Criminal Law.';
		break;
	case 'case_type':
		$('lightbox').innerHTML += '<strong>Case Type</strong> - Please select from the drop down list the type of situation that matches your issue, for example: Divorce or Drunk Driving.';
		break;
  }
  lightboxMorph.start({ opacity: 1 });
}

function hideLightbox() {
  if(lightboxMorph == null) {
    lightboxMorph = new Fx.Morph('lightbox', { duration: 200, transition: Fx.Transitions.Quad.easeIn, link: "cancel" });
    lightboxMorph.set({'opacity' : 1 });
  }
  lightboxMorph.start({ opacity: 0 }).chain(function() {
      $('lightbox').innerHTML = "";
  });
  return false;
}

/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( {blankgif:'ext.gif'} );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);
jQuery.noConflict();
jQuery(document).ready(function(){
                var calculatedWidth = 0;
                jQuery(document).pngFix( );
                jQuery('#nav li').each(function(i) { calculatedWidth += jQuery(this).width(); });
                jQuery('#nav').css('width',calculatedWidth);
                var calculatedWidth = 0;
                jQuery('#footer_nav li').each(function(i) { calculatedWidth += jQuery(this).width(); });
                jQuery('#footer_nav').css('width',calculatedWidth);
                jQuery('a').each(function(i) { jQuery(this).click(function(e) {this.blur();}); });
	});
