var xList = new Array(0, 200, 728, 300, 160);
var yList = new Array(0,  90,  90, 250, 600);
random   = Math.floor(Math.random()*1000000000);

function display_ad(adSize){
	site  = 'edh.drugs';
	zone  = 'generalhealth';
	drugs = '';
	secondary_conditions = '';
	width = 0;
	height = 0;

	// Check that the user has passed in a valid size key.
	if (adSize <= 4){
		width  = xList[adSize];
		height = yList[adSize];
	}
	
	if(this.AD_SITE && AD_SITE.length){
		site = this.AD_SITE;
	}
	
	if(this.AD_ZONE && AD_ZONE.length){
		zone = this.AD_ZONE;
	}
	
	if(this.AD_DRUGS && AD_DRUGS.length){
		for(i=0;i<AD_DRUGS.length;i++){
			drugs += 'dr=' + AD_DRUGS[i] + ';';
		}
	}
	
	if(this.AD_SECOND && AD_SECOND.length){
		for(i=0;i<AD_SECOND.length;i++){
			secondary_conditions += 'sc=' + AD_SECOND[i] + ';';
		}
	}

	// Build the ad tag here.
	adUrl = site + '/' + zone + ';';
	adUrl += drugs;
	adUrl += secondary_conditions;
	
	if(this.AD_CTYPE && AD_CTYPE.length){
		adUrl += 'ct=' + this.AD_CTYPE + ';';
	}
	
	adUrl += 'hl=false;';

	
	// Finish the url
	adUrl += 'tile=' + adSize + ';';
	adUrl += 'sz='   + width + 'x' + height + ';';
	adUrl += 'ord='  + random + '?';
	
	if (location.href.toLowerCase().indexOf("https://") == 0) protocol = "https"; else protocol = "http";
	
	ad = '<script language="javascript" type="text/javascript" src="'+protocol+'://ad.doubleclick.net/adj/' + adUrl + '"></script>';
	document.write(ad);
	if(document.getElementById('jsout')) document.getElementById('jsout').value = ad;
	
	if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV")>= 0){
		document.write('<a href="'+protocol+'://ad.doubleclick.net/jump/adj/'+adUrl+'"  target="_blank">');
		document.write('<img src="'+protocol+'://ad.doubleclick.net/ad/adj/'+adUrl+'" width="'+width+'" height="'+height+'" border="0" alt=""/></a>');
	}
}