//--------------------------------------------------------------------

if (parent.location.href != window.location.href) 
	{
	parent.location.href = window.location.href;
	}
//NOTE - is location.href allowed?

//--------------------------------------------------------------------

function mailLink()
{
var f=0;
var left = "pete";
var right = "e-lang.co.uk";

	document.write('<a href=\"mailto');
	document.write(':' + left + '@');
	document.write(right + '?subject=Re: Phonetic Typewriter (US)\">' + left + '@' + right + '<\/a>');
}


//--------------------------------------------------------------------

var about='typehelp.html';
var home='../../javascript-call-activities/';
var report='typefb.html';
var again='type.html';
var selectedString="";
var ipaCode=new Array();
ipaCode[0]=new Array("","105,058","618","101,618","603","601","712");
ipaCode[1]=new Array("","230","593,058","596,058","650","111,650","716");
ipaCode[2]=new Array("","117,058","652","604","097,618","097,650","596,618");
ipaCode[3]=new Array("","112","98","116","100","679","676","107","103");
ipaCode[4]=new Array("","102","118","952","240","115","122","643","658");
ipaCode[5]=new Array("","109","110","331","104","108","114","119","106");

//BUG - I changed this to specify a zero array length to overcome problems in IE 5.5
var myAnswer=new Array(0);
var help='';

var webNav=new Array("webIE","webNot");
var wordNav=new Array("wordIE","wordNot");

//--------------------------------------------------------------------

browser=navigator.appName;
var IE=false;
if (browser=="Microsoft Internet Explorer")
{
	IE=true;
}

//--------------------------------------------------------------------

function showMenu(foo)
{
	if (IE==true)
	{
		doMenu(foo,0);
	}
	else
	{
		doMenu(foo,1);
	}
	document.forms[0].result.blur()
}

//--------------------------------------------------------------------

function doMenu(foo,bar)
{
	if(document.getElementById) 
		{
			document.getElementById('start').style.visibility = "hidden";
			document.getElementById(foo[bar]).style.visibility = "visible";
//BUG - There is a problem here in some versions of IE5.5 - the element is not an object. Perhaps pop it into a variable first.
		}
		else if(document.all) 
		{
			document.all['start'].style.visibility = "hidden";
			document.all[foo[bar]].style.visibility = "visible";
		}
}

//--------------------------------------------------------------------

function navigate(destination)
{
	parent.location=destination;
}

//--------------------------------------------------------------------

function openExternal(foo){
	var external=window.open(foo,'','');
}

//--------------------------------------------------------------------

function chooseMe(foo)
{
	cx = foo % 10;
	rx = Math.floor(foo / 10);
	b=myAnswer.length;
	myAnswer[b]=ipaCode[rx][cx];
	doAnswer();
}

//--------------------------------------------------------------------


function addSpace()
{
	b=myAnswer.length;
	myAnswer[b]="032";
	doAnswer();
}

//--------------------------------------------------------------------

function clearOne()
{
	if (myAnswer.length>0)
	{
		myAnswer.length=myAnswer.length-1;
	}
	doAnswer();
}

//--------------------------------------------------------------------

function clearAll()
{
	myAnswer.length=0;
//BUG - There is a problem here with some IE5.5 - not an object. Why?
	doAnswer();
}

//--------------------------------------------------------------------

function doAnswer()
{
	var answerString="";
	var oldString="";
	var oldStringLong="";
	var partOne="";
	var partTwo="";
	var finalAnswer="";
	var finalAnswerWord="";
	var finalAnswerWeb="";

	for(i=0;i<myAnswer.length;i++)
	{
		oldString=myAnswer[i];
		if (oldString.length>3) 
		{
			partOne=oldString.substr(0,3)
			partTwo=oldString.substr(4,7)
			answerString=answerString+String.fromCharCode(partOne);
			answerString=answerString+String.fromCharCode(partTwo);
			oldStringLong=oldStringLong+'&#'+partOne+';';
			oldStringLong=oldStringLong+'&#'+partTwo+';';
			partOne=partOne.replace('058','720')
			partTwo=partTwo.replace('058','720')
			finalAnswerWord=finalAnswerWord+String.fromCharCode(partOne);
			finalAnswerWord=finalAnswerWord+String.fromCharCode(partTwo);
		}
		else
		{
			answerString=answerString+String.fromCharCode(myAnswer[i]);
			oldStringLong=oldStringLong+'&#'+oldString+';';
			tempString=myAnswer[i];
			tempString=tempString.replace('058','720');
			finalAnswerWord=finalAnswerWord+String.fromCharCode(tempString);
		}
	}
	if (answerString.length>0)
	{
		finalAnswer="/" +answerString +"/";
	}
	else
	{
		finalAnswer=answerString;
	}
	document.forms[0].resultview.value=finalAnswer;
	document.forms[0].result.value='/'+finalAnswerWord+'/';
	finalAnswerWeb=oldStringLong;
	document.forms[0].resultweb.value='/'+finalAnswerWeb+'/';
}

//--------------------------------------------------------------------

function selectWeb()
{
selectedString=document.forms[0].resultweb.select();
}

function selectWord()
{
selectedString=document.forms[0].result.select();
}

//--------------------------------------------------------------------

var copytoclip=1
function copyResponse(foo) 
{

if (foo=='result')
{	
var tempval=selectedString=document.forms[0].result;
}
if (foo=='resultweb')
{
var tempval=selectedString=document.forms[0].resultweb;
}
//	tempval.focus();
	tempval.select();
	if (document.all&&copytoclip==1)
	{
		therange=tempval.createTextRange()
		therange.execCommand("Copy")
		window.status="The word has been copied to the clipboard!"
		setTimeout("window.status=''",2400);
	}
}

//--------------------------------------------------------------------

function buttonCaption(foo)
{
	var keyString="";
	if (foo.length>3) 
		{
		keyString=keyString+'&#'+foo.substr(0,3)+';'+'&#'+foo.substr(4,7)+';';
		}
		else
		{
		keyString=keyString+'&#'+foo+';';
		}
return (keyString);
}

//--------------------------------------------------------------------


