/aspnet_client/system_web/1_0_3705_6018/SmartNav.js
JavaScript | 244 lines | 244 code | 0 blank | 0 comment | 92 complexity | a5a5f5290cc6ec41d3c9135d364095cf MD5 | raw file
1var snSrc; 2if (window.__smartNav == null) 3{ 4 window.__smartNav = new Object(); 5 window.__smartNav.update = function() 6 { 7 var sn = window.__smartNav; 8 var fd; 9 document.detachEvent("onstop", sn.stopHif); 10 sn.inPost = false; 11 try { fd = frames["__hifSmartNav"].document; } catch (e) {return;} 12 var fdr = fd.getElementsByTagName("asp_smartnav_rdir"); 13 if (fdr.length > 0) 14 { 15 if (sn.sHif == null) 16 { 17 sn.sHif = document.createElement("IFRAME"); 18 sn.sHif.name = "__hifSmartNav"; 19 sn.sHif.style.display = "none"; 20 sn.sHif.src = snSrc; 21 } 22 try {window.location = fdr[0].url;} catch (e) {}; 23 return; 24 } 25 var fdurl = fd.location.href; 26 index = fdurl.indexOf(snSrc); 27 if ((index != -1 && index == fdurl.length-snSrc.length) 28 || fdurl == "about:blank") 29 return; 30 var fdurlb = fdurl.split("?")[0]; 31 if (document.location.href.indexOf(fdurlb) < 0) 32 { 33 document.location.href=fdurl; 34 return; 35 } 36 if (sn.sHif != null) 37 { 38 sn.sHif.removeNode(true); 39 sn.sHif = null; 40 } 41 var hdm = document.getElementsByTagName("head")[0]; 42 var hk = hdm.childNodes; 43 var tt = null; 44 for (var i = hk.length - 1; i>= 0; i--) 45 { 46 if (hk[i].tagName == "TITLE") 47 { 48 tt = hk[i].outerHTML; 49 continue; 50 } 51 if (hk[i].tagName != "BASEFONT" || hk[i].innerHTML.length == 0) 52 hdm.removeChild(hdm.childNodes[i]); 53 } 54 var kids = fd.getElementsByTagName("head")[0].childNodes; 55 for (var i = 0; i < kids.length; i++) 56 { 57 var tn = kids[i].tagName; 58 var k = document.createElement(tn); 59 k.id = kids[i].id; 60 k.mergeAttributes(kids[i]); 61 switch(tn) 62 { 63 case "TITLE": 64 if (tt == kids[i].outerHTML) 65 continue; 66 k.innerText = kids[i].text; 67 hdm.insertAdjacentElement("afterbegin", k); 68 continue; 69 case "BASEFONT" : 70 if (kids[i].innerHTML.length > 0) 71 continue; 72 break; 73 default: 74 var o = document.createElement("BODY"); 75 o.innerHTML = "<BODY>" + kids[i].outerHTML + "</BODY>"; 76 k = o.firstChild; 77 break; 78 } 79 hdm.appendChild(k); 80 } 81 document.body.clearAttributes(); 82 document.body.id = fd.body.id; 83 document.body.mergeAttributes(fd.body); 84 var newBodyLoad = fd.body.onload; 85 if (newBodyLoad != null) 86 document.body.onload = newBodyLoad; 87 var s = "<BODY>" + fd.body.innerHTML + "</BODY>"; 88 if (sn.hif != null) 89 { 90 var hifP = sn.hif.parentElement; 91 if (hifP != null) 92 sn.sHif=hifP.removeChild(sn.hif); 93 } 94 document.body.innerHTML = s; 95 var sc = document.scripts; 96 for (var i = 0; i < sc.length; i++) 97 { 98 sc[i].text = sc[i].text; 99 } 100 sn.hif = document.all("__hifSmartNav"); 101 if (sn.hif != null) 102 { 103 var hif = sn.hif; 104 sn.hifName = "__hifSmartNav" + (new Date()).getTime(); 105 frames["__hifSmartNav"].name = sn.hifName; 106 sn.hifDoc = hif.contentWindow.document; 107 if (sn.ie5) 108 hif.parentElement.removeChild(hif); 109 window.setTimeout(sn.restoreFocus,0); 110 } 111 if (typeof(window.onload) == "string") 112 { 113 try { eval(window.onload) } catch (e) {}; 114 } 115 else if (window.onload != null) 116 { 117 try { window.onload() } catch (e) {}; 118 } 119 sn.attachForm(); 120 }; 121 window.__smartNav.restoreFocus = function() 122 { 123 if (window.__smartNav.inPost == true) return; 124 var curAe = document.activeElement; 125 var sAeId = window.__smartNav.ae; 126 if (sAeId==null || curAe!=null && (curAe.id==sAeId||curAe.name==sAeId)) 127 return; 128 var ae = document.all(sAeId); 129 if (ae == null) return; 130 try { ae.focus(); } catch(e){}; 131 } 132 window.__smartNav.saveHistory = function() 133 { 134 if (window.__smartNav.hif != null) 135 window.__smartNav.hif.removeNode(); 136 if ( window.__smartNav.sHif != null 137 && document.all[window.__smartNav.siHif] != null) 138 document.all[window.__smartNav.siHif].insertAdjacentElement( 139 "BeforeBegin", window.__smartNav.sHif); 140 } 141 window.__smartNav.stopHif = function() 142 { 143 document.detachEvent("onstop", window.__smartNav.stopHif); 144 var sn = window.__smartNav; 145 if (sn.hifDoc == null && sn.hif != null) 146 { 147 try {sn.hifDoc = sn.hif.contentWindow.document;} 148 catch(e){sn.hifDoc=null} 149 } 150 if (sn.hifDoc != null) 151 { 152 try {sn.hifDoc.execCommand("stop");} catch (e){} 153 } 154 } 155 window.__smartNav.init = function() 156 { 157 var sn = window.__smartNav; 158 document.detachEvent("onstop", sn.stopHif); 159 document.attachEvent("onstop", sn.stopHif); 160 try { if (window.event.returnValue == false) return; } catch(e) {} 161 sn.inPost = true; 162 if (document.activeElement != null) 163 { 164 var ae = document.activeElement.id; 165 if (ae.length == 0) 166 ae = document.activeElement.name; 167 sn.ae = ae; 168 } 169 else 170 sn.ae = null; 171 try {document.selection.empty();} catch (e) {} 172 if (sn.hif == null) 173 { 174 sn.hif = document.all("__hifSmartNav"); 175 sn.hifDoc = sn.hif.contentWindow.document; 176 } 177 if (sn.hifDoc != null) 178 try {sn.hifDoc.designMode = "On";}catch(e){}; 179 if (sn.hif.parentElement == null) 180 document.body.appendChild(sn.hif); 181 var hif = sn.hif; 182 hif.detachEvent("onload", sn.update); 183 hif.attachEvent("onload", sn.update); 184 window.__smartNav.fInit = true; 185 }; 186 window.__smartNav.submit = function() 187 { 188 window.__smartNav.fInit = false; 189 try { window.__smartNav.init(); } catch(e) {} 190 if (window.__smartNav.fInit) 191 window.__smartNav.form._submit(); 192 }; 193 window.__smartNav.attachForm = function() 194 { 195 var cf = document.forms; 196 for (var i=0; i<cf.length; i++) 197 { 198 if (cf[i].__smartNavEnabled != null) 199 { 200 window.__smartNav.form = cf[i]; 201 break; 202 } 203 } 204 var snfm = window.__smartNav.form; 205 if (snfm == null) return false; 206 var sft = snfm.target; 207 if (sft.length != 0 && sft.indexOf("__hifSmartNav") != 0) return false; 208 var sfc = snfm.action.split("?")[0]; 209 var url = window.location.href.split("?")[0]; 210 if (url.charAt(url.length-1) != '/' && url.lastIndexOf(sfc) + sfc.length != url.length) return false; 211 if (snfm.__formAttached == true) return true; 212 snfm.__formAttached = true; 213 snfm.attachEvent("onsubmit", window.__smartNav.init); 214 snfm._submit = snfm.submit; 215 snfm.submit = window.__smartNav.submit; 216 snfm.target = window.__smartNav.hifName; 217 return true; 218 }; 219 window.__smartNav.hifName = "__hifSmartNav" + (new Date()).getTime(); 220 window.__smartNav.ie5 = navigator.appVersion.indexOf("MSIE 5") > 0; 221 var rc = window.__smartNav.attachForm(); 222 var hif = document.all("__hifSmartNav"); 223 if (snSrc == null) { 224 snSrc = hif.src; 225 } 226 if (rc) 227 { 228 var fsn = frames["__hifSmartNav"]; 229 fsn.name = window.__smartNav.hifName; 230 window.__smartNav.siHif = hif.sourceIndex; 231 try { 232 if (fsn.document.location != snSrc) 233 { 234 fsn.document.designMode = "On"; 235 hif.attachEvent("onload",window.__smartNav.update); 236 window.__smartNav.hif = hif; 237 } 238 } 239 catch (e) { window.__smartNav.hif = hif; } 240 window.attachEvent("onbeforeunload", window.__smartNav.saveHistory); 241 } 242 else 243 window.__smartNav = null; 244}