if (! window.getfused) { getfused = {} }
if (! window.getfused.ads) { getfused.ads = {} }
if (! window.getfused.ads.AdDisplay) {

getfused.ads.AdDisplay = function () {};

// Static Ad Counter
getfused.ads.AdDisplay.adCount = 0;

// Generic Ad Writing
getfused.ads.AdDisplay.writeAd = function (ad, layout, isLast) {
	// Set the link target
	var target = ' target="_blank"';
	if (ad.target) {
		target = (ad.target != "") ? ' target="' + ad.target + '"' : "";
	}

	// Set style based on the layout
	var style = (layout == "horizontal") ? ' style="float: left;"' : "";

	switch (ad.type) {
		case "html":
			document.write('<div id="gfad_' + getfused.ads.AdDisplay.adCount + '"' + style + '>');
			document.write(ad.html);
			if (ad.impressionUrl && ad.impressionUrl != "") {
				document.write('<img src="' + ad.impressionUrl + '" alt="" />');
			}
			document.write('</div>');
		break;
		case "image":
			var dims = ((ad.width) ? ' width="' + ad.width + '"' : "") + ((ad.height) ? ' height="' + ad.height + '"' : "");
			document.write('\n<div class="gfad"' + style + '><a href="' + ad.href + '"' + target + '>');
			document.write('<img src="' + ad.src + '"' + dims + ' style="border: none;" />');
			document.write('</a>');
			if (ad.impressionUrl && ad.impressionUrl != "") {
				document.write('<img src="' + ad.impressionUrl + '" alt="" />');
			}
			document.write('</div>');
		break;
		case "flash":
			ad.flashVersion = (ad.flashVersion) ? ad.flashVersion : "9";
			document.write('\n<div id="gfad_' + getfused.ads.AdDisplay.adCount + '" class="gfad"' + style + '></div>');
			document.write('\n<script type="text/javascript">');
			document.write('\nvar so = new SWFObject("' + ad.src + '", "gfad_' + getfused.ads.AdDisplay.adCount + '_flash", "' + ad.width + '", "' + ad.height + '", "' + ad.flashVersion + '", "#000000");')
			document.write('\nso.addParam("wmode", "transparent");');
			document.write('\nso.addParam("allowScriptAccess", "sameDomain");');
			if (ad.vars) {
				for (var i in ad.vars) {
					document.write('\nso.addVariable("' + i + '", "' + ad.vars[i] + '");');
				}
			}
			document.write('\nso.write("gfad_' + getfused.ads.AdDisplay.adCount + '");');
			document.write('\n</script>');
			if (ad.impressionUrl && ad.impressionUrl != "") {
				document.write('<img src="' + ad.impressionUrl + '" alt="" />');
			}
		break;
		case "video-flv":
			ad.flashVersion = (ad.flashVersion) ? ad.flashVersion : "9";
			document.write('\n<div id="gfad_' + getfused.ads.AdDisplay.adCount + '" class="gfad"' + style + '></div>');
			document.write('\n<script type="text/javascript">');
			document.write('\nvar so = new SWFObject("http://icc.getfused.com:9000/includes/flash/video-player.swf", "gfad_' + getfused.ads.AdDisplay.adCount + '_flash", "' + ad.width + '", "' + ad.height + '", "' + ad.flashVersion + '", "#000000");')
			document.write('\nso.addParam("wmode", "transparent");');
			document.write('\nso.addParam("allowScriptAccess", "sameDomain");');
			document.write('\nso.addVariable("videoUrl", "' + ad.src + '");');
			document.write('\nso.addVariable("imageUrl", "http://cachemediasrv.patriots.com/ImgDyn.cfm?s=Lockhart_and_Pops_at_SB_XXXVI.JPG&rs=33&q=75&x=143&y=93&w=100&h=100&c=1&h=150&w=200");');
			document.write('\nso.write("gfad_' + getfused.ads.AdDisplay.adCount + '");');
			document.write('\n</script>');
			if (ad.impressionUrl && ad.impressionUrl != "") {
				document.write('<img src="' + ad.impressionUrl + '" alt="" />');
			}
		break;
	}

	if (isLast && layout == "horizontal") {
		document.write('<div style="clear: left;"></div>');
	}
}

// Writes an array of ads to the page, handling vendor
getfused.ads.AdDisplay.writeAds = function (adArray, layout) {
	// Set the layout
	if (layout != "horizontal") {
		layout = "vertical";
	}

	if (adArray) {
		var currAd = null;
		for (var i = 0; i < adArray.length; i++) {
			getfused.ads.AdDisplay.adCount += 1;
			this.writeAd(adArray[i], layout, (i == (adArray.length - 1)));
		}
	}
}
}