    var QUERY_SAVE_INSERT = 0
    var QUERY_SAVE_UPDATE = 1
            
    var winQueryProcess
    var strActiveQueryName

//-------------------------------------------------------------------------------------------------
    function runQuery () {
    
        var i;
        var strDefaultAction = document.forms[0].action;
        var strDefaultTarget = document.forms[0].target;
        var ctrlSelects = document.getElementsByTagName("select");
  
        // First, validate required list fields
        for (i = 0; i <= ctrlSelects.length - 1; i++) {
            if (ctrlSelects.item(i).selectedIndex == -1) {
				var ctrlObj = document.getElementById(ctrlSelects.item(i).id);
                if ((("" + ctrlObj.title).length) && !((ctrlObj.id == 'lstCountry') && (document.getElementById('chkTopCountries').checked))) {                
                  // alert("ctrlSelects.item(i).id = " + ctrlObj.id);
                  // alert("chkTopCountries.checked = " + document.getElementById('chkTopCountries').checked);
                    alert("Please select at least one item from the " + document.getElementById(ctrlSelects.item(i).id).title + " list.");
                    ctrlSelects.item(i).focus();
                    return;
                }
            }
        }

        document.forms[0].hidColumnIndex.value = document.forms[0].lstColumn.selectedIndex;
        document.forms[0].hidOrderIndex.value = document.forms[0].lstOrder.selectedIndex;
        
        //Handle blank summary titles.
        if (document.getElementById("txtCommoditySummary").disabled == false
        && document.getElementById("txtCommoditySummary").value == "")
        {
			document.getElementById("txtCommoditySummary").value = "Untitled Commodity Summary";
        }
    		
        if (document.getElementById("txtAttributeSummary").disabled == false
        && document.getElementById("txtAttributeSummary").value == "")
        {
			document.getElementById("txtAttributeSummary").value = "Untitled Attribute Summary";
        }
        
        if (document.getElementById("txtCountrySummary").disabled == false
        && document.getElementById("txtCountrySummary").value == "")
        {
			document.getElementById("txtCountrySummary").value = "Untitled Country Summary";
        }
        
	    // The target MUST be fraQueryProcess (or _blank) to maintain the
	    // state of the control values used to compose the Query.
	 /*   document.forms[0].target = "fraQueryProcess";
	    document.forms[0].action = "psdResult.aspx";
	    alert("document.forms[0].target " + document.forms[0].target );
	     alert("document.forms[0].action " + document.forms[0].action );
        document.forms[0].submit();
       */  
       //  alert("strDefaultTarget " + strDefaultTarget);
       //   alert("strDefaultAction " + strDefaultAction);
       
  
  //Solomon Mekonnen  08/03/2009
  // The following code is added to inform users and request confirmation that selecting coffee and/or sugar in conjunction with other commodities 
  // need cautious interpretation of the marketing years.     
  
      document.forms[0].hidShowFooter.value = '0';
      var strSplitYear = document.forms[0].hidSplitYear.value;
      var ctrllstCommodity = document.getElementById("lstCommodity");
      var strSelectedCommodity="";
      var sSelectedSplitYearValue = -1;
      var splitYearDiffrence=0;
      var index;
                     
       
    for(var count=0; count < ctrllstCommodity.options.length; count++)
     {  
    
       if(ctrllstCommodity.options[count].selected == true) 
         {
               
                
                index = strSplitYear.indexOf(ctrllstCommodity.options[count].value);
                //get the split year value for every commodity selected 
                 splitYearDiffrence =  strSplitYear.substring(index+8,index+9);
                if (splitYearDiffrence==1)
                {
                  splitYearDiffrence=0;
                }
                  
                  if (splitYearDiffrence != sSelectedSplitYearValue)
                  {
                    if (sSelectedSplitYearValue == -1)
                    {
                        sSelectedSplitYearValue = splitYearDiffrence;
                    }
                    else
                    {
                        document.forms[0].hidShowFooter.value = '1';
                        splitYearDiffrence = -1;
                        break;
                    }
                  }
                  
          }
       
        
    }

       
     
    if (splitYearDiffrence ==-1) 
    {
         if (window.confirm('Warning: When selecting "Coffee,Green" and/or "Sugar,Centrifugal" with other commodities\nit is possible for the marketing years to become misaligned.' + '\n\n' + 'Do you want to continue?  (OK = Yes , Cancel = No)' )==true)
              {                 
                 document.forms[0].target = strDefaultTarget;
                 document.forms[0].action = strDefaultAction;
                 document.forms[0].submit();
             }
    }
  else
    {
        document.forms[0].target = strDefaultTarget;
        document.forms[0].action = strDefaultAction;
         document.forms[0].submit();
    }
   

    
    }
    
//-------------------------------------------------------------------------------------------------
    function saveQuery () {
        var i
        var strDefaultAction = document.forms[0].action
        var strDefaultTarget = document.forms[0].target
        var ctrlSelects = document.getElementsByTagName("select")

        // First, validate required list fields
        for (i = 0; i <= ctrlSelects.length - 1; i++) {
            if (ctrlSelects.item(i).selectedIndex == -1) {
                var ctrlObj = document.getElementById(ctrlSelects.item(i).id);
                if ((("" + ctrlObj.title).length) && !((ctrlObj.id == 'lstCountry') && (document.getElementById('chkTopCountries').checked))) {                
               // if (("" + document.getElementById(ctrlSelects.item(i).id).title).length) {
                    alert("Please select at least one item from the " + document.getElementById(ctrlSelects.item(i).id).title + " list.");
                    ctrlSelects.item(i).focus();
                    return;
                }
            }
        }
        // Now validate required text fields
        for (i = 0; i <= document.forms[0].length - 1; i++) {
            if (document.forms[0].item(i).type == "text") {
                if ("" + document.forms[0].item(i).value.length == 0 || "" + document.forms[0].item(i).value == "Enter a Query Name") {
                    if (("" + document.getElementById(document.forms[0].item(i).id).title).length) {
                        alert("Please enter a value for the " + document.getElementById(document.forms[0].item(i).id).title + " field.");
                        document.forms[0].item(i).select();
                        document.forms[0].item(i).focus();
                        return;
                    }
                }
            }
        }
        
        if (document.forms[0].txtQuery.value.toUpperCase() != strActiveQueryName.toUpperCase() && document.forms[0].hidQuerySaveMode.value == QUERY_SAVE_UPDATE) {
            if (!confirm("Do you wish to Save '" + strActiveQueryName + "' As '" + document.forms[0].txtQuery.value + "'?"))
                return;
            else
                setQuerySaveMode (QUERY_SAVE_INSERT);
        }
        else if (document.forms[0].txtQuery.value.toUpperCase() == strActiveQueryName.toUpperCase() && document.forms[0].hidQuerySaveMode.value == QUERY_SAVE_UPDATE) {
            if (!confirm("Do you want to Overwrite the Custom Query '" + strActiveQueryName + "'?"))
                return;
        }
        
        document.forms[0].hidColumnIndex.value = document.forms[0].lstColumn.selectedIndex;
        document.forms[0].hidOrderIndex.value = document.forms[0].lstOrder.selectedIndex;
    	
    	document.forms[0].hidQuerySave.value = "True";
        document.forms[0].cmdSave.disabled = true;
		document.forms[0].target = "fraQueryProcess";
		document.forms[0].action = "psdQueryFrameProcess.aspx";
		document.forms[0].submit();

        document.forms[0].target = strDefaultTarget;
        document.forms[0].action = strDefaultAction;
    }

//-------------------------------------------------------------------------------------------------
    function loadQuery (intQueryID) {

        var strDefaultAction = document.forms[0].action
        var strDefaultTarget = document.forms[0].target

        setActiveQueryID(intQueryID);
        setQuerySaveMode (QUERY_SAVE_UPDATE);
        document.forms[0].hidLoadQuery.value = "True";
 	    closeQueryProcessWindow();

        document.forms[0].cmdOpen.disabled = true;
		document.forms[0].target = "fraQueryProcess";
		document.forms[0].action = "psdQueryFrameProcess.aspx";
        document.forms[0].submit();
        
        document.forms[0].target = strDefaultTarget;
        document.forms[0].action = strDefaultAction;
    }

//-------------------------------------------------------------------------------------------------
    function showQueryOpenMenu () {

        var strDefaultAction = document.forms[0].action
        var strDefaultTarget = document.forms[0].target

 	    closeQueryProcessWindow();
	    void(winQueryProcess = window.open("", "QueryOpenMenu", "top=" + (screen.availHeight - 310)/2 + ",left=" + (screen.availWidth - 280)/2 + ",width=280,height=310"));
	    document.forms[0].target = "QueryOpenMenu";
	    document.forms[0].action = "psdQueryMenu.aspx";
        document.forms[0].submit();
        
        document.forms[0].target = strDefaultTarget;
        document.forms[0].action = strDefaultAction;
    }

//-------------------------------------------------------------------------------------------------
    function checkAllCountriesSelected (lstCountries) {
        // If "All Countries" is selected, deselect any individual country selections
        
        var i
        if (lstCountries.options[1].selected) {
            for (i = 2; i <= lstCountries.length - 1; i++) {
                lstCountries.options[i].selected = false;
            }
        }
    }

//-------------------------------------------------------------------------------------------------
    function toggleSummaryFields (chkSummarize) {
        var txtSummaryTitle = document.getElementById(("" + chkSummarize.id).replace(/chk/gi, "txt"))
            
        txtSummaryTitle.disabled = !chkSummarize.checked;
        if (chkSummarize.checked) {
            txtSummaryTitle.value = "";
            txtSummaryTitle.focus();
        }
        else
            txtSummaryTitle.value = "Enter Summary Title";
    }

//-------------------------------------------------------------------------------------------------
    function setQuerySaveMode (intQuerySaveMode) {
        document.forms[0].hidQuerySaveMode.value = intQuerySaveMode;            
    }

//-------------------------------------------------------------------------------------------------
    function captureActiveQueryName () {
        if (document.getElementById("txtQuery"))
            strActiveQueryName = document.forms[0].txtQuery.value;
    }

//-------------------------------------------------------------------------------------------------
    function setActiveQueryID (intActiveQueryID) {
        document.forms[0].hidQueryID.value = intActiveQueryID;
    }

//-------------------------------------------------------------------------------------------------
    function getActiveQueryID () {
        return document.forms[0].hidQueryID.value;
    }

//-------------------------------------------------------------------------------------------------
    // Clear specified <select> list of previous option values
	function clearSelectList (strListName) {
		while (document.forms[0].elements[strListName].length) {
			document.forms[0].elements[strListName].options[0] = null;			
		}
	}

//-------------------------------------------------------------------------------------------------
    // Add a new option to the specified <select> list
	function appendSelectList (strListName, sText, sValue) {
		var i
		
		// First, check for duplicates
		for (i = 0; i <= document.forms[0].elements[strListName].options.length - 1; i++) {
			if (document.forms[0].elements[strListName].options[i].value == sValue) {
				return;
			}
		}
		document.forms[0].elements[strListName].options[document.forms[0].elements[strListName].length] = new Option(sText, sValue);
	}

//-------------------------------------------------------------------------------------------------
    // Set the 'selected' property to true for the option value(s)
    // as specified  by the comma delimited strSelectedOptVals input 
    // parameter for the specified <select> list.
	function setSelectListSelections (strListName, strSelectedOptVals) {
		
		var intLastDelimitPosition = -1
		var strValueBuffer = strSelectedOptVals
		var strOptionValue
		var intOptionIndex
		
		document.forms[0].elements[strListName].selectedIndex = -1;
		if (!document.all) deselectNonIEList(document.forms[0].elements[strListName]);
		
		if (("" + strSelectedOptVals).indexOf(",") > -1) {
			while (strValueBuffer.indexOf(',', intLastDelimitPosition + 1) > 0) {
				strOptionValue = strValueBuffer.substr(intLastDelimitPosition + 1, strValueBuffer.indexOf(",", intLastDelimitPosition + 1) - (intLastDelimitPosition + 1));
		        intOptionIndex = getSelectOptionValueIndex(strListName, strOptionValue);
		        if (intOptionIndex > -1) {
		            document.forms[0].elements[strListName].options[intOptionIndex].selected = true;
		        }
				intLastDelimitPosition = strValueBuffer.indexOf(',', intLastDelimitPosition + 1);
			}
			// Capture final parsed element
			strOptionValue = strValueBuffer.substr(intLastDelimitPosition + 1);
		    intOptionIndex = getSelectOptionValueIndex(strListName, strOptionValue);
		    if (intOptionIndex > -1) {
		        document.forms[0].elements[strListName].options[intOptionIndex].selected = true;
		    }
		}
		else {
		    intOptionIndex = getSelectOptionValueIndex(strListName, strSelectedOptVals);
		    if (intOptionIndex > -1) {
		        document.forms[0].elements[strListName].options[intOptionIndex].selected = true;
		    }
		}
	}

//-------------------------------------------------------------------------------------------------
    // Returns the <option> index that corresponds to the <option> value passed in
    // for the specified <select> list.
	function getSelectOptionValueIndex (strListName, strOptionValue) {
    
        var i
        for (i = 0; i <= document.forms[0].elements[strListName].options.length - 1; i++) {
			if (document.forms[0].elements[strListName].options[i].value == strOptionValue) {
				return i;
			}
        }
        return -1;
    }

//-------------------------------------------------------------------------------------------------
    // Sets the interface to appropriate checkbox accessibility settings and
    // populates the Sort Order (lstOrder) <select> list with the appropriate
    // values per the selection in the Column (lstColumn) <select> list.
    function setSortOrderParameters (blnResetlstOrder) {
    
        if (blnResetlstOrder) {
            clearSelectList("lstOrder");

            switch (document.forms[0].lstColumn.options[document.forms[0].lstColumn.selectedIndex].text) {
                case "Year":
                    appendSelectList ("lstOrder", "Commodity/Attribute/Country", "Commodity/Attribute/Country");
                    appendSelectList ("lstOrder", "Commodity/Country/Attribute", "Commodity/Country/Attribute");
                    appendSelectList ("lstOrder", "Country/Commodity/Attribute", "Country/Commodity/Attribute");
                    appendSelectList ("lstOrder", "Country/Attribute/Commodity", "Country/Attribute/Commodity");
                    appendSelectList ("lstOrder", "Attribute/Commodity/Country", "Attribute/Commodity/Country");
                    appendSelectList ("lstOrder", "Attribute/Country/Commodity", "Attribute/Country/Commodity");
                    document.forms[0].chkMonthChange.disabled = false;
                    document.forms[0].chkTopCountries.checked = false;
                    document.forms[0].chkYearChange.disabled = false;
                    document.forms[0].chkTopCountries.disabled = false;
                    document.forms[0].lstTopCountries.selectedIndex = -1;
                    if (!document.all) deselectNonIEList(document.forms[0].lstTopCountries);
                    document.forms[0].lstTopCountries.disabled = true;
                    break;
                case "Attribute":
                    appendSelectList ("lstOrder", "Commodity/Year/Country", "Commodity/Year/Country");
                    appendSelectList ("lstOrder", "Commodity/Country/Year", "Commodity/Country/Year");
                    appendSelectList ("lstOrder", "Country/Commodity/Year", "Country/Commodity/Year");
                    appendSelectList ("lstOrder", "Country/Year/Commodity", "Country/Year/Commodity");
                    appendSelectList ("lstOrder", "Year/Commodity/Country", "Year/Commodity/Country");
                    appendSelectList ("lstOrder", "Year/Country/Commodity", "Year/Country/Commodity");
                    document.forms[0].chkTopCountries.checked = false;
                    document.forms[0].chkTopCountries.disabled = true;
                    document.forms[0].lstTopCountries.selectedIndex = -1;
                    if (!document.all) deselectNonIEList(document.forms[0].lstTopCountries);
                    document.forms[0].lstTopCountries.disabled = true;
                    document.forms[0].chkMonthChange.checked = false;
                    document.forms[0].chkMonthChange.disabled = true;
                    document.forms[0].chkYearChange.checked = false;
                    document.forms[0].chkYearChange.disabled = true;
                    break;
                case "Commodity":
                    appendSelectList ("lstOrder", "Attribute/Year/Country", "Attribute/Year/Country");
                    appendSelectList ("lstOrder", "Attribute/Country/Year", "Attribute/Country/Year");
                    appendSelectList ("lstOrder", "Country/Attribute/Year", "Country/Attribute/Year");
                    appendSelectList ("lstOrder", "Country/Year/Attribute", "Country/Year/Attribute");
                    appendSelectList ("lstOrder", "Year/Attribute/Country", "Year/Attribute/Country");
                    appendSelectList ("lstOrder", "Year/Country/Attribute", "Year/Country/Attribute");
                    document.forms[0].chkTopCountries.checked = false;
                    document.forms[0].chkTopCountries.disabled = true;
                    document.forms[0].lstTopCountries.selectedIndex = -1;
                    if (!document.all) deselectNonIEList(document.forms[0].lstTopCountries);
                    document.forms[0].lstTopCountries.disabled = true;
                    document.forms[0].chkMonthChange.checked = false;
                    document.forms[0].chkMonthChange.disabled = true;
                    document.forms[0].chkYearChange.checked = false;
                    document.forms[0].chkYearChange.disabled = true;
                    break;
                case "Country":
                    appendSelectList ("lstOrder", "Attribute/Year/Commodity", "Attribute/Year/Commodity");
                    appendSelectList ("lstOrder", "Attribute/Commodity/Year", "Attribute/Commodity/Year");
                    appendSelectList ("lstOrder", "Commodity/Attribute/Year", "Commodity/Attribute/Year");
                    appendSelectList ("lstOrder", "Commodity/Year/Attribute", "Commodity/Year/Attribute");
                    appendSelectList ("lstOrder", "Year/Attribute/Commodity", "Year/Attribute/Commodity");
                    appendSelectList ("lstOrder", "Year/Commodity/Attribute", "Year/Commodity/Attribute");
                    document.forms[0].chkTopCountries.checked = false;
                    document.forms[0].chkTopCountries.disabled = true;
                    document.forms[0].lstTopCountries.selectedIndex = -1;
                    if (!document.all) deselectNonIEList(document.forms[0].lstTopCountries);
                    document.forms[0].lstTopCountries.disabled = true;
                    document.forms[0].chkMonthChange.checked = false;
                    document.forms[0].chkMonthChange.disabled = true;
                    document.forms[0].chkYearChange.checked = false;
                    document.forms[0].chkYearChange.disabled = true;
                    break;
            }
        }
        
        if (document.forms[0].lstOrder.options[document.forms[0].lstOrder.selectedIndex].text == "Commodity/Attribute/Country" ||
            document.forms[0].lstOrder.options[document.forms[0].lstOrder.selectedIndex].text == "Attribute/Commodity/Country") {
            document.forms[0].chkTopCountries.checked = false;
            document.forms[0].chkTopCountries.disabled = false;
            document.forms[0].lstTopCountries.selectedIndex = -1;
            if (!document.all) deselectNonIEList(document.forms[0].lstTopCountries);
            document.forms[0].lstTopCountries.disabled = true;
            writeStatusMessage (DEFAULT_STATUS);
        }
        else {
            document.forms[0].chkTopCountries.checked = false;
            document.forms[0].chkTopCountries.disabled = true;
            document.forms[0].lstTopCountries.selectedIndex = -1;
            if (!document.all) deselectNonIEList(document.forms[0].lstTopCountries);
            document.forms[0].lstTopCountries.disabled = true;
            writeStatusMessage ("Top Countries are not available with selected sort order.  The last item must be a Country.");
        }
        
        // Set visual appearance of <label>s to reflect the .disabled property of the checkbox
        // or <select> list that they represent.
        document.getElementById("lblTopCountries").disabled = document.forms[0].chkTopCountries.disabled;
        document.getElementById("lblTopCountriesList").disabled = document.forms[0].lstTopCountries.disabled;
        document.getElementById("lblMonthChange").disabled = document.forms[0].chkMonthChange.disabled;
        document.getElementById("lblYearChange").disabled = document.forms[0].chkYearChange.disabled;
    }

//-------------------------------------------------------------------------------------------------
// 09/22/05 - Sonya 
// When "Include Month Change" is checked, automatically check the "Include Previous Month"
function chkMonthChange_clicked(chkMonthChange)
{
    if (chkMonthChange.checked == true)
	    document.forms[0].chkPrevMonth.checked = true;
}
//-------------------------------------------------------------------------------------------------
// 06/12/07 - Sonya 
// When "Include Previous Month" is UNchecked "Include Month Change" should be unchecked too
function chkPrevMonth_clicked(chkPrevMonth)
{
    if (chkPrevMonth.checked == false)
	    document.forms[0].chkMonthChange.checked = false;
}
//-------------------------------------------------------------------------------------------------
 
    function chkTopCountries_clicked (chkTopCountries) {
       
        document.forms[0].lstTopCountries.disabled = !chkTopCountries.checked;
        document.getElementById("lblTopCountriesList").disabled = document.forms[0].lstTopCountries.disabled;
         //added by Sonya 08/28/2006
      //  document.getElementById("lstCountry").selectedIndex = -1;
        document.getElementById("lstCountry").disabled = !document.forms[0].lstTopCountries.disabled;
        
        if (!chkTopCountries.checked) {
            document.forms[0].lstTopCountries.selectedIndex = -1;
            if (!document.all) deselectNonIEList(document.forms[0].lstTopCountries);
        }
        else // default to Top 10
            document.forms[0].lstTopCountries.selectedIndex = 2;
         
    }

//-------------------------------------------------------------------------------------------------
    // Envokes psdQueryFrameProcess.aspx to retrieve list of Commodities that
    // correspond to the Commodity Filter set via lstGroup.  psdQueryFrameProcess.aspx
    // will populate lstCommodity remotely via JavaScript.
    function loadCommodityList () {
        
        var strDefaultAction = document.forms[0].action
        var strDefaultTarget = document.forms[0].target

		document.forms[0].hidLoadCommodities.value = document.forms[0].lstGroup.options[document.forms[0].lstGroup.selectedIndex].value;
        document.forms[0].lstGroup.disabled = true;
		document.forms[0].target = "fraQueryProcess";
		document.forms[0].action = "psdQueryFrameProcess.aspx";
		document.forms[0].submit();
        
        document.forms[0].target = strDefaultTarget;
        document.forms[0].action = strDefaultAction;
    }

//-------------------------------------------------------------------------------------------------
    // Envokes psdQueryFrameProcess.aspx to retrieve list of Attributes (Data Type) that
    // correspond to the Commodity(s) selected via lstCommodity.  psdQueryFrameProcess.aspx
    // will populate lstAttribute remotely via JavaScript.
    function loadAttributeList () {
        
        var i;
        var countComm = 0;//to track number of selected commodities, 
        //if multiple comm selected disable prev month and month change check boxes
        //added by Sonya 08/27/2006
        
        var strDefaultAction = document.forms[0].action;
        var strDefaultTarget = document.forms[0].target;
	
		document.forms[0].hidLoadAttributes.value = "(";
		// Load comma delimited and quote enclosed values for selected items in lstCommodity
		// This step is being taken instead of simply submitting lstCommodity to 
		// psdQueryFrameProcess.aspx because lstCommodity will be disabled to prevent user
		// error.  Once lstCommodity is disabled, its value cannot be transmitted via a 
		// form submittal.
        for (i = 0; i <= document.forms[0].lstCommodity.options.length - 1; i++) {
			if (document.forms[0].lstCommodity.options[i].selected == true) {
				document.forms[0].hidLoadAttributes.value += "'" + document.forms[0].lstCommodity.options[i].value + "', ";
				countComm = countComm + 1; //increment countComm
			}
        }
               
        document.forms[0].chkMonthChange.disabled = false;
        document.forms[0].chkPrevMonth.disabled = false;
       
		if ( countComm > 1 )
		{
			document.forms[0].chkMonthChange.disabled = true;
			document.forms[0].chkPrevMonth.disabled = true;
		}
       
        // Remove trailing ", "
        document.forms[0].hidLoadAttributes.value = document.forms[0].hidLoadAttributes.value.substring(0, document.forms[0].hidLoadAttributes.value.length - 2);
		document.forms[0].hidLoadAttributes.value += ")";
        
        document.forms[0].lstCommodity.disabled = true;
		document.forms[0].target = "fraQueryProcess";
		document.forms[0].action = "psdQueryFrameProcess.aspx";
		document.forms[0].submit();
        
        document.forms[0].target = strDefaultTarget;
        document.forms[0].action = strDefaultAction;
    }

//-------------------------------------------------------------------------------------------------
    // Initialize the page controls for the initial loading of the page
    function initializePage () {
        if (document.forms[0].lstCommodity.length) {
            document.forms[0].chkCommoditySummary.disabled = false;
            
            
            //added by Sonya
//            
//              var i;
//        var countComm = 0;//to track number of selected commodities, 
//       
//             document.forms[0].hidLoadAttributes.value = "(";
//		    // Load comma delimited and quote enclosed values for selected items in lstCommodity
//		    // This step is being taken instead of simply submitting lstCommodity to 
//		    // psdQueryFrameProcess.aspx because lstCommodity will be disabled to prevent user
//		    // error.  Once lstCommodity is disabled, its value cannot be transmitted via a 
//		    // form submittal.
//            for (i = 0; i <= document.forms[0].lstCommodity.options.length - 1; i++) {
//			    if (document.forms[0].lstCommodity.options[i].selected == true) {
//				    document.forms[0].hidLoadAttributes.value += "'" + document.forms[0].lstCommodity.options[i].value + "', ";
//				    countComm = countComm + 1; //increment countComm
//			    }
//            }
//                
//              
//              // Remove trailing ", "
//                document.forms[0].hidLoadAttributes.value = document.forms[0].hidLoadAttributes.value.substring(0, document.forms[0].hidLoadAttributes.value.length - 2);
//		        document.forms[0].hidLoadAttributes.value += ")";
//        
//            
            //end 
        }
        setSortOrderParameters (true);
        writeStatusMessage (DEFAULT_STATUS);
    }

//-------------------------------------------------------------------------------------------------
    function writeStatusMessage (strMessage) {
        document.getElementById("tdStatusMessage").innerHTML = strMessage;
    }

//-------------------------------------------------------------------------------------------------
    function setNonIELabelStyle () {
        // Defined <label>s on psdQueryFrameDisplay.aspx with position:absolute <style>
        // for those that are assigned to checkboxes or <select> lists that can have
        // their .disabled properties changed dynamically through JavaScript.  This
        // was done to solve an anomaly whereby the labels would disappear whenever the
        // .disabled property of the control to which they were assigned was changed.
        // Having said this, it was discovered that the position:absolute <style> causes
        // the reverse effect in non-Internet Explorer browsers.  Therefore, this function
        // will be used to set the position to relative for such browsers.
        if (document.all) return;
        
        var ctrlLabels = document.getElementsByTagName("label")
        for (i = 0; i <= ctrlLabels.length - 1; i++) {
            if (("" + ctrlLabels.item(i).id).length) {
                document.getElementById(ctrlLabels.item(i).id).style.position = "relative";
            }
        }
    }

//-------------------------------------------------------------------------------------------------
    function deselectNonIEList (lstSelectList) {
        // Internet Explorer allows the deselection of all <options> within
        // a <select> list by simply setting the selectedIndex property to -1.
        // However, this does not work in Netscape.  Therefore, this function
        // will explicitly set each .selected value to false.
        var i
        for (i = 0; i <= lstSelectList.options.length - 1; i++) {
            lstSelectList.options[i].selected = false;
        }
    }

//-------------------------------------------------------------------------------------------------
    function closeQueryProcessWindow () {
	    if (("" + typeof winQueryProcess) == "object") {
		    if (winQueryProcess != null) {
			    if (!winQueryProcess.closed) {
				    winQueryProcess.close();
				    self.focus;
			    }
			    winQueryProcess = null;
		    }
	    }
    }
