
var dx = 0;
var dy = 0;
var sx = 0;
var sy = 0;
var isd = false;
var request = 0;
var p65m_;
var p65m_1;
var p65m_2='';
var vmovep;
var vmovepf;
var vmovepi;
function m() {
	request++;
	var l1 = $("f-2");
	var l=$("f-1");
	if(!l.visible()){
		$("f-077").update("信息");
	}
	l.style.zIndex = "2";
	var l2 = $("f");
	l1.show();
	l2.show();
}
function m1() {
	if (request - 1 == 0) {
		setTimeout("request--;if(request == 0){$('f').hide();$('f-1').style.zIndex = '4';if (!$('f-1').visible()) {$('f-2').hide();}}", 100);
	} else {
		request--;
	}
}
function m2(a, a1) {
	if (!a.visible() || a1) {
		var x = (document.documentElement.clientWidth - a.getWidth()) / 2;
		if (x < 0) {
			x = 10;
		}
		a.style.left = document.documentElement.scrollLeft + x + "px";
		var l;
		if(a.id=='f'){l=2.2;}else{l=3.8;}
		var y = (document.documentElement.clientHeight - a.getHeight()) / l;
		if (y < 0) {
			y = 10;
		}
		a.style.top = document.documentElement.scrollTop + y + "px";
	}
}
/**
 * 页面数据填充。
 * 
 * a url，a1 更新容器id，a2 缓存与否，a3 不遮罩。 
 */
function f(a, a1, a2, a3) {
	var l3 = $(a1);
	if (!a2 || l3.innerHTML == "") {
		m2($("f"));
		if (!a3) {
			m();
		}
		if (typeof (a) == "string") {
			new Ajax.Request(a + "&" + new Date(), {onComplete:function (l) {
				l3.update(l.responseText);
				if (!a3) {
					m1();
				}
			}});
		} else {
			$(a).request({onComplete:function (l4) {
				l3.update(l4.responseText);
				if (!a3) {
					m1();
				}
			}});
		}
	}
}
/**
 * 提交或弹出窗口。
 * 
 * a 表单id/链接。
 */
function f1(a) {
	m2($("f"));
	var l3 = $("f-1");
	l3.hide();
	var l = $("f-7");
	m();
	$("f-78").show();
	if (typeof (a) == "string") {
		new Ajax.Request(a + "&" + new Date(), {onComplete:function (l4) {
			l.update(l4.responseText);
			m2(l3);
			l3.show();
			m1();
		}});
	} else {
		$(a);
		if (a.getAttribute("enctype") == "multipart/form-data") {
			var l1 = a.ownerDocument.createElement("iframe");
			l1.id = "tpf";
			l1.name = "tpf";
			l1.style.display = "none";
			a.ownerDocument.body.appendChild(l1);
			l1.contentWindow.name = l1.name;
			a.target = l1.name;
			var upc = window.setInterval(function () {
				if (l1.contentWindow.location != "about:blank") {
					try {
						window.clearInterval(upc);
						l.update(l1.contentWindow.document.getElementsByTagName("body")[0].innerHTML);
						m2(l3);
						l3.show();
						m1();
						$(l1).remove();
					}
					catch (e) {
						window.clearInterval(upc);
						l.update(e);
						m2(l3);
						l3.show();
						m1();
						$(l1).remove();
					}
				}
			}, 500);
			a.submit();
		} else {
			a.request({onComplete:function (l4) {
				l.update(l4.responseText);
				m2(l3);
				l3.show();
				m1();
			}});
		}
	}
}
/**
 * 安全提交。
 *  a 表单id/链接，a1 点击事件。
 * @author Lkyooo
 */
function f2(a, a1) {
	$("f-6").src = "I?f=1&" + new Date();
	var l = $("f-3");
	var l1 = a1.clientX;
	var l2 = a1.clientY;
	l.style.top = a1.clientY + document.documentElement.scrollTop - 3 + "px";
	var l3 = a1.clientX + document.documentElement.scrollLeft - l.getWidth();
	if (l3 < 0) {
		l.style.left = a1.clientX + document.documentElement.scrollLeft + "px";
	} else {
		l.style.left = l3 + "px";
	}
	l.show();
	var l1 = $("f-4");
	l1.value = "";
	l1.focus();
	$("f-499").onclick = function (e) {
		if (e != undefined) {
			event = e;
		}
		document.cookie = "n1=" + $("f-4").value;
		f1(a);
		l.hide();
	};
}
/**
 * 后台异步请求。
 * 
 * a url。
 */
function f3(a) {
	new Ajax.Request(a, {onComplete:function (l) {
	}});
}
/**
 * 鼠标焦点。
 * @author Lkyooo
 */
function f4(a) {
	a.style.background = "#FFFFEE";
}
/**
 * 鼠标移出焦点。
 * @author Lkyooo
 */
function f5(a) {
	a.style.background = "none";
}
/**
 * 换页。
 * a标签块，a1面板id,a2总类。
 * @author Lkyooo
 */
function f6(a,a1,a2) {
	if(a2==null){a2="p";}
	var l = $$("div.b div."+a2+" div.to");
	for (var t = 0; t < l.length; t++) {
		if (a == l[t]) {
			return false;
		} else {
			l[t].removeClassName("to");
			l[t].addClassName("td");
		}
	}
	Element.extend(a);
	a.removeClassName("td");
	a.addClassName("to");
	var l1 = $$("div.b div."+a2+" div.o");
	for (var t = 0; t < l1.length; t++) {
		l1[t].removeClassName("o");
		l1[t].addClassName("d");
	}
	var l2 = $(a1);
	l2.removeClassName("d");
	l2.addClassName("o");
	return true;
}
/**
 * 条目修改提交后刷新。
 * a div的id，a1序号。
 * @author Lkyooo
 */
function f7(a, a1) {
	var l = $(a + "-c");
	var l1 = l.getAttribute("href");
	var l2;
	if (a1 != null) {
		if (a1.startsWith("?")) {
			l2 = l1.substr(0, l1.indexOf("?")) + a1;
		} else {
			l2 = l1 + "&" + a1;
		}
	} else {
		l2 = l1;
	}
	l.setAttribute("href", l2);
	l.onclick();
	l.setAttribute(l1);
}
/**
 * 链接分析自动填充。
 * a div的id，a1名称框，a2链接框。
 * @author Lkyooo
 */
function f8(a, a1, a2) {
	$(a).setAttribute("contentEditable", "false");
	setTimeout("var d = $('" + a + "');var n = d.childNodes;for (i = 0; i < n.length; i++) {if (n[i].nodeType == 1) {if (n[i].tagName == 'A' || n[i].tagName == 'a') {$('" + a1 + "').value = n[i].innerHTML.replace(/<[^>]+>/g,'');$('" + a2 + "').value = $(n[i]).readAttribute('href');}}}d.update();d.contentEditable = true;d.focus();", 2000);
}
/**
 * 是否是回车键。
 * a 事件。
 * @author Lkyooo
 */
function f9(a) {
	return a.keyCode == 13 ? true : false;
}
/**
 * 光标移动到末尾。
 * a 输入区域。
 * @author Lkyooo
 */
function f10(a) {
	a.focus();
	if (navigator.userAgent.indexOf("Firefox") < 0) {
		var l1 = a.createTextRange();
		l1.moveStart("character", a.value.length);
		l1.collapse(true);
		l1.select();
	}
}
/**
 * 表单验证。
 * a 表单。
 * @author Lkyooo
 */
function f11(a) {
	var l = $(a).getElements();
	for (var t = 0; t < l.length; t++) {
		l[t].removeClassName("e");
	}
	var e;
	var e1;
	for (var t = 0; t < l.length; t++) {			
		//EMAIL地址验证
		var l1 = l[t].readAttribute("fv:email");
		if (l1) {
			if (!jcv_checkEmail(l[t].value)) {
				window.alert("\u7535\u5b50\u90ae\u7bb1\u4e0d\u6b63\u786e");
				e = l[t];
				break;
			}
		}
		//文本验证
		l1 = l[t].readAttribute("fv:textok");
		if (l1) {
			var p = /^\s+$/;
			var p1 = /<script[^>]*>/i;
			if (l[t].value.length == 0 || p.exec(l[t].value)) {
				window.alert("\u503c\u4e0d\u80fd\u4e3a\u7a7a");
				e = l[t];
				break;
			}
			if (p1.exec(l[t].value)) {
				window.alert("\u4e0d\u80fd\u542b\u6709\u811a\u672c\u6807\u7b7e<script>\u3002");
				e = l[t];
				break;
			}
		}		
		//可空文本验证
		l1 = l[t].readAttribute("fv:btextok");
		if (l1) {
			var p = /<script[^>]*>/i;
			if (l[t].value != 0 && p.exec(l[t].value)) {
				window.alert("\u4e0d\u80fd\u542b\u6709\u811a\u672c\u6807\u7b7e<script>\u3002");
				e = l[t];
				break;
			}
		}
		//日期验证
		l1 = l[t].readAttribute("fv:date");
		if (l1) {
			var p = /^\d{4}(\-)\d{1,2}(\-)\d{1,2}$/;
			if (!p.exec(l[t].value)) {
				window.alert("日期格式不正确，应该为yyyy-MM-dd");
				e = l[t];
				break;
			}
		}	
		//非负的数字
		l1 = l[t].readAttribute("fv:number");
		if (l1) {
			var p = /^(\d+|\d+(\.)?\d+){1}$/;
			if (l[t].value.length == 0) {
				l[t].value = 0;
			}
			if (!p.exec(l[t].value)) {
				window.alert("\u5fc5\u987b\u662f\u975e\u8d1f\u7684\u6570\u5b57\u3002");
				e = l[t];
				break;
			}
		}		
		//非负的整数i
		l1 = l[t].readAttribute("fv:inumber");
		if (l1) {
			var p = /^\d+$/;
			if (l[t].value.length == 0) {
				l[t].value = 0;
			}
			if (!p.exec(l[t].value)) {
				window.alert("\u5fc5\u987b\u662f\u975e\u8d1f\u7684\u6574\u6570");
				e = l[t];
				break;
			}
		}		
		//资金格式验证
		l1 = l[t].readAttribute("fv:currency");
		if (l1) {
			var p = /^\d+(\.\d{0,2})?$/;
			if (l[t].value.length == 0) {
				l[t].value = 0;
			}
			if (!p.exec(l[t].value)) {
				window.alert("资金格式不正确，必须是非负数，小数点最多两位");
				e = l[t];
				break;
			}
		}
		//大于某数的数
		l1 = l[t].readAttribute("fv:ebigger");
		if (l1 != null) {
			if (parseFloat(l[t].value) < parseFloat(l1)) {
				window.alert("\u5fc5\u987b\u8981\u5927\u4e8e" + l1);
				e = l[t];
				break;
			}
		}
		//小于某数的数
		l1 = l[t].readAttribute("fv:esmaller");
		if (l1 != null) {
			if (parseFloat(l[t].value) > parseFloat(l1)) {
				window.alert("必须要小于或等于" + l1);
				e = l[t];
				break;
			}
		}	
		//密码格式验证
		l1 = l[t].readAttribute("fv:password");
		if (l1) {
			if (l[t].value.length < 6 || l[t].value.length > 24) {
				window.alert("\u5bc6\u7801\u5fc5\u987b\u662f6\u523024\u4e2a\u7684\u4efb\u610f\u5b57\u7b26");
				e = l[t];
				break;
			}
		}
		//两个输入相等
		l1 = l[t].readAttribute("fv:equal");
		if (l1 != null) {			
			if (l[t].value != l[t + parseInt(l1)].value) {
				e = l[t];
				e1 = l[t + parseInt(l1)];
				window.alert("\u503c\u4e0d\u76f8\u7b49\u3002");
				break;
			}
		}
		//选择框选择验证
		l1 = l[t].readAttribute("fv:checked");
		if (l1) {
			if (!l[t].checked) {
				e = l[t];
				window.alert("\u9009\u62e9\u6846\u672a\u9009\u62e9");
				break;
			}
		}
		//下拉框选择验证
		l1 = l[t].readAttribute("fv:selected");
		if (l1) {
			if (l[t].value.length == 0) {
				e = l[t];
				window.alert("\u4e0b\u62c9\u6846\u672a\u9009\u62e9");
				break;
			}
		}
		//字符数验证
		l1 = l[t].readAttribute("fv:lesschar");
		if (l1!=null) {
			if(countChar(l[t].value)>parseInt(l1)){
				e = l[t];
				window.alert("文本长度不得超过"+l1+"，每个中文类型字符占长度2，西文类型字符占长度1");
				break;
			}
		}
		//用户名验证
		l1 = l[t].readAttribute("fv:username");
		if (l1) {
			var p = /^[a-zA-Z0-9]$/;
			var p1 = /^[\u4e00-\u9fa5]$/;
			var l2=0;
			for (var t1 = 0; t1 < l[t].value.length; t1++) {
				if (p.exec(l[t].value.charAt(t1))) {
					l2++;
				} else {
					if (p1.exec(l[t].value.charAt(t1))) {
						l2++;
						l2++;
					} else {
						e = l[t];
						l2 = 0;
						break;
					}
				}
			}
			if (l2 > 16 || l2 == 0) {
				e = l[t];
				window.alert("\u7528\u6237\u540d\u5fc5\u987b\u662f\u957f\u5ea6\u5c0f\u4e8e16\u4f4d\u7684\u4e2d\u6587/\u6570\u5b57/\u82f1\u6587\u5b57\u6bcd\uff0c\u4e2d\u6587\u53602\u4f4d\uff0c\u6570\u5b57/\u82f1\u6587\u5b57\u6bcd\u5360\u4e00\u4f4d\u3002");
				break;
			}
		}
		//字符数量统合验证
		if(l[t]!=null&&!l[t].readAttribute("fv:nl")){
			if(l[t].value.length>1500){
				e = l[t];
				window.alert("字符数超过了1500，请减少。");
				break;
			}
		}
	}
	if (e != null) {
		e.addClassName("e");
		if (e1 != null) {
			e1.addClassName("e");
		}
		return false;
	} else {
		return true;
	}
}
/*
 * 滑动图片
 * a图片窗体,a1 true 左移,a2 右移
 */
function movep(a,a1){
	var l=a.childElements()[0];
	var l2=parseInt(l.style.left.substring(0,l.style.left.length-2));
	if(a1){	
		var l1=l.getWidth()-a.getWidth();
		if(-l2<l1){
			l.style.left=l2-1+'px';			
		}else{			
			return;
		}
	}else{
		if(l2==0){
			return;
		}else{			
			l.style.left=l2+1+'px'
		}
	}
}

/*
 * 滑动图片
 * a图片窗体,a1 true 左移,a2 右移
 */
function mp(){
	if(vmovepi){	
	var l=vmovep.childElements()[0];
	var l2=parseInt(l.style.left.substring(0,l.style.left.length-2));
	if(vmovepf){	
		var l1=l.getWidth()-vmovep.getWidth();
		if(-l2<l1){
			l.style.left=l2-1+'px';			
		}else{
			vmovepi=false;		
			return;
		}
	}else{
		if(l2==0){
			vmovepi=false;
			return;
		}else{			
			l.style.left=l2+1+'px'
		}
	}	
		setTimeout("mp()",5);
	}
}
function smp(a,a1){	
		if(!vmovepi){
		vmovep=a;
		vmovepf=a1;
		vmovepi=true;
		mp();
		}	
}
function emp(){
	vmovepi=false;
}

/*
 * 处理导航
 * a改变的文字 a1是否添加 a2输入框
 */
function nav(a,a1,a2){
	if (a1) {
		if(!p65m_2.include(a)){
			if (!a.include("_")) {
					p65m_2 = a + "\n";
			} else {
				var l4=a.substring(	0,
															a.lastIndexOf("_"));
				if(p65m_2.include(l4)){
					var l3=new RegExp( l4 + "[^\\n]*\\n","g");
					p65m_2 = p65m_2.replace(	l3,
											a	+ "\n");
				}else{
					p65m_2=p65m_2+a+"\n";
				}
			}
		}
	} else {
		var l3 = new RegExp(a + "[^\\n]*\\n","g");
		p65m_2 = p65m_2.replace(l3,"");
		p65m_2 = p65m_2+a+"\n";
	}
	var l1 = "";
	var l = p65m_2.split("\n");
	for (var t = 0; t < l.length; t++) {		
		if(l[t] != ""){
			var l2 = l[t].split("_");
			for (var t1 = 1; t1 < l2.length; t1++) {
				if (!l1.include(l2[t1])&&!l2[t1].include(" ")) {
					if (l1 != "") {
						l1 = l1	+ " " + l2[t1];
					} else {
					l1 = l2[t1];
					}
				}
			}
		}
	}
	$(a2).value=l1;	
}

/*
 * 列出快捷关键词
 */
function lk(a){
	var l=$("f2-369");
	if(l.innerHTML!=''&&(a.keyCode==40||a.keyCode==38)){				
		var l1=$$("div#f2-369 span");
		if(l1.length==0){					
			l.hide();
			return false;
		}else{					
			l.show();
		}
		var l2;
		var l3;
		for(var t=0;t<l1.length;t++){
			if(l1[t].getAttribute("selt")!=null){
				l2=l1[t];
			}
			l1[t].removeAttribute("selt");
			l1[t].style.background="none";				
		}
		var f=l2!=null;		
		if(a.keyCode==38){
			if(f){
				l3=l2.previous();
			}else{
				l3=l1[l1.length-1];
				$('f2-396').setAttribute("defv",$('f2-396').value);
			}
		}else if(a.keyCode==40){
			if(f){
				l3=l2.next();
			}else{
				l3=l1[0];
				$('f2-396').setAttribute("defv",$('f2-396').value);
			}
		}				
		if(l3!=null){
				l3.setAttribute("selt","true");
				l3.style.background="#FFF0E7";				
				$('f2-396').value=l3.innerHTML;			
		}else{
			$('f2-396').value=$('f2-396').getAttribute("defv");
		}
		return true;
	}else{
		if(f9(a)){
			$('f2-369').hide();
			return false;
		}else{
		new Ajax.Request("p81.jsp?a="+escape($("f2-396").value), {onComplete:function (l4) {
		 	l.update(l4.responseText);				
		  }});
			return false;
		}
	}			
}
/*
 * 鼠标列出快捷关键词
 */
 function lkm(a,a1){ 		
 		var l1=$$("div#f2-369 span");		
		var l2;		
		for(var t=0;t<l1.length;t++){
			if(l1[t].getAttribute("selt")!=null){
				l2=l1[t];
			}
			l1[t].removeAttribute("selt");
			l1[t].style.background="none";				
		}
		if(a1){		
			$(a).setAttribute("selt","true");
			$(a).style.background="#FFF0E7";		
		}
 }
/**
 * 计算字符数。
 * a 文本
 * @author Lkyooo
 */
function countChar(a){
	var p = /^[\u0000-\u00ff]$/;
	var l2 = 0;
	for (var t1 = 0; t1 < a.length; t1++) {
		if (p.exec(a.charAt(t1))) {
			l2++;
		} else {			
				l2++;
				l2++;			
		}
	}
	return l2;
}
/**
 * 清除表单灰输入。
 * a元素，a1表单，a2?password。
 * @author Lkyooo
 */
function cgray(a, a1, a2) {
	if (a1) {
		a = $(a);
		var l = a.getElements();
		for (var t = 0; t < l.length; t++) {			
			if (l[t].style.color == "gray") {
				l[t].onclick();
			}
		}
	} else {
		if (a.style.color == "gray") {
			a.value = "";
			a.style.color = "black";
		}
	}
}
/**
 * 清除文字末空白。
 * a元素，a1表单，a2?password。
 * @author Lkyooo
 */
function cend(text) {
	return text.replace(new RegExp("(<br\\s*\\/>|\\s|(&nbsp;))+$", "gi"), "");
}
/**	
 * commons-validator-1.3.1
 * Reference: Sandeep V. Tamhankar (stamhankar@hotmail.com),
 * http://javascript.internet.com
 */
function jcv_checkEmail(emailStr) {
	if (emailStr.length == 0) {
		return true;
	}
        // TLD checking turned off by default
	var checkTLD = 0;
	var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat = /^(.+)@(.+)$/;
	var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars = "[^\\s" + specialChars + "]";
	var quotedUser = "(\"[^\"]*\")";
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom = validChars + "+";
	var word = "(" + atom + "|" + quotedUser + ")";
	var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat = new RegExp("^" + atom + "(\\." + atom + ")*$");
	var matchArray = emailStr.match(emailPat);
	if (matchArray == null) {
		return false;
	}
	var user = matchArray[1];
	var domain = matchArray[2];
	for (i = 0; i < user.length; i++) {
		if (user.charCodeAt(i) > 127) {
			return false;
		}
	}
	for (i = 0; i < domain.length; i++) {
		if (domain.charCodeAt(i) > 127) {
			return false;
		}
	}
	if (user.match(userPat) == null) {
		return false;
	}
	var IPArray = domain.match(ipDomainPat);
	if (IPArray != null) {
		for (var i = 1; i <= 4; i++) {
			if (IPArray[i] > 255) {
				return false;
			}
		}
		return true;
	}
	var atomPat = new RegExp("^" + atom + "$");
	var domArr = domain.split(".");
	var len = domArr.length;
	for (i = 0; i < len; i++) {
		if (domArr[i].search(atomPat) == -1) {
			return false;
		}
	}
	if (checkTLD && domArr[domArr.length - 1].length != 2 && domArr[domArr.length - 1].search(knownDomsPat) == -1) {
		return false;
	}
	if (len < 2) {
		return false;
	}
	return true;
}
/**
 * 获取Cookie。
 * sName 名称。
 * @author Lkyooo
 */
function getCookie(sName) {
	var aCookie = document.cookie.split("; ");
	for (var i = 0; i < aCookie.length; i++) {
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) {
			return unescape(aCrumb[1]);
		}
	}
	return null;
}
/*
 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
 * in FIPS PUB 180-1
 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for details.
 */
/*
 * Configurable variables. You may need to tweak these to be compatible with
 * the server-side, but the defaults work in most cases.
 */
var hexcase = 0;
/* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad = "";
/* base-64 pad character. "=" for strict RFC compliance   */
var chrsz = 8;
/* bits per input character. 8 - ASCII; 16 - Unicode      */
/*
 * These are the functions you'll usually want to call
 * They take string arguments and return either hex or base-64 encoded strings
 */
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));
}
/*
 * Perform a simple self-test to see if the VM is working
 */
function sha1_vm_test() {
	return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
}
/*
 * Calculate the SHA-1 of an array of big-endian words, and a bit length
 */
function core_sha1(x, len) {
	/* append padding */
	x[len >> 5] |= 128 << (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);
}
/*
 * Perform the appropriate triplet combination function for the current
 * iteration
 */
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;
}
/*
 * Determine the appropriate additive constant for the current iteration
 */
function sha1_kt(t) {
	return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : (t < 60) ? -1894007588 : -899497514;
}
/*
 * Calculate the HMAC-SHA1 of a key and some data
 */
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] ^ 909522486;
		opad[i] = bkey[i] ^ 1549556828;
	}
	var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
	return core_sha1(opad.concat(hash), 512 + 160);
}
/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 * to work around bugs in some JS interpreters.
 */
function safe_add(x, y) {
	var lsw = (x & 65535) + (y & 65535);
	var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
	return (msw << 16) | (lsw & 65535);
}
/*
 * Bitwise rotate a 32-bit number to the left.
 */
function rol(num, cnt) {
	return (num << cnt) | (num >>> (32 - cnt));
}
/*
 * Convert an 8-bit or 16-bit string to an array of big-endian words
 * In 8-bit function, characters >255 have their hi-byte silently ignored.
 */
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;
}
/*
 * Convert an array of big-endian words to a string
 */
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;
}
/*
 * Convert an array of big-endian words to a hex string.
 */
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)) & 15) + hex_tab.charAt((binarray[i >> 2] >> ((3 - i % 4) * 8)) & 15);
	}
	return str;
}
/*
 * Convert an array of big-endian words to a base-64 string
 */
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)) & 255) << 16) | (((binarray[i + 1 >> 2] >> 8 * (3 - (i + 1) % 4)) & 255) << 8) | ((binarray[i + 2 >> 2] >> 8 * (3 - (i + 2) % 4)) & 255);
		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)) & 63);
			}
		}
	}
	return str;
}