(node.nodeType != 9)) { // if attrName is not provided just return TRUE if (node.nodeName == tagName) { var nodeHasAttribute = !!attrName ? node[attrName] : true; if (nodeHasAttribute) return node; } node = node.parentNode; } // no div return null;};searchshield.getHrefFromCiteElement = function (tag){ var rtnHtml; var tp = tag.parentNode; var tgpn = tp ? tp.parentNode : null; if (!tgpn) return; lastChildElem = tgpn.lastChild; while ((lastChildElem != null) && (lastChildElem.nodeName != 'SPAN') && (lastChildElem.nodeName != 'DIV')) { lastChildElem = lastChildElem.previousSibling; } if (lastChildElem) rtnHtml = lastChildElem.getElementsByTagName('cite')[0]; if (rtnHtml) rtnHtml = rtnHtml.innerHTML; return rtnHtml;};searchshield.getHrefFromSpanElement = function (tag){ var rtnHtml; var tp = tag.parentNode; var tgpn = tp ? tp.parentNode : null; if (!tgpn) return; siblingElem = tgpn.nextSibling; while ((siblingElem != null) && (siblingElem.nodeName != 'SPAN') && (siblingElem.className != 'site')) { siblingElem = siblingElem.nextSibling; if (siblingElem && siblingElem.className && (siblingElem.className.match(/res[13]/))) break; } if (siblingElem) rtnHtml = siblingElem.getElementsByTagName('a')[0]; if (rtnHtml) rtnHtml = rtnHtml.innerHTML; return rtnHtml;};searchshield.getTopLevelDocument = function (doc){ // return the top level document for the given doc, could be itself // TODO: determine a method of doing this for IE, if necessary // don't check about:blank if (doc && ((doc.location.href == "about:blank") || (doc.location.href == "about:Tabs"))) return doc; // Check if already a top level document for (var i = 0; i < gBrowser.browsers.length; i++) { if (doc == gBrowser.browsers[i].contentDocument) return doc; } // Not a top level, check all frames var documents; for (var j = 0; j < gBrowser.browsers.length; j++) { // get all docs for each browser documents = searchshield.getDocuments(gBrowser.browsers[j].contentWindow, new Array()); for (var k = 0; k < documents.length; k++) { // check if doc is from current browser if (doc == documents[k]) { // it is, return the top level doc for this browser return gBrowser.browsers[j].contentDocument; } } } return doc;};searchshield.getTopLevelWindow = function (){ // TODO: determine a method of doing this for IE, if necessary return mediator.getMostRecentWindow("navigator:browser");};//Event functionssearchshield.addListener = function (object, evtType, listener, useCapture){ useCapture = !!useCapture; if (object.addEventListener) { object.addEventListener(evtType, listener, useCapture); return true; } else if (object.attachEvent) { object.attachEvent("on"+evtType, listener); return true; } return false;};searchshield.cancelEvent = function (event){ event.cancelBubble = true; event.returnValue = false;};searchshield.doEvent = function (evtObj, evtTarget, evtName, evtType, bubbles, cancelable){ bubbles = !!bubbles; cancelable = !!cancelable; if (document.createEvent) { var evt = document.createEvent("Events"); evt.initEvent(evtName, bubbles, cancelable); evtTarget.dispatchEvent(evt); return true; } else if (document.createEventObject) { var evt = document.createEventObject(evtObj); evtTarget.fireEvent("on" + evtType, evt); return true; } return false;};searchshield.removeListener = function (object, evtType, listener, useCapture){ useCapture = !!useCapture; if (object.removeEventListener) { object.removeEventListener(evtType, listener, useCapture); return true; } else if (object.detachEvent) { object.detachEvent(evtType, listener); return true; } return false;};// HTML functionssearchshield.CleanupHTML = function (data){ if (data == null) return data; // cleanup html data, replace any new lines data = data.replace(/\r/g, ""); data = data.replace(/\n/g, ""); // escape any single quotes data = data.replace(/'/g, "\\'"); return data;};searchshield.removeHtmlTags = function (str){ var re = new RegExp('(<[^>]+>)','g'); var strStr = new String(str); if (!!strStr) return strStr.replace(re, ''); else return str; };// Browser functionssearchshield.elementSize = function (element){ //returns an array [sizeX, sizeY] var elemX; var elemY; elemX = parseInt(element.offsetWidth); elemY = parseInt(element.offsetHeight) return [elemX, elemY];};searchshield.GetFullBoundingRect = function (element){ if (!element) return;