var storynum;
var complete;
var prevstory;

function buttongrayed(n) { //alert('gray' + n);
	if (document.getElementById('btn'+n)) {
		document.getElementById('btn'+n).style.backgroundColor = '#cccccc';
	}
}
function buttonnormal(n) { //alert('normal' + n);
	if (document.getElementById('btn'+n)) {
		document.getElementById('btn'+n).style.backgroundColor = '#990000';
	}
}
function showstory(n) { //alert(story.length + ', ' + n);
	for (var i=0; i<story.length; i++) {
		if (storynum[i] == n) {
			var fullstory = '';
			if (complete[i] == 0) {
				fullstory = ' <a class="fullstory" href="news.html?id=' + n + '">Full&nbsp;Story</a>';
			}
			document.getElementById('wyhnews').innerHTML = story[i] + fullstory;
			buttongrayed(n);
			if (prevstory != n) {
				buttonnormal(prevstory);
				prevstory = n;
			}
		}
	}
}
function preparenews() {
	reg_leftbracket = /%L%/g;
	reg_rightbracket = /%R%/g;
	reg_singlequote = /%SQ%/g;
	reg_doublequote = /%DQ%/g;
	with (document.storydata) { //alert(mystory.value);
		mystory.value = mystory.value.replace(reg_leftbracket,'<');
		mystory.value = mystory.value.replace(reg_rightbracket,'>');
		mystory.value = mystory.value.replace(reg_singlequote,'\''); //'
		mystory.value = mystory.value.replace(reg_doublequote,'\"'); //"
		story = mystory.value.split("#%#");
		storynum = mystorynum.value.split(',');
		complete = mycomplete.value.split(',');
		prevstory = myprevstory.value;
	}
	showstory(prevstory);
	buttongrayed(prevstory);

//	alert(story[0]);
//	alert(document.storydata.complete.value);
}