function getTrans(oldTrans,newTrans){
	oldTrans.value = newTrans.value;
}

function openPopup(strPgName,strWindowNm,window_width,window_height) {
var h,w
h = screen.height //height of screen, not just the parent window
w = screen.width //width of the screen, not just the parent window
var l,t
l = parseInt((w-window_width)/2)
t = parseInt((h-window_height)/2)
popupWin = window.open(strPgName,strWindowNm,'width='+window_width+',height='+window_height+',left='+l+',top='+t+',scrollbars=yes,status=yes')
}

function ontop() 
{self.focus();}

function remove_noise(phrase){
	//dimensionalizing variables
	noisearray=new Array();
	array_phrase=new Array();
	array_pruned=new Array();
	
	var noisearray=new Array ("0","1","2","3","4","5","6","7","8","9","$","a","about","after",
	"all","also","an","and","another","any","are","as","at",
	"b","be","because","been","before","being","between","both",
	"but","by","c","came","can","come","could","d","did","do",
	"does","e","each","else","f","for","from","g","get","got",
	"h","had","has","have","he","her","here","him","himself",
	"his","how","i","if","in","into","is","it","its","j","just",
	"k","l","like","m","make","many","me","might","more","most",
	"much","must","my","n","never","now","o","of","on","only",
	"or","other","our","out","over","p","q","r","re","s","said",
	"same","see","should","since","so","some","still","such",
	"t","take","Test","than","that","the","their","them","then",
	"there","these","they","this","those","through","to","too",
	"u","under","up","use","v","very","w","want","was","way",
	"we","well","were","what","when","where","which","while",
	"who","will","with","would","x","y","you","your","z",
	"ang","ay","ng");
	
	var array_pruned_length=0;
	var counter=0;
	var counter1=0;
	var counter2=0;
	var phrase1;
	var length=0;
	var noise_array_counter=0;
	var search_phrase="";

	//spliting the search phrase into an array
	array_pruned=phrase.split(" ");
	array_pruned_length=array_pruned.length;


	for (counter=0;counter <array_pruned_length;counter++){
		counter2=0;
		counter1=0;
	
		for(counter1=0;counter1<noisearray.length;counter1++){
			if (array_pruned[counter] == noisearray[counter1]){
				search_phrase= " " + array_pruned[counter] + " ";
				search_phrase_first_position = array_pruned[counter] + " ";
				counter2 = phrase.indexOf(search_phrase,0);
				counter3 = phrase.indexOf(search_phrase_first_position,0);
	
				if (counter3<counter2)    
					counter2=counter3;
		
				while (counter2>= 0){
					temp_string=array_pruned[counter];
					length=temp_string.length;
			  
					phrase = phrase.substr(0,counter2) + phrase.substr(counter2+length+1);
					counter2=phrase.indexOf(search_phrase,0);
				}
			}
		}
	} 
	return phrase;
}

// combo box 


var UNDEFINED;  // do not assign!


function getX(obj)
{
  return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );
}

function getY(obj)
{
  return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );
}


function isvalidchar(achar,validstr)
{
 return( validstr.toUpperCase().indexOf(achar.toString().toUpperCase(),0) >= 0 );
}


function onSelectFocus(objSelect, flgInput)
{

if ( document.all ) // IE4
 {

   if ( !document.all.divComboBubble )  // if this is the first time this function is called
   {                                    // then create the bubble text window (<DIV>).
     document.body.insertAdjacentHTML("beforeEnd",
         "<DIV id='divComboBubble' style='position:absolute;top:0px;left:0px;visibilty:hidden'></div>");
   }

   // create/init data elements

   objSelect.X = getX(objSelect)+2;
   objSelect.Y = getY(objSelect)-20;
   objSelect.strKeyInBuf = '';
   objSelect.flgInput = false;

   // if flgInput is 'INPUT' then this is an enterable list box.
   if ( flgInput != UNDEFINED )
   {
      objSelect.flgInput = ( (''+flgInput).toUpperCase() == 'INPUT' );
   }


   // setup event handlers
   objSelect.onmouseover = selectMouseOverHandler;
   objSelect.onmouseout  = selectMouseOutHandler;
   objSelect.onblur      = selectBlurHandler;
   objSelect.onkeydown   = selectKeyDownHandler;
   objSelect.onkeypress  = selectKeyPressHandler;
   objSelect.onkeyup     = null;


   // display bubble help (title)
   //objSelect.onmouseover(window.event);  // this should work, but in early versions of IE4 it doesn't!
   selectMouseOverHandler(window.event);
 }
}


function BubbleText(objSelect)
{
 var s = divComboBubble.innerHTML = '';

 if ( !objSelect )  // for the onBlur event to clear out the bubble help
 {
   return(false);
 }

 with ( objSelect )
 {
   if ( strKeyInBuf.length > 0 )
   {
     if ( strKeyInBuf == title )
     {
        s = '<FONT color="blue">' + strKeyInBuf + '</font>';
     }
     else if ( ( selectedIndex >= 0 ) && ( strKeyInBuf == options[selectedIndex].text ) )  // unique match found
     {
        s = '<B>' + strKeyInBuf + '</b>';
     }
     else
     {
        var c = strKeyInBuf.substring(strKeyInBuf.length-1,strKeyInBuf.length);
        c = ( c == ' ' ) ? '&nbsp;' : '<B>' + c + '</b>';
        s = strKeyInBuf.substring(0,strKeyInBuf.length-1) + c;
     }

     divComboBubble.innerHTML = '<TABLE cellpadding=0 cellspacing=0 style="background-color:INFOBACKGROUND;'
    + 'font:8pt ms sans serif;padding:2px 2px 2px 2px;color:INFOTEXT;border:1px solid INFOTEXT">'
    + '<TR><TD align=left><NOBR>'+s+'</nobr></td></tr></table>';
   }

   divComboBubble.style.posLeft = X;
   divComboBubble.style.posTop  = Y;
   divComboBubble.style.visibility  = '';
 }

 return(true);
}


function findSelectEntry( objSelect, head, tail )  // uses divide-and-conquer search, assumes sorted list
{
 with ( objSelect )
 {
   if ( options.length <= 0 )
   {
     strKeyInBuf = ' <FONT color="red">No selections available.</font> ';
     BubbleText( objSelect );
     window.status = strKeyInBuf = '';
     return(-1);
  }

  if ( strKeyInBuf == '' )
  {
     strKeyInBuf = title;
     BubbleText( objSelect );
     window.status = strKeyInBuf = '';
     selectedIndex=0;  // set to top
     return( selectedIndex = options[selectedIndex].text.length ? -1 : 0 );
  }

  var mid = Math.round( (head+tail)/2 );

  if ( strKeyInBuf.toUpperCase() == options[mid].text.substring(0,strKeyInBuf.length).toUpperCase() )
  {
     while ( (mid>0)  &&  strKeyInBuf.toUpperCase() == options[mid-1].text.substring(0,strKeyInBuf.length).toUpperCase() )
     {
        mid--;  // get the topmost matching item in the list, not just the first found
     }

     selectedIndex=mid;

     window.status = strKeyInBuf = options[mid].text.substring(0,strKeyInBuf.length);

     if ( mid == Math.round( (head+tail)/2 ) )  // if the original mid is an exact match
     {
        if ( (mid==tail) || ( (mid<tail) && strKeyInBuf.toUpperCase() != options[mid+1].text.substring(0,strKeyInBuf.length).toUpperCase() ) )
        {
           window.status = strKeyInBuf = options[mid].text;  // unique match found
        }
     }

     BubbleText( objSelect );

     return( selectedIndex );
   }

   if ( head >= tail )  // then since no exact match was found, go back to previous strKeyInBuf (thus the length-1)
   {
      strKeyInBuf = strKeyInBuf.substring(0,strKeyInBuf.length-1)
      return( findSelectEntry( objSelect, 0, options.length-1 ) );
   }

   if ( strKeyInBuf.toUpperCase() < options[mid].text.substring(0,strKeyInBuf.length).toUpperCase() )
   {
      return( findSelectEntry( objSelect, head, Math.max(head,mid-1) ) );
   }

   return( findSelectEntry( objSelect, Math.min(mid+1,tail), tail ) );
 }
}


function selectMouseOverHandler(e)
{
 var event = e ? e : window.event;  // to handle both NS4 and IE4 events

 if ( event.srcElement.strKeyInBuf == '' )
 {
    event.srcElement.strKeyInBuf = event.srcElement.title;
    BubbleText( event.srcElement );
    event.srcElement.strKeyInBuf = '';
 }
 else
 {
    BubbleText( event.srcElement );
 }

 return(true);
}


function selectMouseOutHandler(e)
{
 var event = e ? e : window.event;  // to handle both NS4 and IE4 events

 if ( event.srcElement != document.activeElement )
 {
    BubbleText( event.srcElement );
 }

 return(true);
}


function selectBlurHandler(e)
{
 var event = e ? e : window.event;  // to handle both NS4 and IE4 events

 event.srcElement.strKeyInBuf = '';
 window.status = (event.srcElement.selectedIndex>=0) ? event.srcElement.options[event.srcElement.selectedIndex].text : '';
 BubbleText( event.srcElement );

 return(true);
}


function selectKeyDownHandler(e)
{
 var event = e ? e : window.event;  // to handle both NS4 and IE4 events

 with ( event.srcElement )
 {
   // this is to correct the search bug when the list is left open after single-click
   if (  ( strKeyInBuf == '' ) && ( event.keyCode > 40 ) )
   {
      event.srcElement.blur();
      event.srcElement.focus();
   }

   switch(event.keyCode)
   {
     case(8):  // backspace
     {
        if ( ( selectedIndex >= 0 ) && ( strKeyInBuf == options[selectedIndex].text ) && !event.srcElement.flgInput )
        {
           window.status = strKeyInBuf = '';
        }
        else
        {
           window.status = strKeyInBuf = strKeyInBuf.substring(0,strKeyInBuf.length-1);
        }

        BubbleText( event.srcElement );
        event.keyCode = 0;
        return(false);
     }

     case(9):   // tab
     case(13):  // enter
     {
        event.keyCode = 9;  // convert enter to tab
        return(true);
     }

     case(27):  // escape
     {
        window.status = strKeyInBuf = '';
        BubbleText( event.srcElement );
        event.keyCode = 0;
        return(false);
     }

     case(32):  // space
     {
        window.status = strKeyInBuf += ' ';
        // this must be fired explicitely for spaces
        return( event.srcElement.flgInput ? event.srcElement.flgInput : selectKeyPressHandler(event) );
     }

     // I don't know if these are universal
     case(33):  // page up
     case(34):  // page down
     case(35):  // end
     case(36):  // home
     case(38):  // up arrow
     case(40):  // down arrow
     {
        window.status = strKeyInBuf = '';
        BubbleText( event.srcElement );
        return(true);
     }

   }  // end switch
 }  // end with

 return(true);
}


function selectKeyPressHandler(e)
{
  var event = e ? e : window.event;  // to handle both NS4 and IE4 events

  if ( event.keyCode == 13 ) { event.srcElement.blur(); event.srcElement.focus(); }

  if ( isvalidchar(String.fromCharCode(event.keyCode),"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 `~!@#$%^&*()_-+={}[]|:;'<>,./?\\\"" ) )
  {
     event.srcElement.strKeyInBuf += String.fromCharCode(event.keyCode);
  }


  if ( event.srcElement.flgInput )   // this is an enterable field
  {
     event.srcElement.options.length = 0;
     event.srcElement.strKeyInBuf    = event.srcElement.strKeyInBuf.substring(0,31);  // maxlength=32, should be set elsewhere
     event.srcElement.options[0]     = new Option( event.srcElement.strKeyInBuf, event.srcElement.strKeyInBuf );
     event.srcElement.selectedIndex  = 0;
  }
  else   // search to find the matching value
  {
     // must use setTimeout to override the default SELECT keypress event(s)
     var strSel = 'document.' + event.srcElement.form.name + '.' + event.srcElement.name;
     setTimeout( 'findSelectEntry(' + strSel + ',0,' + strSel + '.options.length-1);' , 1 );
  }

  return(true);
}


////////////////////////////////// -- End ComboBox.js -- ////////////////////////////////////////



