var searchterm;
function CreateSearchQueryAll(searchterm){
	searchterm = ltrim(searchterm);
	searchterm = rtrim(searchterm);
	
	for (i=1; i < 150; i++) {
	searchterm = searchterm.replace(" ","+");
	}		
	return searchterm;	
}


function CreateSearchQueryAny(searchterm)
{
	
	searchterm = ltrim(searchterm);
	searchterm = rtrim(searchterm);

	
	for (i=1; i < 80; i++) 
{
	searchterm = searchterm.replace(" ","@");
}
	
	for (i=1; i < 60; i++) 
{
	searchterm = searchterm.replace("@@@","@");
	searchterm = searchterm.replace("@@","@");

}

	for (i=1; i < 60; i++) 
{

	searchterm = searchterm.replace("@"," | ");	
}		
	return searchterm;

	}




function CreateSearchQueryExact(searchterm) {
	searchterm = ltrim(searchterm);
	searchterm = rtrim(searchterm);
	searchterm = "'" + searchterm + "'";        
	
	return searchterm;	
}





function CreateSearchQueryWild(searchterm) {
	searchterm = ltrim(searchterm);
	searchterm = rtrim(searchterm);	

	searchterm = searchterm + "*";        
	
	return searchterm;

	
}


function ltrim(argvalue) {

  while (1) {
    if (argvalue.substring(0, 1) != " ")
      break;
    argvalue = argvalue.substring(1, argvalue.length);
  }

  return argvalue;
}


function rtrim(argvalue) {

  while (1) {
    if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
      break;
    argvalue = argvalue.substring(0, argvalue.length - 1);
  }

  return argvalue;
}



function Check() {
	if ( document.formi.rad.checked ) {
	var str1 = window.document.search.terms.value;
	str1 = CreateSearchQueryAny(str1);
	window.document.search.terms.value = str1;}
	
 
	else if ( document.formi.rad1.checked ) {
	var str2 = window.document.search.terms.value;
	str2 = CreateSearchQueryAll(str2);
	window.document.search.terms.value = str2;}

	else if ( document.formi.rad2.checked ) {
	var str3 = window.document.search.terms.value;
	str3 = CreateSearchQueryExact(str3);
	window.document.search.terms.value = str3;}

	else if ( document.formi.rad3.checked ) {
	var str4 = window.document.search.terms.value;
	str4 = CreateSearchQueryWild(str4);
	window.document.search.terms.value = str4;}


}


function InputValidate() {
	if (document.search.terms.value == "") 
	{
		alert("Please enter a search term!");
		return false;
	}
	else
	{
	
		return true;
	}
}

function Deselect0() {

document.formi.rad1.checked=false
document.formi.rad2.checked=false
document.formi.rad3.checked=false

}

function Deselect1() {

document.formi.rad.checked=false
document.formi.rad2.checked=false
document.formi.rad3.checked=false

}
function Deselect2() {

document.formi.rad.checked=false
document.formi.rad1.checked=false
document.formi.rad3.checked=false

}
function Deselect3() {

document.formi.rad.checked=false
document.formi.rad1.checked=false
document.formi.rad2.checked=false

}


function Clear() { 
document.formi.rad.checked=false
document.formi.rad1.checked=false
document.formi.rad2.checked=false
document.formi.rad3.checked=false
document.search.terms.value=""

}
