var showGraphicWhatsHot = true;

var W3CBoxMod = "new";
function checkBoxModel() {
	if (W3CBoxMod == "new") {
		var test;
		if (test = neGetCookie("W3CBoxMod")) {
			W3CBoxMod = (test == "yes");
		} else {
			var tb = document.createElement("DIV");
			tb.style.width='10px';
			tb.style.padding = '1px';
			document.getElementsByTagName("BODY")[0].appendChild(tb);
			W3CBoxMod = (tb.offsetWidth > 10);
			tb.parentNode.removeChild(tb);
			neSetCookie('W3CBoxMod',((W3CBoxMod) ? 'yes' : 'no'));
		}
	}
	return W3CBoxMod;
}

function setTitleHTML(hed) {
   return hed.replace(/<.*?>/,"");
}

var hotInit = false;

function setHTML(item) {
	item = $(item);
	var posVals = item.getAttribute('value').split(':');
	if (!item.hasClassName('age')) item.addClassName("age"+posVals[0]);
	item.style.fontSize=posVals[1]+"em";
	item.style.left=posVals[2]+"px";
	item.style.top=posVals[3]+"px";
	item.style.width = ( (checkBoxModel()) ? posVals[4] - 12 : posVals[4] )+"px";
	item.style.height = ( (checkBoxModel()) ? posVals[5] - 12 : posVals[5] )+"px";
	if (!hotInit) {
		item.title = setTitleHTML(item.innerHTML);
		if (item == $S('#whatsHot .item')[0]) item.innerHTML = "<span class=\"hot\">Hottest story: </span>" + item.innerHTML;
		if (!posVals[0]) {
			if (item.innerHTML.toLowerCase().indexOf("<span>new:") == -1) {
				item.innerHTML = "<span>New: </span>"+item.innerHTML;
			}
		}
	}
}

function setUpMap() {
	if (showGraphicWhatsHot) {
		try {
			$S('#whatsHot .item').each(function(anItem){
				setHTML(anItem);
			});
			if ($('hotList')) $('hotList').id = 'newsMap';
			$('hotViewGraphic').checked="checked";
			if (!hotInit) hotInit=true;
		} catch(e) {
			showGraphicWhatsHot = false;
			$('hotViewSelect').hide();
		}
	} else {
		('hotViewSelect').hide();
	}
}

function changeHotView(how) {
	if (showGraphicWhatsHot) {
		if (how == 'List') {
			if ($('newsMap')) $('newsMap').id = 'hotList';
			$S('#whatsHot .item').each(function(anItem){
				anItem.style.height="auto";
				anItem.style.width="auto";
				anItem.style.fontSize="1em";
			});
			$('mapLegend').hide();
		} else {
			if ($('hotList')) $('hotList').id = 'newsMap';
			setUpMap();
			$('mapLegend').show();
		}
		try { if ($('hotView'+how).checked != "checked") $('hotView'+how).checked = "checked"; }
		catch(e) {}
		neSetCookie('whatshot',how,31);
	} else {
		$('hotViewSelect').hide();
	}
}

