function SetActiveMode()
{
	HiliteOption(document.getElementById("mode1"), false);
	HiliteOption(document.getElementById("mode2"), false);
	HiliteOption(document.getElementById("mode3"), false);
}

function SetupTransForm()
{
	for(i=0; i<NumLangs; i++)
	{
		strId = FromLangs[i].substr(0, 2);
		// check if from lang is already in the list
		for(j=i-1; j >= 0; j--)
		{
			if(strId == FromLangs[j].substr(0, 2))
				break;
		}
		
		if(j < 0)
		{
			if(bIE)
				document.TransForm.FromLangs.add(new Option(FromLangs[i].substr(2), strId));
			else
				document.TransForm.FromLangs.add(new Option(FromLangs[i].substr(2), strId), null);
		}
	}

	if (selectedFromLang != "")
		document.TransForm.FromLangs.value = selectedFromLang;		
	else
		document.TransForm.FromLangs.selectedIndex = 0;
		
/*
	var obj = document.TransForm.text; //all.item("text");
	if(obj != null)
	{
		TIDir = 'ltr';
		for(i=0; i<NumDirs; i++)
		{
			if (LangDir[i].substr(0, 2) == document.TransForm.FromLangs.value)
			{
				TIDir = LangDir[i].substr(2);
				break;
			}
        }
		obj.dir = TIDir;
	}
*/
    setTextDirection();
	SetToLangs();

	
	if(bLongForm) SetActiveMode();
}

function setTextDirection() {
    var obj = document.TransForm.text; //all.item("text");
    if (obj != null) {
        TIDir = 'ltr';
        for (i = 0; i < NumDirs; i++) {
            if (LangDir[i].substr(0, 2) == document.TransForm.FromLangs.value) {
                TIDir = LangDir[i].substr(2);
                break;
            }
        }
        obj.dir = TIDir;
    }
}

function SetToLangs()
{	
	FromId = document.TransForm.FromLangs.options.item(document.TransForm.FromLangs.selectedIndex).value;
	//document.TransForm.ToLangs.options.length = 0;
	for (i=document.TransForm.ToLangs.options.length-1; i>=0; i--)
	{
		document.TransForm.ToLangs.removeChild(document.TransForm.ToLangs.options[i]);
	}
	for(i=0; i<NumLangs; i++)
	{
		strId = FromLangs[i].substr(0, 2);
		if (FromId == strId)
		{
			if(bIE)
				document.TransForm.ToLangs.add(new Option(ToLangs[i].substr(2), ToLangs[i].substr(0, 2)));
			else
				document.TransForm.ToLangs.add(new Option(ToLangs[i].substr(2), ToLangs[i].substr(0, 2)), null);
		}
	}
	
	if (selectedToLang != null && selectedToLang != "")
		document.TransForm.ToLangs.value = selectedToLang;
	else
		document.TransForm.ToLangs.selectedIndex = 0;

}

function BrowseURL()
{
	document.TransForm.Req.value="0";
	document.TransForm.submit()	;
}

function DoTranslate()
{
	document.TransForm.Req.value="1";
	document.TransForm.submit()	;
}
function DoSave()
{
	document.TransForm.Req.value = "s" + document.TransForm.Req.value;
	document.TransForm.submit()	;
}

function SetNewDomainStack(NewStack)
{
}

function EditDomains()
{
	url = "domains.asp?LangPair=";
	url += document.TransForm.FromLangs.value;
	url += "-";
	url += document.TransForm.ToLangs.value;
	
	url += "&Stack=";
	Stq = document.getElementById("Stack"); 	
	url += document.TransForm.DomainStack.value;
	
	if(bIE)
		NewStack = window.showModalDialog(url, "", "dialogHeight:16");
	else
	{
		window.returnValue = "";	
		window.open(url, "_blank", "modal,toolbar=0,status=0,location=0,height=190,width=600");
		NewStack = window.returnValue;		
	}
	
	if (NewStack != null)
	{	
		if (NewStack != "")		
			NewStack += ", General";
		else
			NewStack = "General"
					
		Stq.childNodes[0].nodeValue = NewStack;
		document.TransForm.DomainStack.value = NewStack;
	}
}

function GoHome()
{
	window.open("default.asp", "_top");
}

function SetMode(Mode)
{	
	//obj.Checked = true;
	document.TransForm.What.value = Mode;
	var s;
	s = new String(document.location);
	if (s.substr(s.length-1, 1) == "/") s += "default.asp";
	document.TransForm.target = "_self";
	document.TransForm.action = s;	
	document.TransForm.submit();
}

function HiliteOption(obj, bHilite)
{
	t = "mode" + ActiveMode;
	if (bHilite)
	{
		if(obj.id != t)
			obj.className = "HoverCaption"
			//obj.style.color = "blue";			
	}
	else
	{
		if(obj.id == t)		
		{
			/*obj.style.color = "blue";
			obj.style.fontWeight = "bold";
			obj.style.backgroundColor = "white";
			obj.style.cursor = "default";
			*/
			obj.className = "ActiveCaption"
			obj.style.cursor = "default";
		}
		else
		{			
			/*obj.style.color = "white";
			obj.style.fontWeight = "normal";
			obj.style.backgroundColor = "silver";
			obj.style.cursor = "hand";
			*/
			obj.className = "InActiveCaption"
			obj.style.cursor = "hand";
		}
	}
}

function ToLangChanged(txtobj) {	
	if(txtobj != null)
	{
		TIDir = 'ltr';
		for(i=0; i<NumDirs; i++)
		{
			if (LangDir[i].substr(0, 2) == document.TransForm.ToLangs.value)
			{
				TIDir = LangDir[i].substr(2);
				break;
			}
		}
		txtobj.dir = TIDir;
	}
}