	/**
	 * This class will query the Baynote server
	 * 
	 * By default, it will query against the MostPopular guides
	 */
	function BaynoteGuides(guide)
	{
		this.baynoteDiv = "baynote_guides";
		this.requests = 0;
		this.baynoteGuide = "MostPopular";
		this.baynoteDivClass = "baynote_guides";
		this.callback = null;
		this.callbackParams = null;
		// Omniture Tracking
		this.omnitureTrack = true;
		this.omniturePageName = "Home";
		this.omniturePageSubName = "Top 10 Answers";
		this.omniturePageValue = "FAQ";
	}
	
	/**
	 * This will allow you to specify the div that will be populated with the result set
	 * 
	 * @param {Object} div
	 */
	BaynoteGuides.prototype.setDiv = function(div)
	{
		this.baynoteDiv = div;
	}
	
	/**
	 * This will apply the supplied class to the out ol tag
	 * 
	 * @param {Object} class
	 */
	BaynoteGuides.prototype.setDivClass = function(cssClass)
	{
		this.baynoteDivClass = cssClass;
	}
	
	/**
	 * This will allow you to specify the guide to query
	 * 
	 * @param {Object} guide
	 */
	BaynoteGuides.prototype.setGuide = function(guide)
	{
		this.baynoteGuide = guide;		
	}
	
	/**
	 * This will make a GET request to the Baynote server and return the response
	 * 
	 * @param {Object} attrFilter
	 * @param {Object} resultsPerPage
	 * @param {Object} hardCodedValues
	 */
	BaynoteGuides.prototype.get = function(attrFilter, resultsPerPage, hardCodedValues)
	{
		var obj = this;
		obj.requests++;
		if (hardCodedValues == null) hardCodedValues = [];
				
		$.ajax({
			type: "GET",
			url: "/support/fragments/baynote_content.jsp?baynoteFilterValue=" + attrFilter,
			dataType: "html",
			//async: false,		// This allows for multiple concurrent requests
			cache: true,
			success: function(xml) {
				// Turn the xml string into an xml DOM
				if (typeof xml != "object") {
					xml = stringToXML(xml);
				}
				
				if (obj.callback != null) {
					eval(obj.callback)(xml,obj.callbackParams);
				} else {
					obj.display(xml, resultsPerPage, hardCodedValues);
				}
			},
			error: function(){
				if (obj.callback != null) {
					// This callback function should account for null
					eval(obj.callback)(null,obj.callbackParams);
				} else {
					// Display the default top 10 on error
					obj.display(null, resultsPerPage, getDefaultBaynoteGuides(resultsPerPage));
				}
			}
		});
	}
	
	/**
	 * This receives the response from the GET requests, parses it out and populates the specified div with the results.
	 * 
	 * If any hard coded values are specified, it will force them to the top and remove them from the results.
	 * 
	 * @param {Object} xml
	 * @param {Object} resultsPerPage
	 * @param {Object} hardCodedValues
	 */
	BaynoteGuides.prototype.display = function(xml, resultsPerPage, hardCodedValues)
	{
		// If the xml is null or contains no children we will need to get the default top 10 from the global.js file
		if (xml == null && hardCodedValues.length < resultsPerPage) {
			// Populate the hard-coded value with the default values
			if (hardCodedValues.length < resultsPerPage){
				var missingNum = resultsPerPage - hardCodedValues.length;
				var defaultGuides = getDefaultBaynoteGuides(missingNum);
				for (var i=0; i<defaultGuides.length; i++) {
					hardCodedValues.push(defaultGuides[i])
				}
			}
		}

		var obj = this;
     	var guides = "<ol class='" + this.baynoteDivClass + "'>";
     	var list = "";
     	var max = resultsPerPage - hardCodedValues.length;
     	var count = 0;
     	var found = false;
     	var attr, url, title, i, faq, omnitureCode;

		// Loop through all the r nodes
		$(xml).find('r').each(function(){
			found = false;
			faq = "";
			omnitureCode = "";
			
			// Get the FAQ
			$(this).find('a').each(function(){
				attr = $(this).attr('n');
	         	if (attr == "content-id") {
					faq = $(this).attr('v');
				}
			});
			
			// Check if the FAQ exists in the hard coded values and if so, ignore it!
			if (hardCodedValues.length > 0) {
	         	for (i=0; i<hardCodedValues.length; i++) {
	         		if (faq == hardCodedValues[i][1]) {
	         			found = true;
	         		}
	         	}
	         }

			if (!found) {
				url = $(this).attr('u');
				title = $(this).attr('t');
				
				// Omniture Tracking
				if (obj.omnitureTrack) {
					if (faq == "") {
						obj.omniturePageValue = obj.omniturePageSubName + " - " + title;
					}
					else {
						obj.omniturePageValue = obj.omniturePageSubName + " - FAQ " + faq + " - " + title;
					}
					obj.omniturePageValue = obj.omniturePageValue.replace(/'/ig, "\\'");
					obj.omniturePageValue = obj.omniturePageValue.replace(/"/ig, "");
					omnitureCode = " onclick=\"trackPageClick('" + obj.omniturePageName + "', '" + obj.omniturePageValue + "')\"";
				}
				
				list += "<li><a href='" + url + "'" + omnitureCode + ">" + title + "</a></li>";
				count ++;
			}

			if (count == max) return false;
		}); //close each(

		// Add the hard-coded values
		if (hardCodedValues.length > 0) {
			for (i=0; i<hardCodedValues.length; i++) {
				faq = hardCodedValues[i][1];
				title = hardCodedValues[i][2];
				
				// Omniture Tracking
				if (obj.omnitureTrack) {
					if (faq == "") {
						obj.omniturePageValue = obj.omniturePageSubName + " - " + title;
					}
					else {
						obj.omniturePageValue = obj.omniturePageSubName + " - FAQ " + faq + " - " + title;
					}
					obj.omniturePageValue = obj.omniturePageValue.replace(/'/ig, "\\'");
					obj.omniturePageValue = obj.omniturePageValue.replace(/"/ig, "");
					omnitureCode = " onclick=\"trackPageClick('" + obj.omniturePageName + "', '" + obj.omniturePageValue + "')\"";
				}
				
				guides += "<li><a href='" + hardCodedValues[i][0] + "'" + omnitureCode + ">" + title + "</a></li>";
			}
		}
		guides += list + "</ol>";
		$("#" + obj.baynoteDiv).html(guides);
	}

	/**
	 * Instantiate the guides
	 */
	var bnGuides = new BaynoteGuides();
	
	/*
	########## EXAMPLES ##########
	// Simple request:
	bnGuides.get("DC.coverage.temporal:2007", 10);

	// Advanced request with forced FAQs
	var hardCodedValues = [
		["/support/go/1086", "1086", "-----2007 State Forms for Personal Returns"],
		["/support/go/607", "607", "-----TurboTax Orders, Charges, and Statements"]
	];
	bnGuides.get("DC.coverage.temporal:2007", 10, hardCodedValues);
	
	// How to make another request to populate another div
	bnGuides.setDiv("baynote_div");
	bnGuides.get("", 5);
	##############################
	*/