var okToLeave = true;  // used by applications that warn you before you leave the page (eservice)function changeDisplayStyle(targetId, toWhat){	okToLeave = false;	var target=document.getElementById(targetId);	if (target)	{		target.style.display=toWhat;	}	else	{		alert("Element with Id " + targetId + " does not exist");	}}// Function to deal with correctly popping up the // "Commercial List Hearing Request Forms" link on the home pagefunction changeDisplayStyleCenter(targetId, toWhat) {	var target=document.getElementById(targetId);	if (target)	{		// Stores page values in an array		// Page width, page height, window width, and window height		var page = getPageSize();		var xCoord, yCoord;				var halfCurrHeight = (parseInt(target.style.height) / 2);		var halfCurrWidth = (parseInt(target.style.width) / 2);				xCoord = ((page[3] / 2) - halfCurrHeight);		yCoord = ((page[2] / 2) - halfCurrWidth);				target.style.left = xCoord;		target.style.top = yCoord;		target.style.visibility=toWhat;	}	else	{		alert("Element with Id " + targetId + " does not exist");	}}//// getPageSize()// Returns array with page width, height and window width, height// Core code from - quirksmode.org// Edit for Firefox by pHaez//function getPageSize(){		var xScroll, yScroll;		if (window.innerHeight && window.scrollMaxY) {			xScroll = document.body.scrollWidth;		yScroll = window.innerHeight + window.scrollMaxY;	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac		xScroll = document.body.scrollWidth;		yScroll = document.body.scrollHeight;	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari		xScroll = document.body.offsetWidth;		yScroll = document.body.offsetHeight;	}		var windowWidth, windowHeight;	if (self.innerHeight) {	// all except Explorer		windowWidth = self.innerWidth;		windowHeight = self.innerHeight;	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode		windowWidth = document.documentElement.clientWidth;		windowHeight = document.documentElement.clientHeight;	} else if (document.body) { // other Explorers		windowWidth = document.body.clientWidth;		windowHeight = document.body.clientHeight;	}			// for small pages with total height less then height of the viewport	if(yScroll < windowHeight){		pageHeight = windowHeight;	} else { 		pageHeight = yScroll;	}	// for small pages with total width less then width of the viewport	if(xScroll < windowWidth){			pageWidth = windowWidth;	} else {		pageWidth = xScroll;	}	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 	return arrayPageSize;}//// onLoadPageHeight()// Adjusts lcol's height to extend it to the bottom of the viewport//var eventTooltips = "no";var containingRecords = "no";function onLoadPageHeight() {	var e;		if(document.getElementById("lcol")) {		e = document.getElementById("lcol");	} else {		e = document.getElementById("mcol");	}	var page = getPageSize();	var currWinHeight = parseInt(page[1]);	if(e) {	// masthead height, footer height, nav_links height, IE constant (FF ignores	// it, sort of)		var newHeight = currWinHeight - (81 + 60 + 35 + 17);		e.style.height = newHeight + "px";	}		var mainTable = document.getElementById('mainTable');	if ( mainTable)	{		var lefthandNav = document.getElementById('lefthandNav');		var gradient = document.getElementById('gradient');		if ( lefthandNav && gradient)			gradient.style.height = mainTable.clientHeight - lefthandNav.clientHeight;	}			if ( eventTooltips === 'yes')		createTooltips();	if ( containingRecords == 'yes')		addContainingRecords();}function changeDisplayOfPrefixedElements(groupingId, displayStyle){	var i=0;	while (document.getElementById(groupingId + "_" + i) != null)	{		document.getElementById(groupingId + "_" + i).style.display=displayStyle;		i++;	}	if (i == 0)	{		alert("Couldn't change display style of elements with prefix of " + groupingId);	}	i=0;}var eventTooltips="no";var containingRecords="no";function setValue(targetId, value){	var target=document.getElementById(targetId);	if (target)	{		target.value=value;	}	else	{		alert("Element with Id " + targetId + " does not exist");	}}function getField(fieldId){	var field=document.getElementById(fieldId);	if (field)	{		return field;	}	else	{		alert("Element with Id " + fieldId + " does not exist");	}}function getValue(targetId){	var target=document.getElementById(targetId);	if (target)	{		return target.value;	}	else	{		alert("Element with Id " + targetId + " does not exist");	}}function setInnerHTML(targetId, value){	var target=document.getElementById(targetId);	if (target)	{		target.innerHTML = value;	}	else	{		alert("Element with Id " + targetId + " does not exist");	}}function openPopup(location, height, width) {	window.open(location, 'popup',"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);}var d = new Date();var curr_day = d.getDate();var curr_month = d.getMonth();var curr_year = d.getFullYear();// this function is used to get rid of the greyed out helper textfunction clearDefaultText(field){	field.style.color="#000000";	field.value="";}function resizeOuterTo(w,h){	if (parseInt(navigator.appVersion)>3)	{		if (navigator.appName=="Netscape")		{			top.outerWidth=w;			top.outerHeight=h;		}		else top.resizeTo(w,h);	}}function isEmpty(val){	if (val == null || val == "")	{		return true;	}	return false;}function isValidPassword(password){	var minLength = 6;	var actualLength = password.length;	if (actualLength < minLength)	{		return false;	}	return true;}function isValidEmail(email){	atPos = email.indexOf("@")	stopPos = email.lastIndexOf(".")	if (atPos == -1 || stopPos == -1)	{		return false;	}	if (stopPos < atPos)	{		return false;	}	if (stopPos - atPos == 1)	{		return false;	}	return true;}function openWindow(url, width, height){	window.open(url,'Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + '');}function disableField(fieldId){	var field = document.getElementById(fieldId);	field.readOnly = true;	field.style.backgroundColor = "#F2F2F2";	field.style.color = "#696969";}function isValidDate(date){	if(date.length != 10)	{		return false;	}	var year = date.substr(0,4);	var month = date.charAt(5) + date.charAt(6);	var day = date.substr(8,9);	var firstSeparator = date.charAt(4);	var secondSeparator = date.charAt(7);	if (firstSeparator != "-")	{		return false;	}	if (secondSeparator != "-")	{		return false;	}	if (year < 1900 || year > 2500)	{		return false;	}	if (month == 00 || month > 12)	{		return false;	}	if (day == 0 || day > 31)	{		return false;	}	return true;}function clearDefaultText(field){	if (field.className=="defaultFieldText")	{		field.value="";	}}function isAllowableFileExtension(file){	var allowableExtensions=new Array("pdf","doc","txt");	var actualExtension = file.substring((file.length-3),file.length);	var foundIt = false;	for ( var i = 0; i < allowableExtensions.length; i++ )	{		if (allowableExtensions[i] == actualExtension)		{			foundIt = true;		}	}	return foundIt;}function checkInvalidEmailFormat(pEmail){	var hasInvalidEmailFormat = false;	var email = getField(pEmail);	if (!isEmpty(email.value))	{		if (!isValidEmail(email.value))		{			email.className="invalidEmailField";			hasInvalidEmailFormat=true;		}	}	return hasInvalidEmailFormat;}function IsNumeric(sText){	var ValidChars = "0123456789.";	var IsNumber=true;	var Char;	for (i = 0; i < sText.length && IsNumber == true; i++) 	{		Char = sText.charAt(i); 		if (ValidChars.indexOf(Char) == -1) 		{			IsNumber = false;		}	}	return IsNumber;}//// pause(numberMillis)// Pauses code execution for specified time. Uses busy code, not good.// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602//function pause(numberMillis) {	var now = new Date();	var exitTime = now.getTime() + numberMillis;	while (true) {		now = new Date();		if (now.getTime() > exitTime)			return;	}}var requiredFieldIds = [];function makeFieldRequired(fieldId){	requiredFieldIds.push(fieldId);}var publicDomains = new Array("gmail.com", "googlemail.com", "yahoo.com", "msn.com", "hotmail.com", "mac.com", "aol.com", "yahoo.ca");function getNiceListValidEmailDomains(){	var str;	for(var i = 0; i < publicDomains.length; i++)	{		str = str + publicDomains[i];		if (i != (publicDomains.length - 1))		{			str = str + ", ";		}	}	return str;}function isInvalidEmailDomain(email) {        // Split the user's email address on '@' to get user and domain    var userEmail = email.split('@');    // Iterate through the array with a loop to check if the user's domain matches a public domain     for(var i = 0; i < publicDomains.length; i = i + 1) {        if(userEmail[1] == publicDomains[i]) {            // Match found, return true            return true;        }    }    // Return false unless found     return false;    } var formValues = new Object;function saveOnceAll(){   var frms = document.forms;   for ( i=0; i<frms.length; i++)   		saveOnce( frms[i]);}function saveOnce( frm){		if ( ! frm.id)		return;	if ( frm.id == 'form')		return;	if ( formValues[ frm.id])		return;  // values are already saved	else {		var stored = enteredValues( frm);		formValues[frm.id] = stored;				var show = "";		for ( ix in stored)		{			show += ix + ": " + stored[ix] + "\n";		}	}	return;}		function enteredValues( frm){	var stored = new Object();	for ( i=0; i<frm.elements.length; i++)	{		var e = frm.elements[i];		var vlue = e.value;		if ( e.type == 'hidden')			continue;		if ( e.type == 'submit')			continue;		if ( e.type == 'checkbox')				vlue = ( e.checked ? 'true' : 'false');		if ( e.type == 'radio') {			if ( !e.checked)				continue;		}		stored[e.name] = vlue;	}	return stored;}function valuesChanged( id){	var frm = document.getElementById( id);	if ( ! frm)		return false;	var stored = formValues[id];	if ( ! stored)		return false;	var newValues = enteredValues( frm);	if ( ! newValues)		return false;	for ( ix in newValues) {		var oldValue = stored[ix];		var newValue = newValues[ix];		if ( newValue)		{			if ( ! oldValue)				return true;			if ( oldValue != newValue)				return true;		}	}	return false;}var leaveQuietly = false;function leaveWoWarning(){	leaveQuietly = true;}function leaveWithWarning(){	leaveQuietly = false;}function leavePage(){	if ( leaveQuietly)		return;			var changes = false;		for ( ix in formValues) {		if ( valuesChanged( ix)) {			changes = true;			break;		}			}		if ( changes) 		return "If you leave this page now, you'll lose all your changes";		}function toggleDiv(divId){  var div = document.getElementById(divId);  if ( ! div)  	return;  var way=div.style.display;  if(way=="none")  	div.style.display="block";  else  	div.style.display="none"; } 	  function clearDiv(divId) {	$(divId).innerHTML = "";	toggleOff(divId);} // commonly used stuff from dsfAdmin  function trim(val){	return Trim(val);}  function checkNameUrl(tag) {	var name = document.getElementById(tag + ".name");	var url = document.getElementById(tag + ".url");	var action = document.getElementById("action_" + tag);	if (name.value === "" || url.value === "") {		return;	}	action.value = "insert";}function changeBGColor(div, color) {	$(div).style.backgroundColor = color;}function showDiv(element,msg){   $(element).innerHTML=msg;   toggleOn(element);   }function clearDiv(element){   $(element).innerHTML='';   toggleOff(element);}function toggleOn(element) {	var e = $(element);	if (e) {		e.style.display = "block";	}}function toggleOff(element) {	var e = $(element);	if (e) {		e.style.display = "none";	}}function toggleDiv(element) {	var e = $(element);	if (e) {		e.style.display = ((e.style.display != "block") ? "block" : "none");		$("div_upper_right").innerHTML = _description[e.id]();	}}function loadDivWith(divId, url) {	var ax = new AJAXRequest("POST", url, null, function (AJAX) {		if (AJAX.readyState == 4) {			if (AJAX.status == 200) {				$(divId).innerHTML = AJAX.responseText;			} else {				showError("URL" + url + "<br>There was a problem retrieving the XML data:\n" + AJAX.statusText);			}		}	}, true);}function Trim(STRING) {	STRING = LTrim(STRING);	return RTrim(STRING);}function RTrim(STRING) {	while (STRING.charAt((STRING.length - 1)) == " ") {		STRING = STRING.substring(0, STRING.length - 1);	}	return STRING;}function LTrim(STRING) {	while (STRING.charAt(0) == " ") {		STRING = STRING.replace(STRING.charAt(0), "");	}	return STRING;}function Replace(STRING, REPLACE_THIS, REPLACE_WITH) {	while (STRING.indexOf(REPLACE_THIS) > -1) {		STRING = STRING.replace(REPLACE_THIS, REPLACE_WITH);	}	return STRING;}function dbCheck(STRING) {	if (STRING.indexOf("'") > -1) {		return false;	}}var _ms_XMLHttpRequest_ActiveX = ""; // Holds type of ActiveX to instantiatevar _ajax;                           // Reference to a global XMLHTTPRequest object for some of the samplesvar _logger = true;                  // write output to the Activity Logvar _status_area;                    // will point to the area to write status messages toBASE_URL = ".";if (document.location.href.indexOf("www.clearnova.com") > 0) {	BASE_URL = "/ThinkCAP";}if (!window.Node || !window.Node.ELEMENT_NODE) {	var Node = {ELEMENT_NODE:1, ATTRIBUTE_NODE:2, TEXT_NODE:3, CDATA_SECTION_NODE:4, ENTITY_REFERENCE_NODE:5, ENTITY_NODE:6, PROCESSING_INSTRUCTION_NODE:7, COMMENT_NODE:8, DOCUMENT_NODE:9, DOCUMENT_TYPE_NODE:10, DOCUMENT_FRAGMENT_NODE:11, NOTATION_NODE:12};}// From prototype.js @ www.conio.net | Returns an object reference to one or more strings// ignore the fact that there are no arguments to this method -- javascript doesn't care how many you send (not strongly typed)// The method checks the actual # of arguments -- returns a single object or an arrayfunction $() {	var elements = new Array();	for (var i = 0; i < arguments.length; i++) {		var element = arguments[i];		if (typeof element == "string") {			element = document.getElementById(element);		}		if (arguments.length == 1) {			return element;		}		elements.push(element);	}	return elements;}// Method to get text from an XML DOM objectfunction getTextFromXML(oNode, deep) {	var s = "";	var nodes = oNode.childNodes;	for (var i = 0; i < nodes.length; i++) {		var node = nodes[i];		if (node.nodeType == Node.TEXT_NODE) {			s += node.data;		} else {			if (deep == true && (node.nodeType == Node.ELEMENT_NODE || node.nodeType == Node.DOCUMENT_NODE || node.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) {				s += getTextFromXML(node, true);			}		}	}	return s;}// If you plan on doing anything outside of North America, then you'd better encode the things you pass back and forth// the escape() method in Javascript is deprecated -- should use encodeURIComponent if availablefunction encode(uri) {	if (encodeURIComponent) {		return encodeURIComponent(uri);	}	if (escape) {		return escape(uri);	}}function decode(uri) {	uri = uri.replace(/\+/g, " ");	if (decodeURIComponent) {		return decodeURIComponent(uri);	}	if (unescape) {		return unescape(uri);	}	return uri;}/* * AJAXRequest: An encapsulated AJAX request. To run, call * new AJAXRequest( method, url, async, process, data ) * */function executeReturn(AJAX) {	if (AJAX.readyState == 4) {		if (AJAX.status == 200) {			showDebug("AJAXRequest is complete: " + AJAX.readyState + "/" + AJAX.status + "/" + AJAX.statusText);			if (AJAX.responseText) {				showDebug(AJAX.responseText);				showDebug("-----------------------------------------------------------");				eval(AJAX.responseText);			}		}	}}function AJAXRequest(method, url, data, process, async, dosend) {    // self = this; creates a pointer to the current function    // the pointer will be used to create a "closure". A closure    // allows a subordinate function to contain an object reference to the    // calling function. We can't just use "this" because in our anonymous    // function later, "this" will refer to the object that calls the function    // during runtime, not the AJAXRequest function that is declaring the function    // clear as mud, right?    // Java this ain't	var self = this;	    var urlStart = url.toUpperCase().substring(0,4);    showDebug("url="+url+" start:"+urlStart);    if(urlStart!="HTTP"){       url=basePath+url;       }    // check the dom to see if this is IE or not	if (window.XMLHttpRequest) {	// Not IE		self.AJAX = new XMLHttpRequest();	} else {		if (window.ActiveXObject) {	// Hello IE!        // Instantiate the latest MS ActiveX Objects			if (_ms_XMLHttpRequest_ActiveX) {				self.AJAX = new ActiveXObject(_ms_XMLHttpRequest_ActiveX);			} else {	    // loops through the various versions of XMLHTTP to ensure we're using the latest				var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];				for (var i = 0; i < versions.length; i++) {					try {		    // try to create the object		    // if it doesn't work, we'll try again		    // if it does work, we'll save a reference to the proper one to speed up future instantiations						self.AJAX = new ActiveXObject(versions[i]);						if (self.AJAX) {							_ms_XMLHttpRequest_ActiveX = versions[i];							break;						}					}					catch (objException) {                // trap; try next one					}				}			}		}	}        // if no callback process is specified, then assing a default which executes the code returned by the server	if (typeof process == "undefined" || process == null) {		process = executeReturn;	}	self.process = process;    // create an anonymous function to log state changes	self.AJAX.onreadystatechange = function () {        //showDebug("AJAXRequest Handler: State =  " + self.AJAX.readyState);		self.process(self.AJAX);	};    // if no method specified, then default to POST	if (!method) {		method = "POST";	}	method = method.toUpperCase();	if (typeof async == "undefined" || async == null) {		async = true;	}	showDebug("AJAX Request: " + ((async) ? "Async" : "Sync") + "<br>" + method + "<br>URL: " + url + "<br>Data: " + data);	self.AJAX.open(method, url, async);	if (method == "POST") {		self.AJAX.setRequestHeader("Connection", "close");		self.AJAX.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		self.AJAX.setRequestHeader("Method", "POST " + url + "HTTP/1.1");	}    // if dosend is true or undefined, send the request    // only fails is dosend is false    // you'd do this to set special request headers	if (dosend || typeof dosend == "undefined") {		if (!data) {			data = "";		}		self.AJAX.send(data);	}	return self.AJAX;}// handle some key press eventsfunction handleKeyUp(e) {	e = (!e) ? window.event : e;	target = (!e.target) ? e.srcElement : e.target;	if (e.type == "keyup") {        // skip shift, alt, control keys		if (e.keyCode == 16 || e.keyCode == 17 || e.keyCode == 18) {        // do nothing		} else {			if (target.name == "state1" && !$("state1").value) {				clearCustomersByState();			} else {				if (target.name == "state2" && !$("state2").value) {					clearCustomersByStateXML();				} else {					if (target.name == "google_search") {						if (target.value) {							getSuggest(target);						} else {							$("google_suggest_target").innerHTML = "";						}					}				}			}		}	}}function showBookingForService(id){	window.onbeforeunload = null;	openPopup('/oscar/case/main/oscarBooking.jsp?id=' + id,					700, 700);	window.onbeforeunload = goodbye;}function showBooking(id){	openPopup('/oscar/case/main/oscarBooking.jsp?id=' + id,					712, 712);}function resetCourtFields(){	var fields=['jurisdictionSelect',				'courtLevelSelect',			'regionSelect',			'filingOfficeSelect'		];			for ( var i=0; i<fields.length; i=i+1)	{		var f = document.getElementById( fields[i]);		if ( f)			f.className='';	}}// Functions for performing database updates without reloading the page	var pleaseWait = '<div style="font-size:18pt;color:#cccc99;padding:15px;text-align:center">Please, wait</a>';	function submitFormToDiv( div, url, formId)	{		var params = formParams(formId);			document.getElementById(div).innerHTML = pleaseWait;		loadDivWith( div, url + params);	} 		function formParams( formId)	{		var frm = document.getElementById(formId);		fields = frm.elements;				var params="";		for ( var i=0; i<fields.length; i++)		{			var f = fields[i];			if ( isEmpty(params))				params = "?";			else				params += "&";				params = params + f.name + "=" + encodeURIComponent( f.value);		}		return params;	}