/*************************************************************************
  This function controls the state of visibility for the calendar application
  filter box. It intercepts the HREF from a link and adds on the state
  of whether or not the filter box is visible. The filter can be either
  "on" or "off". This method adds "&filter=on|off"  to the HREF and 
  passes the new HREF to the server.
*************************************************************************/


function filteredHref(href){
    if(document.getElementById("filterDisplayed") != null) {
        var toggleInput = document.getElementById("filterDisplayed");
        var toggleInputValue = toggleInput.value;
     } else {
        var toggleInputValue = "off";
     }
     
    var filterText;
    var newhref;

    if(toggleInputValue == "on") {
        filterText = "&filter=on";
    } else {
        filterText = "&filter=off";
    }

    if(href.indexOf("#") == -1) {
        newhref = href + filterText;
    
    } else {
        var url = href.split("#");
        newhref = url[0] + filterText + "#" + url[1];
    }
    document.location.href = newhref;
}
