var _orgov = {

inDesignMode: false,

currentTopSite: null,

currentLocation: {

latitude: 45.5234515,

longitude: -122.6762071

}, //Default location is Portland

mapContainer: null,

map: null,

geocoder: null,

markers: {},

visibleMarkers: [],

myLocation: null,

infoWindow: null,

locationTypes: [],

 accordionTabbing: function() {

   $('.accordion .collapse').on('hidden', function () {

     $(this).attr("aria-expanded", "false");

     updateInnerLinks(this, '-1');

   });

   $('.accordion .collapse').on('shown', function () {

     $(this).attr("aria-expanded", "true");

     updateInnerLinks(this, '0');

   });

   

   function updateInnerLinks(parent, value) {

     $('a', parent).attr('tabindex', value);

   }

   

   $('.accordion .collapse').each(function() {

     updateInnerLinks(this, '-1');

   });

 },

getGoogleLatLong: function() {

return new google.maps.LatLng(this.currentLocation.latitude, this.currentLocation.longitude);

},

setUserLocation: function(lat, lng) {

_orgov.currentLocation.latitude = lat;

_orgov.currentLocation.longitude = lng;

_orgov.map.setCenter(_orgov.getGoogleLatLong());

_orgov.myLocation.position = _orgov.getGoogleLatLong();

_orgov.myLocation.setMap(_orgov.map);

$("#mapMsg").empty();

},

setMarkers: function(layer, opt) {

var markers = this.markers[layer];

for (var i = 0; i < markers.length; i++) {

markers[i].setVisible(opt);

}

},

showInfoWindow: function(marker) {

if (this.infoWindow) {

this.infoWindow.close();

}

if (marker.getVisible() === true) {

this.infoWindow = new google.maps.InfoWindow({

content: marker.get("content")

});

this.infoWindow.open(this.map, marker);

}

},

createMap: function() {

this.mapContainer = document.getElementById("map_canvas");

var opts = {

center: this.getGoogleLatLong(),

zoom: 11,

overviewMapControl: false

};

this.map = new google.maps.Map(this.mapContainer, opts);

var oregon_bounds = new google.maps.LatLngBounds(

new google.maps.LatLng(41.9917941, -124.6129365),

new google.maps.LatLng(46.2920157, -116.463262)

);

$("#mapInput").geocomplete({

bounds: oregon_bounds

}) //Enable geocomplete plugin functionality

.bind("geocode:result", function(event, result) {

$("#mapMsg").html("<i class=\"icon-refresh icon-spin\"></i> Locating...");

_orgov.setUserLocation(result.geometry.location.lat(), result.geometry.location.lng());

})

.bind("geocode:error", function(event, result) {

$("#mapMsg").addClass("achtung").html("We're sorry! There was a problem loading your map. Please try again. If the problem continues, please <a href=\"/Pages/help.aspx\">contact us</a> for help.");

});

this.setMapData();

},

setMapData: function() {

$().SPServices({

operation: "GetListItems",

webURL: _orgov.parentSite,

async: true,

listName: "Map Locations",

crossDomain: true,

CAMLViewFields: "<ViewFields><FieldRef Name=\"Title\" /><FieldRef Name=\"Address_x0020_1\" /><FieldRef Name=\"Address_x0020_2\" /><FieldRef Name=\"City\" /><FieldRef Name=\"State\" /><FieldRef Name=\"Zip\" /><FieldRef Name=\"Website\" /><FieldRef Name=\"Location_x0020_Type\" /><FieldRef Name=\"Latitude\" /><FieldRef Name=\"Longitude\" /><FieldRef Name=\"Phone\" /></ViewFields>",

CAMLQuery: "<Query><OrderBy><FieldRef Name=\"Location_x0020_Type\" Ascending=\"True\" /></OrderBy></Query>",

completefunc: function(data, status) {

if (status === "success") {

var currentTypeMarkers = [];

var currentType, hash;

$(data.responseXML).SPFilterNode("z:row").each(function() {

var checkData = function(str) {

if (typeof str === "undefined") {

str = "";

}

return str;

};

 

var type = $(this).attr("ows_Location_x0020_Type").split(";#")[1];

if (type !== currentType) {

_orgov.locationTypes.push(type);

if (currentTypeMarkers.length > 0) {

_orgov.markers[hash] = currentTypeMarkers;

}

currentType = type;

hash = currentType.replace(/ /g, "_");

currentTypeMarkers = [];

}

var content = "";

 

if (checkData($(this).attr("ows_Website")).length > 0) {

content = "<a title=\"Go to the " + $(this).attr("ows_Title") + " web site\" href=\"" + $(this).attr("ows_Website").split(",")[1] + "\"><strong>" + $(this).attr("ows_Title") + "</a></strong><br>";

} else {

content = "<strong>" + checkData($(this).attr("ows_Title")) + "</a></strong><br>";

}

content += checkData($(this).attr("ows_Address_x0020_1")) + "<br>";

if (checkData($(this).attr("ows_Address_x0020_2")).length > 0) {

content += $(this).attr("ows_Address_x0020_2") + "<br>";

}

content += checkData($(this).attr("ows_City")) + ", " + checkData($(this).attr("ows_State")) + " " + checkData($(this).attr("ows_Zip")) + "<br>";

content += checkData($(this).attr("ows_Phone"));

 

var marker = new google.maps.Marker({

position: new google.maps.LatLng(parseFloat($(this).attr("ows_Latitude")), parseFloat($(this).attr("ows_Longitude"))),

title: $(this).attr("ows_Title"),

map: _orgov.map,

content: content,

icon: "http://maps.google.com/mapfiles/ms/icons/red-dot.png"

});

if (typeof _orgov.mapIcons[hash] !== "undefined") {

marker.setIcon(_orgov.mapIcons[hash].icon);

}

marker.setMap(_orgov.map);

google.maps.event.addListener(marker, 'click', function() {

_orgov.showInfoWindow(marker);

});

currentTypeMarkers.push(marker);

});

_orgov.markers[hash] = currentTypeMarkers;

_orgov.buildLayerMenu();

 

_orgov.myLocation = new google.maps.Marker({

title: "My Location",

position: _orgov.getGoogleLatLong(),

zIndex: 1500,

icon: _orgov.mapIcons.mylocation.icon

});

_orgov.myLocation.setMap(_orgov.map);

 

//set map behaviors

google.maps.event.addListener(_orgov.map, 'bounds_changed', function() {

_orgov.listVisibleMarkerData();

});

$(document)

.on("mouseover", ".map-item", function(e) {

var ind = $(this).attr("data-visibleindex");

var icon = (typeof marker_type !== "undefined") ? marker_type.activeicon : "http://maps.google.com/mapfiles/ms/icons/blue-dot.png";

_orgov.visibleMarkers[ind].marker.setIcon(icon);

})

.on("mouseout", ".map-item", function(e) {

var ind = $(this).attr("data-visibleindex");

var marker_type = _orgov.mapIcons[$(this).attr("data-maptype")];

var icon = (typeof marker_type !== "undefined") ? marker_type.icon : "http://maps.google.com/mapfiles/ms/icons/red-dot.png";

_orgov.visibleMarkers[ind].marker.setIcon(icon);

})

.on("click", "#locateBtn", function(e) {

e.preventDefault();

$("#mapMsg").html("<i class=\"icon-refresh icon-spin\"></i> Locating...");

_orgov.getLocation(_orgov.setUserLocation);

})

.on("click", ".map-layer-item", function(e) {

e.stopPropagation();

var layer = $(this).attr("data-layer");

var hideLayer = ($(this).is(":checked")) ? true : false;

_orgov.setMarkers(layer, hideLayer);

_orgov.listVisibleMarkerData();

});

} else {

//Error handling if list data cannot be retrieved

$("#mapMsg").addClass("achtung").html("We're sorry! There was a problem loading your map. Please try again. If the problem continues, please <a href=\"/Pages/help.aspx\">contact us</a> for help.");

}

}

});

},

buildLayerMenu: function() {

var count = 0;

var html = "<button id=\"layerBtn\" type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\"><i class=\"icon-reorder\"></i> Filter Locations</button><ul id=\"layerMenu\" class=\"dropdown-menu\">";

for (var layer in _orgov.markers) {

if (_orgov.markers.hasOwnProperty(layer)) {

++count;

}

var full = layer.replace(/_/g, " ");

html += "<li>" + "<input class=\"map-layer-item\" data-layer=\"" + layer + "\" type=\"checkbox\" checked=\"checked\"> " + full + "</li>" + "</li>";

}

html += "</ul>";

if (count >= 2) {

$("#mapButtons").append(html);

}

},

findVisibleMarkers: function() {

var visible_markers = [];

for (var location_type in this.markers) {

var item = this.markers[location_type];

for (var i = 0; i < item.length; i++) {

if (_orgov.map.getBounds().contains(item[i].getPosition()) && item[i].getVisible()) {

var obj = {

"type": location_type,

"marker": item[i]

};

visible_markers.push(obj);

}

}

}

return visible_markers;

},

listVisibleMarkerData: function() {

this.visibleMarkers = this.findVisibleMarkers();

var html = "";

for (var i = 0; i < this.visibleMarkers.length; i++) {

html += "<div class=\"map-item\" data-maptype=\"" + this.visibleMarkers[i].type + "\" data-visibleindex=\"" + i + "\">" + this.visibleMarkers[i].marker.content + "</div>";

}

$("#map_results").html((html.length > 0) ? html : "<p>No results found.</p>");

},

setCookie: function(name, value, days) {

var expires, date;

if (days) {

date = new Date();

date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));

expires = "; expires=" + date.toGMTString();

} else {

expires = "";

}

document.cookie = name + "=" + value + expires + "; path=/";

},

getCookie: function(name) {

var nameEQ = name + "=";

var ca = document.cookie.split(';');

for (var i = 0; i < ca.length; i++) {

var c = ca[i];

while (c.charAt(0) === ' ') {

c = c.substring(1, c.length);

}

if (c.indexOf(nameEQ) === 0) {

return c.substring(nameEQ.length, c.length);

}

}

return null;

},

getParameterByName: function(name, string) {

string = string || window.location.search;

name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");

var regexS = "[\\?&]" + name + "=([^&#]*)";

var regex = new RegExp(regexS);

var results = regex.exec(string);

if (results === null) {

return "";

} else {

return decodeURIComponent(results[1].replace(/\+/g, " "));

}

},

locationNotFound: function(isEnabled) {

if (isEnabled) {

return "There was an error determining your location. Please try again later.";

} else {

return "Your browser does not support sharing current location data.";

}

},

getLocation: function(success) {

   var notFoundError = this.locationNotFound;

   

if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(function(p) {

success(p.coords.latitude, p.coords.longitude, p);

}, function(positionError) {

       

       if (positionError.code === 1)

         window.alert(notFoundError(false));

       else

         window.alert(notFoundError(true));

});

} else {

window.alert(notFoundError(false));

}

},

checkRibbon: function() {

if ($("#s4-ribbonrow").length > 0) {

$("html").addClass("ribboned");

}

},

setCurrentTopSite: function() {

for (var i = 0; i < this.subTopSites.length; i++) { // Iterates over subTopSites to see if any matches the current site

var topSitePath = this.parentSite + this.subTopSites[i];

     

if ($().SPServices.SPGetCurrentSite().toLowerCase() == topSitePath.toLowerCase()) { // If it matches the current URL path, set currentTopSite and break

this.currentTopSite = topSitePath;

break;

}

}

if (this.currentTopSite === null) { // If there was no match, fall back to parent site

this.currentTopSite = this.parentSite;

}

},

setBannerImage: function(banner) {

var alternateBannerImage = $("#alternateBannerImage img");

if (alternateBannerImage.length > 0) {

banner.css("background-image", "url(" + alternateBannerImage.attr("src") + ")");

}

banner.removeClass("noimage");

$("#alternateBannerImage").remove();

},

 getListItems: function(webUrl, listName, viewFields, query, callback) {

   var soapData = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>\

         <soap:Body>\

           <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>\

             <listName>" + listName + "</listName>\

             <viewName></viewName>\

             <query>" + (query || "") + "</query>\

             <viewFields><ViewFields>" + (viewFields || "") + "</ViewFields></viewFields>\

             <rowLimit>0</rowLimit>\

             <queryOptions><QueryOptions></QueryOptions></queryOptions>\

             </GetListItems>\

           </soap:Body>\

         </soap:Envelope>";

   

   var ajaxUrl = webUrl + (webUrl.endsWith("/") ? "" : "/") + "_vti_bin/Lists.asmx";

   

   $.ajax({

     async: true,

     complete: callback,

     contentType: "text/xml;charset='utf-8'",

     data: soapData,

     dataType: "xml",

     type: "POST",

     url: ajaxUrl

   });

 },

fetchSiteWideAlerts: function(webUrl) {

   

   

   this.getListItems(

     webUrl,

     "Site Wide Alert",

     "<FieldRef Name=\"Alert\" />",

     "<Query><Where><Eq><FieldRef Name=\"Display_x003f_\" /><Value Type=\"Boolean\">1</Value></Eq></Where></Query>",

     function (xhr, responseStatus) {

       if (responseStatus === "success") {

         var rows = $("listitems > * > *", xhr.responseXML)

         rows.each(function(index) {

           var rowEl = $(this);

           

           var alert = rowEl.attr("ows_Alert");

           var destinationEl = $("#alertPlaceholder");

           var renderedHtml = '<div class="achtung-wrapper"><div class="achtung container">' + alert + '</div></div>';

           

           destinationEl.empty().html(renderedHtml);

           

           setTimeout(function() {

             $(".achtung-wrapper").removeClass("achtung-hide");

           }, 500);

         });

         

       } else {

         console.error("Get List Items on Site Wide Alerts failed");

       }

       

       // "success" === t && $(e.responseXML).SPFilterNode("z:row").each(function() {

// var e = $(this).attr("ows_Alert");

// if ("undefined" != typeof e) {

// var t = '<div class="achtung-wrapper achtung-hide"><div class="achtung container">';

// t += e, t += "</div></div>", $("#alertPlaceholder").empty().html(t);

// var i = setTimeout(function() {

// $(".achtung-wrapper").removeClass("achtung-hide")

// }, 1e3)

// }

// })

       

       // if (responseStatus === "success") {

         // var rows = $("listitems > * > *", xhr.responseXML);

         

         // rows.each(function(index) {

           // var rowEl = $(this);

           // var title = rowEl.attr("ows_Title");

           // var content = rowEl.attr("ows_Footer_x0020_Column_x0020_1");

           // var columnNumber = rowEl.attr("ows_Column_x0020_Number");

           

           // var destinationEl = $("#footerColumn" + columnNumber);

           // var renderedHtml = "<h3>" + title + "</h3>" + content;

           

           // destinationEl.html(renderedHtml);

         // });

       // } else {

         // console.error("Get List Items on Site Wide Alerts failed");

       // }

     }

   )

   

// $().SPServices({

// operation: "GetListItems",

// webURL: e,

// async: !0,

// listName: "Site Wide Alert",

// crossDomain: !0,

// CAMLViewFields: '<ViewFields><FieldRef Name="Alert" /></ViewFields>',

// CAMLQuery: '<Query><Where><Eq><FieldRef Name="Display_x003f_" /><Value Type="Boolean">1</Value></Eq></Where></Query>',

// completefunc: function(e, t) {

// "success" === t && $(e.responseXML).SPFilterNode("z:row").each(function() {

// var e = $(this).attr("ows_Alert");

// if ("undefined" != typeof e) {

// var t = '<div class="achtung-wrapper achtung-hide"><div class="achtung container">';

// t += e, t += "</div></div>", $("#alertPlaceholder").empty().html(t);

// var i = setTimeout(function() {

// $(".achtung-wrapper").removeClass("achtung-hide")

// }, 1e3)

// }

// })

// }

// });

},

fetchFooterLinks: function(webUrl) {

   // Patch for host header sites in staging to prevent footer from failing. This should be handled differently in the future.

   // if (webUrl == "/" && window.location.hostname.indexOf("staging.apps") > -1) {

     // webUrl = _spPageContextInfo.siteServerRelativeUrl;

   // }

   

   this.getListItems(

     webUrl,

     "Footer Content",

     "<FieldRef Name=\"Title\" /><FieldRef Name=\"Footer_x0020_Column_x0020_1\" /><FieldRef Name=\"Column_x0020_Number\" />",

     "",

     function (xhr, responseStatus) {

       

       if (responseStatus === "success") {

         var rows = $("listitems > * > *", xhr.responseXML);

         

         rows.each(function(index) {

           var rowEl = $(this);

           var title = rowEl.attr("ows_Title");

           var content = rowEl.attr("ows_Footer_x0020_Column_x0020_1");

           var columnNumber = rowEl.attr("ows_Column_x0020_Number");

           

           var destinationEl = $("#footerColumn" + columnNumber);

           var renderedHtml = "<h3>" + title + "</h3>" + content;

           

           destinationEl.html(renderedHtml);

         });

       } else {

         console.error("Get List Items on Footer Content failed");

       }

     }

   )

   

// $().SPServices({

// operation: "GetListItems",

// webURL: webUrl,

     // async: true,

// listName: "Footer Content",

// CAMLViewFields: '<ViewFields><FieldRef Name="Title" /><FieldRef Name="Footer_x0020_Column_x0020_1" /><FieldRef Name="Column_x0020_Number" /></ViewFields>',

// completefunc: function(e, t) {

// "success" === t && $(e.responseXML).SPFilterNode("z:row").each(function() {

// var e = "<h3>" + $(this).attr("ows_Title") + "</h3>" + $(this).attr("ows_Footer_x0020_Column_x0020_1");

// $("#footerColumn" + $(this).attr("ows_Column_x0020_Number")).html(e);

// })

// }

// });

   // SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() {

     // console.log(arguments);

     

     // var siteUrl = _spPageContextInfo.siteServerRelativeUrl;

     // var clientContext = new SP.ClientContext(siteUrl);

     // var oList = clientContext.get_web().get_lists().getByTitle('Footer Content');

       

     // var camlQuery = new SP.CamlQuery();

     // camlQuery.set_viewXml('<ViewFields><FieldRef Name="Title" /><FieldRef Name="Footer_x0020_Column_x0020_1" /><FieldRef Name="Column_x0020_Number" /></ViewFields>');

     // this.collListItem = oList.getItems(camlQuery);

       

     // clientContext.load(collListItem);

       

     // clientContext.executeQueryAsync(

       // Function.createDelegate(

         // this,

         // function success() {

           // console.log('success');

         // }

       // ),

       // Function.createDelegate(

         // this,

         // function fail() {

           // console.log('failure');

         // }

       // )

     // );

 

   // });

},

initializeAgencyFeature: function() {

var s = $('.bxSlider');

$("#slider li").each(function() {

$("#sliderPager").append("<a data-slide-index=\"" + $(this).index() + "\" href=\"#\">" + $(this).attr("data-navcaption") + "</a> ");

});

s.bxSlider({

auto: false,

mode: 'fade',

easing: 'ease-in-out',

pagerCustom: '#sliderPager'

});

if (s.getSlideCount() === 1) {

$(".bx-wrapper").parent().addClass("singleitem");

s.stopAuto();

}

},

initializeAgencyTaskBoxes: function() {

// This piece is a hack to strip out zero width spaces that SharePoint CQWP is injecting into the page. The zero width spaces cause rendering issues in IE.

$("#task-boxes > .container > .row").each(function() {

           

     var richTextFieldEl = $('> .ms-rtestate-field', this).first();

     var legacySpanEl = $('> span', richTextFieldEl).first();

     

     if (legacySpanEl.length > 0) {

       // Legacy V4 span replacement method

       $(this).html(legacySpanEl.html());

     } else {

       // If there's no span tag, add wrapper around any and all task-box elements

       var taskboxesEl = $('.task-box', this);

       taskboxesEl.wrapAll($('<div class="task-box-wrapper"></div>'));

     }

     

//$(this).html($(this).find(".ms-rtestate-field > span").html())

});

$('.link-icon').hide();

$('.task').hover(function() {

$(this).find('.overlay').fadeIn(50);

var icon = $(this).find('.link-icon').show();

icon.removeClass('fadeOutDown').addClass('fadeInUp');

}, function() {

$(this).find('.overlay').fadeOut();

$(this).find('.link-icon').removeClass('fadeInUp').addClass('fadeOutDown');

});

},

initializeAgencyLeftNav: function() {

   var rootListItems = $('#nav-wrapper .root > li');

   

   $(rootListItems).each(function() {

var submenu = $('ul.static', this);

     var selectedLi = $('li.selected', this);

     var parentAnchor = $(this).find('.menu-item').not('.root ul .menu-item');

if (submenu.length > 0) {

if (selectedLi.length > 0) {

         var collapseEl = $("<a class=\"pull-left or-menutrigger\" href=\"#\" tabindex=\"0\"><i class=\"fa fa-minus-square-o icon-collapse-alt pull-left\"></i></a>");

         collapseEl.click(menuTriggerClicked);

         collapseEl.insertBefore(parentAnchor);

//parentAnchor.before("<a class=\"pull-left or-menutrigger\" href=\"#\" tabindex=\"0\"><i class=\"fa fa-minus-square-o icon-collapse-alt\"></i></a>");

} else {

         var collapseEl = $("<a class\"pull-left or-menutrigger\" href=\"#\" tabindex=\"0\"><i class=\"fa fa-plus-square-o icon-expand-alt pull-left\"></i></a>");

         collapseEl.click(menuTriggerClicked);

         collapseEl.insertBefore(parentAnchor);

//parentAnchor.before("<a class\"pull-left or-menutrigger\" href=\"#\" tabindex=\"0\"><i class=\"fa fa-plus-square-o icon-expand-alt\"></i></a>");

}

       

       parentAnchor.addClass('or-menutriggeranchor').attr('tabindex', '0');

}

     

});

   

   $('#nav-wrapper li').each(function() {

     var listItemEl = $(this);

     

     if (listItemEl.hasClass('selected')) {

       listItemEl.closest('ul:hidden').show();

       $('ul:hidden', listItemEl).show();

     }

   });

   

   

   function menuTriggerClicked(e) {

     e.preventDefault();

updateIcons($('i',this));

$(this).parent().find('ul.static').slideToggle(300);

   }

 

   $('span.or-menutriggeranchor').click(function() {

     updateIcons($('i', $(this).prev()));

     $(this).parent().find('ul.static').slideToggle(300);

   });

   // $('.or-menutrigger').keypress(function (e) {

     // if (e.keycode == 13) {

       // updateicons($(this).prev());

       // $(this).parent().find('ul.static').slidetoggle(300);

     // }

   // });

   

   function updateIcons(iconObject) {

     // Old fontawesome icons

if ($(iconObject).hasClass("icon-expand-alt")) {

$(iconObject).removeClass("icon-expand-alt").addClass("icon-collapse-alt");

} else {

$(iconObject).removeClass("icon-collapse-alt").addClass("icon-expand-alt");

}

//new fontawesome icons

if ($(iconObject).hasClass("fa-plus-square-o")) {

$(iconObject).removeClass("fa-plus-square-o").addClass("fa-minus-square-o");

} else {

$(iconObject).removeClass("fa-minus-square-o").addClass("fa-plus-square-o");

}

   }

},

 initializeFilterNav: function (noOfFilters) { // Pass in number of filter categories, currently only supports 1 or 2

   // Constants

   var FILTER_NAV_1_SELECTOR = "#filterNav";

   var FILTER_NAV_2_SELECTOR = "#filterAndNav";

   var FILTER_LIST_CLASS = "or-filterlist";

   var CHECKBOXES_SELECTOR = "input:checkbox";

   

   // Elements

   var filterNav1El;

   var filterNav1ColumnEl;

   var filterNav2El;

   var filterListEl;

   var checkbox1Els;

   var checkbox2Els;

   

   var searchWrapperEl;

   var searchHeaderEl;

   var searchInputEl;

   var searchSpinnerEl;

   var showHideWrapperEl;

   var showAllButtonEl;

   var hideAllButtonEl;

   var noResultsAlertEl;

   

   // Data Variables

   function Category(id, name, checkboxEl) {

     var self = this;

     

     this.id = id;

     this.name = name;

     this.checkboxEl = checkboxEl;

     this.selected = true;

   }

   

   var _categories = [];

   

   function addCategory(category) {

     _categories.push(category);

   }

   

   function getCategory(id) {

     for (var i = 0; i < _categories.length; i++) {

       var category = _categories[i];

       if (category.id == id) {

         return category;

       }

     }

   }

   

   function ListItem(el, content, categories) {

     var self = this;

     this.el = el;

     this.content = content;

     this.categories = categories;

     

     this.contains = function(text) {

       if (text == "")

         return true;

       if (content.indexOf(text.toLowerCase()) >= 0) {

         return true;

       }

       return false;

     }

     this.allCategoriesSelected = function() {

       for (var i = 0; i < self.categories.length; i++) {

         var category = self.categories[i];

         

         if (category == undefined)

           console.log(self);

         

         if (!category.selected)

           return false;

       }

       return true;

     }

   }

   

   var _listItems = [];

   

   function addListItem(listItem) {

     _listItems.push(listItem);

   }

   

   // UI Variables

   var keyupTimer;

   

   // Create Search Elements

   function createSearchSpinnerEl() {

     return $("<i class=\"fa fa-fw fa-spin fa-refresh or-filter-nav-spinner\"></i>");

   }

   

   function createSearchHeaderEl() {

     var el = $("<h4>Filter by search </h4>");

     searchSpinnerEl = createSearchSpinnerEl();

     

     el.append(searchSpinnerEl);

     searchSpinnerEl.hide();

     

     return el;

   }

   

   function createSearchInputEl() {

     return $("<input class=\"span3 or-filter-search\" type=\"text\" id=\"listFilter\" placeholder=\"Type to filter\">");

   }

   

   function createSearchWrapperEl() {

     var el = $("<div></div>");

     

     searchHeaderEl = createSearchHeaderEl();

     searchInputEl = createSearchInputEl();

     

     el.append(searchHeaderEl);

     el.append(searchInputEl);

     

     return el;

   }

   

   // Create Show/Hide Navigation

   function createShowAllButtonEl() {

     return $("<a class=\"or-filternav-showall\" href=\"#_\">Show all categories</a>");

   }

   

   function createHideAllButtonEl() {

     return $("<a class=\"or-filternav-hideall\" href=\"#_\">Hide all categories</a>");

   }

   

   function createShowHideWrapperEl() {

     var el = $("<div class=\"or-filternav-showhide\"></div>");

     showAllButtonEl = createShowAllButtonEl();

     hideAllButtonEl = createHideAllButtonEl();

     

     el.append(showAllButtonEl);

     el.append(" | ");

     el.append(hideAllButtonEl);

     

     return el;

   }

   

   // Attach Interface Elements to Page

   function attachElements() {

     $(' > li', filterListEl).each(function() {

       var listEl = $(this);

       var anchorEl = $(' > a', listEl);

       var classList = listEl.attr("class").split(/\s+/);

       

       for (var i = 0; i < classList.length; i++) {

         var cssClass = classList[i];

         if (cssClass.indexOf("or-category" > -1))

           anchorEl.prepend('<span class="' + cssClass + '"></span>');

       }

     });

   

     // Create and attach show/hide buttons

     showHideWrapperEl = createShowHideWrapperEl();

     filterNav1ColumnEl.prepend(showHideWrapperEl);

     

     // Create and attach search elements

     searchWrapperEl = createSearchWrapperEl();

     filterNav1ColumnEl.prepend(searchWrapperEl);

     

     // Create and attach "no results" message

     noResultsAlertEl = $("<div class=\"alert or-filter-nav-alert\">Your search did not match any items</div>");

     noResultsAlertEl.hide();

     noResultsAlertEl.insertBefore(filterListEl);

   }

   

   function checkAllCheckboxes() {

     checkbox1Els.prop('checked', true);

     checkbox2Els.prop('checked', true);

   }

   

   function uncheckAllCheckboxes() {

     checkbox1Els.prop('checked', false);

     checkbox2Els.prop('checked', false);

   }

   

   function parseCategory(checkboxEl) {

     var id = checkboxEl.val();

     

     

     var labelEl = checkboxEl.next();

     var name = labelEl.text();

     

     var category = new Category(id, name, checkboxEl);

     addCategory(category);

     

     checkboxEl.data('category', category);

   }

   

   function parseCategories() {

     checkbox1Els.each(function () {

       var checkboxEl = $(this);

       parseCategory(checkboxEl);

     });

     checkbox2Els.each(function () {

       var checkboxEl = $(this);

       parseCategory(checkboxEl);

     });

     console.log(_categories);

   }

   

   function parseListItem(listItemEl) {

     var listItemClasses = listItemEl.attr("class").split(" ");

     var categories = [];

     

     var content = listItemEl.text().toLowerCase();

 

     for (var i = 0; i < listItemClasses.length; i++) {

       var listItemClass = listItemClasses[i];

       

       if (listItemClass != 'hidden' && listItemClass != '') {

         var category = getCategory(listItemClass);

         if (category != null)

           categories.push(category);

       }

     }

     

     addListItem(new ListItem(listItemEl, content, categories));

   }

   

   function parseListItems() {

     var listItemEls = $('> li', filterListEl);

     

     listItemEls.each(function () {

       var listItemEl = $(this);

       parseListItem(listItemEl);

     });

     console.log(_listItems);

   }

   

   function updateResults() {

     var atLeastOneResult = false;

     

     for (var i = 0; i < _listItems.length; i++) {

       var listItem = _listItems[i];

       

       if (listItem.contains(searchInputEl.val()) && listItem.allCategoriesSelected()) {

         if (listItem.el.hasClass('hidden'))

           listItem.el.removeClass('hidden');

         atLeastOneResult = true;

       } else {

         if (!listItem.el.hasClass('hidden'))

           listItem.el.addClass('hidden');

       }

     }

     

     if (atLeastOneResult) {

       noResultsAlertEl.hide();

     } else {

       noResultsAlertEl.show();

     }

   }

   

   function onCheckboxChange(checkboxEl) {

     var category = checkboxEl.data('category');

     category.selected = checkboxEl.is(':checked');

     

     updateResults();

   }

   

   function showAllClicked() {

     checkAllCheckboxes();

     for (var i = 0; i < _categories.length; i++) {

       var category = _categories[i];

       category.selected = true;

     }

     updateResults();

   }

   

   function hideAllClicked() {

     uncheckAllCheckboxes();

     for (var i = 0; i < _categories.length; i++) {

       var category = _categories[i];

       category.selected = false;

     }

     updateResults();

   }

   

   function onSearchInputChange() {

     searchSpinnerEl.show();

     clearTimeout(keyupTimer);

     keyupTimer = setTimeout(function() {

       searchSpinnerEl.hide();

       updateResults();

     }, 200);

   }

 

   

   function attachEventListeners() {

     checkbox1Els.on('click touchstart', function() { onCheckboxChange($(this)); });

     checkbox2Els.on('click touchstart', function() { onCheckboxChange($(this)); });

     searchInputEl.on('keyup change paste input', onSearchInputChange);

     showAllButtonEl.on('click', showAllClicked);

     hideAllButtonEl.on('click', hideAllClicked);

   }

   

   // Init

   var initialize = function() {

     // Get elements rendered by webparts

     filterNav1El = $(FILTER_NAV_1_SELECTOR);

     filterNav1ColumnEl = filterNav1El.closest("#aside");

     filterNav2El = $(FILTER_NAV_2_SELECTOR);

     filterListEl = $("." + FILTER_LIST_CLASS);

     checkbox1Els = $(CHECKBOXES_SELECTOR, filterNav1El);

     checkbox2Els = $(CHECKBOXES_SELECTOR, filterNav2El);

     

     // Attach additional UI elements

     attachElements();

     

     // Check all checkboxes to start

     checkAllCheckboxes();

     

     // Parse categories from checkboxes

     parseCategories();

     

     // Parse list items from li elements

     parseListItems();

     

     // Finally, attach all the event listeners

     attachEventListeners();

   };

   $(initialize);

 

   /* var filterSearchInput = null;

   var spinner = null;

   var noResultsAlert = null;

   var filterResults = $("#filterResults li");

   var checkboxes1 = $("#filterNav input:checkbox");

   var checkboxes2 = $("#filterAndNav input:checkbox");

   var selectedCategories1 = [];

   var selectedCategories2 = [];

   var keyupTimer;

   var spinnerTimer;

 

   function init() {

     createUI();

     spinner.hide();

     noResultsAlert.hide();

     checkAllBoxes(checkboxes1);

     checkAllBoxes(checkboxes2);

     selectedCategories1 = getSelectedCategories(checkboxes1);

     selectedCategories2 = getSelectedCategories(checkboxes2);

   }

 

   // Builds necessary UI elements and populates variables that reference them

   function createUI() {

     $("#aside").prepend("<h4>Filter by search <i class=\"fa fa-fw fa-spin fa-refresh or-filter-nav-spinner\"></i></h4><input class=\"span3 or-filter-search\" type=\"text\" id=\"listFilter\" placeholder=\"Type to filter\">");

     $("#filterNav").prepend("<div class=\"or-filternav-showhide\"><a class=\"or-filternav-showall\" href=\"#_\">Show all categories</a> | <a class=\"or-filternav-hideall\" href=\"#_\">Hide all categories</a></div>");

     $("<div class=\"alert or-filter-nav-alert\">No results match your criteria</div>").insertBefore("#filterResults");

     

     createColorBoxElements();

 

     filterSearchInput = $("#listFilter");

     spinner = $(".or-filter-nav-spinner");

     noResultsAlert = $(".or-filter-nav-alert");

   }

   

   function createColorBoxElements() {

     $(filterResults).each(function(i, node) {

       var listItemEl = $(this);

       var listItemClass = listItemEl.attr("class");

       

       var checkboxWrapperEl = $(listItemClass, ".or-filternav");

       var categoryLabelEl = $("label", checkboxWrapperEl);

       

       var categoryLabelText = categoryLabelEl.text();

       

       var anchorEl = $("a:first-child", listItemEl);

       anchorEl.prepend('<span class="' + listItemClass + '" title="' + categoryLabelText + '"></span>');

     });

   }

 

   // Pass in list of checkboxes and check them all and vice versa

   function checkAllBoxes(checkboxes) { $(checkboxes).each(function () { this.checked = true; });}

   function uncheckAllBoxes(checkboxes) { $(checkboxes).each(function () { this.checked = false; });}

 

   // Pulls category name from value attribute ("or-category-1", etc.) of currently selected checkboxes and returns array of selected categories.

   function getSelectedCategories(checkboxes) {

     var selectedCategories = [];

 

     $(checkboxes).each(function () {

       if ($(this).prop("checked")) {

         selectedCategories.push($(this).attr("value").toString());

       }

     });

 

     return selectedCategories;

   }

 

   // Update results based on current filter criteria

   function updateResults() {

     var searchValue = filterSearchInput.val();

     var matchCount = 0;

     

     if (noOfFilters == 1) { // Checks to see how many filters are there to know how many to test

       filterResults.each(function() {

         if (itemContainsQuery(searchValue, this) && itemInSelectedCategory(selectedCategories1, this)) { // An item must meet both tests to be shown

           $(this).show();

           matchCount++;

         } else {

           $(this).hide();

         }

       });

     } else if (noOfFilters == 2) {

       filterResults.each(function() {

         if (itemContainsQuery(searchValue, this) && itemInSelectedCategory(selectedCategories1, this) && itemInSelectedCategory(selectedCategories2, this)) { // An item must meet all three tests to be shown

           $(this).show();

           matchCount++;

         } else {

           $(this).hide();

         }

       });

     }

 

     if (matchCount == 0) {

       noResultsAlert.show();

     } else {

       noResultsAlert.hide();

     }

 

     spinnerTimer = setTimeout(function () { spinner.hide(); }, 200);

   }

 

   // Tests whether an item contains the search text

   function itemContainsQuery(query, listItem) {

     textToCheck = $(listItem).text().toLowerCase();

 

     if (textToCheck.indexOf(query.toLowerCase()) >= 0) {

       return true;

     } else {

       return false;

     }

   }

 

   // Pass in an array of category names and test whether an item matches any currently selected category

   function itemInSelectedCategory(selectedCategories, listItem) {

     for (var i = 0; i < selectedCategories.length; i++) { // Iterate over categories to see if listItem matches

       if ($(listItem).hasClass(selectedCategories[i])) {

         return true;

       }

     }

     return false;

   }

 

   // Initialize the component

   init();

 

   // Attach event listeners

   $("#listFilter").on("keyup change paste input", function() {

     clearTimeout(spinnerTimer);

     spinner.show();

     clearTimeout(keyupTimer);

     keyupTimer = setTimeout(function() { updateResults(); }, 200);

   });

   $("[name='filternav-checkbox']").on("click touchstart", function () {

     selectedCategories1 = getSelectedCategories(checkboxes1); // Only parse category names from checkbox value attributes when values have changed.

     selectedCategories2 = getSelectedCategories(checkboxes2);

     updateResults();

   });

   $(".or-filternav-showall").on("touchstart click", function() {

     checkAllBoxes(checkboxes1);

     checkAllBoxes(checkboxes2);

     selectedCategories1 = getSelectedCategories(checkboxes1);

     selectedCategories2 = getSelectedCategories(checkboxes2);

     updateResults();

   });

   $(".or-filternav-hideall").on("touchstart click", function() {

     uncheckAllBoxes(checkboxes1);

     uncheckAllBoxes(checkboxes2);

     selectedCategories1 = getSelectedCategories(checkboxes1);

     selectedCategories2 = getSelectedCategories(checkboxes2);

     updateResults();

   }); */

 },

bootstrapTopNav: function() {

$("#portalBar .root").attr("role", "navigation").find("li > ul").each(function(ind) {

$(this).addClass("dropdown-menu").attr("role", "menu").attr("aria-labelledby", "drop" + ind);

$(this).find(">li").attr("role", "presentation").find("> a").attr("role", "menuitem").attr("tabindex", "-1");

$(this).parentsUntil("ul")

.addClass("dropdown")

.find("> a")

.addClass("dropdown-toggle")

.attr("role", "button")

.attr("data-toggle", "dropdown")

.attr("id", "drop" + ind++)

.find("span span")

.append("<b class=\"caret\"></b>");

});

},

embedMedia: function() {

if (!this.inDesignMode) {

$("#primaryContent div.or-rteElement-embedded, #primaryContent div.ms-rteElement-embedded").each(function() {

var html = $(this).html();

var embed, yt;

if (html.indexOf("youtu.be") !== -1) {

yt = /(?:.+)youtu\.be\/([0-9a-zA-Z-]*)/g;

} else {

yt = /(?:.+)youtube\.com?(?:.+)(?:v=([0-9a-zA-Z-]*))/g;

}

embed = html.replace(yt, "<div class=\"videoWrapper\"><iframe width=\"530\" height=\"350\" src=\"http://www.youtube.com/embed/$1?rel=0\" frameborder=\"0\" allowfullscreen></iframe></div>");

$(this).html(embed);

});

}

},

initializeSearch: function() {

var handleSearch = function(e) {

e.preventDefault();

var searchTerm = "";

searchTerm = document.getElementById('searchBox').value;

var qs = '?cx=005482606056434223770:uq7asij-tbc&cof=FORID%3A10&ie=UTF-8&q=' + encodeURIComponent(searchTerm).replace(/%20/g, '+').replace(/%22/g, '\\"');

var siteScope = '&as_siteSearch=oregon.gov' + encodeURIComponent(_orgov.parentSite);

document.location.href = _orgov.parentSite + "_layouts/OID.Web.V3/Pages/SearchResults.aspx" + qs + siteScope;

};

 

if ($("#___gcse_0").length > 0) {

//Set up Google Custom Search

this.initializeSearchListener();

} else {

$("#portalbarGoButton").click(function(e) {

handleSearch(e);

});

$("#searchBox").keydown(function(e) {

if (_orgov.isEnter(e)) {

handleSearch(e);

}

});

}

},

// Google Custom Search initialization -- DEPRECATED

initializeSearchListener: function() {

$("#search").bind("DOMSubtreeModified", function() {

if ($(".gsc-results-wrapper-overlay").length > 0) {

$("#search").unbind("DOMSubtreeModified");

$(".gsc-results-wrapper-overlay").bind("DOMSubtreeModified", function() {

var searchterm;

if ($(".gsc-cursor-box").length > 0 && $("#googlePortalSearchLink").length === 0) {

searchterm = $("#gsc-i-id1").val();

$(".gsc-cursor-box").append(" -&nbsp;&nbsp;<span id=\"googlePortalSearchLink\"><a href=\"http://www.oregon.gov/Pages/index.aspx#search?q=" + searchterm + "\">Search all of Oregon.gov for \"" + searchterm + "\"</a></span>");

} else if ($(".gs-no-results-result").length > 0 && $("#googlePortalSearchLink").length === 0) {

searchterm = $("#gsc-i-id1").val();

$(".gs-no-results-result").append("<span id=\"googlePortalSearchLink\"><a href=\"http://www.oregon.gov/Pages/index.aspx#search?q=" + searchterm + "\">Search all of Oregon.gov for \"" + searchterm + "\"</a></span>");

}

});

}

});

},

attachAnalyticsListeners: function(anchors) {

anchors.each(function() {

if (this.protocol && this.protocol === "mailto:") {

$(this).attr("onClick", "_orgov.trackOutboundLink(this, \"Mailto Links\", \'" + $(this).attr("href") + "\");");

} else if (this.getAttribute("id") === "whoson_chat_link" || this.getAttribute("id") === "serffLink") {

return;

} else if (this.hostname && (this.hostname).split(":")[0] === (location.hostname).split(":")[0]) {

var path = this.pathname + this.search;

var isDoc = path.match(/\.(?:doc|dot|docx|dotx|eps|jpg|png|svg|xls|xlt|xlsx|xlst|ppt|pps|pptx|ppsx|pot|potx|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mpg|mpeg|mp3)($|\&|\?)/i);

if (isDoc) {

$(this).attr("onClick", "_orgov.trackOutboundLink(this, \"Document Links\", \"" + $(this).attr("href") + "\");");

}

} else if (this.hostname && (this.hostname).split(":")[0] !== (location.hostname).split(":")[0]) {

$(this).attr("onClick", "_orgov.trackOutboundLink(this, \"Outbound Links\", \"" + $(this).attr("href") + "\");");

}

});

},

trackOutboundLink: function(link, category, action) {

_gaq.push(['_trackEvent', category, action]);

},

isEnter: function(e) {

return (e.which === 13) ? true : false;

},

encodeTerm: function(q) {

var encoded = escape(q);

encoded = encoded.replace(/\//g, "%2F");

encoded = encoded.replace(/\?/g, "%3F");

encoded = encoded.replace(/=/g, "%3D");

encoded = encoded.replace(/&/g, "%26");

encoded = encoded.replace(/@/g, "%40");

return encoded;

},

attachSocialMedia: function(path) {

var icons = {

Facebook: "fa-facebook-square",

Twitter: "fa-twitter-square",

YouTube: "fa-youtube-square",

GooglePlus: "fa-google-plus-square",

Flickr: "fa-flickr",

Instagram: "fa-instagram",

Vine: "fa-vine",

Vimeo: "fa-vimeo-square",

Blog: "fa-rss-square"

};

   

$().SPServices({

operation: "GetListItems",

webURL: path,

async: true,

listName: "Social Media Assets",

crossDomain: true,

CAMLQuery: "<Query><Where><Eq><FieldRef Name=\"Display\" /><Value Type=\"Boolean\">1</Value></Eq></Where><OrderBy><FieldRef Name=\"Service\" Ascending=\"True\" /></OrderBy></Query>",

CAMLViewFields: "<ViewFields><FieldRef Name=\"Title\" /><FieldRef Name=\"Link\" /><FieldRef Name=\"Service\" /></ViewFields>",

completefunc: function(data, status) {

if (status === "success") {

var html = "<div id=\"agencyConnect\"><i class=\"fa fa-facebook-square\"></i> <i class=\"fa fa-twitter-square\"></i> <i class=\"fa fa-youtube-square\"></i><div id=\"socialMediaList\" class=\"agency-medialist\">";

html += "<h3>Stay Connected</h3>";

$(data.responseXML).SPFilterNode("z:row").each(function() {

var icon = "<i class=\"fa " + (icons[$(this).attr("ows_Service")] || "fa-share-alt") + "\"></i> ";

var link = $(this).attr("ows_Link").split(", ");

html += "<div class=\"agency-medialist-item\"><a href=\"" + link[0] + "\">" + icon + link[1] + "</a></div>";

});

html += "</div></div>";

$("footer .translator").after(html);

} else {

console.log("An error has occured fetching Social Media Assets list");

}

}

});

},

initializeAgencyDirectory: function(agencyDirectory) {

var html = "<div id=\"directoryNav\"><h3>Jump To</h3>";

agencyDirectory.find("h3.or-sectiontitle").each(function() {

var text = $(this).text();

var id = "or-" + text.replace(/ /g, "").toLowerCase();

$(this).attr("id", id);

var anchor = "<a href=\"#" + id + "\">" + text + "</a>";

html += anchor;

});

html += "</div>";

$("#aside").prepend(html);

},

initializeVideoLibrary: function() {

$(".or-videoblock img").click(function() {

var vid = $(this).attr("data-videonumber");

$("#" + vid).addClass("active");

});

$(".or-close").click(function() {

$("#" + $(this).attr("data-videonumber")).removeClass("active");

});

$(".or-videowrapper").each(function() {

var width = $(this).find("iframe").attr("width") + "px";

$(this).css("width", width);

});

},

handleMultipleAccordions: function() {

var ind = 0;

$(".accordion").each(function() {

var newID = $(this).attr("id") + ind++;

$(this).attr("id", newID);

$(this).find(".accordion-heading > a").each(function() {

$(this).attr("data-parent", "#" + newID);

});

});

},

//Flexbox polyfill adapted from http://osvaldas.info/flexbox-based-responsive-equal-height-blocks-with-javascript-fallback

patchFlexBox: function() {

var $list = $("#task-boxes .row"),

$items = $list.find(".task-box"),

setHeights = function() {

$items.css("height", "auto");

var perRow = Math.floor($list.width() / $items.width());

if (perRow === null || perRow < 2) {

return true;

}

for (var i = 0, j = $items.length; i < j; i += perRow) {

var maxHeight = 0,

$row = $items.slice(i, i + perRow);

maxHeight = getRowMaxHeight($row, maxHeight);

$row.css("height", maxHeight);

}

},

getRowMaxHeight = function($row, maxHeight) {

$row.each(function() {

var itemHeight = parseInt($(this).outerHeight());

if (itemHeight > maxHeight) {

maxHeight = itemHeight;

}

});

return maxHeight;

};

 

setHeights();

$(window).on("resize", setHeights);

//$list.find( "img" ).on( "load", setHeights );

},

recordsRequest: {

initialize: function() {

$(".gov-recrequest-info").click(function() {

var description = $(this).next();

if (description.hasClass("active")) {

description.removeClass("active");

} else {

$(".gov-recrequest-desc").removeClass("active");

description.addClass("active");

}

});

$(".gov-recrequest-info").hover(

function() {

$(this).next().addClass("hovered");

},

function() {

$(this).next().removeClass("hovered");

}

);

$(".gov-recrequest-desc").hover(

function() {

$(this).prev().addClass("hovered");

},

function() {

$(this).prev().removeClass("hovered");

}

);

 

}

},

 sortSiteMap: function() {    

   function sortUL(selector) {

     // Use javascript's native sort method and jquery append to alphabetize sitemap list

     $(selector).children("li").sort(function(a, b) {

       var upA = $('a', a).text().toUpperCase(); // Grab the inner <a> tag text and compare case-insensitive

       var upB = $('a', b).text().toUpperCase();

       return (upA < upB) ? -1 : (upA > upB) ? 1 : 0; // Return 0, -1, or 1 to the js sort method to determine new order of items in array

     }).appendTo(selector);

   }

   

   $('.siteMapSite > ul').each(function() {

     sortUL($(this)); // Call the method

   });

   

   $('ul.siteMap').closest('div.hidden').removeClass('hidden'); // Don't show the list until it's been sorted.

 },

agencyInitialization: function() {

if (this.inDesignMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value, this.inDesignMode) {

     $("html").addClass("designmode");

   } else {

var e = $("#bannerSplash");

e.length > 0 && this.setBannerImage(e)

}

if (Modernizr.mq("only all and (min-width: 480px)")) {

     this.attachSocialMedia(this.parentSite);

   }

   this.bootstrapTopNav();

   this.setCurrentTopSite();

 

   this.fetchFooterLinks(this.currentTopSite);

   this.fetchSiteWideAlerts(this.parentSite);

   

   this.checkRibbon();

   this.embedMedia();

   this.initializeSearch();

   $(window).stellar();

   if ($(".accordion").length > 0) {

     this.accordionTabbing();

   }

   if ($(".accordion").length > 1) {

     this.handleMultipleAccordions();

   }

   if ($(".bxSlider").length > 0) {

     this.initializeAgencyFeature();

   }

   if ($(".task").length > 0) {

     this.initializeAgencyTaskBoxes();

   }

   if ($("#nav-wrapper").length > 0) {

     this.initializeAgencyLeftNav();

   }

   if ($("#filterNav").length > 0 && $("#filterAndNav").length === 0) {

     this.initializeFilterNav(1);

   }

   if ($("#filterNav").length > 0 && $("#filterAndNav").length > 0) {

     this.initializeFilterNav(2);

   }

   if ($("#map_canvas").length > 0) {

     this.createMap();

   }

   if ($("#videoLibrary").length > 0) {

     this.initializeVideoLibrary();

   }

   if ($(".no-flexbox #task-boxes").length > 0) {

     this.patchFlexBox();

   }

   if ($('ul.siteMap').length > 0) {

     this.sortSiteMap();

   }

var agencyDirectory = $("#agencyDirectory");

if (agencyDirectory.length > 0) {

     this.initializeAgencyDirectory(agencyDirectory);

   }

   if ($(".gov-recrequest").length > 0) {

     this.recordsRequest.initialize();

   }

}

};