function codeit(forward)
{
	var keys = ["","FDKFDL", "FDFDFA", "KKJKJF", "JFJDFF", "JLJLJD", "JJDFDD", "FDLKJS", "JJDDFD", "FDFDKD", "KJJDFD", "DFDKJJ", "DFDFJK", "JJFDSS", "KJDFDJ", "JJDDSA", "JJDDFC", "JFJFEE", "DFDDFD", "DFJKFD", "DFJKJD", "JJJDFS", "FFDFDJ", "FJKJDF", "KJDFDD", "DFJKJD", "VCVFFG", "VGYUJN", "JHKUIH", "RRTKKL", "GHNNJY", "YTTYUJ", "TY676J", "GGTY63", "TT56HG", "FGHFDS", "GDRWHJ"];
	var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	          + "abcdefghijklmnopqrstuvwxyz";
	var key;
	var level;
	var names;
	var cleanText;
	var input
	var name1
	var name2
	var compare;
	var check;
	var condition;

	if(forward == true)
	{		
		level= document.cipher.level.value
		
		name1 = document.cipher.name1.value
		name2 = document.cipher.name2.value
		names = name1 + name2 
	
		key = keys[level]
		
		input = cleanup(names)
		
		// Validate key:
		var key_len = key.length;
		var i;
		var adjusted_key = "";
		for(i = 0; i < key_len; i ++)
		{
			var key_char = chars.indexOf(key.charAt (i));
			if (key_char < 0)
			continue;
			adjusted_key += chars.charAt (key_char);
		}

		key = adjusted_key;
		key_len = key.length;
	   			
		compare = transform(chars,input, forward, key_len, key)
		document.cipher.encoded.value=compare
	}
	else if(forward == false)
	{
		name1 = document.cipher.name1.value
		name2 = document.cipher.name2.value
		names = name1 + name2
		input = document.cipher.decode.value

		check = cleanup(names)

		for(x = 1; x <= 36; x++)
		{
			key = keys[x]

			// Validate key:
			var key_len = key.length;
			var i;
			var adjusted_key = "";
			for(i = 0; i < key_len; i ++)
			{
				var key_char = chars.indexOf(key.charAt (i));
				if (key_char < 0)
				continue;
				adjusted_key += chars.charAt (key_char);
			}

			key = adjusted_key;
			key_len = key.length;

			compare = transform(chars,input, forward, key_len, key)
			if(compare == check)
				{
					switch(x) {
					case 1:
					condition ="true"
					location.href="default.asp?sectionID=309"
					break;
					
					case 2:
					condition ="true"
					location.href="default.asp?sectionID=314"
					
					case 3:
					condition ="true"
					location.href="default.asp?sectionID=315"
					break;
					
					case 4:
					condition ="true"
					location.href="default.asp?sectionID=316"
					break;
					
					case 5:
					condition ="true"
					location.href="default.asp?sectionID=317"
					break;
					
					case 6:
					condition ="true"
					location.href="default.asp?sectionID=318"
					break;
					
					case 7:
					condition ="true"
					location.href="default.asp?sectionID=319"
					break;
					
					case 8:
					condition ="true"
					location.href="default.asp?sectionID=321"
					break;
					
					case 9:
					condition ="true"
					location.href="default.asp?sectionID=322"
					break;
					
					case 10:
					condition ="true"
					location.href="default.asp?sectionID=323"
					break;
					
					case 11:
					condition ="true"
					location.href="default.asp?sectionID=324"
					break;
					
					case 12:
					condition ="true"
					location.href="default.asp?sectionID=326"
					break;
					
					case 13:
					condition ="true"
					location.href="default.asp?sectionID=327"
					break;
					
					case 14: 
					condition ="true"
					location.href="default.asp?sectionID=328"
					break;
					
					case 15:
					condition ="true"
					location.href="default.asp?sectionID=329"
					break;
					
					case 16:
					condition ="true"
					location.href="default.asp?sectionID=331"
					break;
					
					case 17:
					condition ="true"
					location.href="default.asp?sectionID=333"
					break;
					
					case 18:
					condition ="true"
					location.href="default.asp?sectionID=334"
					break;
					
					case 19:
					condition ="true"
					location.href="default.asp?sectionID=336"
					break;
					
					case 20:
					condition ="true"
					location.href="default.asp?sectionID=337"
					break;
					
					case 21:
					condition ="true"
					location.href="default.asp?sectionID=338"
					break;
					
					case 22:
					condition ="true"
					location.href="default.asp?sectionID=339"
					break;
					
					case 23:
					condition ="true"
					location.href="default.asp?sectionID=340"					
					break;
					
					case 24:
					condition ="true"
					location.href="default.asp?sectionID=341"
					break;
					
					case 25:
					condition ="true"
					location.href="default.asp?sectionID=342"
					break;
					
					case 26:
					condition ="true"
					location.href="default.asp?sectionID=343"
					break;
					
					case 27:
					condition ="true"
					location.href="default.asp?sectionID=344"
					break;
					
					case 28:
					condition ="true"
					location.href="default.asp?sectionID=345"
					break;
					
					case 29:
					condition ="true"
					location.href="default.asp?sectionID=346"
					break;
					
					case 30:
					condition ="true"
					location.href="default.asp?sectionID=347"
					break;
					
					case 31:
					condition ="true"
					location.href="default.asp?sectionID=348"
					break;
					
					case 32:
					condition ="true"
					location.href="default.asp?sectionID=350"
					break;
					
					case 33:
					condition ="true"
					location.href="default.asp?sectionID=351"
					break;
					
					case 34:
					condition ="true"
					location.href="default.asp?sectionID=175"
					break;
					
					case 35:
					condition ="true"
					location.href="default.asp?sectionID=353"
					break;
					
					case 36:
					condition ="true"
					location.href="default.asp?sectionID=363"
					break;
					
					
					default://This probably will never be use, because if they is not a match it will never get this far, but better safe than sorry.
					alert("Sorry, but you have entered a wrong code or first and last name")
					break;
					}
					
				}	
									
				else if((condition !="true" ) && (x == 36)) 
				
				{alert("You have entered a wrong code or, first or last name")}
			}
			
		}
		
	}




function cleanup(names)
{	
	var cleanText1	
	
	cleanText1 = names.toLowerCase();
	cleanText1 = cleanText1.replace(/\s+/g,' ');
	cleanText1 = cleanText1.replace(/[^a-z0-9\s]/g,'');
	if(cleanText1.length == 0 || cleanText1.match(/^\s+$/) != null) { return false; }
	
	
	return cleanText1;
}



function transform(chars, input, forward, key_len, key)
{
// Transform input:
	var input_len = input.length;
	var output = "";
	var key_index = 0;
	var in_tag = false;
	for (i = 0; i < input_len; i ++)
	{
		var input_char = input.charAt(i);
		if (input_char == "<")
			in_tag = true;
		else if (input_char == ">")
			in_tag = false;
		if (in_tag)
		{
			output += input_char;
			continue;
		}
		var input_char_value = chars.indexOf(input_char);
		if (input_char_value < 0)
		{
			output += input_char;
			continue;
		}
		var lowercase = input_char_value >= 26 ? true : false;
		if (forward)
			input_char_value += chars.indexOf(key.charAt(key_index));
		else
			input_char_value -= chars.indexOf(key.charAt(key_index));
		input_char_value += 26;
		if(lowercase)
			input_char_value = input_char_value % 26 + 26;
		else
			input_char_value %= 26;
		output += chars.charAt(input_char_value);
		key_index=(key_index + 1) % key_len;

	}

	return output;

}

