	
	
	
	//Initiate request to server 
		function initAJAX(){
		var getDataXML = new XMLDoc();
		var checkValue = document.getElementById("lstprod").firstChild
			
		//set up the request for the file
			//I will add a conditional statement that will decide what .xml file to pull from the server
			
	
			//Create the variables for the Regular Expressions that will be created 
  var isTiffany, isMica, isWood, isIron, isBrass, isBronze, isCeramic, isCrystal, isGlass, isAccent,isChandelier;
  var dataUrl;
  var headValue = document.getElementsByTagName("h1")[0].firstChild.nodeValue;
			
			isTiffany = /tiffany/i;
			isMica = /mica/i;
			isWood = /wooden/i;
			isIron = /iron/i;
			isBrass = /brass/i;
			isBronze =/bronze/i;
			isCeramic = /ceramic/i;
			isCrystal = /crystal/i;
			isGlass = /glass/i;
			isAccent = /accent/i;
			isChandelier = /chandeliers/i;
			
			//Determine which xml file to load based on the regular expression test
						switch(!false){
						
						case isTiffany.test(headValue):
						dataUrl = "datafiles/tiffany.xml";
						break;
						
						case isMica.test(headValue):
						dataUrl = "datafiles/mica.xml";
						break;
						
						case isWood.test(headValue):
						dataUrl = "datafiles/wooden.xml";
						break;
						
						case isIron.test(headValue):
						dataUrl = "datafiles/wroughtiron.xml";
						break;
						
						case isBrass.test(headValue):
						dataUrl = "datafiles/brass.xml";
						break;
						
						case isBronze.test(headValue):
						dataUrl = "datafiles/bronze.xml";
						break;
						
						case isCeramic.test(headValue):
						dataUrl = "datafiles/ceramic.xml";
						break;
						
						case isCrystal.test(headValue):
						dataUrl = "datafiles/crystal.xml";
						break;
						
						case isGlass.test(headValue):
						dataUrl = "datafiles/glass.xml";
						break;
						
						case isAccent.test(headValue):
						dataUrl = "datafiles/accent.xml";
						break;
						
						case isChandelier.test(headValue):
						dataUrl = "datafiles/chandeliers.xml";
						break;
						
						default: 
						alert("We apologize for the inconvenience \nThere seems to be a technical issue at the moment\n\n Please try again later." );
						
						}
					
			
			var oneCall = document.getElementById("lstprod");
			//This if statement  checks to make sure multiple requests are not sent to the server which will create duplicate product feeds
			//and mess up the presentation
			if (oneCall.getAttribute("name") == null){
			getDataXML.loadXMLDoc(dataUrl, displayXML);
			}else{
			 return false;
			 
			}
			
		}
			
			function displayXML(req){
				req = req.request;
				if(req.readyState == 4 && req.status == 200){
				//set up the variable for the XML response and retrieve the XML document's root element
				var	prodData = req.responseXML;
				var	rootElem = prodData.getElementsByTagName("item");
				

				
				//These variables will be used in the for loop 
				var i, getProdName, getImgUrl, getLinkUrl, getPrice;
				var brElem, brElem2, pName, pImgLink, pUrlLink, p_Price, imageTag, anchorTag;
				var elemDiv = document.getElementById("lstprod");
					elemDiv.setAttribute("name", "servercheck");
				
				//Iterate through the identified XML elements, extract the data and append it to the document
				//var altText = pName.firstChild.
			
			for (i = 0; i < rootElem.length; i++){
				    getMerchant = prodData.getElementsByTagName("merchantname")[i].firstChild.nodeValue;           
					getProdName = prodData.getElementsByTagName("productname")[i].firstChild.nodeValue;
					getImgUrl = prodData.getElementsByTagName("imageurl")[i].firstChild.nodeValue; 	
					getLinkUrl = prodData.getElementsByTagName("linkurl")[i].firstChild.nodeValue; 
					getPrice = prodData.getElementsByTagName("price")[i].firstChild.nodeValue;	
					//These are the line break elements
					brElem = document.createElement("br");
					brElem2 = document.createElement("br");
					brElem3 = document.createElement("br");
					//these will be appended to elem to then be inserted into the document
					
					mName = document.createTextNode(" ( " + getMerchant + " ) " );
					pName = document.createTextNode(" " + getProdName);	
					p_Price = document.createTextNode("$" + getPrice + " ");
					buttonText = document.createTextNode("Buy Now");
					//----------------------set up the HTML tags and their attributes---------------------------
					callAct = document.createElement("button");
					callAct.setAttribute("class", "press_bnt");
					callAct.appendChild(buttonText);
					anchorTag = document.createElement("a");
					anchorTag.setAttribute("href",getLinkUrl);
					anchorTag.setAttribute("target","new");
					
					imageTag = document.createElement("img")
					imageTag.setAttribute("src", getImgUrl);			
					imageTag.setAttribute("border","0");
					imageTag.setAttribute("alt", getProdName);
					
					anchorTagText = document.createElement("a");
					anchorTagText.setAttribute("href",getLinkUrl);
					anchorTagText.setAttribute("target","new");
					
					//anchorButton = document.createElement("a")
	//---------------------------------------------------------------------------------------------------
					//Append product info and links to the approriate elements
					anchorTag.appendChild(imageTag)
					anchorTagText.appendChild(mName);
					anchorTagText.appendChild(pName);
					anchorTagText.appendChild(p_Price);
					anchorTagText.appendChild(callAct);
					//Insert data into the document 
					elemDiv.appendChild(brElem);
					elemDiv.appendChild(anchorTag);
					elemDiv.appendChild(brElem2);
					elemDiv.appendChild(anchorTagText);
					elemDiv.appendChild(brElem3);
					
						
					
				}
	
			}
			
		}
			
			
			
	