
	
	function jumpToArch(sel01,sel02){
		var sel01Val = $(sel01).value;
		var sel02Val = $(sel02).value;
	
		var url = "/topgear/show/episodes/";
		if (sel01Val != "null" && sel02Val != "null") 
		{
			url += (sel01Val + sel02Val + ".shtml");	
			document.location.href = url;
		}
		return true;
	}			
	
	function setArchSelOpts(sel01,sel02)
	{
			var numArchEps = new Array(10,10,9,10,9,11,7,8,7,10,6,7);//number of episodes in each series - first series, 10; second series, 10 etc.
			var intLangEquiv = new Array("null","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen");// natural language equivalent to cardinal numbers
			var sel01OptsSelInd = sel01.options.selectedIndex; // index of selected option in the 'series' dropdown
			var sel02 = $(sel02); // the 'episodes' select object
			var sel02opts = sel02.options; // the 'episodes' select object's options array
	
			// remove all the options in the second dropdown:
			sel02opts.length = 0;
	
			var optVal = '';
			var OptTxt = '';
			for(i=0;i<=numArchEps[(sel01OptsSelInd - 1)];i++)
			{
				if(i == 0){
					sel02opts[i] = new Option ("Select an episode","null");
				}
				else {
					optVal = "episode" + i;
					optTxt = "Episode " + intLangEquiv[i];						
					sel02opts[i] = new Option (optTxt,optVal);
				}
			}
	
			return true;	
	}
	
	//initialising function onLoad - to set series dropdown back to default (select a series) and do similar for episodes but this time remove all the other options until user chooses a series.
	function initSelOpts(sel01,sel02)
	{
		var sel01 = $(sel01); // the 'episodes' select object
		var sel02 = $(sel02); // the 'episodes' select object
		var sel01opts = sel01.options; // the 'episodes' select object's options array
		var sel02opts = sel02.options; // the 'episodes' select object's options array
	
		sel01opts[0].selected = true;
		
		sel02opts.length = 0;
		sel02opts[0] = new Option ("Select an episode","null");
		
		return true;
	}
	
	function init()
	{
		initSelOpts("select_series","select_episode");
		return true;
	}
	