1/* 2* Clear Default Text: functions for clearing and replacing default text in 3* <input> elements. 4*/ 5function registerClearDefaultItem(id, DefaultText) { 6 7 try { 8 theInput = document.getElementById(id); 9 addEvent(theInput, 'focus', clearDefaultText, false); 10 addEvent(theInput, 'blur', replaceDefaultText, false); 11 12 /* Save the current value */ 13 if (theInput.value != '') { 14 15 theInput.defaultText = DefaultText; 16 } 17 } catch (e) { } 18} 19 20function clearDefaultText(e) { 21 var target = window.event ? window.event.srcElement : e ? e.target : null; 22 if (!target) return; 23 24 if (target.value == target.defaultText) { 25 target.value = ''; 26 } 27} 28 29function replaceDefaultText(e) { 30 var target = window.event ? window.event.srcElement : e ? e.target : null; 31 if (!target) return; 32 33 if (target.value == '' && target.defaultText) { 34 target.value = target.defaultText; 35 } 36} 37/* 38* Event Handling: Cross Browser compliant event handling 39* <input> elements. 40*/ 41function addEvent(element, eventType, lamdaFunction, useCapture) { 42 try { 43 if (element.addEventListener) { 44 element.addEventListener(eventType, lamdaFunction, useCapture); 45 return true; 46 } else if (element.attachEvent) { 47 var r = element.attachEvent('on' + eventType, lamdaFunction); 48 return r; 49 } else { 50 return false; 51 } 52 } catch (e) { } 53} 54 55function killEvent(eventObject) { 56 if (eventObject && eventObject.stopPropagation) { 57 eventObject.stopPropagation(); 58 } 59 if (window.event && window.event.cancelBubble) { 60 window.event.cancelBubble = true; 61 } 62 if (eventObject && eventObject.preventDefault) { 63 eventObject.preventDefault(); 64 } 65 if (window.event) { 66 window.event.returnValue = false; 67 } 68} 69 70function cancelEventSafari() { 71 return false; 72} 73 74function GetEventSrcElement(eventElement) { 75 if (eventElement.srcElement) { 76 return eventElement.srcElement 77 } 78 // Netscape and Firefox 79 else if (eventElement.target) { 80 return eventElement.target 81 } 82} 83 84//General 85function ContensisSubmitFromTextbox(event, SubmitButton) { 86 var btn = document.getElementById(SubmitButton) 87 if (document.all) { 88 if (event.keyCode == 13) { 89 event.returnValue = false; 90 event.cancel = true; 91 killEvent(event); // [Added BJ 30/01/2012 for IE9] 92 btn.click(); 93 } 94 } 95 else if (document.getElementById) { 96 if (event.which == 13) { 97 event.returnValue = false; 98 event.cancel = true; 99 killEvent(event); // [Added iG 18/01/2012] 100 btn.click(); 101 } else { 102 // Do nothing 103 } 104 } 105 else if (document.layers) { 106 if (event.which == 13) { 107 event.returnValue = false; 108 event.cancel = true; 109 btn.click(); 110 } else { 111 // do nothing 112 } 113 } 114} 115//used for linkbuttons etc. 116function registerSubmitOnReturn(id, eventTarget) { 117 var Textbox = document.getElementById(id); 118 if (Textbox) { 119 Textbox.LinkButtonID = eventTarget 120 addEvent(Textbox, 'keypress', handleSubmitOnReturn, false) 121 } 122} 123function handleSubmitOnReturn(e) { 124 if (e.keyCode == 13) { 125 //alert("Submit") 126 e.cancelBubble = true; 127 e.returnValue = false; 128 var el = GetEventSrcElement(e) 129 __doPostBack(el.LinkButtonID, '') 130 } 131} 132 133 134function URLEncode(value) { 135 // The Javascript escape and unescape functions do not correspond 136 // with what browsers actually do... 137 var SAFECHARS = "0123456789" + // Numeric 138 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic 139 "abcdefghijklmnopqrstuvwxyz" + 140 "-_.!~*'()"; // RFC2396 Mark characters 141 var HEX = "0123456789ABCDEF"; 142 143 var plaintext = value; 144 var encoded = ""; 145 for (var i = 0; i < plaintext.length; i++) { 146 var ch = plaintext.charAt(i); 147 if (ch == " ") { 148 encoded += "+"; // x-www-urlencoded, rather than %20 149 } else if (SAFECHARS.indexOf(ch) != -1) { 150 encoded += ch; 151 } else {
152 var charCode = ch.charCodeAt(0); 153 if (charCode > 255) { 154 alert("Unicode Character '" 155 + ch 156 + "' cannot be encoded using standard URL encoding.\n" + 157 "(URL encoding only supports 8-bit characters.)\n" + 158 "A space (+) will be substituted."); 159 encoded += "+"; 160 } else { 161 encoded += "%"; 162 encoded += HEX.charAt((charCode >> 4) & 0xF); 163 encoded += HEX.charAt(charCode & 0xF); 164 } 165 } 166 } // for 167 return encoded; 168} 169 170//This is only required when email obfuscation is enabled 171function UnObfuscateHyperlinks() { 172 var links = document.getElementsByTagName('a'); 173 for (var l = 0; l < links.length; l++) { 174 if (!links[l].onclick) { 175 links[l].onclick = function() { 176 link_click(this); 177 } 178 } 179 } 180} 181 182function link_click(anchor) { 183 var href = anchor.getAttribute('href'); 184 if (href) { // [Altered by iG 28/03/2012] - Check if href is not undefined 185 var address = href.replace(/.*mailcontacts\//, ''); 186 if (href != address) { 187 address = address.replace(/\+\+/, '@'); 188 address = address.replace(/\+/g, '.'); 189 anchor.setAttribute('href', 'mailto:' + address); 190 } 191 } 192} 193 194function IEFixBackgroundImageFlicker() { 195 try {
196 document.execCommand('BackgroundImageCache', false, true); 197 } catch (e) { } 198} 199 200//This function allows you to attach the print function to an element in the dom for its click event. 201function AttachPrintHandler(elementID) { 202 var element = document.getElementById(elementID); 203 addEvent(element, 'click', function(e) { 204 window.print(); 205 killEvent(e); 206 }, 207 false); 208 addEvent(document, 'keydown', function(e) { 209 if (e.ctrlKey) { 210 if ((e.keyCode == 80) || (e.keyCode == 112)) { 211 window.print(); 212 killEvent(e); 213 } 214 } 215 }, 216 false); 217} 218
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.