// google ad serving code that goes in the head

var txt;
txt = "<script type='text/javascript' src='http://partner.googleadservices.com/gampad/google_service.js'></script>";
txt += "<script type='text/javascript'>";
txt += 'GS_googleAddAdSenseService("ca-pub-6809056582700616");';
txt += "GS_googleEnableAllServices();";
txt += "</script>";
txt += "<script type='text/javascript'>";
txt += 'GA_googleAddSlot("ca-pub-6809056582700616", "MandB_Banner_728x90");';
txt += 'GA_googleAddSlot("ca-pub-6809056582700616", "MandB_Skyscraper");';
txt += "</script>";
txt += "<script type='text/javascript'>GA_googleFetchAds();</script>";
document.write(txt);

// some non-Google-related code needed for the sidebar, for now -- won't need this once sidebar ads delivered through DFP

/* display one ad */
function displayAd(ad) {
	if (ad.type == "flash")
		{
			displayFlash(ad);
		} 
	else	// assume non-Flash files are images
		{
			displayImage(ad);
		}
}


/* display one image ad */
function displayImage(ad) {
	var txt;
	txt = '<a href="' + ad.url + '" target=_blank">';
	txt = txt + '<img src="ads/' + ad.img + '"';
	txt = txt + ' alt="ad: ' + ad.title + '"></a>';
	document.write(txt);
}

/* display one Flash ad */
function displayFlash(ad) {
	var txt;
	txt = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"';
	txt = txt + ' WIDTH="' + ad.w + '" HEIGHT="' + ad.h + '"';
	txt = txt + ' id="' + ad.title + '">';
	txt = txt + '<PARAM NAME=movie VALUE="ads/' + ad.img + '">';
	txt = txt + '<PARAM NAME=quality VALUE=high>';
	txt = txt + '<EMBED src="ads/' + ad.img + '" quality=high '
	txt = txt + 'WIDTH="' + ad.w + '" HEIGHT="' + ad.h + '" NAME="' + ad.title + '" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	document.write(txt);
}

/* shuffle an array */
function shuffle(list) {
	list.sort(function() {return 0.5 - Math.random()})
}


