// JavaScript Document
// ADS PARSER SCRIPT
/* This script parses the "ad" info that appears in the lower right hand column on the home page */

function parseAds() {
	//alert("parseAds was called");
	
	var adList = adsXML.getElementsByTagName("ad");
	
	for(i = 0; i < adList.length; i++) {
		var image = getValue(i, adList, "image");
		var path = getValue(i, adList, "link");
		var altText = getValue(i, adList, "alt");
		
		createAd(image, path, altText);
	}
	
}

function createAd(image, path, altText) {
	//alert("createAd was called");
	
	var adDiv = document.getElementById("ADS");
	
	var adItem = document.createElement("div");
	adItem.setAttribute("className","adItem");
	adItem.setAttribute("class", "adItem");
	
	var adAnchor = document.createElement("a");
	adAnchor.setAttribute("href", path);
	
	var adImage = document.createElement("img");
	adImage.setAttribute("src", image);
	adImage.setAttribute("alt", altText);
	adImage.setAttribute("border", "0");
	
	adAnchor.appendChild(adImage);
	adItem.appendChild(adAnchor);
	adDiv.appendChild(adItem);
}

