	function hideboth() {
		var debug=false;
		if (debug) alert("showDropdown2");
		$("#public_sort_dynamic_dd").hide("normal", function(){$("#text_search_form").hide("normal");});	
	}


	function showDropdown__() {
		var debug=false;
		if (debug) alert("showDropdown2");
		$("#text_search_form").hide("normal", function(){$("#public_sort_dynamic_dd").show("normal");});	
	}




	function showSearchText() {
		var debug=false; 
		if (debug) alert("showSearchText");
		$("#public_sort_dynamic_dd").hide("normal", function(){ $("#text_search_form").show("normal"); } );
	}




	function loadSearchDropdowns(admin, sortbyvalue, sortbyvalue2, searchterm) {
		debug = false;
		if (debug) alert("loadSearchDropdowns!");
		if (debug) alert("sortbyvalue:" + sortbyvalue);
		
		x=1;
		
		// load dropdown 
		var sortby_dropdown = document.getElementById("sortby");
		sortby_dropdown.options.add(new Option("Order by Name", (""+(x++)) ));             	//1
		sortby_dropdown.options.add(new Option("Order by Submission Date", (""+(x++)) ));	//2
		sortby_dropdown.options.add(new Option("Search by Last Name", (""+(x++)) ));		//3
		sortby_dropdown.options.add(new Option("Search by First Name", (""+(x++)) ));		//4
		sortby_dropdown.options.add(new Option("Search by Medium", (""+(x++)) ));			//5
		sortby_dropdown.options.add(new Option("Search by Title", (""+(x++)) ));			//6
		
		if (admin==1) {
			sortby_dropdown.options.add(new Option("Order by Rating", (""+(x++)) ));
			sortby_dropdown.options.add(new Option("Search by Rating", (""+(x++)) ));
			sortby_dropdown.options.add(new Option("Search by Special Flag", (""+(x++)) ));
			sortby_dropdown.options.add(new Option("Search by Submission Id", (""+(x++)) ));
			//sortby_dropdown.options.add(new Option("Search by Medium", "10"));		
		}
		
		//persist the dropdown...
		if(!sortbyvalue) sortbyvalue=1;
		if (debug) alert("sortbyvalue:" + sortbyvalue);
		sortby_dropdown[sortbyvalue-1].selected = true;
		
		updateSort(sortbyvalue2, "none", false, searchterm);
	}



	function updateSort(sortbyvalue2, aurl, isrealsearch, searchterm) {
		
		var debug = false;
		
		if (debug) alert("updateSort!");
		if (debug) alert("sortbyvalue2:" + sortbyvalue2);
		
		var sortby_dropdown = document.getElementById("sortby");
		var sortby_dropdown_value = sortby_dropdown.options[sortby_dropdown.selectedIndex].value;
		if (debug) alert("updateSort sortby_dropdown_value:["+sortby_dropdown_value+"]");
			
		if (sortby_dropdown_value=="1") {    	  // Order by Last Name, First Name
			$("#sortby2").empty();
			var theOptions = {
				"-1" : "Select",
				"1"  : "First Name",
				"2"  : "Last Name"
			}
			$("#sortby2").addOption(theOptions, false);
			showDropdown__();
		} else if (sortby_dropdown_value=="2") {  //Order by Submission Date 
			
			$("#sortby2").empty();
			var theOptions = {
				"-1" : "Select",
				"1"  : "Newest First",
				"2"  : "Oldest First"
			}
			$("#sortby2").addOption(theOptions, false);
			showDropdown__();
		
		}  else if (sortby_dropdown_value=="3") { //Search by Last Name
			showSearchText();
		} else if (sortby_dropdown_value=="4") { //Search by First Name
			showSearchText();
		} else if (sortby_dropdown_value=="5") {  // Search by Medium
			
			$("#sortby2").empty();
			var theOptions = {
				"-1" : "Select",
				"1"  : "Painting",
				"2"  : "Drawing",
				"3"  : "Sculpture",
				"4"  : "Installation",
				"5"  : "Video",
				"6"  : "Photography",
				"7"  : "Print",
				"8"  : "Mixed Media"
			}
			$("#sortby2").addOption(theOptions, false);		
			showDropdown__();
		} else if (sortby_dropdown_value=="6") {  // search by title
			showSearchText();
		} else if (sortby_dropdown_value=="7") {  // (Admin) Order by Rating
			
			$("#sortby2").empty();
			var theOptions = {
				"-1" : "Select",
				"1"  : "Ascending",
				"2"  : "Descending"
			}
			$("#sortby2").addOption(theOptions, false);
			showDropdown__();
		
		} else if (sortby_dropdown_value=="8") {  // (Admin) Search by Rating
			$("#sortby2").empty();
			var theOptions = {
				"-1" : "Select",
				"1"  : "Unrated",
				"2"  : "1",
				"3"  : "2",
				"4"  : "3",
				"5"  : "4",
				"6"  : "5",
				"7"  : "6",
				"8"  : "7",
				"9"  : "8",
				"10" : "9",
				"11" : "10"
			}
			$("#sortby2").addOption(theOptions, false);
			showDropdown__();
			
		} else if (sortby_dropdown_value=="9") {  // (Admin) Search by Special Flag
			
			$("#sortby2").empty();
			var theOptions = {
				"-1" : "Select",
				"1"  : "On",
				"2"  : "Off"
			}
			$("#sortby2").addOption(theOptions, false);		
			showDropdown__();
			
		} else if (sortby_dropdown_value=="10") {  // note if this changes -- change value in processSearch()      //(Admin) Search by Submission Id 
			showSearchText();
		}
		
		
		
		
		
		//persist the dropdowns and text box
		if(!sortbyvalue2) {
			sortbyvalue2="-1";
		}
		
		if (debug) alert("sortbyvalue2:" + sortbyvalue2);
		if(sortbyvalue2 != "-1") {
			try {
				var public_sort_dynamic_dd = document.getElementById("sortby2");
				public_sort_dynamic_dd[sortbyvalue2].selected = true;
			} catch (err) {
				
			}
		} 
		
		if (!searchterm) searchterm = "";
		document.getElementById("text_search").value = searchterm;
	}



	function processSearch(aurl) {
		
		var debug=false;
		if (debug) alert("processSearch!");
		
		
		var isValidRequest = true;
		var sortby_dropdown = document.getElementById("sortby");
		var sortby_dropdown_value = sortby_dropdown.options[sortby_dropdown.selectedIndex].value;
		
		
		var newurl = "";
		if (sortby_dropdown_value=="1" || sortby_dropdown_value=="2" || sortby_dropdown_value=="5" ||  
			sortby_dropdown_value=="7" || sortby_dropdown_value=="8" || sortby_dropdown_value=="9") {   	// items that need the second dropdown
			
				var sortby_dropdown2 = document.getElementById("sortby2");
				var sortby_dropdown2_value = "-1";
				try {
					sortby_dropdown2_value = sortby_dropdown2.options[sortby_dropdown2.selectedIndex].value;
				} catch (err) {

				}
				
				if (sortby_dropdown2_value == "-1") {
					isValidRequest = false;
				}
				
				//newurl = aurl + "?sortby=" + sortby_dropdown_value + "&sortby2=" + sortby_dropdown2_value;
				newurl = site_url + "/" + sortby_dropdown_value + "/" + sortby_dropdown2_value;
				
		} else {							// items that need the text box
				
				var searchterm = document.getElementById("text_search").value;
				searchterm = $.trim(searchterm);
				if (searchterm=="") {
					alert("Please enter a search term.");
				}
				
				if (sortby_dropdown_value=="10" && isNaN(searchterm)) { // admin search by submission id
					alert("Please enter a number.");
					searchterm="";
				}
		
				//newurl = aurl + "?sortby=" + sortby_dropdown_value + "&sortby2=-1" + (searchterm!=""?("&search="+searchterm):"");
				newurl = site_url + "/" + sortby_dropdown_value + "/" + (searchterm!=""? searchterm :"");
		}
		
		if (debug) alert("newurl:" + newurl);
		
		if (isValidRequest) {
			location.href = newurl;
		}
	}
