var def_list = "\
have:has;\
has:haz;\
help:halp;\
the:teh;\
puts:putz;\
rubs:rubz;\
its:itz;\
else:els;\
gets:getz;\
birth:birf;\
are : r ;\
cake:caek;\
until:till;\
hey:hay;\
kitty:kitteh;\
needs:needz;\
president:prezidunt;\
more:moar;\
cheese:cheez;\
i am:i's;\
your :ur ;\
you :youz ;\
ing :in ;\
truck:truk;\
preentin:dokumintz;\
what:wha;\
that:dat;\
burger:brgr;\
my:mah;\
this:dis;\
glass:glas;\
funny:funneh;\
me:mez;\
delicious:delishus;\
carrot:karut;\
bucket:bukkit;\
believe:bleev;\
flavor:flaver;\
really:rly;\
with:wif;\
functioned:funkshind;\
function:funkshin;\
return:raturn;\
right:rite;\
position:pozishin;\
please:plz;\
give me:gimmie;\
sweat:swet;\
tasty:tsty;\
health:helth;\
tion:shun;\
some:sum;\
dig:digz;\
balls:bls;\
hair:har;\
back:bak;\
there:der;\
reach:reech;\
 hi : oh hai ;\
hello:hallo;\
crook:krook;\
quart:quort;\
take:takez;\
it is:iz;\
ready:redy;\
you look:u lookz;\
sex:secks;\
through:thru;\
innocent:inosent;\
present:prezint;\
excuse:scuze;\
light:lite;\
awesome:awsum;\
over:ovar;\
father:fathur;\
don't:doan;\
do not:doan;\
packed:paked;\
chicken:chikin;\
charged:chrgd'\
says:sez;\
yes:yez;\
taken:takin;\
good:gud;\
was:wuz;\
comfy:cumfy;\
for:4;\
finally:finlee;\
too:tew;\
write:rite;\
so:sew;\
about:bowt;\
thank:fank;\
this:dis;\
prove:proov;\
guys:guyz;\
what is:whaz;\
furry:frry;\
just kidding :jk ;\
laughing out loud :lol ;\
laugh out loud : lol ;\
gay:ghey;\
yeah really:ya rly;\
oh really:o rly;\
need:needz;\
pizza:za;\
thanks:thx;\
okay:kthxbai;\
bye:bai;\
translator:trahnslatah;\
thank you:kthxbai;\
you're:ur;\
work:werk;\
text:txt;\
word:werd;\
learn:lern;\
 to : 2 ;\
bunny:bunneh;\
 ate : eated ;\
lolcat language:lolspeak;\
laugh out loud : lol ;\
God:ceiling cat;\
"
var txt = document.getElementById('txt')
var lol = document.getElementById('lol') 
var x = new Array(); //Array structure x[position]new Array("txt","lol")
var array_length = def_list.match(/;/g).length-1; 
var pairs = new Array;
pairs = def_list.split(';')
for (i=0;i<=array_length;i++){
	var words = new Array();
	words = pairs[i].split(":")
	x[i] = new Array(words[0],words[1])
}
var dictswitch = document.getElementById("dict-switch")
function convert(order) {
	if (order == 0) {
		var a=0
		var b=1
		var src=txt.value
	}
	if (order == 1) {
		var a=1
		var b=0
		var src=lol.value;
	}
	if (src.charAt(0)!= " "){
		src = " " + src;
	}
	for (i=0;i<=array_length;i++) {
		var reg = new RegExp (x[i][a], "ig")
		src = src.replace(reg,x[i][b]);		
	}
	if (src.charAt(0) == " ") {
		src = src.substring(1,src.length)
		}
	return src;
}
function txt2lol() {
	lol.value = convert(0)
	}
function lol2txt() {
	txt.value = convert(1)
}
function createDict() {
	var contents
	var dicUL = document.getElementById("dictionary")
	x.sort();
	var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
	var z=0
	for (i=0;i<=array_length;i++) {
		
		if (x[i][0].charAt(0)==alphabet[z] || x[i][0].charAt(0)== " " && x[i][0].charAt(1)==alphabet[z]) {
				 var ul = document.createElement("ul")
				 ul.id= alphabet[z]
				 var header = document.createElement("li")
				 header.className = "index"
				 header.innerHTML = alphabet[z]
				 ul.appendChild(header)
				 dicUL.appendChild(ul)
				z++;
			}
		if (z == 9 || z == 11 || z == 21 || z == 23) { //j = 9, l = 11,  v = 21, x = 23
			z++;
			}
 		var entry = document.createElement("LI")
				 entry.innerHTML = x[i][0] + " = " + x[i][1]
				 ul.appendChild(entry)
	}
}
function hideDict() {
	document.getElementById("dictionary").className = "hide"
	document.getElementById("bottom-dict-switch").className = "hide"
	dictswitch.href = "javascript:showDict()"
	dictswitch.innerHTML = "+Show Dictionary"
	
}
function showDict() {
	document.getElementById("dictionary").className = ""
	document.getElementById("bottom-dict-switch").className = ""
	dictswitch.href = "javascript:hideDict()"
	dictswitch.innerHTML = "-Hide Dictionary"
}
function sendWord() {
	var newtxt = document.getElementById("new-TXT").value
	var newlol = document.getElementById("new-LOL").value
	newtxt.toLowerCase();
	newlol.toLowerCase();
	var cleantxt = newtxt.replace(/\s/ig,"");
	var cleanlol = newlol.replace(/\s/ig,"");
	for (i=0;i<=array_length;i++) {
		if (cleantxt == x[i][0].replace(/\s/ig,"") && cleanlol == x[i][1].replace(/\s/ig,"")) {
				alert("This is already in the dictionary. \n" + x[i][0] + " = " + x[i][1])
				return false;
		}
		if (cleantxt == x[i][0].replace(/\s/ig,"") || cleanlol == x[i][1].replace(/\s/ig,"")) {
				var partial = confirm("The following is in the dictionary: \n" + x[i][0] + " = " + x[i][1] + "\n \n Would you still like to submit your word?");
				if (!partial) {
					return false;
				}
		}
	}
}