/* Design & Code (c) Empire Group, Inc. */

function isBrowserIE6(){
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var b_version=parseFloat(b_version.substring(b_version.indexOf("MSIE")+5));
	if ((browser=="Microsoft Internet Explorer")&&(b_version<7)) return true;
	else return false;
}

var myrules = {
	'#search_txt' : function(el){
		el.onfocus = function(){
			if(this.value=="Search FindLaw") this.value = "";
		}
		el.onblur = function(){
			if(this.value=="") this.value = "Search FindLaw";
		}
	},
	'#legal_issue' : function(el){
		el.onfocus = function(){
			if(this.value=="e.g., Bankruptcy") this.value = "";
		}
		el.onblur = function(){
			if(this.value=="") this.value = "e.g., Bankruptcy";
		}
	},
	'#attorney_name' : function(el){
		el.onfocus = function(){
			if(this.value=="Optional") this.value = "";
		}
		el.onblur = function(){
			if(this.value=="") this.value = "Optional";
		}
	},
	'#location' : function(el){
		el.onfocus = function(){
			if(this.value=="e.g., Palo Alto, CA or 94036") this.value = "";
		}
		el.onblur = function(){
			if(this.value=="") this.value = "e.g., Palo Alto, CA or 94036";
		}
	},
	'#question' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '0px 0px';
			this.style.height = '110px';
			this.select('h2')[0].style.backgroundImage = 'url(http://images.findlaw.com/www/lp/chevron_down.gif)';
			$('question_ctnt').show();
		}
		el.onmouseout = function(){
			this.style.backgroundPosition = '244px 0px';
			this.style.height = '2px';
			this.select('h2')[0].style.backgroundImage = 'url(http://images.findlaw.com/www/lp/chevron.gif)';
			$('question_ctnt').hide();
		}
	},
	'#advSearchLink' : function(el){
		el.onclick = function(){
			var box = $("advSearchContent");
			var parentBox = $("advSearchParent");
			var parentBoxReplace = $("advSearchParentReplace");
			var parentBoxBtm = parentBox.select('div.btm_border')[0];
			if(typeof openSearch!="boolean"){
				parentBoxReplace.setStyle({height:parentBox.getHeight()+"px"});
				box.toggle();
				parentBoxReplace.show();
				parentBox.absolutize();
				parentBoxBtm.absolutize();
				if(!isBrowserIE6()){
					parentBox.setStyle({backgroundImage:'url(http://images.findlaw.com/www/lp/home_mid_box_left_btm_shadow_large.png)',backgroundPosition:'left bottom',width:'483px',paddingBottom:'7px'});
				}
				else{
					parentBox.style.filter += "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/www/lp/home_mid_box_left_btm_shadow_large.png',sizingMethod='image')";
				}
				parentBoxBtm.hide();
				openSearch = true;
				$(this).addClassName('slActive');
			}
			else{
				box.toggle();
				parentBoxReplace.hide();
				parentBox.relativize();
				parentBoxBtm.relativize();
				parentBox.setStyle({backgroundImage:'url(http://images.findlaw.com/www/lp/home_mid_box_left_rep.png)',backgroundPosition:'center bottom',width:'477px',paddingBottom:'0px'});
				parentBoxBtm.show();
				openSearch = null;
				$(this).removeClassName('slActive');
			}
			return false;
		}
	},
	'#advFLSearchLink' : function(el){
		el.onclick = function(){
			if($('advSearchContent').visible()){
				$(this).removeClassName('slActive');
			} else {
				$(this).addClassName('slActive');
			}
			$('advSearchContent').toggle();
			return false;
		}
	},
	'#tools .share' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-59px 0px';
			$('share_box').toggle();
//			this.style.overflow = 'visible';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
		}
	},
	'#share_box' : function(el){
		el.onmouseover = function(){
			this.show();
		}
		el.onmouseout = function(){
			this.hide();
		}
	},
	'#btnA-L' : function(el){
		el.onclick = function(){
			$('atoz_nav').select('li.selected').each(function(res){
				res.removeClassName('selected');
			});
			$('resParent').select('.atoz_res').each(function(res){
				res.hide();
			});
			$(this.parentNode).addClassName('selected');
			$('resA-L').show();
		}
	},
	'#btnI-J' : function(el){
		el.onclick = function(){
			$('atoz_nav').select('li.selected').each(function(res){
				res.removeClassName('selected');
			});
			$('resParent').select('.atoz_res').each(function(res){
				res.hide();
			});
			$(this.parentNode).addClassName('selected');//this line throws an error in ie6
			$('resI-J').show();
		}
	},
	'#btnK-N' : function(el){
		el.onclick = function(){
			$('atoz_nav').select('li.selected').each(function(res){
				res.removeClassName('selected');
			});
			$('resParent').select('.atoz_res').each(function(res){
				res.hide();
			});
			$(this.parentNode).addClassName('selected');
			$('resK-N').show();
		}
	},
	'#btnO-S' : function(el){
		el.onclick = function(){
			$('atoz_nav').select('li.selected').each(function(res){
				res.removeClassName('selected');
			});
			$('resParent').select('.atoz_res').each(function(res){
				res.hide();
			});
			$(this.parentNode).addClassName('selected');
			$('resO-S').show();
		}
	},
	'#btnT-W' : function(el){
		el.onclick = function(){
			$('atoz_nav').select('li.selected').each(function(res){
				res.removeClassName('selected');
			});
			$('resParent').select('.atoz_res').each(function(res){
				res.hide();
			});
			$(this.parentNode).addClassName('selected');
			$('resT-W').show();
		}
	},
	'#btnX-Z' : function(el){
		el.onclick = function(){
			$('atoz_nav').select('li.selected').each(function(res){
				res.removeClassName('selected');
			});
			$('resParent').select('.atoz_res').each(function(res){
				res.hide();
			});
			$(this.parentNode).addClassName('selected');
			$('resX-Z').show();
		}
	},

	'#find_lawyer_btn input' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-145px 0px';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
		}
	},
	'#sub_ctnt.home div.home_mid_ctnt div.box_left div.col input#post_q': function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-94px 0px';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
		}
	},
	'#sub_ctnt div.learn_panel div.learn_box input#find_lawyer_btn' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-93px 0px';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
		}
	},
	'#sub_ctnt div.comment_add input.cmt_submit' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-77px 0px';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
		}
	},
	'input.browse_btn' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-92px 0px';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
		}
	},
	'#sub_ctnt div.filter_search div#filter_left input.filter_search_btn' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-60px 0px';
			this.style.color = '#ff9900';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
			this.style.color = '#ffffff';
		}
	},
	'div.nav_right div.vote_sec input.vote' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-44px 0px';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
		}
	},
	'#sub_ctnt div.search_pro input.search_btn_narrow' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-112px 0px';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '0px 0px';
		}
	},
	'#search_btn' : function(el){
		el.onmouseover = function(){
			this.style.backgroundPosition = '-6px 0px';
		},
		el.onmouseout = function(){
			this.style.backgroundPosition = '100px 0px';
		}
	}	
};
Behaviour.register(myrules);

bcResize = function(){
	var menuItems = $$('ul#bc_nav li.bc_link a.nav_hd span');
	menuItems.each( function(menuItem){
		newWidth = Element.getWidth(menuItem) + 16; //14 is the total horizontal padding and margins surrounding the element
		menuItem.parentNode.parentNode.style.width  = newWidth+"px";
		$(menuItem.parentNode.parentNode).select('div.line')[0].setStyle({width:newWidth - 2 + "px"});
	});
}

/* Temporarily hide the "tabber" class so it does not "flash"
   on the page as plain HTML. After tabber runs, the class is changed
   to "tabberlive" and it will appear. */
document.write('<style type="text/css">.tabber{display:none;}<\/style>');