

/* Credits: Stu Nicholls - stuHover functions only */
/* URL: http://www.stunicholls.com/menu/pro_dropdown_2/stuHover.js */

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function bookmark(){
//12/20/10 - SLS Addition - just bookmark the current page
pageName=window.location.pathname;
url="http://www.shouselaw.com"+pageName;
title=document.title;

if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
window.external.AddFavorite(url,title);
} else if (navigator.appName == "Netscape") {
window.sidebar.addPanel(title,url,"");
} else {
alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
}
}

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];}}
}

preload = function() {
	MM_preloadImages('http://www.shouselaw.com/images/brown-button.jpg','http://www.shouselaw.com/images/brown-button-over.jpg','http://www.shouselaw.com/images/blue-button.jpg','http://www.shouselaw.com/images/blue-button-over.jpg', 'http://www.shouselaw.com/share/images/icons/bm_ask.gif', 'http://www.shouselaw.com/share/images/icons/bm_blinklist.gif', 'http://www.shouselaw.com/share/images/icons/bm_blogmarks.gif', 'http://www.shouselaw.com/share/images/icons/bm_bluedot.gif', 'http://www.shouselaw.com/share/images/icons/bm_delicious.gif', 'http://www.shouselaw.com/share/images/icons/bm_digg.gif', 'http://www.shouselaw.com/share/images/icons/bm_facebook.gif', 'http://www.shouselaw.com/share/images/icons/bm_furl.gif', 'http://www.shouselaw.com/share/images/icons/bm_google.gif', 'http://www.shouselaw.com/share/images/icons/bm_icq.gif', 'http://www.shouselaw.com/share/images/icons/bm_linkagogo.gif', 'http://www.shouselaw.com/share/images/icons/bm_live.gif', 'http://www.shouselaw.com/share/images/icons/bm_mixx.gif', 'http://www.shouselaw.com/share/images/icons/bm_myspace.gif', 'http://www.shouselaw.com/share/images/icons/bm_reddit.gif', 'http://www.shouselaw.com/share/images/icons/bm_simpy.gif', 'http://www.shouselaw.com/share/images/icons/bm_spurl.gif', 'http://www.shouselaw.com/share/images/icons/bm_stumbleupon.gif', 'http://www.shouselaw.com/share/images/icons/bm_technorati.gif', 'http://www.shouselaw.com/share/images/icons/bm_twitter.gif', 'http://www.shouselaw.com/share/images/icons/bm_yahoo.gif', 'http://www.shouselaw.com/images/loading-circle.gif')
}

if (window.attachEvent) window.attachEvent("onload", preload);

// onhover ajax mouseovers scripts

var posX;
var posY;
var ldv;
var thType;
var dnme2;
var ii;
var allDvs=new Array();

// browser size detection
var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

// find tooltip parent link position script
function findPos(popdv){
	var obj = document.getElementById(popdv);
	posX = obj.offsetLeft;
	posY = obj.offsetTop;
	while(obj.offsetParent){
		posX=posX+obj.offsetParent.offsetLeft;
		posY=posY+obj.offsetParent.offsetTop;
		if(obj==document.getElementsByTagName('body')[0]){ break }
			else{ obj=obj.offsetParent;}
	}
}

// create tooltip div on the fly script (click version)
function createDiv(dnme) {
	dnme2 = dnme;
 	var divTag = document.createElement("div");                
	divTag.id = dnme;                             
	divTag.className ="definition";
	document.body.appendChild(divTag);    
}

// ajax div content loader (click version)
function getDef(thWrd){
	ldv = 'tooltip-'+thWrd;
	createDiv(thWrd);
	var ajaxDisplay = document.getElementById(thWrd);
	var linkDisplay = document.getElementById(ldv);
	findPos(ldv);
	posiY = linkDisplay.offsetHeight + posY;
	var midd = myWidth / 2;
	if ( midd >= posX) { thType='left'; } else {thType='right'; posX = posX - 476 + linkDisplay.offsetWidth; }
	ajaxDisplay.style.top = posiY+"px";
	ajaxDisplay.style.left = posX+"px";
			
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			ajaxDisplay.style.visibility = "visible";
		}
	}
	var queryString = "?getdef=" + thWrd + "&type=" + thType;
	ajaxRequest.open("GET", "../get-definition.php" + queryString, true);
	ajaxRequest.send(null); 
}
// create tooltip div on the fly script (mouse over version)
function createDiv2(dnme) {
	allDvs.push(dnme);
	dnme2 = dnme;
 	var divTag = document.createElement("div");                
	divTag.id = dnme;                             
	divTag.className ="definition";
	divTag.onmouseover = function()
		{
			clearTimeout(clearDiv);
		};
	divTag.onmouseout = function()
		{
			clearDiv=setTimeout('closeDef2()', 25);
		};
	document.body.appendChild(divTag);    
}

// ajax div content loader (mouse over version)
function getDef2(thWrd,thId){
	closeDef2();
	ldv = 'tooltip-'+thId;
	createDiv2(thWrd);
	var ajaxDisplay = document.getElementById(thWrd);
	var linkDisplay = document.getElementById(ldv);
	findPos(ldv);
	posiY = linkDisplay.offsetHeight + posY;
	var midd = myWidth / 2;
	if ( midd >= posX) { thType='left'; posX = posX - 20;} else {thType='right'; posX = posX - 476 + linkDisplay.offsetWidth; }
	ajaxDisplay.style.top = posiY+"px";
	ajaxDisplay.style.left = posX+"px";
			
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			ajaxDisplay.style.visibility = "visible";
		}
	}
	var queryString = "?getdef=" + thWrd + "&type=" + thType;
	ajaxRequest.open("GET", "../get-definition.php" + queryString, true);
	ajaxRequest.send(null); 
}

// close tooltip window script
function closeDef(thWrd){
	var defDisplay = document.getElementById(thWrd);
	defDisplay.innerHTML = '';
	defDisplay.style.visibility = "hidden";
}
// better close tooltip window script
function closeDef2(){
	i=0;
	for (i=0;i<allDvs.length;i++) {
		var defDisplay = document.getElementById(allDvs[i]);
		defDisplay.innerHTML = '';
		defDisplay.style.visibility = "hidden";
	}
}

// end onhover ajax mouseovers scripts

