/** * Utility functions * -------------------------- * Lost Boys - www.lostboys.nl */ // IE Anti-background flicker /*@cc_on try { document.execCommand('BackgroundImageCache', false, true); } catch (e) {} @*/ function getElementsByAttributeValue(attribute, value, root) { var output = new Array; var attributeName = (document.all && attribute.toLowerCase() == "class") ? "className" : attribute; var rootElement = root ? root : document; var els = (rootElement.all ? rootElement.all : rootElement.getElementsByTagName("*")); var attributeReg = new RegExp('(^|\\s)'+value+'($|\\s)'); var attributeValue; // IE8 doesn't recognize getAttribute("className"). The className property works on all browsers. if (attribute.toLowerCase() == "class") for(var i = els.length-1; i >= 0; i--) { attributeValue = els[i].className; if(attributeValue && (!value || attributeReg.test(attributeValue))) output[output.length] = els[i]; } else for(var i = els.length-1; i >= 0; i--) { attributeValue = els[i].getAttribute(attributeName); if(attributeValue && (!value || attributeReg.test(attributeValue))) output[output.length] = els[i]; } return output.reverse(); } var ClassName = { add:function(node, name) { if(!this.contains(node, name)) node.className += node.className? (' ' + name) : name; }, remove:function(node, name) { if(node.className) node.className = node.className.replace(new RegExp('(^|\\s)'+name+'(\\s|$)','g'), ' '); }, contains:function(node, name) { return new RegExp('(^|\\s)'+name+'(\\s|$)').test(node.className); }, swap:function(node, old, name) { node.className = this.contains(node, old)? node.className.replace(new RegExp('(^|\\s)'+old+'(\\s|$)','g'), '$1'+name+'$2') : node.className.replace(new RegExp('(^|\\s)'+name+'(\\s|$)','g'), '$1'+old+'$2'); }, toggle:function(node, name) { if(!this.contains(node, name)) { this.add(node, name); } else { this.remove(node, name); } } } var Class = { extend:function(Base, constructor, prototype) { var Extended = function() { Base.apply(this, arguments); constructor.apply(this, arguments); } this.implement(Extended, Base.prototype); if(prototype) this.implement(Extended, prototype); return Extended; }, implement:function(Class, protoface) { for(var i in protoface) { Class.prototype[i] = protoface[i]; } } } var LinkListener = { init:function() { this.relations = []; EventListener.addEvent(document, 'click', this.scope(this.handleClicks)); }, addRelation:function(rel, handler) { if(!this.relations) this.init(); //jit init // register link relation handler, as regular expression this.relations.push({type:rel, handler:handler}); }, handleClicks:function(e) { if(e.shiftKey || e.ctrlKey || e.altKey) return; var target = EventListener.getTarget(e, 'a'); var rel = target? target.getAttribute('rel') : null; var handler = rel? this.searchHandler(rel) : null; if(handler && handler(target, rel)) { // if handler returns true, cancel default event EventListener.cancelEvent(e); } }, searchHandler:function(rel) { for(var relation,i=0; i= 2 && checked <=3) return true; return false; }, scope:function(method) { var scope = this; return function() { return method.apply(scope, arguments); } } } EventListener.addEvent(window, "load", function(e){ new compareForms(); }); var selectAll = { init:function() { for (var i=0; i'); } /** * onDOMContentLoaded * ------------------------- */ var DOMContent = { init:function() { this.handlers = []; var onload = function() { DOMContent.onload(); } try { window.addEventListener('load', onload, false); document.addEventListener('DOMContentLoaded', onload, false); } catch(e) { window.attachEvent('onload', onload); /*@cc_on @*/ /*@if (@_win32) document.write('