// Helper function to trim whitespace
String.prototype.trim = function()
{
  var strThis = this;
  strThis = strThis.replace(/^\s*(.*)/, "$1");
  strThis = strThis.replace(/(.*?)\s*$/, "$1");
  return strThis;
}

//translates the query to VQL
function performBasicQuery()
{
    var strQuery = document.getElementById("basicQueryText").value;
    var strResult = strQuery;
    var terms = strQuery.split(" ");
    if (terms.length > 1)
	{
		strResult = "\"" + strQuery + "\"";
	}
	strResult = "(<THESAURUS>" + strQuery + ")";
	strResult = "(" + strResult + "<IN>div<WHEN>id=bodyArea)";
	//strResult = "(<THESAURUS> " + strQuery.replace(/\s+/g, " , <THESAURUS> ") + ")";
    document.getElementById("resultingQueryText").value = strResult;
    document.getElementById("frmBasicQuery").submit();
}


function performBasicQueryTop()
{	
    document.getElementById("basicQueryText").value = document.getElementById("basicQueryTextTop").value;
    performBasicQuery();
    return false;
}

function performBasicQueryBottom()
{	
	document.getElementById("basicQueryText").value = document.getElementById("basicQueryTextBottom").value;	
	performBasicQuery();
	return false;
}
