function loadAreasTypes() {
	
	//rs - database type was removed so much of the code functionality is not needed anymore - see backups > qsearch.js for original
	
	//var qs = getQS('db'); // call function to get current query string, if none, gets 1 as default
	
	var qs = 5;
	
	var rich = document.getElementById("dbtrich"); 
	rich.value = qs; // change hidden field
	
	//var spaceDiv = document.getElementById("spaces");

	
	/* set selected option based on query string 
	if(qs == 1){
		document.searchform.dbtype.options.selectedIndex = 0;	
		//spaceDiv.innerHTML = "";
	}
	else if(qs == 2){
		document.searchform.dbtype.options.selectedIndex = 1;	
		//spaceDiv.innerHTML = "";
		
	}
	else if(qs == 5){
		document.searchform.dbtype.options.selectedIndex = 2;	
		//spaceDiv.innerHTML = "<input type=\"hidden\" name=\"ia1\" value=\"0\" id=\"ia1\" /> <input type=\"hidden\" name=\"ia2\" value=\"6000000\" id=\"ia2\" />";
	}
	else{
		document.searchform.dbtype.options.selectedIndex = 0;	
		//spaceDiv.innerHTML = "";
	}*/
	
	//var dbtype = document.searchform.dbtype.options[document.searchform.dbtype.selectedIndex].value; // get value from selected option
	//document.searchform.dbt.value = dbtype;
	
	var formname = "searchform";								//rs Name of form
	var aloarray = eval("alo" + qs);							//rs Locations
	var typarray = eval("typ" + qs);							//rs Type
	var alopulldown = window.document.forms[formname].alo;	// drop down select name called alo
	var typpulldown  = window.document.forms[formname].typ; // drop down select name called typ
	
	for (i = 0; i < aloarray.length; i++ ) {
		alopulldown.options[i+1] = new Option( aloarray[i], "'" + aloarray[i] + "'");
	}
	
	for (i = 0; i < typarray.length; i++ ) {
		typpulldown.options[i+1] = new Option( typarray[i], "'" + typarray[i] + "'");
	}
	
	
	
}


function loadAreasTypes2() {
	var dbtype = document.searchform.dbtype.options[document.searchform.dbtype.selectedIndex].value; // get value from selected option
	document.searchform.dbt.value = dbtype; // change value of hidden field to select right database
	
	var storyQs = getQS('story');
	if(storyQs == 1){ // if story query string exists then use gup function 1 else, use 2nd gup function
		var db_param = gup('db',dbtype);	
	}else{
		var db_param = gup2('db',dbtype);	
	}
	
	
	window.location.href = db_param; // re-direct with new query string
}


/* Changes query string on change of the drtop down and refreshes page with new query to populate other menus accordingly */

function gup(name,x){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if(results == null ){
		myLocation = window.location + "?db=" + x;
		return myLocation;
	}
	else{
		var myoldLocation = window.location.href;
		myLocation = myoldLocation.replace("db="+results[1],"db="+x);
		return myLocation;
		//alert(myLocation);
	}
}
function gup2(name,x){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if(results == null ){
		myLocation = window.location + "&db=" + x;
		return myLocation;
	}
	else{
		var myoldLocation = window.location.href;
		myLocation = myoldLocation.replace("db="+results[1],"db="+x);
		return myLocation;
		//alert(myLocation);
	}
}

/* Function for returning current query string, if none, returns 1 for default */

function getQS(name){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if(results == null){
		return 1;	
	}
	else{
		return results[1];
	}
	
}
