// JavaScript Document
function Dept(key, name, url){
	this.deptno = key;
	this.deptname = name;
	this.url = url;
}

function tier(key, name){
	this.key = key;
	this.name = name;
}

function Sbmt() {
//	str = "window.location.href = 'Search.cfm?Code=2&Department='+this.document.DDS.Department.value+'&Division='+this.document.DDS.Division.value+'&Section='+this.document.DDS.Section.value;";
	if(!isWhiteSpace(document.DDS.searchByAlpha.value)){
		str = "window.location.href = serverNamePath +'/Search.cfm?Code=1&Alpha='+this.document.DDS.searchByAlpha.value;";
		alert(str); eval (str);
	/*}else if  (isWhiteSpace(document.DDS.keywords.value)){
		str = "window.location.href = serverNamePath + '/Search.cfm?Code=2&Department='+this.document.DDS.Department.value+'&Division='+this.document.DDS.Division.value+'&Section='+this.document.DDS.Section.value;";
	}else if(document.DDS.joinHow.value=='and'){*/
	}else{
		parms = serverNamePath + '/Search.cfm?Code=2';
		parms = parms + '&Department='+this.document.DDS.Department.value;
		parms = parms + '&Division='+this.document.DDS.Division.value;
		parms = parms + '&Section='+this.document.DDS.Section.value;
		parms = parms + '&KW='+this.document.DDS.keywords.value;
		alert(parms);
		parms = parms + '&pub='+this.document.DDS.publications.value;
		parms = parms + '&city='+this.document.DDS.city.value;
		parms = parms + '&Sort='+this.document.DDS.sortCol.value;
		parms = parms + '&order='+this.document.DDS.order.value;
		alert(parms);
		window.location.href = parms;
	   //str = "window.location.href = serverNamePath + '/Search.cfm?Code=2&Department='+this.document.DDS.Department.value+'&Division='+this.document.DDS.Division.value+'&Section='+this.document.DDS.Section.value+'&KW='+this.document.DDS.keywords.value+'&pub='+this.document.DDS.publications.value+'&city='+this.document.DDS.city.value+parms;";
	  }/*else if  (isWhiteSpace(document.DDS.keywords.value) && isWhiteSpace(document.DDS.publications.value)){
		str = "window.location.href = serverNamePath + '/Search.cfm?Code=2&Department='+this.document.DDS.Department.value+'&Division='+this.document.DDS.Division.value+'&Section='+this.document.DDS.Section.value;"; 	   
	  }else if(isWhiteSpace(document.DDS.publications.value)){		
		str = "window.location.href = serverNamePath + '/Search.cfm?Code=3&KW='+this.document.DDS.keywords.value;";						
	  }else{
		str = "window.location.href = serverNamePath + '/Search.cfm?Code=4&pub='+this.document.DDS.publications.value;";
	  }*/
	 // alert(str);
	//eval (str);
	
	return false;
}

function populateSearchByAlpha(branch, showDiv){
	document.forms[0].Department.options[0].selected=true;
	if(showDiv)
		document.DDS.Division.options[0].selected=true;
	else
		document.DDS.Division.value='0';
	//document.forms[0].Section.options[0].selected=true;
	document.forms[0].keywords.value='';
	document.forms[0].city.value='';
	document.forms[0].publications.value='';
	
	document.forms[0].searchByAlpha.value=branch;
	document.forms[0].submit();
}		
function populateSearchByAll(){
	//resetAll();
	document.forms[0].searchByAlpha.value='All';
	document.forms[0].submit();
}

function resetSearchByAlpha(){
	document.forms[0].searchByAlpha.value='';
}
function TxtSrch(){
	str = "window.location.href = 'Search.asp?Code=3&Str='+this.document.Srch.Search.value;";
	eval (str);
	return false;
}

function populate(deptKey){
	document.forms[0].Division.disabled=false; 
	populateDivs(deptKey);

       		document.forms[0].inst.selectedIndex = 0;
 	    //alert ('inst is now set to ' +document.forms[0].inst.selectedIndex );	
	resetSearchByAlpha();
}

function populateDivs(deptkey){
	document.forms[0].Division.options.length=0;
	document.forms[0].Division.options[0]=new Option('View All','0',  false, false);
	var tempDivObj;
	var divKeys = divList.keys();
	for(i=0, j=1; i<divKeys.length; i++){
		tempDivObj=divList.get(divKeys[i]);  // tempDivObj is an instance of tier object-- parent_key, currName
		if(tempDivObj.key == deptkey){
			document.forms[0].Division.options[j++]=new Option(tempDivObj.name, divKeys[i],  false, false);
		}
	}
	if(j==1){
		document.forms[0].Division.options[0]=new Option('------------','0',  false, false);
	}
}

function populateSecs(divKey){
	document.forms[0].Section.options.length=0;
	document.forms[0].Section.options[0]=new Option('View All','0',  false, false);
	var tempSecObj;
	var secKeys = secList.keys();
	for(i=0, j=1; i<secKeys.length; i++){
		tempSecObj=secList.get(secKeys[i]);  // tempDivObj is an instance of tier object-- parent_key, currName
		if(tempSecObj.key == divKey){
			document.forms[0].Section.options[j++]=new Option(tempSecObj.name, secKeys[i],  false, false);
		}
	}
	if(j==1){
		document.forms[0].Section.options[0]=new Option('---------------','0',  false, false);
	}
}

var deptList = new Hashtable();
var deptObj;
var divList = new Hashtable();
var divObj;
var secList = new Hashtable();
var secObj;
var SearchCols = new Array();
var searchColIdx=0;

function resetAll(){
	//alert('in resetAll()' + searchColIdx);
	for(x=0; x<searchColIdx; x++){
		eval(SearchCols[x]);
	}
}

	
