
// if false, certain functions will know to not bother trying
var bDHTML = ( document.getElementById || document.all || document.layers );

// helper function -- try various things to create an XMLHttpRequest object
function createXHR()
{
	// DOM Compliant browsers (easy!)
	if(typeof(XMLHttpRequest) != 'undefined')
		{ return new XMLHttpRequest(); }
	
	// IE (...)
	var ts=[
		'Microsoft.XMLHTTP',
		'Msxml2.XMLHTTP.6.0',
		'Msxml2.XMLHTTP.4.0',
		'Msxml2.XMLHTTP.3.0',
		'Msxml2.XMLHTTP'];
	
	// loop through the possibilities
	for(var i=0;i<ts.length;i++)
	{
		try { return new ActiveXObject(ts[i]); }
		catch(e) { }
	}

	// no luck
	return false;
}

loaded = new Array();
/**
 * extend 
 *   add some functions to elements that are accessed via $()
 * 
 * @param mixed $element 
 * @access public
 * @return element the element
 */
function extend(element)
{
	element.toggleDisplay = function( bState )
	{
		if( typeof( bState ) == 'undefined' )
		{
			// toggle between none and default
			this.style.display = (element.style.display != 'none') ? 'none' : '';
		}
		else
		{
			// a specific state was requested
			this.style.display = ( bState ) ? '' : 'none';
		}
		return element;
	};

	element.toggleInnerHTML = function( defaultHTML, alternateHTML )
	{
		// sanity check
		if(!defaultHTML || !alternateHTML)
			{ return element; }

		if( element.innerHTML == defaultHTML )
			{ element.innerHTML = alternateHTML; }
		else
			{ element.innerHTML = defaultHTML; }

		return element;
	};

	element.toggleClass = function( class1, class2 )
	{
		element.className = ( element.className == class1 ) ? class2 : class1;
		return element;
	};

	element.fillWithPage = function( URL, bAppend, callbackProc )
	{
		if(!bAppend) { bAppend=false; } // defaults
		if(!callbackProc) { callbackProc=false; }
//		if(!bSync) { bSync=false; } // default = async

		var xhr = createXHR();
		if(!xhr)
			{ return false; }
		
		xhr.onreadystatechange=function()
		{
			if( xhr.readyState==4 && xhr.status==200)
			{
				var temp = create('div');
				temp.innerHTML = xhr.responseText;
				//var temp = xhr.responseText;

				if(bAppend)
				{ 
					//element.innerHTML += xhr.responseText; 
					element.appndChild( temp );
				}
				else
				{ 
					//element.innerHTML = xhr.responseText; 
					element.clearAll();
					element.appendChild( temp );
				}

				if( callbackProc )
					{ callbackProc(); }
			}	
		};

		xhr.open("get", URL, true);
		xhr.send(null);	

		return element;
	};

	element.fillWithPagePost = function( URL, args, bAppend, callbackProc )
	{
		if(!bAppend) { bAppend=false; } // defaults
		if(!callbackProc) { callbackProc=false; } // defaults

		var xhr = createXHR();
		if( !xhr ) { return false; }
		
		xhr.onreadystatechange=function()
		{
			if( xhr.readyState==4 && xhr.status==200)
			{
				if(bAppend)
					{ element.innerHTML += xhr.responseText; }
				else
					{ element.innerHTML = xhr.responseText; }

				if( callbackProc )
					{ callbackProc(); }
			}	
		};
		
		
		xhr.open("post", URL, true);
		
		xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr.setRequestHeader("Content-length", args.length);
		xhr.setRequestHeader("Connection", "close");
		
		xhr.send(args);
	};

	element.fillWithPageOnce = function( URL, bAppend )
	{
		if(!bAppend) { bAppend=false; }

		if( element.__filledURL && element.__filledURL==URL )
			{ return element; }

		element.__filledURL = URL;
		
		return element.fillWithPage( URL, bAppend );
	};
	
	element.fillWithPageToggle = function( URL )
	{
	  try {
		if (loaded[URL] ) {
				loaded[URL] = false;
				element.innerHTML = '';
				return true;
		}
	  } catch(e) {
		loaded[URL] = true;
	  }
	  loaded[URL] = true;

		return element.fillWithPage( URL, false );
	};
	
	element.fillPropertyWithPage = function( URL, property )
	{
		var xhr = createXHR();
		if(!xhr)
			{ return false; }

		xhr.onreadystatechange = function()
		{
			if( xhr.readyState==4 && xhr.status==200 )
			{
				this[property] = xhr.responseText;
			}
		};

		xhr.open("get", URL, true); 
		xhr.send(null);

		return element;
	};

	element.clearAll = function()
	{
		try
		{
			while( element.firstChild )
				{ element.removeChild( element.firstChild ); }
		}
		catch(e) { }

		return element;
	};

	element.append = function( child )
	{
		if( typeof(child) == 'string' || typeof(child) == 'number' )
			{ child = document.createTextNode( child ); }

		element.appendChild( child );
		return element;
	};

	// insert NODE into element after REFERENCENODE
	element.insertAfter = function(node, referenceNode)
	{
		if(referenceNode.nextSibling)
			{ element.insertBefore( node, referenceNode.nextSibling ); }
		else // if the reference node is last, we can simply append it
			{ element.appendChild( node ); }

		return element;
	};

	element.set = function( property, value )
	{
		element[property] = value;
		return element;
	};

	element.setStyle = function( data )
	{
		var key;
		for( key in data )
		{
			element.style[key] = data[key];
		}

		return element;
	};

	element.setImgAlt = function( value )
	{
		element.alt = value;
		element.title = value;

		return element;
	};

	// return size and position info for the element
	element.getSize = function() 
	{
		var p = { width:0, height:0, x:0, y:0 };
	
		// width & height
		p.width = element.offsetWidth || element.style.pixelWidth;
		p.height = element.offsetHeight || element.style.pixelHeight;

		// top & left
		if(element.offsetParent)
		{
			p.x = element.offsetLeft;
			p.y = element.offsetTop;
			
			var el = element;
			while( el = el.offsetParent )
			{
//				alert( el.nodeName + ' '+el.offsetTop+' '+el.id );
				if(el.nodeName=='BODY')
					{ break; }
				p.x += el.offsetLeft;
				p.y += el.offsetTop;
			}
		}
	
		return p;
	};

	// get the value of an input element -- bool for checkboxes, values of the selected item for selects, 
	//  value for all other inputs
	element.getValue = function()
	{
		var tag = element.tagName.toLowerCase();

		if( tag == "input" && (element.type.toLowerCase() == "checkbox" || element.type.toLowerCase() == "radio" ))
			{ return element.checked; }
		else if( tag == "input" )
			{ return element.value; }
		else if( tag == "select" )
		{
			if( element.selectedIndex >= 0 )
				{ return element.options[ element.selectedIndex ].value; }
			return false;
		}
		else if( tag == "textarea" )
			{ return element.value; }
		else 
		{
			// non input items
			return element.innerHTML; 
		}

		return false;
	};

	// return an array of selected values-- for select objects where more than one can be selected at once
	element.getAllValues = function()
	{
		var num = 0;
		var selected = new Array();

		for( i=0; i<element.options.length; i++ )
		{
			if( element.options[i].selected )
			{
				selected[num] = element.options[i].value;
				num++;
			}
		}

		return selected;
	}

	// test to see if this node contains the specified node.  
	//  contains() is already a part of IE, so we only need to define this for those that don't have it
	if( !element.contains )
	{
		element.contains = function( child )
		{
		/*
			// unfortunately, this just doesn't seem reliable in FF3

			// from http://quirksmode.org/blog/archives/2006/01/contains_for_mo.html
			// element.comapareDocumentPosition bitmasks:
			//  1: position disconnected
			//  2: precedes
			//  4: follws
			//  8: contains
			//  16: is contained by
			
			try 
			{
				if(element.compareDocumentPosition( child ) & 16)
					{ return true; }
			}
			catch(e) {}

			return false;
		*/	

			//  travel up the DOM starting at the child node.  if element is hit, then child is contained by it
			// for most normal pages, this should be plenty efficient ( 6-10 steps to get to 'body' perhaps )
			while( child != element && child.nodeName != 'BODY' )
			{ 
				child = child.parentNode; 
				if( child == null )
					{ break; }
			}

			if( child == element )
				{ return true; }

			return false;
		};
	}
	
	// confirm that a mouseout event is completely leaving the element-- not just moving between element children
	element.confirmMouseLeaving = function(e)
	{
		if(!e) { var e = window.event; }
		var movedToElement = $((e.relatedTarget) ? e.relatedTarget : e.toElement);

		if( element.contains( movedToElement ) )
			{ return false; }

		return true;
	};

	element.showChildNodesMatchingClass = function( className )
	{
		if( !className )
			{ className = 'all'; }

		var childNodes = element.childNodes;
		for( var i=0; i<childNodes.length; i++ )
		{
			if( !childNodes[i].className )
				{ continue; }

			if( childNodes[i].className == className || className == 'all' )
				{ $(childNodes[i]).setStyle( { 'display':'' } ); }
			else
				{ $(childNodes[i]).setStyle( { 'display':'none' } ); }
		}

		return element;
	};

	// recursively select all nodes matched in the args, returns an array of matched, extended elements
	// currently only selects by node name
	if( !element.select ) {
	element.select = function()
	{
		var nodes = new Array();
		if( !arguments.length )
			{ return nodes; }

		var walk_nodes = function( node, selectors, found_elements )
		{
			// check this node, push it onto the array if it matches
			for(var n=0; n<selectors.length; n++)
			{
				if( node.nodeName == selectors[n].toUpperCase() )
				{
					found_elements.push( $(node) );
					break;
				}
			}

			// iterate child nodes
			for(var i=0; i<node.childNodes.length; i++)
			{
				found_elements = walk_nodes( node.childNodes[i], selectors, found_elements );
			}

			return found_elements;
		};

		return walk_nodes( element, arguments, nodes );
	};
	}

	return element;
}

/**
 * $
 *   safe document.getElementById
 * 
 * @param string $id id of the element to find
 * @access public
 * @return object the element
 */
function $(id)
{
	if(!bDHTML) { return false; }

	// most likely 'this' -- just extend it
	if( typeof(id) == 'object' )
		{ return extend(id); }

	var element = false;
	try
	{
		if(document.getElementById)
			{ element = document.getElementById(id); }
		else if(document.all)
			{ element = document.all[id]; }
		else if(document.layers)
			{ element = document.layers[id]; }
		else
			{ }
	}
	catch(e) {}

	if(!element) { return false; }
	return extend(element);
}

/**
 * getById 
 *   \depreciated  use $() instead
 *
 * @param id $id 
 * @access public
 * @return object the element
 */
function getById(id)
{
	return $(id);
}

// helper function for creating text nodes
function _t(text)
{
	return document.createTextNode(text);
}

/**
 * _ts 
 * 
 * @access protected
 * @return timestamp in seconds
 */
function _ts()
{
	return (new Date()).getTime(); 
}

/**
 * fetchURLSync 
 *   syncronously fetch a URL
 *
 * @param string $url  
 * @access public
 * @return string the contents of the page at the specified URL
 */
function fetchURLSync( url )
{
	var xhr = createXHR();
	if(!xhr)
		{ return false; }
		
	xhr.open("get", url, false);
	xhr.send(null);	
	
	if( xhr.readyState==4 && xhr.status==200)
	{
		return xhr.responseText;
	}	
	
	return false;
}

/**
 * _niceTS 
 * 
 * @access protected
 * @return string php-ish date
 */
function _niceTS()
{
	var d = new Date();
	var day=d.getDate(); 
	if(day < 10) 
		{ day = "0"+day; }
	var mon=d.getDate()+1; 
	if(mon < 10) 
		{ mon = "0"+mon; }

	var year=d.getFullYear();

	return year + "-" + mon + "-" + day;
}

// helper function for grabbing specific element values out of XML
function getFirst(o, id)
{
	try
	{
		var x = o.getElementsByTagName(id)[0].firstChild.nodeValue;
		return x;
	}
	catch(e) {}
	return false;
}

// helper function -- a bit less to type
function create(type, className, childNode)
{
	var element = document.createElement(type);

	if(className)
		{ element.className = className; }

	if(childNode)
		{ element.appendChild( childNode ); }

	return extend(element);
}

function createLink(text, href, className, id, not_used, onclick)
{
	var el = document.createElement("a");

	if( text )
		{ el.appendChild( _t(text) ); }

	if(className)
		{ el.className = className; }

	if(href)
		{ el.href = href; }
	else
		{ el.href = "javascript:void(0)"; }

	if(id)
		{ el.id = id; }

/* // whoops.  can't do this, don't even try.
	if(style)
		{ el.style = style; }
*/

	if(onclick)
		{ el.onclick = onclick; }

	return extend(el);
}

function createImage(src, className, id, alt)
{
	var el = create("img", className);

	el.src = src;

	if(id) { el.id = id; }

	if(alt)
	{
		el.alt = alt;
		el.title = alt;
	}

	return extend(el);
}

function clearAll(el)
{
	try
	{
		while( el.firstChild )
		{
			el.removeChild( el.firstChild );
		}
		return true;
	}
	catch(e) { return false; }
}


function _callback( xhr, proc, bDoText )
{
	// sanity check
	if(!xhr) { return; }

	if(xhr.readyState == 4)
	{
		if(xhr.status && xhr.status==200)
		{
			var response;
			if( bDoText)
				{ response = xhr.responseText; }
			else
				{ response = xhr.reponseXML; }
			
			if( response  && proc )
				{ proc( response ); }
			else if( proc )
				{ proc(); }

		}
		else if( (xhr.status==408) || (xhr.status==504) )
		{
			/* timeout */
			alert("Error: The request to the server has timed out.");
		}
		else
		{
			/* really bad... */
			alert("Error: The page requested does not exist, or access is denied");
		}

		// should be redundant
		xhr.onreadystatechange = null;
	}
}


/**
 * delById 
 * 
 * @param id $id 
 * @access public
 * @return void
 */
function delById(id)
{
        try
        {
                var i = getById(id);
                while(i.firstChild)
                {
                        i.removeChild(i.firstChild);
                }
                i.parentNode.removeChild(i);
        }
        catch(e) { }
}

/**
 * fetchPageInto 
 * 
 * @param url $url 
 * @param id $id 
 * @param append  $append  
 * @access public
 * @return void
 */
function fetchPageInto( url, id, append )
{
	if(!append) { append=false; }

	var xhr = createXHR();
	if(!xhr)
		{ return false; }

	xhr.onreadystatechange=function()
	{
		if( xhr.readyState==4 && xhr.status==200)
		{
			var body = xhr.responseText;

			if(append)
				{ $(id).innerHTML += body; }
			else
				{ $(id).innerHTML = body; }
		}
	};

	xhr.open("get", url, true);  // true = async
	xhr.send(null);
}

/// get the adjusted position of an element.  reletive to the entire page.
/**
 *  \DEPRICIATED
 *  use getElementPosition() and getElementSize instead.
 */
function getElementPos(el) 
{
	var x,w,y,h;
	if (el.getBoundingClientRect) 
	{
		var rect = el.getBoundingClientRect();
		x = rect.left;
		w = rect.right - rect.left;
		y = rect.top;
		h = rect.bottom - rect.top;
	} 
	else if(document.getBoxObjectFor) 
	{
		var bo = document.getBoxObjectFor(el);
		x = bo.x;
		w = bo.width;
		y = bo.y;
		h = bo.height;
	}

	el.x = x;
	el.y=y;
	el.w= w;
	el.h = h;
	
	var p = { left:x, top:y, width:w, height:h };
	return p;
}

/// get the adjusted position of an element.  relative to the entire page.
/**
 *  tweaked from quirksmode ( http://www.quirksmode.org/js/findpos.html )
 *  @param el the element to determine the position of
 *  @return [x,y] position
 */
function getElementPosition(el)
{
	var p = { x:0, y:0 };
	if(el.offsetParent)
	{
		p.x = el.offsetLeft;
		p.y = el.offsetTop;
		while( el = el.offsetParent )
		{
			p.x += el.offsetLeft;
			p.y += el.offsetTop;
		}

		return p;
	}
}

function getElementSize(el) 
{
	var p = { x:0, y:0 };

	p.x = el.offsetWidth || el.style.pixelWidth;
	p.y = el.offsetHeight || el.style.pixelHeight;

	return p;
}

// get the x,y position of the cursor.  needs to be called from an event, with e
function getCursorPos(e)
{
	var p = { x:0, y:0 };

	if(!e) { e = window.event; }
	if(e.pageX || e.pageY)
	{
		p.x = e.pageX;
		p.y = e.pageY;
	}
	else if(e.clientX || e.clientY)
	{
		p.x = e.clientX + document.body.scrollLeft;
		p.y = e.clientY + document.body.scrollTop;
	}

	p.x -= self.image_area_position.left;
	p.y -= self.image_area_position.top;

	return p;
}

/// determine the inner dimensions of the client
/**
 *  adapted from http://quirksmode.org/viewport/compatibility.html
 */
function getInnerDims()
{
	var p = { x:0, y:0 };

	if( self.innerHeight )
	{
		// all but IE
		p.x = self.innerWidth;
		p.y = self.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight )
	{
		// IE6 Strict
		p.x = document.documentElement.clientWidth;
		p.y = document.documentElement.clientHeight;
	}
	else if( document.body )
	{
		// all other IE
		p.x = document.body.clientWidth;
		p.y = document.body.clientHeight;
	}

	return p;
}

function getPageDims()
{
	var p = { x:0, y:0 };


	if( document.documentElement.scrollHeight )
	{
		// FF/IE/Chrome... 
		p.y = document.documentElement.scrollHeight;
		p.x = document.documentElement.scrollWidth;
	}
	else if( document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth )
	{
		// worse case--this may be the innerDims and not page dims
		p.x = document.documentElement.clientWidth;
		p.y = document.documentElement.clientHeight;
		
	}
	
	if ( document.compatMode == "BackCompat" && document.body && document.documentElement && document.documentElement.clientWidth === 0) 
	{
		p.x = document.body.scrollWidth;
		p.y = document.body.clientHeight;
	}

	// the innerDims can be bigger in cases where the height of the window > height of the page
//	var id = getInnerDims();
//	p.x = Math.max( p.x, id.x );
//	p.y = Math.max( p.y, id.y );
	
	return p;
}

function getScrollPosition()
{
        var p = { x:0, y:0 };

        if( self.pageXOffset || self.pageYOffset )
        {
                p.x = self.pageXOffset;
                p.y = self.pageYOffset;
        }
        else if( document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop) )
        {
                p.x = document.documentElement.scrollLeft;
                p.y = document.documentElement.scrollTop;
        }
        else if( document.body.scrollLeft || document.body.scrollTop )
        {
                p.x = document.body.scrollLeft;
                p.y = document.body.scrollTop;
        }

        return p;
}

/**
 * readCookie 
 *  reads the value of a cookie
 *  based on quirksmode  http://www.quirksmode.org/js/cookies.html
 * 
 * @param string cookieName  
 * @access public
 * @return mixed value of the cookie
 */
function readCookie( cookieName )
{
	var searchName = cookieName + "=";
	
	var ca = document.cookie.split( ';' );
	for( var i=0; i<ca.length; i++ )
	{
		var c = ca[i];
		while( c.charAt(0)==' ' ) 
		{
			c = c.substring( 1, c.length );
		}

		if( c.indexOf( searchName ) == 0 )
		{
			return c.substring( searchName.length, c.length );
		}
	}

	return null;
}

function createCookie( cookieName, value, path, days )
{
	var expires = "";
	if( days )
	{
		var date = new Date();
		date.setTime( date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	
	document.cookie = cookieName+"="+value+expires+"; path="+path;
}

/// insert a NODE into PARENT after REFERENCENODE
/**
 *  @param prnt parent node
 *  @param node node to add
 *  @param referenceNode node to insert after
 */
function insertAfter(prnt, node, referenceNode)
{
	if(referenceNode.nextSibling)
		{ prnt.insertBefore(node, referenceNode.nextSibling); }
	else // if the reference node is last, we can simply append it
		{ prnt.appendChild(node); }
}

function submitForm( the_form, callback_proc )
{
        var data = 'ts='+_ts();
        var bPost = false;
        var targetURL = $(the_form).getAttribute('action');
        var bAllFilled = true;

        // sanity check
        if( !targetURL || !targetURL.length )
                { return false; }

        // get or post?
        if( $(the_form).getAttribute('method') && $(the_form).getAttribute('method').toLowerCase() != 'get' )
                { bPost = true; }

        // find all the form elements, make the data string
        var children = $(the_form).select('input','textarea','select');
        for( var i=0; i<children.length; i++ )
        {
                // we have to ignore elements that have no name field, what would we submit them as?
                if( children[i].getAttribute('name') == null )
                        { continue; }

                if( children[i].getAttribute('required') && !children[i].getValue() )
                {
                        // highlight somehow...
                        bComplete = false;
                }
                else
                {
                        // unhighlight...
                }

                data += "&"+children[i].getAttribute('name')+"="+escape( children[i].getValue() );
        }

        // error out of not all required fields are filled
        if( !bAllFilled )
        {
                alert('Error: Not all required fields are filled.');
                return;
        }

        // send the request
        var xhr = createXHR();
        if(!xhr) { return false; }

        // set the callback
        xhr.onreadystatechange = function()
        {
                if( xhr.readyState==4 && xhr.status==200)
                {
                        if( callback_proc )
                                { callback_proc( xhr.responseText ); }
                }
        };

        if( bPost )
        {
                xhr.open("POST", targetURL, true);
                xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xhr.setRequestHeader("Content-length", data.length);
                xhr.setRequestHeader("Connection", "close");
                xhr.send(data);
        }
        else
        {
                xhr.open("GET", targetURL+'?'+data, true);
                xhr.send(null);
        }

	return;
}



/**
 * addWindowOnload 
 *   add a function to window.onload -- preserving any previous window.onload functions
 * 
 * @param function $func the function to call with window.onload
 * @access public
 * @return void
 */
function addWindowOnload( func )
{
	if( window.onload && typeof(window.onload) == 'function' )
	{
		var original_func = window.onload;
		window.onload = function() 
		{
			original_func();
			func();
		};
	}
	else
	{
		window.onload = func;
	}
}

/**
 * addWindowHandler 
 *   add a function to a window event (onload, onresize, etc) -- preserving any previous function that exists
 * 
 * @param theEvent $theEvent 
 * @param func  $func  
 * @access public
 * @return void
 */
function addWindowHandler( theEvent, func )
{
	if( window[theEvent] && typeof(window[theEvent]) == 'function' )
	{
		var original_func = window[theEvent];
		window[theEvent] = function() 
		{
			original_func();
			func();
		};
	}
	else
	{
		window[theEvent] = func;
	}	
}

/**
 * addEvent
 *   add an event handler to an object.  this is needed for iframe documents (within rich text editors for instance)
 *    to resolve the scope issues.  (e.g., `iframe.document.onload = blah` doesn't work across browsers) 
 * 
 * @param mixed $obj the object to attache the handler to
 * @param string $type the type of handle to add ('click', 'load', 'unload', etc)
 * @param function $fn the function to add
 * @access public
 * @return void
 */
function addEvent( obj, type, fn )
{
	if(!obj)
	{
		alert("bad error: addEvent: no object.");
		return;
	}

	if (obj.addEventListener)
	{
		obj.addEventListener( type, fn, false );
	}
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function loadLawFooter()
{
	try {
		if( typeof(bNoLawFooter) != 'undefined' && bNoLawFooter )
			{ return; }
		
		if( $('lawFooter') )
			{ return; }

		// load the lawfooter css
		var lfcss = create('link').set('type','text/css').set('rel','stylesheet').set('href','/js/lawFooter.css?ts='+_ts());
		var h = document.getElementsByTagName("head");
		if( typeof(h) != 'undefined' )
			{ h[0].appendChild( lfcss ); }
		else
			{ document.body.appendChild( lfcss ); }

		// load the lawFooter js
		var lfjs = fetchURLSync('/js/lawFooter.js?ts='+_ts());
		eval( lfjs );

		window['UWLawFooter'] = eval('UWLawFooter');
		var ft = new UWLawFooter();

		createCookie('lawFooter', '1', '/', 365);
	} catch(e) {}
}

// law footer onload
addWindowOnload( function() {
	if( typeof(bNoLawFooter) != 'undefined' && bNoLawFooter )
		{ return; }

	try {
		if( window.location.search && window.location.search.match(/iLawFooter=1/) )
			{ loadLawFooter(); }
		else if( readCookie('lawFooter') == '1' )
			{ loadLawFooter(); }
	} catch(e) { }
} );


