function BrowseBy() {
	BrowseByMenu('myTopic','/menu/topic/A2_2010.htm','topic_a');
	BrowseByMenu('myCountry','/menu/country/AB2_2010.htm','country_ab');
	BrowseByMenu('myPubType','/menu/pubtype/AZ2_2010.htm','');
	BrowseByMenu('mySpeaker','/menu/speaker/AC2_2010.htm','speaker_ac');
}

function BrowseByMenu(targetDiv, url, hiliteId){
	// well, ok, not necessarily a div, but anything with an id
	if(hiliteId != '') {
		hilite = '#'+hiliteId;
		// get the id name of the last hilited item (it's stored in a hidden html div)
		if (url.indexOf('speaker') != -1) {
			lastHilite = $('#lastSpeaker').html();
			$(lastHilite).removeClass("selected");
			// store the new hilited name in lastHilite html
			$('#lastSpeaker').html(hilite);
		}
		if (url.indexOf('country') != -1) {
			lastHilite = $('#lastCountry').html();
			$(lastHilite).removeClass("selected");
			$('#lastCountry').html(hilite);
		}
		if (url.indexOf('topic') != -1) {
			lastHilite = $('#lastTopic').html();
			$(lastHilite).removeClass("selected");
			$('#lastTopic').html(hilite);
		}
		$(hilite).addClass("selected");
	}
	target = '#'+targetDiv;
	$(target).load(url);
	//$(target).load('/proxy.cfm?path='+url);
}

function Jump2Search(word) {
  //url = "http://search.state.gov/search?"+word+"&filter=0&Search.x=0&Search.y=0&author=&start_date=&end_date=&as_occt=&as_filetype=&as_epq=&as_oq=&as_eq=&getfields=*&site=stategov_facet|oig|fpc|bmena|usawc|mepi|travel|stategov_exchanges|careers|foia|aiep|pepfar|cspo&entqr=3&getfields=*&entsp=0&output=xml_no_dtd&lr=lang_en&client=stategov_frontend&ud=1&search-button=Search&oe=UTF-8&ie=UTF-8&proxystylesheet=TEST_parametric_&search-button.x=0&search-button.y=0";
  url = "http://search.state.gov/search?"+word+"&filter=0&start_date=&end_date=&getfields=*&site=stategov|oig|fpc|bmena|usawc|mepi|travel|stategov_exchanges|careers|foia|aiep|pepfar|cspo&output=xml_no_dtd&client=stategov_frontend&as_q=inurl:gov&proxystylesheet=stategov_frontend";


  window.location = url;
}

function Jump2Url(url) {
  window.location = url;
}

function BrowseByDate(daysBack) {
  var today = new Date(); 
  var d = new Date(); 
  switch(daysBack)
  {
  case 2:
    d.setDate(today.getDate()-2); 
    break;
  case 7:
    d.setDate(today.getDate()-7); 
    break;
  case 90:
    d.setDate(today.getDate()-90); 
    break;
  }
  var month1=d.getMonth() + 1;
  var month2=today.getMonth() + 1;
  var day1=d.getDate();
  var day2=today.getDate();

  if (month1 < 10) { month1 = "0"+month1; }
  if (month2 < 10) { month2 = "0"+month2; }
  if (day1 < 10) { day1 = "0"+day1; }
  if (day2 < 10) { day2 = "0"+day2; }

  var dateRange = d.getFullYear() + "-" + month1 + "-" + day1 + ".." + today.getFullYear() + "-" + month2 + "-" + day2;
  
  	//added to fix date issue for facets phase 2
	var start_date = d.getFullYear() + "-" + month1 + "-" + day1;
  	var end_date = today.getFullYear() + "-" + month2 + "-" + day2;

  
  url='http://search.state.gov/search?q=inmeta:dc_date:daterange:'+dateRange+'&displayname=daterange '+dateRange+'&Search.x=0&Search.y=0&author=&start_date='+start_date+'&end_date='+end_date+'&partialfields=&as_occt=&as_filetype=&as_epq=&as_oq=&as_eq=&getfields=*&site=stategov|oig|fpc|bmena|usawc|mepi|travel|stategov_exchanges|careers|foia|aiep|pepfar|cspo&entqr=3&getfields=*&entsp=0&output=xml_no_dtd&lr=lang_en&client=stategov_frontend&ud=1&search-button=Search&oe=UTF-8&ie=UTF-8&proxystylesheet=stategov_frontend&ignore&search-button.x=0&search-button.y=0&as_q=inurl:gov&filter=0';
  Jump2Url(url);
}

