// JavaScript Document

function setStatePage() {
	//add the region to the url query (can't tell which for colorado/wyoming)
	
	try {
		var theState, theRegion;
		var args = new Object();
		var query = location.search.substring(1);
		var vals = query.split(",");
		for (var i = 0; i < vals.length; i++) {
			if (i == 0) 
				theState = vals[i];
			else
				theRegion = vals[i];
		}
	
		var stateName = setState(theState);
	
		var url = "";
		var showRegion = true;
		if (theRegion == "W")
			url = "DM_west.htm";
		else if (theRegion == "HP")
			url = "DM_highplains.htm";
		else if (theRegion == "MW") 
			url = "DM_midwest.htm";
		else if (theRegion == "S") 
			url = "DM_south.htm";
		else if (theRegion == "SE")
			url = "DM_southeast.htm";
		else
			url = "DM_northeast.htm";
			
		if ((theState == "AK") || (theState == "HI") || (theState == "PR")) 
			showRegion = false;
	
		var el;
		
		if (showRegion) {
			if (document.all) {
				document.all['regionLink'].innerHTML = '<span class="style6">Return to ' + '<a href="' + url + '">Region</a></span>';
			} else if (document.getElementById) {
				el = document.getElementById('regionLink');
				el.innerHTML = '<span class="style6">Return to ' + '<a href="' + url + '">Region</a></span>';
			}
		}
				
		url = "pics/" + theState.toLowerCase() + "_dm.png";
		
		if (document.all) {
			document.all['statedm'].innerHTML = '<IMG SRC="' + url + '" ' + 'width="670" height="498">';
		} else if (document.getElementById) {
			el = document.getElementById('statedm');
			while (el.hasChildNodes())
				el.removeChild(el.lastChild);
			var img = document.createElement('IMG');
			img.src = url;
			img.width = "670";
			img.height = "498";
			el.appendChild(img);
		}
		
		url = "pdfs/" + theState.toLowerCase() + "_dm.pdf";
		if (document.all) {
				document.all['pdfCell'].innerHTML = 'For a .pdf version of the ' + stateName + ' Drought Monitor, click <a href="' + url + '">here</a>.';
			} else if (document.getElementById) {
				el = document.getElementById('pdfCell');
				el.innerHTML = 'For a .pdf version of the ' + stateName + ' Drought Monitor, click ' + '<a href="' + url + '">here</a>.';
			}
			
		url = "DM_tables.htm?" + theState;
		if (document.all) {
				document.all['tabCell'].innerHTML = 'To view tabular statistics for ' + stateName + ', click <a href="' + url + '">here</a>.';
			} else if (document.getElementById) {
				el = document.getElementById('tabCell');
				el.innerHTML = 'To view tabular statistics for ' + stateName + ', click ' + '<a href="' + url + '">here</a>.';
			}
		
		/*if (document.all) {
				document.all['archiveCell'].innerHTML = 'To view the archive for ' + stateName + ', click <a href="DM_archive.htm?' + theState + '">here</a>. To compare the current Drought Monitor with previous weeks, click <a href="DM_compare.htm?'+theState+'">here</a>.';
			} else if (document.getElementById) {
				el = document.getElementById('archiveCell');
				el.innerHTML = 'To view the archive for ' + stateName + ', click <a href="DM_archive.htm?' + theState + '">here</a>. To compare the current Drought Monitor with previous weeks, click <a href="DM_compare.htm?'+theState+'">here</a>.';
			}*/
	} catch (e) {
		
	}
}


