// stepmenu.js
// Department of Energy | Energy Information Administration
// State/Territory Energy Profiles ~ State/Territory Pulldown Menu JS.
//	Version ~ v1.0 | 20090603

function menu_goto(menuform)
{
	var baseurl = "";
	// var baseurl = "http://tonto.eia.doe.gov/state/";
	
	selecteditem = menuform.sid.selectedIndex;
	
	// Builder
	sid = menuform.sid.options[ selecteditem ].value ;
	spage = "state_energy_profiles.cfm?sid=";
	tpage =  "";
	
	switch (sid)
	{
	case "AQ": 	tpage = "territory_profile_aq.html"		
				if (sid.length != 0) { 
				location.href = baseurl + tpage; }
				break;
	case "GQ": 	tpage = "territory_profile_gq.html"		
				if (sid.length != 0) { 
				location.href = baseurl + tpage ; }
				break;
	case "CQ": 	tpage = "territory_profile_cq.html"		
				if (sid.length != 0) {
				location.href = baseurl + tpage ; }
				break;
	case "PR": 	tpage = "territory_profile_pr.html"		
				if (sid.length != 0) { 
				location.href = baseurl + tpage ; }
				break;
	case "VI":	tpage = "territory_profile_vi.html"		
				if (sid.length != 0) { 
				location.href = baseurl + tpage ; }
				break;
	default:	if (sid.length != 0) {
				location.href = baseurl + spage + sid ; }
				break;	 		
	}
	
	//reset on submit
	_CF_this = location.href;
	_CF_error_exists = false;
	_CF_error_messages = new Array();
	_CF_error_fields = new Object();
	_CF_FirstErrorField = null;		
	
	//display error messages and return success
	if( _CF_error_exists ) {
		if( _CF_error_messages.length > 0 ) {
			// show alert() message
			_CF_onErrorAlert(_CF_error_messages);
			// set focus to first form error, if the field supports js focus().
			if( _CF_this[_CF_FirstErrorField].type == "text" ) { 
				_CF_this[_CF_FirstErrorField].focus(); 
				}
		}
		return false;
	} else {
		return true;
	}		
}