/*
*
* Bohuzel z tohoto JavaScriptu nazvy filmu nevyctete ;-), tym filmovykviz.cz
*
*/

movie = new Array();

movie['movie01'] = 'c5971b3b7fba9306c97524f';
movie['movie02'] = '1ff52e11f5a378dfe62c08f40';
movie['movie03'] = '3187be6973a761e79137fa79e';
movie['movie04'] = 'e45db3fa68d3131a11339403';
movie['movie05'] = '18fc913a9cd2785f19fbaa3';
movie['movie06'] = 'e450f0b21b6afb603aa0a8ce';
movie['movie07'] = '71f85feb10330314301413e2';
movie['movie08'] = '2a71013be2407cc4816769d3';
movie['movie09'] = '12569ddbf1a69348568e5e6a2';
movie['movie10'] = 'f77c2d0a58e2aaf14c9cae2';
movie['movie11'] = 'adfbf0f15f503e8d5b6cb309';
movie['movie12'] = '104e83f0f48c06f6920dd333c';
movie['movie13'] = '19229a061fda44a33efd266d';
movie['movie14'] = '6ad9b9c741dc91e61a34f8fb';
movie['movie15'] = '124f8816076ae329c15f3198b';
movie['movie16'] = '2afacae3497bce627283bd07';
movie['movie17'] = 'b0e95ba2194212fe1f2d4303';
movie['movie18'] = 'ca1af975f55a4cd2f5ccf1a';
movie['movie19'] = 'ce2a896b96a3948b1a042';
movie['movie20'] = '121c6d1316a88b5081d28bd1c';

var cnt = 0;
var MOVIE_CNT = 20;

function checkMovie(str) 
{
	if(movie[str].indexOf(tripleHash(document.getElementById(str).value.toUpperCase())) != -1)
	{
		if(document.getElementById(str).disabled == false) 
		{
			cnt++;
			document.getElementById(str).style.border = '2px solid #06CE06';
			document.getElementById(str).disabled = true;
			document.getElementById('count').innerHTML = document.getElementById('count').innerHTML*1 + 1;
			if(cnt == MOVIE_CNT)
				document.getElementById('bravo').innerHTML = document.getElementById('bravo').innerHTML='&nbsp; &nbsp; Bravo!';
		}
	}
	else
	{
		if(document.getElementById(str).value=='')
			document.getElementById(str).style.border = '2px solid lightblue';
		else
			document.getElementById(str).style.border = '2px solid red';
	}
}

function tripleHash(msg)
{
   var i;
	 var hash = 0;
	 var seed = 13131313;
	 
   for(i = 0; i < msg.length; i++)
		 hash = msg.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
	 
	 h1 = Math.abs(hash);
	 h1 = h1.toString(16) + '';
	 
   hash = 1315423911;
	 
   for(i = 0; i < msg.length; i++)
      hash ^= ((hash << 5) + msg.charCodeAt(i) + (hash >> 2)); 
	 
	 h2 = Math.abs(hash);
	 h2 = h2.toString(16) + '';
	 
   hash = 0xAAAAAAAA;

   for(i = 0; i < msg.length; i++)
      hash ^= ((i & 1) == 0) ? ((hash <<  7) ^ msg.charCodeAt(i) ^ (hash >> 3)) : (~((hash << 11) ^ msg.charCodeAt(i) ^ (hash >> 5)));
	 
	 h3 = Math.abs(hash);
	 h3 = h3.toString(16) + '';
	 
	 hash = h1 + h2 + h3;
   return hash;
}


