<!--
function popitup(mylink, windowname)
{
if (!window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=500,height=500,scrollbars=yes,left=0,top=0');
return false;
}

function setloadoptions() {
 setendyearoptions();
}

function erssetloadoptions() {
setendyearoptions();
//ERSWarning("ERSWarning.htm");
}

//function ERSWarning(URL) {
//closetime = 10;
//ERSWarning = window.open(URL, 'ERSWarning', //'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=250,height=20//0,left = 50,top = 50');
//if (closetime) setTimeout("ERSWarning.close();", closetime*1000);
//}

function setlogin(pid) {
 if (document.Selection.QI.value == "") {
     window.location="USTLogin.asp?type=0&progid=" + pid;
 }
 else {
     document.GoToPage.QI.value="";
     if (pid != 19) {
         document.Search.QI.value="";
         document.Selection.QI.value="";
     }
     if (pid == 0) {
        window.location="USTExBICO.asp?QI="
     }
     if (pid == 1) {
        window.location="USTExFAS.asp?QI="
     }
     if (pid == 2) {
        window.location="USTExHS2.asp?QI="
     }
     if (pid == 3) {
        window.location="USTExHS4.asp?QI="
     }
     if (pid == 4) {
        window.location="USTExHS6.asp?QI="
     }
     if (pid == 5) {
        window.location="USTExHS10.asp?QI="
     }
     if (pid == 6) {
        window.location="USTImBICO.asp?QI="
     }
     if (pid == 7) {
        window.location="USTImFAS.asp?QI="
     }
     if (pid == 8) {
        window.location="USTImHS2.asp?QI="
     }
     if (pid == 9) {
        window.location="USTImHS4.asp?QI="
     }
     if (pid == 10) {
        window.location="USTImHS6.asp?QI="
     }
     if (pid == 11) {
        window.location="USTImHS10.asp?QI="
     }
     if (pid == 12) {
        window.location="USTRxHS2.asp?QI="
     }
     if (pid == 13) {
        window.location="USTRxHS4.asp?QI="
     }
     if (pid == 14) {
        window.location="USTRxHS6.asp?QI="
     }
     if (pid == 15) {
        window.location="USTRxHS10.asp?QI="
     }
     if (pid == 16) {
        window.location="USTExFatus.asp?QI="
     }
     if (pid == 17) {
        window.location="USTImFatus.asp?QI="
     }
     if (pid == 18) {
        window.location="USTRxFatus.asp?QI="
     }
     if (pid == 19) {
        window.location="USTSaved.asp?QI="
     }
     if (pid == 20) {
        window.location="USTManual.asp?QI="
     }
     if (pid == 21) {
        window.location="USTHelp.asp?QI="
     }
     if (pid == 22) {
        window.location="USTTips.asp?QI="
     }
     if (pid == 23) {
        window.location="Release.asp?QI="
     }
     if (pid == 24) {
        window.location="USTExRICO.asp?QI="
     }
     if (pid == 25) {
        window.location="USTRxFAS.asp?QI="
     }
     if (pid == 50) {
        window.location="USTRxProcFood.asp?QI="
     }
     if (pid == 51) {
        window.location="USTExProcFood.asp?QI="
     }
 }
}

function CheckStartYear() {
 var syear=document.Selection.StartYear.selectedIndex;
 var smonth=document.Selection.StartMonth.selectedIndex;
 var cmonth=parseInt(document.Selection.currentmonth.value,10);
 var emonth;
 cmonth = cmonth - 1;
 setendyearoptions();
 if (syear == 0) {
     var eyear=document.Selection.EndYear.selectedIndex;
     if (smonth > cmonth) {
         document.Selection.StartMonth.selectedIndex=0;
     }
//     if ((eyear == 1) && (smonth > cmonth)) {
//         document.Selection.StartMonth.selectedIndex=cmonth;
//     }
     emonth = cmonth;
 }
 else {
   if (smonth > 0 ) {
       emonth = smonth - 1;
   }
   else {
       emonth = 11;
   }
 }

// If the starting year is one year less than the current year
// ie current year = 2001 and start year is 2000
// Check the number of items in the end year list. If there
// is more than one then the ending year is the current year
// and the ending month can't be greater than the current month
 if (syear == 1) {
     var elistobj = document.Selection.EndYear;
     if (elistobj.length > 1) {
         if (emonth > cmonth) {
             emonth = cmonth;
         }
     }
 }

 document.Selection.EndMonth.selectedIndex=emonth;
 return;
}

function CheckStartMonth() {
 var smonth=document.Selection.StartMonth.selectedIndex;
 var syear=document.Selection.StartYear.selectedIndex;
 var cmonth=parseInt(document.Selection.currentmonth.value,10);
 cmonth = cmonth - 1;
 setendyearoptions();
 var eyear=document.Selection.EndYear.selectedIndex;
 var emonth=document.Selection.EndMonth.selectedIndex;

// When the start month is January:
// - If the start year is the current year, set the end month to current month
// - else set the end month to December
 if (smonth == 0) {
     if (syear == 0) { document.Selection.EndMonth.selectedIndex=cmonth - 1; }
     else { document.Selection.EndMonth.selectedIndex=11; }
 }
 else {
// When the start year is the current year and start month not January:
// - The start month can not be greater than the current month
// - Set the end year and month to current year and month
   if (syear == 0) {
       if (smonth > cmonth) {
           document.Selection.StartMonth.selectedIndex=cmonth;
       }
       document.Selection.EndMonth.selectedIndex=cmonth;
   }
   else {
// When the end year is the current year
// - The end month can not be greater then the current month
    if (EndYearIsCurrentYear()) {
        if (smonth > cmonth) {
            document.Selection.EndMonth.selectedIndex=cmonth;
        }
        else {
            document.Selection.EndMonth.selectedIndex=smonth - 1;
        }
    }
    else {
       document.Selection.EndMonth.selectedIndex=smonth - 1;
    }
   }
 }
 return;
}

function setendyearoptions() {
 var elistobj = document.Selection.EndYear;
 var slistobj = document.Selection.StartYear;
 var smonth=document.Selection.StartMonth.selectedIndex;
 var syear=slistobj.selectedIndex;
 elistobj.length = 0;
 if ((smonth == 0) || (syear == 0)) {
      elistobj.options[0] = new Option(slistobj.options[syear].text,slistobj.options[syear].value,1,1);
 }
 else {
     elistobj.options[0] = new Option(slistobj.options[syear-1].text,slistobj.options[syear-1].value,1,1);
     elistobj.options[1] = new Option(slistobj.options[syear].text,slistobj.options[syear].value,0,0);
 }
 return;
}

function CheckEndYear() {
 var eyear=document.Selection.EndYear.selectedIndex;
 var smonth=document.Selection.StartMonth.selectedIndex;
 var emonth=document.Selection.EndMonth.selectedIndex;
 var cmonth=parseInt(document.Selection.currentmonth.value,10);
 cmonth = cmonth - 1;
// If the end year is the current year
// - The ending month can not be greater than the current month
 if (EndYearIsCurrentYear()) {
     if (emonth > cmonth) {
         document.Selection.EndMonth.selectedIndex=cmonth;
     }
 }
 else {
// It's ok if the end year equals the start year,
// but, the end month can not be less then the
// start month
   if (eyear == 1) {
       if (smonth > emonth) {
           document.Selection.EndMonth.selectedIndex=smonth;
       }
   }
   else
// The end year can be one year greater than the
// start year, but, the end month can not be greater
// then or equal to the start month
   if (eyear == 0) {
       if (smonth <= emonth) {
           document.Selection.EndMonth.selectedIndex=smonth - 1;
       }
   }
 }
 return;
}

function CheckEndMonth() {
 var emonth=document.Selection.EndMonth.selectedIndex;
 var smonth=document.Selection.StartMonth.selectedIndex;
 var eyear=document.Selection.EndYear.selectedIndex;
 var syear=document.Selection.StartYear.selectedIndex;
 var cmonth=parseInt(document.Selection.currentmonth.value,10);
 cmonth =  cmonth - 1;
// If the end year is the current year
// - The end month can not be less than the start month
// - or greater than the current database month
 if (EndYearIsCurrentYear()) {
     if (emonth < smonth) {
         if (emonth > cmonth) {
             document.Selection.EndMonth.selectedIndex=cmonth;
         }
//         else {
//             document.Selection.EndMonth.selectedIndex=smonth-1;
//         }
     }
     if (emonth > cmonth) {
         document.Selection.EndMonth.selectedIndex=cmonth;
     }
 }
 else {
// If the end year equals the start year
// -  The end month can not be less than the start month
   if (StartEqualsEnd()) {
       if (emonth < smonth) {
           document.Selection.EndMonth.selectedIndex=smonth;
       }
   }
   else {
// If the end year is greater than the start year
// -  The end month must be less than or equal to
// -  the start month
     if (emonth >= smonth) {
         document.Selection.EndMonth.selectedIndex=smonth - 1;
     }
   }
 }
 return;
}

function EndYearIsCurrentYear() {
 var cyear=document.Selection.currentyear.value;
 var eindex=document.Selection.EndYear.selectedIndex;
 var eyear=document.Selection.EndYear[eindex].value;
 if (cyear == eyear) return true;
 else return false;
}

function StartEqualsEnd() {
 var eindex=document.Selection.EndYear.selectedIndex;
 var eyear=document.Selection.EndYear[eindex].value;
 var sindex=document.Selection.StartYear.selectedIndex;
 var syear=document.Selection.StartYear[sindex].value;
 if (syear == eyear) return true;
 else return false;
}

function noEntry() {
mt=document.Search.searchvalue.value;
mt = RemoveBad(mt);
document.Search.searchvalue.value = mt;

if (mt.length<3) {
    alert("Search Must Include 3 or More Characters!!!");
    document.Search.searchvalue.value="**Enter Search Here";
    document.Search.searchvalue.focus();
    return false;
}
if (mt.substring(0,2)=="**") {
    alert("Please enter something to search for!!!");
    document.Search.searchvalue.value="**Enter Search Here";
    document.Search.searchvalue.focus();
    return false;
}
return true; 
}

function noSelection(tag) {

var formatindex=document.Selection.format.selectedIndex;
if (document.Selection.format.options[formatindex].value != "6") {
    var cntryindex=document.Selection.country.selectedIndex;
    if (cntryindex < 0) {
        alert("Please select one or more countries");
        document.Selection.country.focus();
        return false;
    }
}

var cmdtyindex=document.Selection.commodity.selectedIndex;
if (cmdtyindex < 0) {
    alert("Please select one or more commodities");
    document.Selection.commodity.focus();
    return false;
}

if (document.Selection.cntrysum.checked) {
    var cnname =  document.Selection.cntrysumname.value;
    cnname = RemoveBad(cnname);
    document.Selection.cntrysumname.value = cnname;
}

if (document.Selection.cmdtysum.checked) {
    var cmname =  document.Selection.cmdtysumname.value;
    cmname = RemoveBad(cmname);
    document.Selection.cmdtysumname.value = cmname;
}

document.Selection.saveselection.value="0";
if (tag == 1) {
    if (!SaveSelection()) return false;
}

document.forms[0].submit();
}

function wtonoSelection(tag) {

var formatindex=document.Selection.format.selectedIndex;
if (document.Selection.format.options[formatindex].value != "6") {
    var cntryindex=document.Selection.country.selectedIndex;
    if (cntryindex < 0) {
        alert("Please select one or more countries");
        document.Selection.country.focus();
        return;
    }
}

var cmdtyindex=document.Selection.commodity.selectedIndex;
if (cmdtyindex < 0) {
    alert("Please select one or more commodities");
    document.Selection.commodity.focus();
    return;
}

if (document.Selection.cntrysum.checked) {
    var cnname =  document.Selection.cntrysumname.value;
    cnname = RemoveBad(cnname);
    document.Selection.cntrysumname.value = cnname;
}

if (document.Selection.cmdtysum.checked) {
    var cmname =  document.Selection.cmdtysumname.value;
    cmname = RemoveBad(cmname);
    document.Selection.cmdtysumname.value = cmname;
}

document.Selection.saveselection.value="0";
if (tag == 1) {
    if (!SaveSelection()) return;
}

document.forms[0].submit();
}

function BICOnoSelection(tag) {
var formatindex=document.Selection.format.selectedIndex;
if (document.Selection.format.options[formatindex].value != "6") {
    var cntryindex=document.Selection.country.selectedIndex;
    if (cntryindex < 0) {
        alert("Please select one or more countries");
        document.Selection.country.focus();
        return;
    }
}
if (document.Selection.format.options[formatindex].value != "5") {
    var cmdtyindex=document.Selection.commodity.selectedIndex;
    if (cmdtyindex < 0) {
        alert("Please select one or more commodities");
        document.Selection.commodity.focus();
        return;
    }
}

if (document.Selection.cntrysum.checked) {
    var cnname =  document.Selection.cntrysumname.value;
    cnname = RemoveBad(cnname);
    document.Selection.cntrysumname.value = cnname;
}

if (document.Selection.cmdtysum.checked) {
    var cmname =  document.Selection.cmdtysumname.value;
    cmname = RemoveBad(cmname);
    document.Selection.cmdtysumname.value = cmname;
}

document.Selection.saveselection.value="0";
if (tag == 1) {
    if (!SaveSelection()) return;
}

document.forms[0].submit();
}

function SaveSelection () {

if (document.Selection.QI.value == "") {
    var progid = document.Selection.programid.value
    window.location="USTLogin.asp?type=0&progid=" + progid;
    return false;
}
document.Selection.saveselection.value="1";

var inputedData = prompt ("Please enter a name for the new selection:", "" );
if (inputedData == null || inputedData == "") return false;
if (inputedData.length<3) {
    alert("Selection name must include 3 or more characters!!!, Please try again!");
    return false;
}
if (inputedData.length>50) {
    alert("Selection name can not be over 50 characters!!!, Please try again!");
    return false;
}
 document.Selection.selectionname.value=inputedData;
 return true;
}

function gotopage() {
var whereindex=document.GoToPage.ThePage.selectedIndex;
var whereto = document.GoToPage.ThePage[whereindex].value
var UID = document.GoToPage.QI.value
var progid = document.GoToPage.programid.value
if (whereto == 99) { location = "USTHome.asp?QI=" + UID; }
if (whereto == 0) { location = "USTEXBico.asp?QI=" + UID; }
if (whereto == 1) { location = "USTEXFAS.asp?QI=" + UID;  }
if (whereto == 2) { location = "USTEXHS2.asp?QI=" + UID; }
if (whereto == 3) { location = "USTEXHS4.asp?QI=" + UID; }
if (whereto == 4) { location = "USTEXHS6.asp?QI=" + UID; }
if (whereto == 5) { location = "USTEXHS10.asp?QI=" + UID; }
if (whereto == 6) { location = "USTIMBico.asp?QI=" + UID; }
if (whereto == 7) { location = "USTIMFas.asp?QI=" + UID; }
if (whereto == 8) { location = "USTIMHS2.asp?QI=" + UID; }
if (whereto == 9) { location = "USTIMHS4.asp?QI=" + UID; }
if (whereto == 10) { location = "USTIMHS6.asp?QI=" + UID; }
if (whereto == 11) { location = "USTIMHS10.asp?QI=" + UID; }
if (whereto == 12) { location = "USTRXHS2.asp?QI=" + UID; }
if (whereto == 13) { location = "USTRXHS4.asp?QI=" + UID; }
if (whereto == 14) { location = "USTRXHS6.asp?QI=" + UID; }
if (whereto == 15) { location = "USTRXHS10.asp?QI=" + UID; }
if (whereto == 16) { location = "USTExFatus.asp?QI=" + UID; }
if (whereto == 17) { location = "USTImFatus.asp?QI=" + UID; }
if (whereto == 18) { location = "USTRxFatus.asp?QI=" + UID; }
if (whereto == 19) { location = "USTSaved.asp?QI=" + UID; }
if (whereto == 20) { location = "USTLogin.asp?type=0&progid=" + progid; }
if (whereto == 21) { location = "USTHelp.asp?QI=" + UID; }
if (whereto == 22) { location = "USTTips.asp?QI=" + UID; }
if (whereto == 23) { location = "Release.asp?QI=" + UID; }
if (whereto == 24) { location = "USTRXBico.asp?QI=" + UID; }
if (whereto == 25) { location = "USTRXFAS.asp?QI=" + UID;  }
if (whereto == 26) { location = "USTAgDef.asp?QI=" + UID;  }
if (whereto == 27) { location = "USTMaunal.asp?QI=" + UID;  }
if (whereto == 50) { location = "USTExProcFood.asp?QI=" + UID;  }
if (whereto == 51) { location = "USTRxProcFood.asp?QI=" + UID;  }
return;
}

function ustreset() {
 document.forms[0].reset();
 document.forms[1].reset();
 setendyearoptions();
}

function notAvailable() {
 alert("This option is NOT currently available!");
}

function RemoveBad(strTemp) { 
strTemp = strTemp.replace(/\<|\>|\/|\"|\'|\%|\;|\(|\)|\&|\+|\-/g,""); 
return strTemp;
}  


// -->
