var core = null var as = null; var sfh = null; var OSCore = "OSSecoyaCore1.992b"; var GFXCore = "GFXSecoyaCore1.992b/DefaultSkin/"; var JSCore = "JSSecoyaCore1.992b"; var callbackInterval = 120000; function performSearch(){ elm = document.getElementById('theSearchBox'); document.location='./?show=search&q='+elm.value; } function secoyaCoreLight(){ this.className = "secoyaCoreLight v1.0"; this.browser = null; this.zIndex = 5000; this.dimLayer = null; this.popup = null; this.getValue = function(id){ var tmp = document.getElementById(id); if(tmp.value) return tmp.value; else return ''; } this.initialize = function(){ this.browser = new secoyaBrowser(); var j =0; for(j = 0; j < inits.length; j++){ if(inits[j].initialize) inits[j].initialize(); } var op = 0.6; var dimLayer = document.createElement('div'); document.body.appendChild(dimLayer); dimLayer.style.backgroundColor = 'rgb(0,0,0)'; dimLayer.style.opacity = op; dimLayer.style.mozOpacity = op; dimLayer.style.filter = 'alpha(opacity='+(op*100)+')'; dimLayer.style.zIndex = '20'; dimLayer.style.width ='100%'; dimLayer.style.height ='100%'; dimLayer.style.backGroundRepeat = 'repeat'; dimLayer.style.position ='absolute'; dimLayer.style.top ='0px'; dimLayer.style.left ='0px'; dimLayer.style.display = 'none'; this.dimLayer = dimLayer; var logIn = document.createElement('div'); document.body.appendChild(logIn); logIn.innerHTML = 'test'; logIn.style.backgroundColor = 'rgb(255,255,255)'; logIn.style.position ='absolute'; logIn.style.zIndex = '30'; logIn.style.display = 'none'; logIn.style.borderWidth = '4px'; logIn.style.borderColor = 'rgb(155,155,155)'; logIn.style.borderStyle = 'solid'; this.popup = logIn; this.addEvent(document,'keydown',lightCore.checkKey); } this.loginVisible = false this.toggleLogin = function(){ //Find the top most window WITH the lightCore object. if(window!=window.top && window.parent.lightCore){ var tmp = window; while(tmp!=window.top && tmp.parent.lightCore){ tmp = tmp.parent; } tmp.lightCore.toggleLogin(); return; } if(this.loginVisible){ this.loginVisible = false; this.toggleDim(true); this.hidePopup(); }else{ this.loginVisible = true; as.invokeMethod("logMeIn"); } } this.hidePopup = function(){ var to = new turnOff(this.popup); fin = new fader(this.popup); fin.setDuration(200); fin.activateAfter(to); fin.fadeOut(); fin.start(); } this.showPopup = function(w,h,x,y,contents){ this.popup.style.display = 'block'; this.popup.innerHTML = contents; this.popup.style.width = w+'px'; this.popup.style.minHeight = h+'px'; if(x=='center'){ this.popup.style.left = (((this.getClientWidth()/2) - (w/2))+this.scrollLeft())+'px'; }else this.popup.style.left = x+'px'; if(y=='center'){ this.popup.style.top = (((this.getClientHeight()/2) - (h/2))+this.scrollTop())+'px'; }else this.popup.style.top = y+'px'; fin = new fader(this.popup); fin.setDuration(200); fin.fadeIn(); fin.start(); } this.toggleDim = function(off){ if(this.dimLayer.style.display=='none' && !off){ this.dimLayer.style.display='block'; this.dimLayer.style.widht = Math.max(document.body.offsetWidth,this.getClientWidth()); this.dimLayer.style.height = Math.max(document.body.offsetHeight,this.getClientHeight()); }else{ this.dimLayer.style.display='none'; } } this.clearIf = function(elm,val){ if(elm.value==val) elm.value=''; } this.setOpacity = function(elm,op){ if(lightCore.browser.getName()=='IE') elm.style.filter = 'alpha(opacity='+op+')'; else elm.style.MozOpacity = op/100; } this.clearOpacity = function(elm){ if(lightCore.browser.getName()=='IE') elm.style.filter = null; else elm.style.MozOpacity = null; } this.getZIndex = function(){ this.zIndex++; return this.zIndex; } this.clearSelection = function(){ if(this.browser.getName()=='IE'){ document.selection.empty(); }else{ window.getSelection().removeAllRanges(); } } this.getClientWidth = function(){ if(this.browser.getName()=="IE"){ return document.documentElement.clientWidth; }else{ return window.innerWidth; } } this.getClientHeight = function(){ if(this.browser.getName()=="IE"){ return document.documentElement.clientHeight; }else{ return window.innerHeight; } } this.addEvent = function(obj,typen,fn){ if(obj.addEventListener){ obj.addEventListener(typen,fn,false); }else if(obj.attachEvent){ obj["e"+typen+fn]=fn obj[typen+fn]=obj["e"+typen+fn] obj.attachEvent("on"+typen,obj[typen+fn]); } } this.removeEvent = function(obj,typen,fn){ if(obj.removeEventListener){ obj.removeEventListener(typen,fn,false); }else if(obj.detachEvent){ if(obj[typen+fn]!=undefined){ obj.detachEvent("on"+typen,obj[typen+fn]) obj[typen+fn]=null obj["e"+typen+fn]=null; } } } this.checkKey = function(event){ if(lightCore.ctrlHold(event)){ if(lightCore.getKeyCode(event)==16){ lightCore.toggleLogin(); } } } this.ctrlHold = function(event){ return this.checkKeyHold(event,'ctrl'); } this.checkKeyHold = function(event,k){ if(!event) return false; if(k=='ctrl') return event.ctrlKey || event['ctrlKey']; if(k=='alt') return event.altKey || event['altKey']; if(k=='shift') return event.shiftKey || event['shiftKey'];; return false; } this.getKeyCode = function(e){ var code = null; if (!e) var e = window.event if (e.keyCode) code = e.keyCode; else if (e.which) code = e.which; return code; } var inits = new Array(); this.registerInit = function(obj){ inits[inits.length] = obj; } this.setFocus = function(id){ var elm = document.getElementById(id); elm.focus(); } this.getBrowser = function(){ return this.browser; } this.getEvent = function(e){ if(e) return e; else return window.Event; } this.getElmFromEvent = function(e){ var targ if (!e) var e = window.Event if (e.target) targ = e.target else if (e.srcElement) targ = e.srcElement return targ; } this.posY = function(obj){ var curtop = 0; if (obj.offsetParent){ while (obj.offsetParent){ curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } this.posX = function(o){ // Get an object left position from the upper left viewport corner // Tested with relative and nested objects oLeft = o.offsetLeft // Get left position from the parent object while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element oParent = o.offsetParent // Get parent object reference oLeft += oParent.offsetLeft // Add parent left position o = oParent } // Return left postion return oLeft } /* this.posX = function(obj){ var curtop = 0; if(obj.offsetParent){ while(obj.offsetParent){ curtop += obj.offsetLeft if(this.getStyle(obj,'position')=='relative'){ curtop = obj.offsetLeft break; } obj = obj.offsetParent; } } else if (obj.x){ curtop += obj.x; } return curtop; }*/ this.getStyle = function(elm,name){ if(elm.tagName=="HTML") return ''; if(document.defaultView && document.defaultView.getComputedStyle){ var val = document.defaultView.getComputedStyle(elm,null).getPropertyValue(name); if(val) return document.defaultView.getComputedStyle(elm,null).getPropertyValue(name); }else{ if(!elm.currentStyle) return ""; return elm.currentStyle[name]; } return ''; } this.scrollTop = function(elm){ var pos = 0; if(elm!=undefined){ while(elm.tagName!='HTML'){ if(elm.scrollTop && elm.scrollTop!=0){ pos += elm.scrollTop; } if(elm.parentNode) elm = elm.parentNode; else break; } } if (window.innerHeight) pos += window.pageYOffset; else if (document.documentElement && document.documentElement.scrollTop) pos += document.documentElement.scrollTop; else if (document.body) pos += document.body.scrollTop; return pos; } this.scrollLeft = function(elm){ var pos = 0; if(elm!=undefined){ while(elm.tagName!='HTML'){ if(elm.scrollTop && elm.scrollLeft!=0){ pos += elm.scrollLeft; } if(elm.parentNode) elm = elm.parentNode; else break; } } if (window.innerHeight) pos += window.pageXOffset; else if (document.documentElement && document.documentElement.scrollLeft) pos += document.documentElement.scrollLeft; else if(document.body) pos += document.body.scrollLeft; return pos; } } var lightCore = new secoyaCoreLight(); function secoyaBrowser(){ this._name=''; this._version=''; this._os=''; this.getName = function(){ return this._name; } this.getVersion = function(){ return this._version; } this.getOS = function(){ return this._os; } var detect = navigator.userAgent.toLowerCase(); if(checkString('konqueror')){ this._name="Konqueror"; this._os="Linux"; }else if(checkString('safari')) this._name="Safari"; else if(checkString('omniweb')) this._name="OmniWeb"; else if(checkString('opera')) this._name="Opera"; else if(checkString('webtv')) this._name="WebTV"; else if(checkString('icab')) this._name="iCab"; else if(checkString('msie')) this._name="IE"; else if(!checkString('compatible')){ this._name="Netscape"; this._version=detect.charAt(8); }else this._name="none"; if(this._version=='') this._version=detect.charAt(place+detect.length); if(this._os==''){ if(checkString('linux')) this._os="Linux"; else if(checkString('x11')) this._os="Unix"; else if(checkString('mac')) this._os="Mac"; else if(checkString('win')) this._os="Windows"; else this._os="none"; } function checkString(string){ place = detect.indexOf(string); return place!=-1; } } function secoyaMenu(){ this.className = "secoyaMenu v1.0"; this.menuNames = new Array(); this.menus = new Object(); this.currentItem = null; this.currentlyOut = true; this.currentMenu = null; lightCore.registerInit(this); this.initialize = function(){ for(var i = 0; i < this.menuNames.length; i++){ //Collect the menu this.addMenu(this.menuNames[i]); } if(core) core.addHoldListener(this); } this.reportHoldEvent = function(){ if(this.currentMenu){ //this.collapseAll(); //core.addFrameUpdateListener(this); //this.setRemote(true); } } this.reportEndHold = function(){ //this.setRemote(false); //this.closeMenusAfterUpdate(); } this.reportFrameUpdate = function(){ core.removeFrameUpdateListener(this); setTimeout("sMenu.closeMenusAfterUpdate()",0); } this.closeMenusAfterUpdate = function(){ this.currentlyOut = true; this.collapseAll(); this.setRemote(false); } this.addMenu = function(name){ var domElm = document.getElementById(name); var m = new menuItem(domElm.id,null); if(domElm.getAttribute('dynamic')=='true') m.dynamic = true; m.initialize(domElm); m.getChildItems(); this.menus[name] = m; } this.registerMenu = function(name){ this.menuNames[this.menuNames.length] = name; } this.updateMenu = function(id){ this.setRemote(true) menuElm = this.getElementById(id); menuElm.initialize(null); this.setRemote(false); } this.checkOut = function(){ if(sMenu!=null && sMenu.currentlyOut){ var currentItem = sMenu.currentItem; if(currentItem!=null){ sMenu.triggerOutItem(currentItem); } sMenu.currentItem = null; } } this.enterItem = function(elm){ var menuElm = this.getElementById(elm.id); if(menuElm==null || menuElm.isLocked())return; sMenu.currentlyOut = false; if(!menuElm.isHighlighted()){ if(menuElm.parent) menuElm.parent.clearHighligts(); menuElm.highlight(); if(menuElm.dynamic){ menuElm.showSubMenu(); } sMenu.currentItem = menuElm; }else{ menuElm.clearHighligts(); } //Handle multiple menus if(menuElm && menuElm.getLevel()==1){ if(!this.currentMenu){ this.currentMenu = menuElm.parent; }else if(!this.currentMenu.isLocked() && this.currentMenu.getUID()!=menuElm.parent.getUID()){ sMenu.currentlyOut = true; this.triggerOutItem(this.currentMenu); this.currentMenu = menuElm.parent; sMenu.currentlyOut = false; } } } this.leaveItem = function(elm){ menuElm = this.getElementById(elm.id); if(menuElm==null || menuElm.isLocked()) return; sMenu.currentlyOut = true; setTimeout("sMenu.checkOut()",1000); } this.triggerOverItem = function(menuElm){ sMenu.currentlyOut = false; if(menuElm && menuElm.parent) menuElm.parent.clearHighligts(); if(menuElm){ menuElm.highlight(); menuElm.showSubMenu(); } } this.triggerOutItem = function(menuElm){ if(sMenu.currentlyOut){ while(menuElm){ menuElm.dehighlight(); menuElm.hideSubMenu(); menuElm = menuElm.parent; } } } this.overItemId = function(theID){ var tmp = this.getElementById(theID); this.triggerOverItem(tmp); } this.collapseAll = function(){ for(var uid in this.menus){ this.triggerOutItem(this.menus[uid]) } } this.getElementById = function(id){ for(var uid in this.menus){ if(uid==id) return this.menus[id]; var ptry = this.menus[uid].getElementById(id); if(ptry) return ptry; } return null; } this.getMenuElm = function(elm){ if(elm.tagName=='HTML') return null; if(elm.tagName=='TABLE') return elm; else return this.getMenuElm(elm.parentNode); } this.navigate = function(url,target){ if(as!=null && sfh!=null){ this.closeMenusAfterUpdate(); this.currentItem = null; this.currentlyOut = true; this.currentMenu = null; as.invokeMethod('navigate',url); }else{ if(target){ self.frames[target].location.href = url; }else{ document.location = url; } } } this.ajaxNavigate = function(url,target){ if(as!=null){ as.invokeMethod('navigate',url); } } this.setRemote = function(bb){ for(var uid in this.menus){ if(!bb && this.menus[uid].isLocked()) this.menus[uid].unlockMenu(); else if(bb && !this.menus[uid].isLocked()) this.menus[uid].lockMenu(); } } this.lockMenu = function(menuUID){ menuElm = this.getElementById(menuUID); menuElm.lockMenu(); } this.unlockMenu = function(menuUID){ menuElm = this.getElementById(menuUID); menuElm.unlockMenu(); } } function menuItem(id,parent){ this.id = id; this.parent = parent; this.level = 0; this.normalSub = null; this.overSub = null; this.menuItems = new Array(); this.on = false; this.visible = true; this.activeElement = null; this.container = null; this.highlighted = false; this.dynamic = false; this.locked = false; this.subVisible = false; this.lockMenu = function(){ this.locked = true; for(var c = 0; c < this.menuItems.length; c++){ this.menuItems[c].lockMenu(); } } this.unlockMenu = function(){ this.locked = false; for(var c = 0; c < this.menuItems.length; c++){ this.menuItems[c].unlockMenu(); } } this.isLocked = function(){ return this.locked; } this.initialize = function(domElm){ if(this.parent){ this.level = this.parent.getLevel() + 1; } if(domElm!=null){ domElm.style.zIndex = lightCore.getZIndex(); //this.subOrientation = domElm.getAttribute('orientation'); } this.getChildItems(); this.unlockMenu(); this.highlighted = false; this.on = false; } this.isHighlighted = function(){ return this.highlighted; } this.getContainer = function(){ if(this.container!=null){ return this.container; } var elm = document.getElementById(this.id); while(elm.tagName!='BODY' && elm.getAttribute('dropstyle')!="float"){ elm = elm.parentNode; } if(elm.getAttribute('dropstyle')=='float') this.container = elm; else this.container= 'none'; return this.container; } this.getChildItems = function(){ this.menuItems = new Array(); var subObj = document.getElementById(this.getUID()+'sub'); if(!subObj) return; var tmpItems = new Array(); var children = subObj.childNodes; var cc = children.length; for(var c = 0; c < cc; c++){ if(children[c].tagName=='LI'){ var cI = new menuItem(children[c].id,this); cI.dynamic = this.dynamic; cI.initialize(children[c]); tmpItems[tmpItems.length] = cI; } } this.menuItems = tmpItems; } this.getLevel = function(){ return this.level; } this.getUID = function(){ return this.id; } this.showSubMenu = function(){ var subObj = document.getElementById(this.getUID()+'sub'); if(!subObj) return; subObj.setAttribute('oldX',lightCore.getStyle(subObj,'left')); subObj.setAttribute('oldY',lightCore.getStyle(subObj,'top')); subObj.className = subObj.getAttribute('overClass'); subObj.style.zIndex = lightCore.getZIndex(); var obj = document.getElementById(this.getUID()); var placeS = obj.getAttribute('placeSub'); placeS = this.checkSpace(obj,subObj,placeS); this.placeSubMenu(obj,subObj,placeS); this.subVisible = true; } this.checkSpace = function(parent,sub,place){ cw = lightCore.getClientWidth(); ch = lightCore.getClientHeight(); switch(place){ case 'n': break; case 'e': var left = parseInt(lightCore.posX(parent) + parent.offsetWidth + sub.offsetWidth); if(left > cw) place = 'w'; break; case 'w': break; case 's': var bottom = parseInt(lightCore.posY(parent) + parent.offsetHeight + sub.offsetHeight); if(bottom > ch) place = 'n'; break; } return place; } this.placeSubMenu = function(parent,sub,place){ var left = 0; var top = 0; switch(place){ case 'n': left = this.posX(parent); top = (this.posY(parent) - sub.offsetHeight); break; case 'e': var bottom = parseInt(lightCore.posY(parent) + sub.offsetHeight); if(bottom > (lightCore.getClientHeight() + lightCore.scrollTop())) top = this.posY(parent) - sub.offsetHeight + parent.offsetHeight; else top = this.posY(parent); left = this.posX(parent) + parent.offsetWidth; break; case 'w': var bottom = parseInt(lightCore.posY(parent) + sub.offsetHeight); if(bottom > (lightCore.getClientHeight() + lightCore.scrollTop())) top = this.posY(parent) - sub.offsetHeight + parent.offsetHeight; else top = this.posY(parent); left = this.posX(parent) - sub.offsetWidth; break; case 's': left = this.posX(parent); top = (this.posY(parent) + parent.offsetHeight); break; } sub.style.left = parseInt(left) + 'px'; sub.style.top = parseInt(top) + 'px'; return place; } this.highlight = function(){ var domElm = document.getElementById(this.getUID()); domElm.className = domElm.getAttribute('overClass'); this.parent.activeElement = this; this.highlighted = true; } this.clearHighligts = function(){ if(this.activeElement){ this.activeElement.dehighlight(); this.activeElement.hideSubMenu(); } } this.hideSubMenu = function(){ var subObj = document.getElementById(this.getUID()+'sub'); if(!subObj) return; if(subObj.getAttribute('oldY')){ if(subObj.getAttribute('oldY')=='auto') subObj.style.top = 'auto' else subObj.style.top = parseInt(subObj.getAttribute('oldY'))+'px'; } if(subObj.getAttribute('oldX')){ if(subObj.getAttribute('oldX')=='auto') subObj.style.left = 'auto' else subObj.style.left = parseInt(subObj.getAttribute('oldX'))+'px'; } subObj.className = subObj.getAttribute('normalClass'); this.subVisible = false; } this.dehighlight = function(){ var domElm = document.getElementById(this.getUID()); //possible HACK if(!domElm){ return; } domElm.className = domElm.getAttribute('normalClass'); if(this.activeElement){ this.activeElement.dehighlight(); this.activeElement.hideSubMenu(); } this.highlighted = false; } this.getElementById = function(id){ var cc = this.menuItems.length; for(var i = 0; i < cc; i++){ var child = this.menuItems[i]; if(child.id==id) return child; var ptry = child.getElementById(id); if(ptry) return ptry; } return null; } this.posY = function(obj){ var curtop = 0; if (obj.offsetParent){ while (obj.offsetParent){ if(obj.getAttribute('dropstyle')=="float") break; curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } this.posX = function(obj){ var curtop = 0; if (obj.offsetParent){ while (obj.offsetParent){ if(obj.getAttribute('dropstyle')=="float") break; curtop += obj.offsetLeft obj = obj.offsetParent; } } else if (obj.x) curtop += obj.x; return curtop; } } var sMenu = new secoyaMenu(); function setCookie( name, value, expires, path, domain, secure ) { var today = new Date(); today.setTime( today.getTime() ); if ( expires ) { expires = expires * 1000 * 60 * 60 * 24; } var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name+'='+escape( value ) + ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString() ( ( path ) ? ';path=' + path : '' ) + ( ( domain ) ? ';domain=' + domain : '' ) + ( ( secure ) ? ';secure' : '' ); } function doRegister(form){ // encrypt pass using salt if(form['passfield1'].value.length > 0){ form['pass1'].value = hex_hmac_sha1(form['salt'].value, form['passfield1'].value); } if(form['passfield2'].value.length > 0) { form['pass2'].value = hex_hmac_sha1(form['salt'].value, form['passfield2'].value); } // pass_field_curr does not allways exist // must be encrypted with key AND salt if(form['passfieldcurr'] && form['passfieldcurr'].value.length > 0){ form['passcurr'].value = hex_hmac_sha1(form['key'].value, hex_hmac_sha1(form['salt'].value, form['passfieldcurr'].value)); } // clear field fake = ''; for (i = 0; i < form['passfield1'].value.length; i++) { fake = fake + '-'; } form['passfield1'].value = fake; fake = ''; for (i = 0; i < form['passfield2'].value.length; i++) { fake = fake + '-'; } form['passfield2'].value = fake; fake = ''; // pass_field_curr does not allways exist if(form['passfieldcurr']){ for (i = 0; i < form['passfieldcurr'].value.length; i++) { fake = fake + '-'; } form['passfieldcurr'].value = fake; } return true; } function doLogin(form){ // first encrypt pass using salt form['b-01.pass'].value = hex_hmac_sha1(form['b-01.salt'].value, form['b-01.password'].value); // clear field fake = ''; for (i = 0; i < form['b-01.password'].value.length; i++) { fake = fake + '-'; } form['b-01.password'].value = fake; // then set cookie if(form['b-01.remember'] && form['b-01.remember'].checked){ setCookie('u_pass', form['b-01.pass'].value, 100, '/'); } // then encrypt pass again using session key form['b-01.pass'].value = hex_hmac_sha1(form['b-01.key'].value, form['b-01.pass'].value); return true; } var hexcase = 0; var b64pad = ""; var chrsz = 8; function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));} function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));} function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));} function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));} function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));} function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));} function sha1_vm_test(){ return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d"; } function core_sha1(x, len){ x[len >> 5] |= 0x80 << (24 - len % 32); x[((len + 64 >> 9) << 4) + 15] = len; var w = Array(80); var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; var e = -1009589776; for(var i = 0; i < x.length; i += 16){ var olda = a; var oldb = b; var oldc = c; var oldd = d; var olde = e; for(var j = 0; j < 80; j++){ if(j < 16) w[j] = x[i + j]; else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1); var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),safe_add(safe_add(e, w[j]), sha1_kt(j))); e = d; d = c; c = rol(b, 30); b = a; a = t; } a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); e = safe_add(e, olde); } return Array(a, b, c, d, e); } function sha1_ft(t, b, c, d){ if(t < 20) return (b & c) | ((~b) & d); if(t < 40) return b ^ c ^ d; if(t < 60) return (b & c) | (b & d) | (c & d); return b ^ c ^ d; } function sha1_kt(t){ return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : (t < 60) ? -1894007588 : -899497514; } function core_hmac_sha1(key, data){ var bkey = str2binb(key); if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz); var ipad = Array(16), opad = Array(16); for(var i = 0; i < 16; i++){ ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz); return core_sha1(opad.concat(hash), 512 + 160); } function safe_add(x, y){ var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function rol(num, cnt){ return (num << cnt) | (num >>> (32 - cnt)); } function str2binb(str){ var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32); return bin; } function binb2str(bin){ var str = ""; var mask = (1 << chrsz) - 1; for(var i = 0; i < bin.length * 32; i += chrsz) str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask); return str; } function binb2hex(binarray){ var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++){ str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); } return str; } function binb2b64(binarray){ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var str = ""; for(var i = 0; i < binarray.length * 4; i += 3){ var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16) | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 ) | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF); for(var j = 0; j < 4; j++){ if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); } } return str; } String.prototype.decodeEntities = function() { return this.replace(/&(\w+);/g, function(m, a) { return { AElig: "\xC6", Oslash: "\xD8", Aring: "\xC5", aelig: "\xE6", oslash: "\xF8", aring: "\xE5", amp: '&', quot: '"', apos: "'", lt: '<', gt: '>' }[a]; }); }