// JavaScript Document

var nativeStr="";
var translatedStr="";
var selectionN="";
var selectionT="";
var formLength=12;
/*added below*/
var intervalId=0;
var node; 
var itemsA;
var myfr2;
var fr2Ref;
var intId=0;
var inId=0;
/*eofadded*/ 
   // google.load("language", "1");
  /*
    function initialize(ix) {
    if(document.formOp.elements["selN"].selectedIndex==0){
    alert("Select language to translate from.");}
    else if(document.formOp.elements["selT"].selectedIndex==0){
    alert("Select language to translate to.");}
var text=nativeStr;
var nl=document.formOp.elements["selN"].value;
var tl=document.formOp.elements["selT"].value;
         google.language.translate(text,nl,tl,function(result) {
            var translated = document.getElementById("translation");
            if (result.translation) {            
			translatedStr=result.translation;		
      translatedStr=translatedStr.replace(/\&#39;/,"'");
				if(ix<100){document.formW.elements["t"+ix].value=translatedStr;}
				else {showTranslatedStr();}
//window.document.translate20.SetVariable("langN", result.translation);
            }
          });//eof language.translate

    }
 */
/*added new functions below*/
function getmyL(){
   intId = setInterval ( "waitL()", 2000 );
setTimeout('clearInterval(intId)', 20000);   
  }
function waitL(){
   try{
   linkAF = window.frames["fr2"].document.getElementById("divOne").getElementsByTagName("a");
   if(linkAF.length!=1){return;}
   }catch(err){
   return; 
   
   }
   try{
   linkAF[0].click();
   }catch(err){
   return;
   }
   clearInterval(intId);
   inId = setInterval ( "showTranslatedStr()", 2000 );
setTimeout('clearInterval(inId)', 20000);
   
}
function getLangHtml(){
var gmyL="support/la/la"+document.formOp.elements["selT"].value+".html";
document.getElementById("fr2").src=gmyL;
}
/*eof added new functions*/
function sendToGame(){
var tempTN="";
var subN="";
var subT="";
var tempT="";
var tempN="";
for(i=0;i<12;i++){
subN="langN"+i;
subT="langT"+i;
//window.document.translate20.SetVariable(subN, tempN);
//window.document.translate20.SetVariable(subT, tempT);
//sendToActionScript(this.form.input.value);
}
var i=0;

for(i=0;i<formLength;i++){
if(document.formW.elements["t"+i].value.length>0){
tempTN=document.formW.elements["t"+i].value;
tempTN=(tempTN.replace(/^\u0020+/,'')).replace(/\u0020+$/,'');
document.formW.elements["t"+i].value=tempTN;
}}
for(i=0;i<formLength;i++){
if(document.formW.elements["n"+i].value.length>0){
tempTN=document.formW.elements["n"+i].value;
tempTN=(tempTN.replace(/^\u0020+/,'')).replace(/\u0020+$/,'');
document.formW.elements["n"+i].value=tempTN;
}}
var j=0;
for(i=0;i<formLength;i++){
if((document.formW.elements["n"+i].value.length>0)&&(document.formW.elements["t"+i].value.length>0)){
subN="langN"+j;
subT="langT"+j;
tempN=document.formW.elements["n"+i].value;
tempT=document.formW.elements["t"+i].value;
//window.document.translate20.SetVariable(subN, tempN);
//window.document.translate20.SetVariable(subT, tempT);
sendToActionScript(i,tempN,tempT);
j++;
}}
}

function showTranslatedStr(){
var wF=window.frames["fr2"].document.getElementById("tranOne").innerHTML;
if(wF=="Here")return;
node=window.frames["fr2"].document.getElementById("tranOne");
var nodeV="2";
while(node.childNodes){
	if(node.childNodes[0].nodeName!=="#text"){
	node=node.childNodes[0];
}else{	
nodeV=node.childNodes[0].nodeValue;
if(nodeV=="undefined" || nodeV=="2")return;
clearInterval(inId);
var temp="";
var tempN="";
tempN=nativeStr.split(",");
temp=nodeV.split(",");
document.formW.reset();
var i=0;
for(i=0;i<tempN.length-1;i++){
temp[i] = (temp[i].replace(/^\u0020+/,'')).replace(/\u0020+$/,'');
tempN[i] = (tempN[i].replace(/^\u0020+/,'')).replace(/\u0020+$/,'');
document.formW.elements["t"+i].value=temp[i];
document.formW.elements["n"+i].value=tempN[i];
}
break;
}
}
}



function makeNStr(){
var temp="";
var i=0;
nativeStr="";
for(i=0;i<formLength;i++){
if(document.formW.elements['n'+i].value>""){
temp=document.formW.elements['n'+i].value;
//temp=(temp.replace(/^\W+/,'')).replace(/\W+$/,'');
nativeStr+=temp+',';
}}
//document.getElementById("text").innerHTML=nativeStr;
}



function sendToTranslate(){
if(document.formOp.elements["selN"].selectedIndex==0){
alert("Select language to translate from.");return}
else if(document.formOp.elements["selT"].selectedIndex==0){
alert("Select language to translate to.");return;}
makeNStr();
getLangHtml();
}

function translateOne(ix){
nativeStr=document.formW.elements["n"+ix].value;
initialize(ix);
}

function presetWords(arrP,nuI){
document.formOp.elements["selN"].selectedIndex=nuI;
var i=0;
while(i<formLength){
document.formW.elements["n"+i].value=arrP[i];
i++;
}
}

function getLanguages(){
var v0="<";var v10a="\">";var v1="a href";var v2="=\"m";var v3="ail";var v4="to:";var v5="we";var v6="bmast";var v7="er@";
var v8="mylingos";var v9=".c";var v10="om";var v11="con";var v12="tact us";
var vtot="";
vtot=v0+v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v10a+v11+v12+v0+"\/a"+v10a;

document.getElementById("cont").innerHTML=vtot;
selectionN=document.formOp.elements["selN"];
selectionT=document.formOp.elements["selT"];
if(GetCookie("languages")){
languages=GetCookie("languages");
var bothL=languages.split(",");
	selectionN.selectedIndex=bothL[0];
	selectionT.selectedIndex=bothL[1];
	}



}

function makeDefault(){
var val="";
val=selectionN.selectedIndex+','+selectionT.selectedIndex;


SetCookie("languages",val,null,"/");
getLanguages();
}
// bof keyboard functions

//bof drag keyboard functions
//if  (document.getElementById){
//(function(){
//Stop Opera selecting anything while dragging.
if (window.opera){
document.write("<input type='hidden' id='Q' value=' '>");
}

var n = 500;
var dragok = false;
var y,x,d,dy,dx;
dx=100;dy=500;
function move(e){
if (!e) e = window.event;
 if (dragok){
  d.style.left = dx + e.clientX - x + "px";
  d.style.top  = dy + e.clientY - y + "px";
 
  return false;
 }
}

function down(e){
if (!e) e = window.event;
var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass"){
 temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
 }
 
if (temp.className == "dragclass"){
 if (window.opera){
  document.getElementById("Q").focus();
 }
 dragok = true;
 temp.style.zIndex = n++;
 d = temp;
 dx = parseInt(temp.style.left+0);
 dy = parseInt(temp.style.top+0);
 x = e.clientX;
 y = e.clientY;
 document.onmousemove = move;
 return false;
 }
}

function up(){
dragok = false;
document.onmousemove = null;
}
document.onmousedown = down;
document.onmouseup = up;
 //})();
//}//--eof drag --

  function showKeyboard(a){
  if(a==1)return;
  var str=a.split("#");
  var st="http://en.wikipedia.org/wiki/Keyboard_layout#";
  st=st.concat(str[1]);         
kd=document.getElementById("keyDiv").style;
kd.left="150px";
kd.top="500px";
document.getElementById("keyImg").src="support/images/keyboards/"+str[0];
                                                                
var selIn=document.forms["keyForm"].keyboard.selectedIndex;
document.getElementById("titleKeyDiv").innerHTML=document.forms["keyForm"].keyboard.options[selIn].text;
document.getElementById("moreInfo").innerHTML='<a class=\"info\" href=\"'+st+'\" target=\"_blank\">more info...</a>';

kd.visibility="visible";
restoreKey();
document.keyForm.keyboard.selectedIndex=0;
}

function closeKey(){
kd.visibility="hidden";
document.getElementById("keyImg").src="support/images/spacer.gif";
kd.height="2px";
kd.width="2px";
kd.left="-10px";
kd.top="500px";
}
function minKey(){
kd.height="21px";
kd.overflow="hidden";
}
function restoreKey(){
kd.width="500px";
kd.height="181px";
kd.overflow="visible";
}




//-----end of keyboard functions----------
//---pass data to flash----

     var jsReady = false;
     function isReady() {
         return jsReady;
     }
     function pageInit() {
         jsReady = true;
        // document.forms["form1"].output.value += "\n" + "JavaScript is now ready from html.\n";
     }
     function thisMovie(movieName) {
         if (navigator.appName.indexOf("Microsoft") != -1) {
             return window[movieName];
         } else {
             return document[movieName];
         }
     }
     function sendToActionScript(i,tempN,tempT) {
         thisMovie("world").sendToActionScript(i,tempN,tempT);
     }
 
