// JavaScript Document
var iVals = [5,8,10,15,40,80,105,110,205,210,215,280,380,405,505,580,605,680,710,780,805,880,980];
var usVals = [6,50,95,97,101,199,395];
var srVals = [1,2,3,4,9,12,13,14,16,17,18,19,20,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,
							38,39,41,43,44,45,46,47,48,49,51,52,53,54,55,56,57,58,59,60,61,62,63,65,66,67,68,70,71,
							72,73,74,75,76,77,78,79,82,83,84,85,86,87,88,89,90,91,92,94,96,98,99,103,104,107,108,
							109,111,112,113,114,115,116,118,119,120,121,123,124,125,126,127,128,129,130,131,132,
							133,134,135,136,137,138,139,140,141,142,144,145,146,147,149,150,151,152,153,154,155,
							156,158,159,160,161,162,163,164,165,166,167,167,168,169,170,172,173,174,175,177,178,180,182,
							183,184,185,186,187,188,189,190,191,192,193,195,197,198,200,201,202,203,204,207,209,211,213,216,
							217,218,219,220,221,222,223,224,225,227,229,232,233,236,237,238,241,242,243,244,245,246,247,252,253,
							254,255,259,260,262,263,265,266,267,269,270,271,273,274,275,281,282,283,284,299,330,371,905];

function changeType() {
	var newOption;
	var numberSelect = document.getElementById('routeVal');
	while(numberSelect.length > 0)
	  numberSelect.remove(numberSelect.length - 1);
	
	rType = document.getElementById('routeType');
	rType = rType.options[rType.selectedIndex].value;
	
	var numArray;
	if (rType == 'I')
	  numArray = iVals;
	else if (rType == 'US')
	  numArray = usVals;
	else if (rType == 'SR')
	  numArray = srVals;
	
	for (var i = 0; i < numArray.length; ++i) {
		newOption = document.createElement('option');
		newOption.value = rType.toLowerCase() + numArray[i];
		newOption.text = rType + '-' + numArray[i];
		try {
		  numberSelect.add(newOption,null);
		}
		catch(ex) {
			numberSelect.add(newOption);
		}
	}
	changeNum();
}

function showData(strData) {
	document.getElementById('trafficDetail').href = strData;
}

function changeNum() {
	var numElement = document.getElementById('routeVal');
	var linkURL = 'http://www.dot.ca.gov/hq/roadinfo/' + numElement.options[numElement.selectedIndex].value;
	document.getElementById('trafficDetail').src = linkURL;
	//ajaxCallback(linkURL, showData);
}
