//primary function: actually submitting the form
function submitform() {
	var z = trim(document.f.t.value);
	document.f.t.value = z;
	if (document.f.perform.value != "setcookie") {
		if (z == "") {
			alert("Please enter some text or a URL (web page)");
			}
/*
//arghh, why doesn't this work??			
		else if (document.f.from.value==document.f.to.value) {
			alert("Whoops: you've chosen the same language twice.");
			}
*/			
		else {
			if (document.f.perform.value == "identify") {
				if (z.length>200) {
					document.f.method = "post";
					}
				document.f.action = "http://www.faganfinder.com/translate/identify.php";
				}
			else if (parent.location.href.indexOf("/id_trans.php") > 0) {
				document.f.target = "_parent";
				}
			document.f.submit();
			}
		}
	else {
		document.f.submit();
		}
	}

//switch languages buttom
function switchlangs() {
	var temp = document.f.from.value;
	document.f.from.value = document.f.to.value;
	document.f.to.value = temp;
	document.f.t.focus();
	}

//show or hide the international keyboard
function showkey(bool) {
	if (bool) {
		document.getElementById("keyboard").style["display"] = "block";
		document.getElementById("showkey").style["display"] = "none";
		document.getElementById("hidekey").style["display"] = "inline";
		}
	else {
		document.getElementById("keyboard").style["display"] = "none";
		document.getElementById("showkey").style["display"] = "inline";
		document.getElementById("hidekey").style["display"] = "none";
		}
	}
	
//change direction of the textbox
function direction() {
	if (document.f.t.dir == "ltr") {
		document.f.t.dir = "rtl";
		}
	else {
		document.f.t.dir = "ltr";
		}
	}

//types the characters from the international keyboard
function type(c) {
	var temp = document.f.t.value + String.fromCharCode(c);
	document.f.t.value = "";
	textfocus();
	document.f.t.value = temp;
	}

//change the direction of the main textbox if appropriate
function fromlang() {
	var direction = "ltr";
	document.f.t.dir = "ltr";
	for (var i=0; i<rtl.length; i++) {
		if (document.f.from.value == rtl[i]) {
			direction = "rtl";
			var t = document.f.t.value.toLowerCase();
			if (!(t.indexOf(" ")==-1 && (t.substring(0,7)=="http://" || t.substring(0,4)=="www."))) {
				document.f.t.dir = "rtl";
				}
			break;
			}
		}
	if (direction == "ltr") {
		document.getElementById("dir").style["display"] = "none";		
		}
	else {
		document.getElementById("dir").style["display"] = "inline";		
		}
	for (var i=0; i<alphlist.length; i++) {
		document.getElementById("alph-"+alphlist[i]).style["display"] = "none";		
		}
	document.getElementById("alph-"+alphs[document.f.from.selectedIndex]).style["display"] = "inline";
	}

//submit form when user is typing in the textbox
function checkifdone() {
	var z = document.f.t.value;
	if (z.charCodeAt(document.f.t.value.length-1)==10) {
		if (z.indexOf(" ")==-1) {
			document.f.t.value = z.substring(0,z.length-2);
			document.f.elements[4].click();
			}
		}
	}