/* toggles range control */
function toggleListFilter(name)
{
   var divname = 'list_filter_' + name;
   var divhide = 'list_filter_hide_' + name;
   var divshow = 'list_filter_show_' + name;

   if (document.getElementById(divname).style.visibility == "visible")
   {
      hideDiv(divname);
      showDiv(divshow);
      hideDiv(divhide);
   }
   else
   {
      showDiv(divname);
      showDiv(divhide);
      hideDiv(divshow);
   }
}

/* toggles list configuration */
function toggleListConfiguration(name)
{
   var divname = 'list_config_' + name;
   var divhide = 'list_config_hide_' + name;
   var divshow = 'list_config_show_' + name;

   if (document.getElementById(divname).style.visibility == "visible")
   {
      hideDiv(divname);
      showDiv(divshow);
      hideDiv(divhide);
   }
   else
   {
      showDiv(divname);
      showDiv(divhide);
      hideDiv(divshow);
   }
}

/* toggles list configuration */
function toggleListConfigurationNavBar(name)
{
   var divname = 'list_config_' + name;

   if (document.getElementById(divname).style.visibility == "visible")
   {
      hideDiv(divname);
   }
   else
   {
      showDiv(divname);
   }
}

function toggleListHeight(name)
{
   var divname = 'list_height_' + name;
   var divcollapse = 'list_collapse_' + name;
   var divexpand = 'list_expand_' + name;

   if (document.getElementById(divname).style.overflow == "auto")
   {
      document.getElementById(divname).style.overflow = "visible";

      showDiv(divcollapse);
      hideDiv(divexpand);
   }
   else
   {
      document.getElementById(divname).style.overflow = "auto";

      showDiv(divexpand);
      hideDiv(divcollapse);
   }
}

function toggleSecondFilter(name,typeCombo,aCount)
{
   var index=typeCombo.selectedIndex
   var type =typeCombo.options[index].value

   if (type == "between")
   {
      for (x=1;x<=aCount;x++)
      {
         var divname = name + '_filterDiv' + String(x);
         showDiv(divname);
      }
   }
   else
   {
      for (x=1;x<=aCount;x++)
      {
         var divname = name + '_filterDiv' + String(x);
         hideDiv(divname);
      }
   }
}

function hideDiv(divname)
{
   document.getElementById(divname).style.visibility = "hidden";
   document.getElementById(divname).style.display = "none";
}

function showDiv(divname)
{
   document.getElementById(divname).style.visibility = "visible";
   document.getElementById(divname).style.display = "block";
}

/* Scripts for the dual listbox */
function changeSecondList(dual_list_name,parentlist,childlist)
{
   var parentselectedindex = parentlist.selectedIndex;

   var childtext = eval(dual_list_name + "_text_" + parentselectedindex);
   var childvalue = eval(dual_list_name + "_value_" + parentselectedindex);

   var childlength = childlist.options.length;

   for (i=0; i<childlength; i++)
   {
      childlist.options.remove(0);
   }

   for (i=0; i<childtext.length; i++)
   {
      var newoption = document.createElement("<option>");
      childlist.options.add(newoption);
      newoption.innerText = childtext[i];
      newoption.value = childvalue[i];
   }

   if (childtext.length > 0)
   {
      childlist.selectedIndex = 0;
   }
}

/* dual listbox (combo-input) */
function changeSecondHidden(dual_list_name,parentlist,childlist)
{
   var parentselectedindex = parentlist.selectedIndex;
   var childvalue = eval(dual_list_name + "_value_" + parentselectedindex);

   for (i=0; i<childvalue.length; i++)
   {
      childlist.value = childvalue[i];
   }
}

/* view in excel */
function viewInExcel(name)
{
   var wnd="";
   var options="";
   var loc="?"+name+".viewInExcel=true";
   var myWindow = window.open (loc, wnd, options);
   if (navigator.appName=='Netscape') { myWindow.focus(); }
}

/* Scripts for checkboxes */
function changeCheckbox(id,checkctl,ontrue,onfalse)
{
	if (checkctl.checked == true)
	{
		document.getElementById(id).value = ontrue;
	}
	else
	{
		document.getElementById(id).value = onfalse;
	}
}
