// add an extra action once this page is completely loaded function addOnLoadFunc (newfunc) { var oldLoad = window.onload; window.onload = function () { if (oldLoad) { oldLoad(); } newfunc(); } } // for putting a default into search inputs and then clearing it as needed var changedSearch = {}; function clearSearch (e) { var n = e.form.name+e.name; if (!changedSearch[n]) { e.value = ''; changedSearch[n] = true; } return true; } // track what major features we have access to (equiv to browser testing) var ie4 = (document.all ? true : false); var ns4 = (document.layers ? true : false); var w3c = (document.getElementById ? true : false); // shortcut function to get object using appropriate browser feature function getByID (id) { if (w3c) { return document.getElementById(id); } else if (ie4) { return document.all[id]; } else if (ns4) { return document.layers[id]; } return null; } // basic image rollover functions -- onmouseover="imgOn('imgName')" function imgOn (name) { document[name].src = '/pictures/'+name+'2.gif'; } function imgOff (name) { document[name].src = '/pictures/'+name+'.gif'; } // rollover for input type="image" -- onmouseover="imgOn(this)" function imgOn2 (elem) { elem.src = elem.src.replace(/(\.[^\.]+)$/,'2$1'); } function imgOff2 (elem) { elem.src = elem.src.replace(/(2\.[^\.]+)$/,'$1'); } // this is a SAMPLE of how to preload the images: // precaching of rollover images //a = new Image(); a.src = '/pictures/name2.gif'; // checks to see if we have actually left a menu for onMouseOut // got inspiration from: // http://www.quirksmode.org/js/events_mouse.html#mouseover // e == the event from onMouseOut="isInMenu(event,this)" or this => "getByID('base_id')" // b == the base element, are we really moving out of this? function isInMenu (e,b) { // adapt to NS/IE naming differences if (!e) { e = window.event; } var p = (e.relatedTarget ? e.relatedTarget : e.toElement); // check all parents, see if they are the base element while (p) { // one of the parents is the base element, we're still over it if (p == b) { return true; } // this parent is not the base, keep checking the next parent up p = p.parentNode; } // we never found the base in all parents of event's target // ergo, we really are no longer over the base element return false; } // used for adding css :hover attribute to any element in IE // adapted from: http://www.htmldog.com/articles/suckerfish/dropdowns/ function IEHover (id, tag) { var elem = document.getElementById(id); if (elem) { var els = elem.getElementsByTagName(tag); for (var i in els) { els[i].onmouseover = function () { this.className += " iehover"; }; els[i].onmouseout = function () { this.className = this.className.replace(new RegExp(" iehover\\b"), ""); } }}} // add iehover class only in IE, but for any number of id+tag pairs function onloadIEHover (r) { if (window.attachEvent) { for (var i in r) { window.attachEvent("onload", function () { IEHover(r[i][0],r[i][1]) }); } } } // ex: onloadIEHover([['dropdown_menu','LI'],]);