function addEvent(obj,evt,fn) {
	if (obj.addEventListener)
		obj.addEventListener(evt,fn,false);
	else if (obj.attachEvent)
		obj.attachEvent('on'+evt,fn);
}

function resize(id,width,margin) {
	var items = document.getElementById(id).getElementsByTagName("li");
	var total = document.getElementById(id).clientWidth;
	var row = Math.floor(total/(width+margin*2));
	var cell = Math.floor(total/row - margin*2);
	//window.status = "total="+total+" row="+row+" cell="+cell;
	for (var i in items)
		items[i].style.width = cell+"px";
}
function resizable(id,width,margin) {
	function resizeThis() { resize(id,width,margin); };
	addDOMLoadEvent(resizeThis);
	addEvent(window,'resize',resizeThis);
}
