//
// Copyright (C) 2009 Endeca Technologies, Inc.
//
// The use of the source code in this file is subject to the ENDECA TECHNOLOGIES, INC. SOFTWARE TOOLS
// LICENSE AGREEMENT. The full text of the license agreement
// can be found in the ENDECA INFORMATION ACCESS PLATFORM THIRD-PARTY SOFTWARE USAGE AND LICENSES 
// document included with this software distribution.
//

//---------------------------------------------------------------------------
// Function used by SearchBar.jsp to submit the search request
//---------------------------------------------------------------------------
function Search(form, pageUrl) {
	


	  // Get search property and term values from form elements
	  var property = form.Ntk.value;
	  var terms = encodeURIComponent(form.Ntt.value);
	  
	  // Get current navigation state encoded for N param
	  var currentDimsN = form.N.value;
	  
	  // Get other search properties for search within
	  var otherprops = form.Ntk_other.value;
	  
	  // Get other search term values for search within
	  var otherterms = encodeURIComponent(form.Ntt_other.value);
	  
	  // Get current dimension search terms
	  var dimterms = form.D_other.value;
	  
	  // Get match mode for all searches
	  var matchmodes = form.Ntx_other.value;
	  
	  var removeterms = ["N","Nrc","No","Nao","Nty","Ntx","Ntk","Ntt","D","Dn","Dx","in_dym","in_dim_search"];
	  
	  var addterms;
	  var newurl;
	  
	   
	  if (terms == "") {
		  addterms = ["N=0"];
		  newurl = ConstructURL(pageUrl, "CURRENTURL", removeterms, addterms);
	  }	  
	  //else if (form.searchWithin.checked == true) {
	//	  addterms = ["N="+currentDimsN,"Ntk="+otherprops+property,"Ntt="+otherterms+terms,"Nty=1","D="+dimterms+terms,"Ntx="+matchmodes+"mode+matchallpartial","Dx=mode+matchall"];
	//	  newurl = ConstructURL(pageUrl, "CURRENTURL", removeterms, addterms);
	//  }
	  else {
		  addterms = ["N=0","Ntk="+property,"Ntt="+terms,"Nty=1","D="+terms,"Ntx=mode+matchallpartial","Dx=mode+matchall"];
		  newurl = ConstructURL(pageUrl, "CURRENTURL", removeterms, addterms);
	  }
	  
	 
	  location = newurl;
}

