function translate(origmsg, msg, bd)
{
	var fnt = "";
	var snd = "";
	var phn = "";

	for (i = 0; i < msg.length; i++)
	{
		c = msg.charAt(i);
		cc = msg.substring(i, i+2);
		if ((c == "n") || (c == "m")) {
			if ((bd == "false") || (c == "n")) {
				fnt += "<img src=n.gif>";
				snd += "-nooh";
				phn += "no";
			} else if (c == "m") {
				fnt += "<img src=n.gif>";
				snd += "-naah";
				phn += "na";
			}
		} else if ((c == "s") || ((c == "c") && (cc != "ch")) || (c == "z") || (c == "S")) {
			if ((bd == "false") || (c == "s") || ((c == "c") && (cc != "ch"))) {
				fnt += "<img src=s.gif>";
				snd += "-saah";
				phn += "sa";
			} else if ((c == "z") || (c == "S")) {
				fnt += "<img src=s.gif>";
				snd += "-seee";
				phn += "si";
			}
		} else if ((c == "l") || (c == "r")) {
			if ((bd == "false") || (c == "l")) {
				fnt += "<img src=l.gif>";
				snd += "-leee";
				phn += "li";
			} else if (c == "r") {
				fnt += "<img src=l.gif>";
				snd += "-laah";
				phn += "la";
			}
		} else if ((c == "h") || (cc == "ch")){
			if (cc == "ch") i++;
			fnt += "<img src=x.gif>";
			snd += "-chaah";
			phn += "xa";
		} else if ((c == "i") || (c == "e") || (c == "y")) {
			fnt += "<img src=i.gif>";
			snd += "-eee";
			if (phn.charAt(phn.length-1) == "i") phn += "-";
			phn += "i";
		} else if (c == "a") {
			fnt += "<img src=a.gif>";
			snd += "-aah";
			if (phn.charAt(phn.length-1) == "a") phn += "-";
			phn += "a";
		} else if ((c == "o") || (c == "u") || (cc == "oo")) {
			if (cc == "oo") i++;
			if (phn.charAt(phn.length-1) == "o") phn += "-";
			if ((bd == "false") || (c == "o")) {
				fnt += "<img src=o.gif>";
				snd += "-ooh";
				phn += "o";
			} else if ((c == "u") || (cc == "oo")) {
				fnt += "<img src=oo.gif>";
				snd += "-oou";
				phn += "oo";
			}
		} else if ((c == "k") || (c == "C") || (c == "G")) {
			if ((bd == "false") || (c == "k") || (c == "C")) {
				fnt += "<img src=k.gif>";
				snd += "-kaah";
				phn += "ka";
			} else if (c == "G") {
				fnt += "<img src=k.gif>";
				snd += "-keee";
				phn += "ki";
			}
		} else if ((c == "t") || (c == "d") || (cc == "th")) {
			if (cc == "th") i++;
			if ((bd == "false") || ((c == "t") && (cc != "th"))) {
				fnt += "<img src=t.gif>";
				snd += "-teee";
				phn += "ti";
			} else if ((c == "d") || (cc == "th")) {
				fnt += "<img src=t.gif>";
				snd += "-taah";
				phn += "ta";
			}
		} else if ((c == "p") || (c == "b") || (c == "v") || (c == "f")) {
			if ((bd == "false") || (c == "p") || (c == "b")) {
				fnt += "<img src=p.gif>";
				snd += "-paah";
				phn += "pa";
			} else if ((c == "v") || (c == "f")) {
				fnt += "<img src=p.gif>";
				snd += "-pooh";
				phn += "po";
			}
		} else if ((c == "j") || (c == "g")) {
			if (phn.charAt(phn.length-1) == "i") phn += "-";
			if ((bd == "false") || (c == "j")) {
				fnt += "<img src=ia.gif>";
				snd += "-eeah";
				phn += "ia";
			} else if (c == "g") {
				fnt += "<img src=io.gif>";
				snd += "-eeoh";
				phn += "io";
			}
		} else if (c == "w") {
			fnt += "<img src=oa.gif>";
			snd += "-ooah";
			if (phn.charAt(phn.length-1) == "o") phn += "-";
			phn += "oa";
		} else if (c == "q") {
			fnt += "<img src=k.gif><img src=oa.gif>";
			snd += "-kooah";
			phn += "koa";
		} else if (c == "x") {
			fnt += "<img src=k.gif><img src=s.gif><img src=a.gif>";
			snd += "-ksaah";
			phn += "ksa";
		} else if (c == " ") {
			fnt += "<img src=space.gif>";
			snd += " ";
			phn += " ";
		}
	}
	
	snd = snd.substring(1, snd.length)
	var snd2 = "";
	for (i = 0; i < snd.length; i++) {
		snd2 += snd.substring(i, i+1)		
		if (snd.substring(i, i+2) == " -") {
			i++;
		}
	}
	
	document.write("<script src='translate.js'></script>");
	document.write("<BODY BGCOLOR='#000000' LINK='#FF0000' VLINK='#FF0000' TEXT='#FFFFFF' TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 alink='#FF0000'><center><img src='atlantislight.jpg' width='229' height='167' border='0'><br> <font color='#FFFFFF' face='Verdana, Arial, Helvetica, sans-serif' size='5'>~The Great Pure-Loving-Atlantean-O-Matic Translator!~ </font><br><br>");
	document.write("<font face='Verdana, Arial, Helvetica, sans-serif' size='2' color='#CCFFFF'>");
	document.write("<font size=4>Original Message: </font><br><br><font size=2>" + origmsg + "<br><br>");
	document.write("<font size=4>Translation to Atlantean Phonemes: </font><br><br><font size=2>" + phn + "<br><br>");
	document.write("<font size=4>Translation to Atlantean Sound: </font><br><br><font size=2>" + snd2 + "<br><br>");
	document.write("<font size=4>Translation to Atlantean Alphabet: </font><br><br>Want this font? <a href=font.htm>Click here!</a><br><br><font size=2>" + fnt + "<br><br>");
}

function analyse(msg, bd)
{
	var origmsg = msg;
	var word = "";
	var needfeed = false;
	var newform = "";
	
	if (msg == "Please type your message here! Use phonetic spelling for shorter translation!") return;

	msg = msg.toLowerCase();
	if (msg.indexOf(" ") == -1) {
		word = msg; 
		ns = -1;
	} else {
		ns = msg.indexOf(" ");
		word = msg.substring(0, ns);
	}
	newform += "<BODY BGCOLOR='#000000' LINK='#FF0000' VLINK='#FF0000' TEXT='#FFFFFF' TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 alink='#FF0000'><html><SCRIPT SRC='translate.js'></SCRIPT><center> <img src='atlantislight.jpg' width='229' height='167' border='0'><br> <font color='#FFFFFF' face='Verdana, Arial, Helvetica, sans-serif' size='5'>~The Great Pure-Loving-Atlantean-O-Matic Translator!XXX~ </font><font face='Verdana, Arial, Helvetica, sans-serif' size='2' color='#CCFFFF'><br><br>";
	newform += "<font size=4>Original Message: </font><br><br><font size=2>" + origmsg + "<br><br>";
	newform += "<form>";
	newform += "<input type=hidden name=om value='"+origmsg+"'>"
	newform += "<input type=hidden name=m value='"+msg+"'>"
	newform += "<input type=hidden name=bd value='"+bd+"'>"
	for (i = 0; i < msg.length; i++)
	{
		if (ns != msg.indexOf(" ", i)) {
			
			if (msg.indexOf(" ", i) == -1) {
				word = msg.substring(ns, msg.length); 
				ns = -1;
			} else {
				ns = msg.indexOf(" ", i);
				word = msg.substring(i, ns);
			}
		}
		c = msg.charAt(i);
		if ((c == "g") || (c == "c")) {
			newform += 'In the word "'+word+'", check here if the letter "'+c+'" is hard: <input type=checkbox name=hardlet'+i+' onclick="m.value=caseset(m.value,'+(i+1)+',hardlet'+i+'.checked)"><br>';
			needfeed = true;
		}			
		if (c == "s") {
			newform += 'In the word "'+word+'", check here if the letter "'+c+'" is pronouced like a "z": <input type=checkbox name=hardlet'+i+' onclick="m.value=caseset(m.value,'+(i+1)+',hardlet'+i+'.checked)"><br>';
			needfeed = true;
		}			
	}
	newform += "<br><input type=button value='Translate!' onclick='document.close(); translate(om.value, m.value, bd.value)')></form></body></html>";
	if (needfeed == false) {
		translate(origmsg, msg, bd.toString());
	} else {
		document.write(newform);
	}
}

function caseset(s, i, u)
{
	if (u == true)
		return s.substring(0, i-1) + s.charAt(i-1).toUpperCase() + s.substring(i, s.length);
	else
		return s.substring(0, i-1) + s.charAt(i-1).toLowerCase() + s.substring(i, s.length);
}

