$(document).ready(function() {
// Load Application Profiles
		//get xml
		var appProfileXmlLocation = "../../../../../literature/application_profiles/application_profiles_library.xml";
		var appProfileMoreLocation = "../../../../../literature/application_profiles/";
		var urlFolder = "http://www.strongwell.com/PDFfiles/Application Profiles/";
		var displayByMarkets = true;
		var displayByProducts = false;
		var marketsToDisplay = "ARCHITECTURAL";
		var productsToDisplay = "";

		$.ajax({
		type: "GET",
		url: appProfileXmlLocation,
		dataType: "xml",
		error: function (XMLHttpRequest, textStatus, errorThrown) {
		  this; // the options for this ajax request
		  alert("Error Loading Applications XML: " + appProfileXmlLocation + "\n" + this.errorThrown);
		},
		success: function(xml) 
		{
			$("#associatedAppProfiles").html('<ul id="appProfileList"></ul>');		
			
			$(xml).find('ap').each(
				function()
				{
					var id = $(this).find('id').text();
					var product = $(this).find('product').text();
					var title = $(this).find('title').text();
					var markets = $(this).find('markets').text();
					var customer = $(this).find('customer').text();
					var url = $(this).find('link').text();				
					if(displayByMarkets)
					{	
						var searchresults =markets.search(marketsToDisplay);
						if(searchresults != -1)
						{						
							$("#appProfileList").prepend('<li><a href="' + urlFolder + url + '" target="_blank">' + title + '</a></li>');
						}
					}
				}//end function
			);//end each
			
			//$("#appProfileList").prepend('<li><a href="' + appProfileMoreLocation + '">' + View More Application Profiles + '</a></li>');
			$("#appProfileList").append('<li><strong><a href="' + appProfileMoreLocation + '">More Application Profiles</a></strong></li>');
										 
										 
		}//end success
	});
});