// JavaScript Document

function getCompanyData(xmlFile){
	var xmlDoc;
	//var path = "http://www.shoparoundamerica.com/xml/";
	var path = "xml/categories/";
	var compNumber = 0;
	var itemCount;
	
	if (window.XMLHttpRequest) {
		  xmlDoc=new window.XMLHttpRequest();
		  xmlDoc.open("GET",path+xmlFile,false);
		  xmlDoc.send("");
		  xmlDoc=xmlDoc.responseXML;
	} else if (ActiveXObject("Microsoft.XMLDOM")) {
		  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		  xmlDoc.async=false;
		  xmlDoc.load(path+xmlFile);
	}
	var compData = xmlDoc.getElementsByTagName("company");
	for ( nu=0; nu<compData.length; nu++) {
		if(thisPageName == compData[nu].getElementsByTagName("category1")[0].childNodes[0].nodeValue
			|| thisPageName == compData[nu].getElementsByTagName("category2")[0].childNodes[0].nodeValue
			|| thisPageName == compData[nu].getElementsByTagName("category3")[0].childNodes[0].nodeValue
			){
			compNumber += 1;
		}
	}
	document.write("Number of companies on this page: <b>"+compNumber +"</b> ");
	document.write("<br /><br />");
	
	
	for ( i=0; i<compData.length; i++) {
		if(thisPageName == compData[i].getElementsByTagName("category1")[0].childNodes[0].nodeValue
			|| thisPageName == compData[i].getElementsByTagName("category2")[0].childNodes[0].nodeValue
			|| thisPageName == compData[i].getElementsByTagName("category3")[0].childNodes[0].nodeValue
			|| thisPageName == compData[i].getElementsByTagName("category4")[0].childNodes[0].nodeValue
			|| thisPageName == compData[i].getElementsByTagName("category5")[0].childNodes[0].nodeValue
			){
			
		document.write("<div class='bannerLarge'>");
					document.write("<div class='bannerMed'>");
						document.write("<a href='"+compData[i].getElementsByTagName("bannerurl")[0].childNodes[0].nodeValue+"' class='titleLink' target='_blank'>")
						document.write(compData[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
						document.write("&nbsp;&nbsp;");
						document.write("</a>")
						document.write(compData[i].getElementsByTagName("description")[0].childNodes[0].nodeValue);
						document.write("<br /><br />");
						document.write("<i>Keywords: "+compData[i].getElementsByTagName("keyphrases")[0].childNodes[0].nodeValue+"</i>");
						document.write("<br /><br />");
					document.write("</div>");
					document.write("<div class='bannerSmall'>");
						if(compData[i].getElementsByTagName("bannerimage")[0].childNodes[0].nodeValue == "none"){
							
						} else {
						document.write("<a href='"+compData[i].getElementsByTagName("bannerurl")[0].childNodes[0].nodeValue+"' target='_blank'>")
						document.write("<img alt='' border='0' src='"+compData[i].getElementsByTagName("bannerimage")[0].childNodes[0].nodeValue+"'>")
						document.write("</a>")
						}
						
						if(compData[i].getElementsByTagName("trackerurl")[0].childNodes[0].nodeValue == "none"){
							
						} else {
						document.write("<img alt='' border='0'width='1' height='1' src='"+compData[i].getElementsByTagName("trackerurl")[0].childNodes[0].nodeValue+"'>")
					
						}
					document.write("</div>");
				document.write("</div>");
				
				document.write("<a href='"+compData[i].getElementsByTagName("bannerurl")[0].childNodes[0].nodeValue+"'  class='visitLink' target='_blank'>")
				document.write("Visit this site now!")
				document.write("</a>")
				document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
				
				var itemName = compData[i].getElementsByTagName("products")[0].childNodes[0].nodeValue;
				var itemURL = "products.htm?name="+itemName;
				if(itemName == "none"){
				
				} else {
					document.write( '  <a href=     "javascript: poponload('+  "'"+  itemURL + "'"   +')"  class="visitLink"     >');
					document.write("View special Offers for this company!");
					document.write("</a>");
				}
				
				if(i != compData.length-1){
					document.write("<hr class='line3' />")	
				} else {
					document.write("<br /><br />")	
				}
				
			
		} else {
			itemCount += 1;
		}
	
	}
	
	if(itemCount > 1){
		document.write("<span class='smallnormalBlack'><b>Notice: </b>There are currently no companies or promotions to display for this category.<span>");
	}
}