/*
   Copyright 2009-2011 United States Government. 

   This software is licensed under the GNU General Public License
   version 2 (see the file LICENSE for details)
*/

function onChange(dropdown)
{
	var myindex = dropdown.selectedIndex;
	var SelValue = dropdown.options[myindex].value;

	if(SelValue == "Select")
		return;
	
	var url = document.location.href;
	
	

	if(url.indexOf("&limit") != -1)
	{
		var param_limit = get_url_parameter("limit")
		url = url.replace("&limit="+param_limit,"");
	}
	if(url.indexOf("&offset") != -1)
	{
		var param_offset = get_url_parameter("offset")
		url = url.replace("&offset="+param_offset,"");
	}
	
	if(dropdown.options[myindex].text == "All"){
		if((url.indexOf("cost-summary") != -1) || (url.indexOf("schedule-summary") != -1))
			url += "&limit="+SelValue+"&offset=0&showAll=1";
		else
			url += "&limit="+SelValue+"&offset=0";
		}
	else
		url += "&limit="+SelValue+"&offset=0";
	
	window.location.href = url
}

function get_url_parameter(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}



