function createDeals(name)
{	
	// get references from xmlDoc
	xmlDoc=loadXMLDoc("packages/" + name + ".xml");

		var dealsTotal = xmlDoc.getElementsByTagName("DEAL");
		// alert(dealsTotal.length);
		
		

		// creates <div> for entire section
		var newDiv = document.createElement("div");

		// creates <div> to go inside newDiv
		// creating another one because instead of appending insideTheDiv to newDiv, using innerHTML
		var insideTheDiv = document.createElement("div");
		insideTheDiv.setAttribute("class", "CreatedDeal");
		insideTheDiv.setAttribute("className", "CreatedDeal");
		insideTheDiv.setAttribute("id", "packageFeed");

				if(xmlDoc.getElementsByTagName("ERROR").length > 0) {
					var noDeal = document.createElement("div");
					noDeal.setAttribute("class", "noDeal");
					noDeal.setAttribute("className", "noDeal");
					var noDealStr = document.createTextNode("No deals for  " + name + " at this time.");
					noDeal.appendChild(noDealStr);
					insideTheDiv.appendChild(noDeal);
				} 
				else { 
				
					var theDestination = document.createElement("div");
					theDestination.setAttribute("class", "theDestination");
					theDestination.setAttribute("className", "theDestination");
					var destinationStr = document.createTextNode("Desintation: " + xmlDoc.getElementsByTagName("Destination")[0].firstChild.data);
					theDestination.appendChild(destinationStr);
					insideTheDiv.appendChild(theDestination);
				
				for (var i=0; i < dealsTotal.length; i++) {
					
					// new <div> for each deal box
					var newCard = document.createElement("div");
					newCard.setAttribute("className","packageDeal");
					newCard.setAttribute("class","packageDeal");
					newCard.setAttribute("style", "display: block;");
					
					// store a reference to the current DEALS
					var currentCard = dealsTotal[i]; 
					
					// test to see if it's gathering data
					// alert(currentCard.getAttribute("NUMBER") + "\n" + currentCard.getElementsByTagName("Image")[0].getAttribute("src") )
					
		
					// add image 
					if(currentCard.getElementsByTagName("Image")[0]){
						var newPicture = document.createElement("div");
							newPicture.setAttribute("class", "picture");
							newPicture.setAttribute("className", "picture");
						var newImage = document.createElement("img");
							newImage.setAttribute("src", currentCard.getElementsByTagName("Image")[0].getAttribute("src"));
							newImage.setAttribute("style", "display: block;");
							newPicture.appendChild(newImage);	
							newCard.appendChild(newPicture);
						} else {
							var newPicture = document.createElement("div");
							newPicture.setAttribute("class", "picture");
							newPicture.setAttribute("className", "picture");
							var newImage = document.createElement("img");
							newImage.setAttribute("src", "images/filler.gif");
							newImage.setAttribute("style", "display: block;");
							newPicture.appendChild(newImage);	
							newCard.appendChild(newPicture);
							}
							
					// new Price Link
					var priceLink = document.createElement("a");
						priceLink.setAttribute("class", "priceLink");
						priceLink.setAttribute("className", "priceLink");
						priceLink.setAttribute("href", "http://travel.wwte1.com" + currentCard.getElementsByTagName("Url")[0].firstChild.data + "&eapid=50577-30001&olid=&mdpcid=50577-30001.0.1");
						priceLink.setAttribute("target", "_blank");
						priceLink.setAttribute("style", "display: block; margin-left: 20px;");
						var priceStr = document.createTextNode(currentCard.getElementsByTagName("Price")[0].firstChild.data);
						priceLink.appendChild(priceStr);
						newPicture.appendChild(priceLink);
					
		
					// create <div> for Hotel
					var newHotel = document.createElement("div");
					newHotel.setAttribute("className","hotel");
					newHotel.setAttribute("class","hotel");
					var hotelStr = document.createTextNode(currentCard.getElementsByTagName("Name")[0].firstChild.data + " ");
						// create <a> for hotel name
						var hotelNameLink = document.createElement("a");
						hotelNameLink.setAttribute("class", "hotelName");
						hotelNameLink.setAttribute("className", "hotelName");
						hotelNameLink.setAttribute("href", "http://travel.wwte1.com" + currentCard.getElementsByTagName("Url")[0].firstChild.data + "&eapid=50577-30001&olid=&mdpcid=50577-30001.0.1");
						hotelNameLink.setAttribute("target", "_blank");
						hotelNameLink.appendChild(hotelStr);
						newHotel.appendChild(hotelNameLink);
						
						
					//var starRateStr = document.createTextNode( " " + currentCard.getElementsByTagName("StarRating")[0].firstChild.data + " stars");
						var starURL = currentCard.getElementsByTagName("StarRating")[0].getAttribute("url");
						var starImage = document.createElement("img");
						starImage.setAttribute("class", "star");
						starImage.setAttribute("className", "star");
						starImage.setAttribute("src", starURL);
						newHotel.appendChild(starImage);	
						newCard.appendChild(newHotel);
		
		
		
					// create <div> for destination
					var newDestination = document.createElement("div");
					newDestination.setAttribute("className","destination");
					newDestination.setAttribute("class","destination");
					var destinationStr = document.createTextNode("To: " + currentCard.getElementsByTagName("Destination")[0].firstChild.data);
					newDestination.appendChild(destinationStr);
					newCard.appendChild(newDestination);
						
					// create a <div> for the origin
					var newOrigin = document.createElement("div");
					newOrigin.setAttribute("className","origin");
					newOrigin.setAttribute("class","origin");
					var originStr = document.createTextNode("From: " + currentCard.getElementsByTagName("Origin")[0].firstChild.data);
					newOrigin.appendChild(originStr);
					newCard.appendChild(newOrigin);
							
					// create <div> for Info
					var newInfo = document.createElement("div");
					newInfo.setAttribute("className","info");
					newInfo.setAttribute("class","info");
					var infoStr = document.createTextNode(currentCard.getElementsByTagName("DealText")[0].firstChild.data + currentCard.getElementsByTagName("Price")[0].firstChild.data);
					newInfo.appendChild(infoStr);
					newCard.appendChild(newInfo);
					
							
					insideTheDiv.appendChild(newCard);		
					} // end for loop
			}
			
	newDiv.appendChild(insideTheDiv);
	// append the new <div> to the html document
	document.getElementById("insidePackageDeals").innerHTML =  newDiv.innerHTML;

	}
	
	

function createDeals02(name)
{	
	// this is for the HOTEL DEALS ONLY
	// get references from xmlDoc
	xmlDoc02=loadXMLDoc02("hotels/" + name + ".xml");

		var dealsTotal = xmlDoc02.getElementsByTagName("DEAL");
		// alert(dealsTotal.length);

		// creates <div> for entire section
		var newDiv = document.createElement("div");

		// creates <div> to go inside newDiv
		// creating another one because instead of appending insideTheDiv to newDiv, using innerHTML
		var insideTheDiv = document.createElement("div");
		insideTheDiv.setAttribute("class", "CreatedDeal");
		insideTheDiv.setAttribute("className", "CreatedDeal");
		insideTheDiv.setAttribute("id", "packageFeed");

				if(xmlDoc02.getElementsByTagName("ERROR").length > 0) {
					var noDeal = document.createElement("div");
					noDeal.setAttribute("class", "noDeal");
					noDeal.setAttribute("className", "noDeal");
					var noDealStr = document.createTextNode("No deals for  " + name + " at this time.");
					noDeal.appendChild(noDealStr);
					insideTheDiv.appendChild(noDeal);
				} 
				else { 
		
					var theDestination = document.createElement("div");
					theDestination.setAttribute("class", "theDestination");
					theDestination.setAttribute("className", "theDestination");
					var destinationStr = document.createTextNode("Hotels in " + xmlDoc02.getElementsByTagName("Destination")[0].firstChild.data);
					theDestination.appendChild(destinationStr);
					insideTheDiv.appendChild(theDestination);
		

				for (var i=0; i < dealsTotal.length; i++) {
					
					// new <div> for each deal box
					var newCard = document.createElement("div");
					newCard.setAttribute("className","packageDeal");
					newCard.setAttribute("class","packageDeal");
					newCard.setAttribute("style", "display: block; height: 100px;");
					
					// store a reference to the current DEALS
					var currentCard = dealsTotal[i]; 
		
		
					// Add picture 
								// add image 
		
					var pictureBox = document.createElement("div");
					pictureBox.setAttribute("class", "hotelPicBox");
					pictureBox.setAttribute("className", "hotelPicBox");
					pictureBox.setAttribute("style", "float: left;");
					var picture = document.createElement("img");
					picture.setAttribute("class", "hotelPic");
					picture.setAttribute("className", "hotelPic");
						if(currentCard.getElementsByTagName("Image")[0]){
							picture.setAttribute("src", currentCard.getElementsByTagName("Image")[0].getAttribute("src"));
						} else {
							picture.setAttribute("src", "images/filler.gif");
							}
					picture.setAttribute("style", "float: left;");
						// creates a price to go underneath the picture, links to hotel
					var priceLink = document.createElement("a");
					priceLink.setAttribute("class", "hotelPriceLink");
					priceLink.setAttribute("className", "hotelPriceLink");
					priceLink.setAttribute("href", "http://travel.wwte1.com" + currentCard.getElementsByTagName("Url")[0].firstChild.data + "&eapid=50577-30001&olid=&mdpcid=50577-30001.0.2");
					var priceStr =  document.createTextNode(currentCard.getElementsByTagName("Price")[0].firstChild.data);
					priceLink.appendChild(priceStr);
					pictureBox.appendChild(picture);
					pictureBox.appendChild(priceLink);
					newCard.appendChild(pictureBox);
		
		
					// Create Hotel Name with Link and stars to the right
					var newLinkBox = document.createElement("div");
					newLinkBox.setAttribute("class", "nameLinkBox");
					newLinkBox.setAttribute("className", "nameLinkBox");
					newLinkBox.setAttribute("style", "padding-top: 7px;");
					var starImage = document.createElement("img");
					starImage.setAttribute("class", "starRateImage");
					starImage.setAttribute("className", "starRateImage");
					starImage.setAttribute("style", "float: right;");
					starImage.setAttribute("src", currentCard.getElementsByTagName("StarRating")[0].getAttribute("url"));
					newLinkBox.appendChild(starImage);			
					var newLink = document.createElement("a");
					newLink.setAttribute("class", "hotelName");
					newLink.setAttribute("className", "hotelName");
					newLink.setAttribute("href", "http://travel.wwte1.com" + currentCard.getElementsByTagName("Url")[0].firstChild.data + "&eapid=50577-30001&olid=&mdpcid=50577-30001.0.2");
					newLink.setAttribute("target", "_blank");
					var linkStr = document.createTextNode(currentCard.getElementsByTagName("Name")[0].firstChild.data);
					newLink.appendChild(linkStr);
					newLinkBox.appendChild(newLink);
					newCard.appendChild(newLinkBox);
		
		
					// Adds detail information
					var dealInfo = document.createElement("div");
					dealInfo.setAttribute("class", "hotelDealInfo");
					dealInfo.setAttribute("className", "hotelDealInfo");
					var infoStr = document.createTextNode(currentCard.getElementsByTagName("DealText")[0].childNodes[0].data + currentCard.getElementsByTagName("Price")[0].firstChild.data + currentCard.getElementsByTagName("DealText")[0].childNodes[2].data)
					
					
			/*		if(currentCard.getElementsByTagName("DealText")[0].textContent) {
						var infoStr = document.createTextNode(currentCard.getElementsByTagName("DealText")[0].textContent);
					} else {
						var infoStr = document.createTextNode(currentCard.getElementsByTagName("DealText")[0].innerText);
						} */
						
					dealInfo.appendChild(infoStr);
					newCard.appendChild(dealInfo);
					
					insideTheDiv.appendChild(newCard);		
		
				}
		}
					
		newDiv.appendChild(insideTheDiv);
		document.getElementById("insidePackageDeals02").innerHTML =  newDiv.innerHTML;
	
		
}