function IniVar(){
	iCounter = 3; //How many retries
	TID = 0;
	longer = 0;
	alphabet = new Array("0@","1#","2$","3%","4^","5&","6*","7 = ","8-","9+","Aa","Bb","Cc","Dd","Ee","Ff","Gg","Hh","Ii","Jj","Kk","Ll","Mm","Nn","Oo","Pp","Qq","Rr","Ss","Tt","Uu","Vv","Ww","Xx","Yy","Zz");
	firstWrite = "";
	base= new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9","A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z","a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")
	pass="";
	z=23;
	y=28;
	f= new Array();
	K= new Array();
	for (x=0; x<10; x++){
		f[x]=x<<9
		f[x]+=23
	}
	for (x=10; x<36; x++){
		y=y<<1
		v= Math.sqrt(y)
		v = parseInt(v,16)
		v+=5
		f[x]=v
		y++
	}
	for (x=36; x<62; x++){
		z=z<<1
		v= Math.sqrt(z)
		v = parseInt(v,16)
		v+=74
		f[x]=v
		z++
	}
}

function inc(){
	iCounter--
	if (iCounter > 0){
		if (confirm("\nMot de passe incorrect.\n\n\n\nEssayez de nouveau?"))
			Check()
		else
			alert('Mot de passe incorrect.');
			//history.go(-1);
			location.href='index.html';
	}
	else
		alert('Vos trois essais sont épuisé. Accès Refusé.');

	//history.go(-1);
	location.href='index.html';
}

function Check(){
	tmp = prompt("Entrez votre mot de passe.","")
	if(tmp==null || tmp==""){
		//history.go(-1)
		location.href='index.html';
	}
	else{
		preTime('nadzone',tmp,1);
		pass = firstWrite;
		var lpass=(pass.length)+1
		for (l=1; l<lpass; l++){
			K[l]=pass.charAt(l)
		}
		var code=0;
		for (y=1; y<lpass; y++){
			for(x=0; x<62; x++){
				if (K[y]==base[x]){
					code+=f[x]
					code*=y
			}
		}
	}

	if (code==43751448) 		// code==[your access code]
		go()
	else
		inc()
   }
}

function go(){
	location.href=pass+".html";
}

function preTime(coco, uinput, question) {
	longer = coco.length - 1;
	placement = 0;
	ref = 0 ;
	firstWrite = "";
	code1(coco, uinput, longer, question);
}
function findshift(letter) {
	for (i = 0; i < 36; i++) {
		if ((alphabet[i].substring(0,1) == letter) || (alphabet[i].substring(1,2) == letter)) {
			if (alphabet[i].substring(0,1) == letter) {
				x = 0;
			}
			if (alphabet[i].substring(1,2) == letter) {
				x = 1;
			}
			return i;
      }
   }
}

function check(letter) {
bill = "no";
	for (i = 0; i < 36; i++) {
		if ((alphabet[i].substring(0,1) == letter) || (alphabet[i].substring(1,2) == letter)) {
			bill = "yes";
		}
	}
	if (bill == "yes") {
		return true;
	}
	else {
		return false;
   }
}

function fixoffset(takin) {
	if (takin > 35) {
		return (takin - 36);
	}
	else {
		return takin;
   }
}

function code1(inval1,inval2,inval3,sage) {
	if (check(inval2.charAt(placement))) {
		if (check(inval1.charAt(ref))) {
			if (sage == 0) {
				shift = findshift(inval1.charAt(ref));
			}
			if (sage == 1) {
				shift = 36 - findshift(inval1.charAt(ref));
			}
		}
		else {
			shift = 0;
		}
		orig = findshift(inval2.charAt(placement));
		firstWrite = firstWrite+alphabet[fixoffset(orig+shift)].charAt(x);
	}
	else {
		firstWrite = firstWrite+inval2.charAt(placement);
	}

	placement++;
	if (ref == inval3) {
		ref = 0;
	}
	else {
		ref++;
	}
	if (placement == (inval2.length)) {
		return firstWrite;
	}
	else {
		one = inval1;
		two = inval2;
		three = inval3;
		goer = sage;
		code1(one, two, three, goer);
	}
}