
//function to go to the url of the options's value
function jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//function to get the query vars and build an array
function getQueryArgs(global)
{
  var args = {};
  var loc = window.location.href;
  var q = loc.indexOf("?");
  if (q==-1) return false;
  loc = loc.substring(q+1);
  var pairs = loc.split("&");
  for (var i=0; i<pairs.length;i++){
    if (global) eval(pairs[i]);
    var keyval = pairs[i].split("=");
    
    args[keyval[0]] = unescape(keyval[1]);
  }
  return args;
}



setupJumpMenus = function (){
	//get the select menus 
	jumpmenu = document.getElementById('txtNumResults');
	jumpmenu2 = document.getElementById('txtNumResults2');
	jumpmenu3 = document.getElementById('txtSortBy');
	jumpmenu4 = document.getElementById('txtSortBy2');
	
	//handle a null results set	
	if(jumpmenu==null||jumpmenu2==null||jumpmenu3==null||jumpmenu4==null)
	return;
	
	//make them to "jump" on release
	jumpmenu.onchange = function(){
		jumpMenu('parent',this,0);
		}
	jumpmenu2.onchange = function(){
		jumpMenu('parent',this,0);
		}
	jumpmenu3.onchange = function(){
		jumpMenu('parent',this,0);
		}
	jumpmenu4.onchange = function(){
		jumpMenu('parent',this,0);
		}	
	
	//make an array from the URL query vars	
	var args = getQueryArgs();
	
	//get the hits variable's value
	myNum = args["hits"];
	
	//set the current choice in the jumpmenus
	if(myNum == 10){jumpmenu.selectedIndex = 0; jumpmenu2.selectedIndex = 0;}
	if(myNum == 20){jumpmenu.selectedIndex = 1; jumpmenu2.selectedIndex = 1;}
	if(myNum == 30){jumpmenu.selectedIndex = 2; jumpmenu2.selectedIndex = 2;}
	if(myNum == 40){jumpmenu.selectedIndex = 3; jumpmenu2.selectedIndex = 3;}
	
	//get the sortby variable's value
	sortby = args["sortby"];
	
	if(sortby == 'relevance'){jumpmenu3.selectedIndex = 0; jumpmenu4.selectedIndex = 0;}
	if(sortby == 'date'){jumpmenu3.selectedIndex = 1; jumpmenu4.selectedIndex = 1;}
}