<!--
var perpromomsgPool;
var perpromomsgSelected;
var perpromomsgWeight;

function disablePerPromoMsg(i) {
	perpromomsgPool[i].enabled=false;
	perpromomsgWeight-=perpromomsgPool[i].weight;
}

function createPerPromoMsgPool() {
	var i,j;
	var rand;
	var curr;
	var free;
	var now=new Date();

	perpromomsgWeight=0;
	//perpromomsgnum=perpromomsgPool.length;	
	
	for (i=0;i<perpromomsgPool.length;i++) {
		if (now<perpromomsgPool[i].effective)
			perpromomsgPool[i].enabled=false;
		if (now>perpromomsgPool[i].expiry)
			perpromomsgPool[i].enabled=false;
		if (perpromomsgPool[i].enabled)
			perpromomsgWeight+=perpromomsgPool[i].weight;
	}

	perpromomsgSelected=new Array();
	for (i=0;i<perpromomsgnum;i++)
		perpromomsgSelected[i]=-1;

	for (i=0;i<perpromomsgPool.length;i++)
		if (perpromomsgPool[i].enabled & perpromomsgPool[i].pos>=1) {
			perpromomsgSelected[perpromomsgPool[i].pos-1]=i;
			disablePerPromoMsg(i);
		}

	free=new Array();
	j=0;
	for (i=0;i<perpromomsgnum;i++)
		if (perpromomsgSelected[i]<0)
			free[j++]=i;

	for (i=0;i<perpromomsgPool.length & j>0;i++)
		if (perpromomsgPool[i].enabled & perpromomsgPool[i].force) {
			rand=Math.round(Math.random()*(j-1));
			curr=free[rand];
			perpromomsgSelected[curr]=i;
			disablePerPromoMsg(i);
			free[rand]=free[j-1];
			j--;
		}

	for (i=0;i<perpromomsgnum;i++) {
		if (perpromomsgSelected[i]<0) {
			curr=-1;
			rand=Math.random()*perpromomsgWeight;
			for (j=0;j<perpromomsgPool.length & rand>0 & curr<0;j++)
				if (perpromomsgPool[j].enabled) {
					if (rand < perpromomsgPool[j].weight)
						curr=j;
					rand-=perpromomsgPool[j].weight;
				}
			if (curr>=0) {
				disablePerPromoMsg(curr);
				perpromomsgSelected[i]=curr;
			}
		}
	}
}

function createPerPromoMsg() {
	var html='';
	var now=new Date();
	var	i;
	
	definePerPromoMsg();
	createPerPromoMsgPool();

	html+='';

	for (i=0; i<perpromomsgnum; i++)	{
		var c=perpromomsgSelected[i];
		if (c>=0)
		{
			html+='<li><a ' + perpromomsgPool[c].link + ' class="redlink" onmousedown="return clk(\'' + perpromomsgPool[c].sect + '\', \'' +  perpromomsgPool[c].to + '\')" class=link>' + perpromomsgPool[c].text + '</a></li>\n';
/*
			html+='			<table width="100%" border="0" cellspacing="0" cellpadding="0">\n';
			html+='				<tr>\n';
			html+='					<td width="25" align="right" valign="top"><img src="/hsb/image/bul_red.gif" width="5" height="5" hspace="6" vspace="4"></td>\n';
			html+='					<td class="h1"><a ' + perpromomsgPool[c].link + ' class="redlink" onmousedown="return clk(\'' + perpromomsgPool[c].sect + '\', \'' +  perpromomsgPool[c].to + '\')" class=link>' + perpromomsgPool[c].text + '</a></td>\n';
			html+='				</tr>\n';
			html+='			</table>\n';
			html+='			<table width="10" height="8" border="0" cellpadding="0" cellspacing="0">\n';
			html+='				<tr>\n';
			html+='					<td><img src="/hsb/com/spacer.gif" width="10" height="8"></td>\n';
			html+='				</tr>\n';
			html+='			</table>\n';*/
		}
	}
	document.write(html);
}
//-->
