q = new Array();

q['q1'] = new Array('08a075992d5d5d198cfa8ebbd41d49443d744a90', '937062379781adbc92beccfa7d59eb6b44391540' );

q['q2'] = new Array('1ad1d275f4adcd454a9a1bd448e04ca601d3524d', 'ad1ff12899a9f8a934f74e1c9bb0818d563e130b', 'd81579014d9e397d7e808ed1d8db3eb7b6dc02d2', '2ba6191adfae60212f7f24a8771f3050c5054def' );

q['q3'] = new Array('0d277bc642f2e9c749032b644a0239f4d3f9b4aa', '6e6ac36212081a2a0d21e3dd8931703cf39e71a4', '94b90aafe2eac022e3eb3e2f6c91c228a820cec5' , '9f95310afd68f31a85ffa59e03b6cf30b6f5dba7' );

q['q4'] = new Array('b74ee0888e662926255d6fbefe2509483890a2e3', 'd448b28cfd17a6abc9d377896adb18e30fd0fa00');

q['q5'] = new Array('32a7200b239630544f62655b24ac47881974e041', '132ba9e795c8ddad5b6801f8c42d7a7ef1c23f86' );

q['q6'] = new Array('8cf33187c665d236826cf1054f0a5f1d287284c7', '31f7277cd99f566a653ffc7fa80cd92a8c0d0b9a', '5862bfe66c7eb05ae5584388bd92d551181c1c73' );

q['q7'] = new Array('8df51fd7ded7538600e6cc3fdd8520f313ba4810', '9b44c135e38edb0d45212c43afd9c34c2ccb8e07', '3896e70eb13a84ec78000d389d2c5667a3d9fbaf' );

q['q8'] = new Array('33444c5d8bdd94e634650ac4985fd251af6822c3', '022381c22e0b46237f06339e5b873bc4dba6c433', '6ddf7c23c3d248d13c59fb6d04f7d47da72550b7' );

q['q9'] = new Array('fc0d31e929b643ad62184fe38acda71c870e887f', '7f7eebbaaa9d09d92e3acaebc5879866ef89573d', 'd7f72b4b9f479fd5ee8456a9cb2713ea95cc7f3b', 'c86c05829bfb458fe2c0b9e6d250c65e9768b3d8' );

q['q10'] = new Array('439d4b49637311aacddd285d85191cfcf75a0ba9', '9cddd3a9f2eca194ee1f40cb8794419c1ed8134b', '299a4fdf92b4e168d1aa6dbdd213cc603d544549', '207b1e56c53ed7b0266d5c5e3994b640c3fb726c', '417e5acad783daee08fdae8e0a9bc7a36b1d853c', '9c6addd353659946fc8c4b0fa4b0a288696c0b65' );

q['q11'] = new Array('20c5b4b83b4875cbe10bce5a80630863616e6446', '75307fb796b42e39eb17e89743e8df399308832d', '20f2566b84fadff1fe05e77f7b61954f3a788bba' );

q['q12'] = new Array('ec88dada0b9db28efb1fc371f59623bff652aae6', '7aad009a1ee8b1052f87e93569320a1015654e7b', '0b963bc08a30d22f633561028d643872270414b6' );

q['q13'] = new Array('db75ed01d7909337738b6433c12d5201555b2331', '8a7b19f69d565031e22266b8fba64386d9af4f44' );

q['q14'] = new Array('a2604b37908f157be94a9d0f1a9fdc57a3e44b2a', '6fe7a0bd6df7219232c4a4e8351aeafd158604e4', '57cafc079fd4da63208a39c76f4a5b94b5d5fb8a' );

q['q15'] = new Array('52f3d01d054af70409ad4359133e4608bdcc533e', 'cbb3777a515f3693e26a7e36e08ee75cceff5cc5' );

q['q16'] = new Array('b31c9ebd3dac82375322cd27ff439df3069e3f0f', '283d7d79b4c58a3d13631f1ef7c05ef714effb36', 'a2da7c254080db34b7002c4d847871415d28bdb5' );

q['q17'] = new Array('eda7cbc49cb0a33d9ddf464fb97a064d64f494a9', 'cb0905e3542f122ca30e32f03b521ad10bde0573' );

q['q18'] = new Array('32ef5f173bb3aff1d6915bebe91741972905497e', 'dcc21ec954c67f12544ae42212667e48f8273d27', '71ea91070e32ac9345e68d8e53a0550cf2a1a527' );

q['q19'] = new Array('b6fa07f387993df6cd13c46175c50211e3f1b7b9', '927a76b6f6018ed2ae58c22a6e02ccdae8f84822', 'b02c088eac6ea0335c5d4b631cff453d5bea53cc' );

q['q20'] = new Array('dac73ebb66034ff0d48d5c4f3e8967e33bf24a87', 'cabd534c35ee6a39365f4ed3bce4eafdcc3d4b8d', 'bbf43d7402637262ed65d25a889622e4e5b099ec', '49dae3470ed6cfad651dc6372d5c3a9e975c9a67' );

q['q21'] = new Array('8e67e03a02e691511f1d286e5a18b2ee309efc93', '5f06782137d60e8e6963dceb5d6b94a3ff62f44e', '7b7387adc68cd1916b1300d9267ea87e7f7efebe' );

q['q22'] = new Array('cecbe3c1efcd7e9c1dfbcc7e8b11972cd2156b1f', '67ca2c7b295fb69b68962a634c606fb9647c2d18' );

q['q23'] = new Array('333b00ab60e9d4505e16ab3417f66a6b414fff4d', 'c0c91980ea310cf350e0daa40b93f21cd75bf4a7', '7b170ad1fb61f6fc724f3a0a6d229d3b02404672' );

q['q24'] = new Array('5487e7d6c8511220076c088887b32f5dee308438', 'e8ab69d453fc17f5f985427604646c6ad627fbf3' );

q['q25'] = new Array('421e7988599e5af999c23f39389aaa97e7354d7f' );

q['q26'] = new Array('765f7f4c5a75cd19747f1de13139c720f5f2b8ce' );

q['q27'] = new Array('1c1bcb24cffa054e5fd7d06de56bf73a3e74d02e', '16a56191ef0a6611701f49bb837ccbfe85292380', '68fc5d43cdb74cd14e44afe7eb31c5d19029db1b' );

q['q28'] = new Array('2297b7bd154bfdad3266c5ac7a0651afa9674c11', 'ad0217a2c108a04760c6ead16ebec4a2d707bea6', '25baf8985493e70c6731478903b1eaf57a2f00d8' );

q['q29'] = new Array('632b94d263a4f6de6cfb6a272a885e86e1250bde', '4ff263dc0a9962aaaa25e68fba6667d5055d4581', 'bad92509c3f101404f16c205af19e79ad09f0d03', '067c4880feea9b6a9f23637ac0497f29e762f176' );

q['q30'] = new Array('080e46cbe1992c77b1c983e319bca6ce2203a89c', '239d591a0b6403e1f229dbc1270fdcf412480ed3', '1331c13c14ab4732715146705e11adc3ccb4696a' );

q['q31'] = new Array('eaba0c35d02b086af6ad4962eebe1effa215011b', 'b8c6b8cb5e6d16d86ad0145c5f66c3ddc8474d1b', 'b6fe119eb20d14da62b5a8ba8497891e382d12f8' );

q['q32'] = new Array('3d746dda556040e89298836acac87580181c104a' );

q['q33'] = new Array('d1a0f6dd78d7f9f8d02cfd2464198ea1e4f764d5' );

q['q34'] = new Array('0a6edec36f10422a40f384bba18a8066ab755368', 'd996aedb883e0a3e0a0b2423fb93a5a7054b735b', '14396f0520958a9783132945d91037a28f336a46' );

q['q35'] = new Array('4cd6a7ab54d2e319f5f9f0616b3e1cdd4e51d5fe' );

q['q36'] = new Array('2e9da8a1da64de4bc5faf7077ac735296b2a780b', '80ae44559229b68c07fec6a8a68b605055ff6172', '44157296ac6470ac0c8cf74948454b29bc0d0af3' );

q['q37'] = new Array('ccfc3ecbacbb922ecde3167b4683f093331501d9', '31018700c59e54b7a19da4ce5c48a608507a14d9' );

q['q38'] = new Array('8dba6a0189a0afe41e4d191e576f00158959582e', 'e7af5388b672bac469dd4c67884364d0e7d6fba9', '4776a543e3dcfb2694f07f4d386ef817e26713f6', '10f500041c5a9c8cb676ff0f64bf2924eeb09493', 'cf562e8c276d02776570cdbac303e7a76f4f59f2' );

q['q39'] = new Array('2d93ce9385ac2d96d0f33b4313f305f9cd0790ec', 'f618d334720b6b662df424d3d28e87aed131872b', '4681496f40e6c698967b39524854cd42e30712c4', 'a314f56a491bb0a91b619b92f50d534c0fc956e4' );

q['q40'] = new Array('cae79d3a5bb668b37189608832a3e72eaa3aefca', 'cf3d8014771a1839c2a88857b51dfc0ae395d298' );






function simplifica(msg) {
	
	var str=msg.toUpperCase();
	str=str.replace(/ /g,'');			
	str=str.replace(/\,/g,'');			
	str=str.replace(/\./g,'');			
	str=str.replace(/\-/g,'');			
	str=str.replace(/\'/g,'');			
	str=str.replace(/\:/g,'');			
	str=str.replace(/\(/g,'');			
	str=str.replace(/\)/g,'');	
	str=str.replace(/\?/g,'');			
	str=str.replace(/\¿/g,'');			
	str=str.replace(/\!/g,'');			
	str=str.replace(/\¡/g,'');							
	str=str.replace(/Á/g,'A');
	str=str.replace(/É/g,'E');
	str=str.replace(/Í/g,'I');
	str=str.replace(/Ó/g,'O');
	str=str.replace(/Ú/g,'U');
	/*str=sha1Hash(str);*/ 
	
	return str;
	
}  


function mira(str) {

var ok=0;
for (x in q[str])
{
	if(sha1Hash(simplifica(document.getElementById(str).value)) == (q[str][x]) 	)
	{
		
		ok=1;
	}
}  

 
	if(ok)
	{
		valida1(str);
	}
	else
	{
		valida2(str);
	}
	
}

function carga() { 
	
	for (var i=1; i<41; i++) {		
		str='q'+i;	
		document.getElementById(str).style.border = '1px solid #A5ACB2';
		document.getElementById(str).disabled = false;
	} 
} 


function valida1(qstr) { 
	if(document.getElementById(qstr).disabled == false) {
	document.getElementById(qstr).disabled = true;
	document.getElementById(qstr).style.border = '2px solid #00FF00'; 
	document.getElementById('correct').innerHTML = document.getElementById('correct').innerHTML*1 + 1;
	}
}

function valida2(qstr) {
	if(document.getElementById(qstr).value=='') {
		document.getElementById(qstr).style.border = '1px solid #A5ACB2'; 
	}
	else
	{
	document.getElementById(qstr).style.border = '2px solid #FF0000'; 
	}
}


function sha1Hash(msg)
{
    // constants [4.2.1]
    var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];

    // PREPROCESSING 
 
    msg += String.fromCharCode(0x80);  // add trailing '1' bit to string [5.1.1]

    // convert string msg into 512-bit/16-integer blocks arrays of ints [5.2.1]
    var l = Math.ceil(msg.length/4) + 2;  // long enough to contain msg plus 2-word length
    var N = Math.ceil(l/16);              // in N 16-int blocks
    var M = new Array(N);

    for (var i=0; i<N; i++) {
        M[i] = new Array(16);
        for (var j=0; j<16; j++) {  // encode 4 chars per integer, big-endian encoding
            M[i][j] = (msg.charCodeAt(i*64+j*4)<<24) | (msg.charCodeAt(i*64+j*4+1)<<16) | 
                      (msg.charCodeAt(i*64+j*4+2)<<8) | (msg.charCodeAt(i*64+j*4+3));
        } // note running off the end of msg is ok 'cos bitwise ops on NaN return 0
    }
    // add length (in bits) into final pair of 32-bit integers (big-endian) [5.1.1]
    M[N-1][14] = ((msg.length-1) >>> 30) * 8;
    M[N-1][15] = ((msg.length-1)*8) & 0xffffffff;

    // set initial hash value [5.3.1]
    var H0 = 0x67452301;
    var H1 = 0xefcdab89;
    var H2 = 0x98badcfe;
    var H3 = 0x10325476;
    var H4 = 0xc3d2e1f0;

    // HASH COMPUTATION [6.1.2]

    var W = new Array(80); var a, b, c, d, e;
    for (var i=0; i<N; i++) {

        // 1 - prepare message schedule 'W'
        for (var t=0;  t<16; t++) W[t] = M[i][t];
        for (var t=16; t<80; t++) W[t] = ROTL(W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1);

        // 2 - initialise five working variables a, b, c, d, e with previous hash value
        a = H0; b = H1; c = H2; d = H3; e = H4;

        // 3 - main loop
        for (var t=0; t<80; t++) {
            var s = Math.floor(t/20); // seq for blocks of 'f' functions and 'K' constants
            var T = (ROTL(a,5) + f(s,b,c,d) + e + K[s] + W[t]) & 0xffffffff;
            e = d;
            d = c;
            c = ROTL(b, 30);
            b = a;
            a = T;
        }

        // 4 - compute the new intermediate hash value
        H0 = (H0+a) & 0xffffffff;  // note 'addition modulo 2^32'
        H1 = (H1+b) & 0xffffffff; 
        H2 = (H2+c) & 0xffffffff; 
        H3 = (H3+d) & 0xffffffff; 
        H4 = (H4+e) & 0xffffffff;
    }

    return H0.toHexStr() + H1.toHexStr() + H2.toHexStr() + H3.toHexStr() + H4.toHexStr();
}

//
// function 'f' [4.1.1]
//
function f(s, x, y, z) 
{
    switch (s) {
    case 0: return (x & y) ^ (~x & z);
    case 1: return x ^ y ^ z;
    case 2: return (x & y) ^ (x & z) ^ (y & z);
    case 3: return x ^ y ^ z;
    }
}

//
// rotate left (circular left shift) value x by n positions [3.2.5]
//
function ROTL(x, n)
{
    return (x<<n) | (x>>>(32-n));
}

//
// extend Number class with a tailored hex-string method 
//   (note toString(16) is implementation-dependant, and  
//   in IE returns signed numbers when used on full words)
//
Number.prototype.toHexStr = function()
{
    var s="", v;
    for (var i=7; i>=0; i--) { v = (this>>>(i*4)) & 0xf; s += v.toString(16); }
    return s;
}
function resetForm() {
	
	for(i=1;i<34;i++) {
	document.getElementById('q'+i).disabled = false;
	}
	document.forms[0].reset();
}