﻿// JScript File
function LT_OnSubmit()
{
    jhhhk
    var words = document.ltiprice.w.value;
    var errmsg = "";
    var CHAR_LIMIT = 1900;
    var WORD_LIMIT = 500;
    if (words.length == 0)
    {
        errmsg = "Please enter some text to translate";
    }
    else if (words.length > CHAR_LIMIT)
    {
        errmsg = "Please limit your text (currently " + words.length + " characters) to " + CHAR_LIMIT + " characters";
    }
    else if (words.split(/\s*/).length == 0)
    {
        errmsg = "Please enter one or more words to translate";
    }
    else if (words.split(/\s+/).length > WORD_LIMIT)
    {
        errmsg = "Please limit your text (currently " + words.split(/\s+/).length + " words) to " + WORD_LIMIT + " words";
    }
    if (errmsg.length == 0)
    {
        return true;
    }
    else
    {
        alert(errmsg);
        return false;
    }
}

function FillDest(slid)
{
    var ddd = document.getElementById('lt_d');
    ddd.options.length = 0;
    for (j=0; j < slid.length; j++)
    {
        var oOption = document.createElement("OPTION");
        oOption.text = slid[j].D;
	    oOption.value = slid[j].DI;
	    try{ddd.add(oOption, null);}catch(ex){ddd.add(oOption);}
    }
}

function FillDest1(slid)
{
    var ddd = document.getElementById('lt_d1');
    ddd.options.length = 0;
    for (j=0; j < slid.length; j++)
    {
        var oOption = document.createElement("OPTION");
        oOption.text = slid[j].D;
	    oOption.value = slid[j].DI;
	    try{ddd.add(oOption, null);}catch(ex){ddd.add(oOption);}
    }
}


function Fill()
{
    var sdd = document.getElementById('lt_s');
   
    for (i=0; i < opts.length; i++)
    {
        var oOption = document.createElement("OPTION");
	    oOption.text = opts[i].S;
	    oOption.value = opts[i].SI;
	    try{sdd.add(oOption, null);}catch(ex){sdd.add(oOption);}
	}
    FillDest(opts[0].DL);
}

function Fill1()
{   
    var sdd1 = document.getElementById('lt_s1');
  
    for (i=0; i < opts.length; i++)
    {
        var oOption1 = document.createElement("OPTION");
	    oOption1.text = opts[i].S;
	    oOption1.value = opts[i].SI;
	    try{sdd.add(oOption1, null);}catch(ex) {sdd1.add(oOption1);}
	}
    FillDest1(opts[0].DL);
}

function ChangeLang(source)
{
  
    var sdd = document.getElementById('lt_s');
    var ddd = document.getElementById('lt_d');
    var curS = sdd.selectedIndex;
    var curD = ddd.selectedIndex;
    FillDest(opts[curS].DL);         
    if (curD < opts[curS].DL.length && curD >= 0)
        { ddd.selectedIndex = curD;	}
	else
	    { ddd.selectedIndex = 0; }
}

function ChangeLang1(source)
{   
    var sdd = document.getElementById('lt_s1');
    var ddd = document.getElementById('lt_d1');
    var curS = sdd.selectedIndex;
    var curD = ddd.selectedIndex;
    FillDest1(opts[curS].DL);         
    if (curD < opts[curS].DL.length && curD >= 0)
        { ddd.selectedIndex = curD;	}
	else
	    { ddd.selectedIndex = 0; }
}