/*
 * Copyright 2006 Servelots Infotech Pvt. Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You may
 * obtain a copy of the License at:
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
/*
This function is used to trim all leading and trailing spaces in a string.
This function takes a string as input and returns the trimmed string.
At present this function uses substr() method, on the assumption that 
first argument to substr() will never be negative and 
second argument will never be greater than str.length
*/
function trim(str){
	var start= str.length, end = 0, ch, i;
	for(i=0;i<str.length;i++) {
		ch = str.charAt(i);
		if(ch !=' '){
			start = i;
			break;
		}
	}
	for(i=str.length-1;i>=0;i--) {
		ch = str.charAt(i);
		if(ch !=' '){
			end = i;
			break;
		}
	}
	if (start<=end)
		return str.substr(start,end-start+1);
	else
		return "";
}


// This function is copied from wmpagelts.js
// for Tsunami website
function submitCustomSearchForm(type)
{
   document.customSearchPanelForm.request.value='search';
   document.customSearchPanelForm.excell.value='';
   document.customSearchPanelForm.pageno.value='1';
   document.customSearchPanelForm.selection.value=type;
   // it should be set to empty string otherwise
   // while doing a customn search the Match All and Match Any
   // in normal search try to downlod the results to sql or xls
   //document.customSearchPanelForm.req.value=""
                                                                                                                    
   // Modified by Raghavan - 14-09-2004. While calling "Dump" the
   // parameter "req" should not be null instead it should
   // be "displayResults/download/jpivot".
   // So, setting the value of hidden variable
   // 'req.value='displayResults'
   document.customSearchPanelForm.req.value="displayResults";
   // End - Raghavan 14-09-2004
                                                                                                                    
   document.customSearchPanelForm.submit();
}

