////////////////////////////////////////////////
//  SET FILTER FIELDS BEFORE SUMBITTING FORM  //
////////////////////////////////////////////////
function set_filter_fields(field_title)
{
    // reference the form
    var filter_form = document.getElementById('filters');

    // if it's the month field, values don't need to reset
    if (field_title != "month")
    {
        // reference all <select> fields
        var fields = document.getElementsByTagName('select');

        // whether looping has passed the changed field that is passed in
        var passed = false;

        // for each field
        for (var i = 0; i < fields.length; i++)
        {
            // if it's passed the changed one and it's not the month field
            if (passed == true)
            {
              // remove it's invalid value
              fields[i].value = "";
            }

            // if it's not passed and this field is the changed field
            else if ( fields[i].id == field_title )
            {
              // all others are passed
              passed = true;
            };
        };

    };

    // submit the form
    filter_form.submit();
};



///////////////////////
//  OPEN NEW WINDOW  //
///////////////////////
var popup_window;
function open_columns(detail, page_title)
{
  var details_window;
  var qs = "";
  var qsobj = getQueryObject();
  qsobj.detail = detail;


  // for each existing property
  for (prop in qsobj)
  {
    // if it's not the first variable
    if (qs.length > 0)
    {
      qs += "&";
    }

    // if it's the first variable
    else
    {
      qs += "?";
    };

    qs += (prop + "=" + qsobj[prop]);
  };
  
  // go to the details
  popup_window = window.open(page_title + "_slim.php" + qs, 'popup_window_name', 'width=790,height=500');
  popup_window.focus();
};

