//analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1012733-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

//insert chat script javascript and CSS (doesnt work??)
/*
var headID = document.getElementsByTagName("head")[0];         
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.href = 'http://www.clientchatlive.com/js/pop_over.css';
cssNode.media = 'screen';
headID.appendChild(cssNode);

var newScript3 = document.createElement('script');
newScript3.type = 'text/javascript';
newScript3.src = 'http://www.clientchatlive.com/js/jquery_script.js';
headID.appendChild(newScript3);

var newScript2 = document.createElement('script');
newScript2.type = 'text/javascript';
newScript2.src = 'http://www.clientchatlive.com/js/jquery_cookie.js';
headID.appendChild(newScript2);

var newScript1 = document.createElement('script');
newScript1.type = 'text/javascript';
newScript1.src = 'http://www.clientchatlive.com/js/site/injuredclient/pop_over.js';
headID.appendChild(newScript1);
*/
//end chat script javascript inserts

//if by phone requried values (doesnt work??)
/*
var _ibp_public_key = "e6e8dbbc9a46bcffd86f7c1d1bbd598f6ccf8bf4";
var _ibp_formatting = true;
var _ibp_keyword_set = 18491;
*/


<!-- Place this right above the header tag --> 

// REDIRECT CODE FOR MOBILE USERS:
testReferrer = document.referrer;
currentPage = document.URL;

if(testReferrer.indexOf("injuredclient.com/") == -1 ) {
	if (screen.width<=239) {
		if( currentPage.indexOf("/book") == -1 )
			if( currentPage.indexOf("/test") == -1  )
				window.location = "http://www.injuredclient.com/mobile/mini.html";
	} else if (screen.width>=240 && screen.width<=480) {
		if( currentPage.indexOf("/book") == -1 )
			if( currentPage.indexOf("/test") == -1  )
				window.location = "http://www.injuredclient.com/mobile/index.html";
	}
}


// PRELOAD IMAGES:
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.thepagefirm.com/build/images/main-wrap-bg.jpg')
}

if (window.attachEvent) window.attachEvent("onload", preload);

// Javascript originally by Patrick Griffiths and Dan Webb.

// http://htmldog.com/articles/suckerfish/dropdowns/

sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("li");
for (var i=0; i<sfEls.length; i++) {
   sfEls[i].onmouseover=function() {
      this.className+=" hover";
   }
   sfEls[i].onmouseout=function() {
      this.className=this.className.replace(new RegExp(" hover\\b"), "");
   }
}

}

if (window.attachEvent) window.attachEvent("onload", sfHover);

// SPONSORS IMAGE TOOLTIPS 
/* Image w/ description tooltip v2.0

* Created: April 23rd, 2010. This notice must stay intact for usage 

* Author: Dynamic Drive at http://www.dynamicdrive.com/

* Visit http://www.dynamicdrive.com/ for full source code

*/


var ddimgtooltip={
tiparray:function(){

	var tooltips=[]

	//define each tooltip below: tooltip[inc]=['path_to_image', 'optional desc', optional_CSS_object]

	//For desc parameter, backslash any special characters inside your text such as apotrophes ('). Example: "I\'m the king of the world"

	//For CSS object, follow the syntax: {property1:"cssvalue1", property2:"cssvalue2", etc}
	tooltips[0]=["http://www.injuredclient.com/images/spon-bms.png"]

	tooltips[1]=["http://www.injuredclient.com/images/spon-bbbs.png"]

	tooltips[2]=["http://www.injuredclient.com/images/spon-apda.png"]

	tooltips[3]=["http://www.injuredclient.com/images/spon-mod.png"]
	return tooltips //do not remove/change this line

}(),
tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
//***** NO NEED TO EDIT BEYOND HERE
tipprefix: 'imgtip', //tooltip ID prefixes
createtip:function($, tipid, tipinfo){

	if ($('#'+tipid).length==0){ //if this tooltip doesn't exist yet

		return $('<div id="' + tipid + '" class="ddimgtooltip" />').html(

			'<div style="text-align:center"><img src="' + tipinfo[0] + '" /></div>'

			+ ((tipinfo[1])? '<div style="text-align:left; margin-top:5px">'+tipinfo[1]+'</div>' : '')

			)

		.css(tipinfo[2] || {})

		.appendTo(document.body)

	}

	return null

},
positiontooltip:function($, $tooltip, e){

	var x=e.pageX+this.tooltipoffsets[0], y=e.pageY+this.tooltipoffsets[1]

	var tipw=$tooltip.outerWidth(), tiph=$tooltip.outerHeight(), 

	x=(x+tipw>$(document).scrollLeft()+$(window).width())? x-tipw-(ddimgtooltip.tooltipoffsets[0]*2) : x

	y=(y+tiph>$(document).scrollTop()+$(window).height())? $(document).scrollTop()+$(window).height()-tiph-10 : y

	$tooltip.css({left:x, top:y})

},



showbox:function($, $tooltip, e){

	$tooltip.show()

	this.positiontooltip($, $tooltip, e)

},
hidebox:function($, $tooltip){

	$tooltip.hide()

},


init:function(targetselector){

	jQuery(document).ready(function($){

		var tiparray=ddimgtooltip.tiparray

		var $targets=$(targetselector)

		if ($targets.length==0)

			return

		var tipids=[]

		$targets.each(function(){

			var $target=$(this)

			$target.attr('rel').match(/\[(\d+)\]/) //match d of attribute rel="imgtip[d]"

			var tipsuffix=parseInt(RegExp.$1) //get d as integer

			var tipid=this._tipid=ddimgtooltip.tipprefix+tipsuffix //construct this tip's ID value and remember it

			var $tooltip=ddimgtooltip.createtip($, tipid, tiparray[tipsuffix])

			$target.mouseenter(function(e){
var $tooltip=$("#"+this._tipid)
ddimgtooltip.showbox($, $tooltip, e)

			})

			$target.mouseleave(function(e){
var $tooltip=$("#"+this._tipid)
ddimgtooltip.hidebox($, $tooltip)

			})

			$target.mousemove(function(e){
var $tooltip=$("#"+this._tipid)
ddimgtooltip.positiontooltip($, $tooltip, e)

			})

			if ($tooltip){ //add mouseenter to this tooltip (only if event hasn't already been added)
$tooltip.mouseenter(function(){
ddimgtooltip.hidebox($, $(this))
})

			}

		})
	}) //end dom ready

}

}
//ddimgtooltip.init("targetElementSelector")

ddimgtooltip.init("*[rel^=imgtip]")


// END SPONSORS IMAGE TOOLTIPS

//##************* Sliding Footer Script **************##//
//jQuery
$(function() {
	//footer starts closed
	var open = false;
	//holder for interval
	var t = null;
	
	//run displayFooter every so-many miliseconds; 2000 = 2 seconds
	t = setInterval('$.displayFooter()', 2000);
	
	//displayFooter OPENS the footer; use this for the interval
	$.displayFooter = function() {
		if(open === false) {//footer currently closed		
			$('#footerSlideContent').animate({ height: '300px' });//open it, but nicely w/ animate()
			$('#footerSlideButton').css('backgroundPosition', 'bottom left');//reorient button BG image (if any)
			$('#footerSlideButton').css('background', 'url(/images/footer-close.png) top left no-repeat transparent');//use this to set your new image, or color
			open = true;//set open to true, so close functions will work
		}//end if
		
		//remove the interval so that it doesnt keep opening the footer
		clearInterval(t);
	}//end function
	
	//jQuery function; manages the click controls for the slider
	$('#footerSlideButton').click(function() {//if you click the open/close button...
		if(open === false) {//same as displayFooter, above
			$('#footerSlideContent').animate({ height: '300px' });
			$(this).css('backgroundPosition', 'bottom left');
			$(this).css('background', 'url(/images/footer-close.png) top left no-repeat transparent');
			open = true;
		} else {//it's already open, so close the footer
			$('#footerSlideContent').animate({ height: '0px' });//close it, but gently with animate()
			$(this).css('backgroundPosition', 'top left');//reorient button BG image to top left, like default
			$(this).css('background', 'url(/images/footer-open.png) top left no-repeat transparent');//use this to set your new image, or color
			open = false;
		}//end if-else
	});//end function
	
});//end jQuery

//##************ END SLIDING FOOTER SCRIPT *************##//


/* FADE IN HOVER SPRITE */

