//Javascript Functions
//Used by the CSR for functionality in the "Browse the CSR" section


function changeSection() {
	//Function changeSection
	// Updates the pages in the 'page' select based on the currently selected section.
 	var list = document.PageSelection.section
	var index = list.selectedIndex;
	var section = list.options[index].value;
	
	var pageSelect = document.PageSelection.page;
	pageSelect.length = 0;
	pageSelect.options[0] = new Option("Select Table/Figure.");
	pageSelect.options[0].value = '';
   pageSelect.selectedIndex = 0;
	
   var CurrPage;
	if(section != '')
		{
   	var CurrSection = aCSRPages[section];
		for(var i=0; i < aCSRPages[section].length; i++)
			{
			pageSelect.options[i+1] = new Option(aCSRPages[section][i][1]);
			pageSelect.options[i+1].value = aCSRPages[section][i][0];
			}
		}
}


function validate(){
	
   var bReturnValue= false;

	var sectionVar = document.PageSelection.section;
	var sectionIndex = sectionVar.selectedIndex;
	var sectionValue = sectionVar.options[sectionIndex].value;
	
	var pageVar = document.PageSelection.page;
	var pageIndex = pageVar.selectedIndex;
	var pageValue = pageVar.options[pageIndex].value;
	
	if(sectionValue == '' && pageValue =='')
		{
		alert ("Please select both a Section and a Table/Figure.");
		}	
	else if(sectionValue == '')
		{
		alert ("Please select a Section.");
		}	
	else if(pageValue =='')
		{
		alert ("Please select a Table or Figure.");
		}	
	else
		bReturnValue = true;

	return bReturnValue;
}
