/* "PyukiWiki" version 0.2.0-alpha16 $$ */
/* $Id: passwd.js,v 1.74 2011/10/19 22:07:04 papu Exp $ */

function pencf(c,b,e){var a;if(c.value==""){return}b.value=penc(utf16to8(c.value),utf16to8(e.value));c.value=""}function penc(g,f){var e,a,c,b;c="";for(e=0;e<g.length;e++){b=(Math.floor(Math.random()*127)+e)%127;c=c+f.substr(b/16,1)+f.substr(b%16,1);a=g.charCodeAt(e)+b;c=c+f.substr(a/16,1)+f.substr(a%16,1)}return c}function getid(a){return d.getElementById(a)}function keyCode(a){var a=window.event||a;if(d.all){return a.keyCode}else{if(d.getElementById){return a.keyCode?a.keyCode:a.charCode}else{if(d.layers){return a.which}}}}function keypress(b){if(b==null){return true}var a=keyCode(b);if(a==32||a==13){return true}return false}function fsubmit(f,a,b){if(keypress(b)==false){return}var c="mypassword_";pencf(getid(c+a),getid(c+a+"_enc"),getid(c+a+"_token"));fsubmitdelay(f,b)}var fid;function fsubmitdelay(b,a){if(keypress(a)==false){return}fid=b;setTimeout("fsub();",30)}function fsub(){getid(fid).submit()}function editpost(a,g){var b="editform";var c=getid(b);if(c.mypreviewjs_adminedit){c.mypreviewjs_adminedit.value="";if(a==0){c.mypreviewjs_adminedit.value="1"}}if(c.mypreviewjs_edit){c.mypreviewjs_edit.value="";if(a==0){c.mypreviewjs_edit.value="1"}}if(c.mypreviewjs_write){c.mypreviewjs_write.value="";if(a==1){c.mypreviewjs_write.value="1"}}if(c.mypreviewjs_cancel){c.mypreviewjs_cancel.value="";if(a==2){c.mypreviewjs_cancel.value="1"}}fsubmit(b,"frozen",g)}function utf16to8(f){var b,e,a,g;b="";a=f.length;for(e=0;e<a;e++){g=f.charCodeAt(e);if((g>=1)&&(g<=127)){b+=f.charAt(e)}else{if(g>2047){b+=String.fromCharCode(224|((g>>12)&15));b+=String.fromCharCode(128|((g>>6)&63));b+=String.fromCharCode(128|((g>>0)&63))}else{b+=String.fromCharCode(192|((g>>6)&31));b+=String.fromCharCode(128|((g>>0)&63))}}}return b};
