/**
 * @author Timo 24.11.2005
 */
/**
 * Open every text, which containes s_glyph
 * @param s_glyph - text to search for
 */
menu.search=function(s_glyph){
		menu.search.a_matches=new Array();
		menu.search.a_visible=new Array();
		s_glyph=s_glyph.toLowerCase();
		var i_while=1;
		var i_wend=PhraseBook.phraseBooks[PhraseBook.currentId]._aCaption.length;
		while(i_while<i_wend){
			var s_momId=menu.html.S_MOM_ID+i_while;
			var i_parentId=PARENTS[i_while];
			var e_Div=document.getElementById(s_momId);
			var b_hasGlyph=false;
			var s_caption=PhraseBook.phraseBooks[PhraseBook.currentId]._aCaption[i_while];
			if(s_caption==null){s_caption='';}
			b_hasGlyph=Log.charTool.hasGlyph(s_caption.toLowerCase(), s_glyph, 1);
			if(b_hasGlyph==true){
				menu.search.showDiv(e_Div, i_parentId, i_while);
			}//if(b_hasGlyph
			i_while=i_while+1;
		}//while(i_while
		menu.search.showMatches(menu.tree._aNodes[1]);
}//search
/**
 * Show the menu
 * @see MenuBuilder
 */
menu.search.showMatches=function(a_parent, f_unction){
	var menuBuilder=new MenuBuilder();
	menuBuilder.GENERATIONS_TO_RECURSE= PhraseBook.phraseBooks[PhraseBook.currentId]._aCaption.length+1; 
	var sHtml=menuBuilder.createGenerations(a_parent, menuBuilder.addString);
	var menuDiv=document.getElementById(page.id._sTreeId);
	menuDiv.innerHTML=sHtml;
	//menu.search.openAllGenerations();
}//showMatches
/**
 */
menu.search.showDiv=function(e_Div, i_parentId, i_while){
	menu.search.a_visible[i_while]=true;
	menu.search.markAncestors(i_while);
}//showDiv
/**
 */
menu.search.markAncestors=function(i_while){
	var i_parentId=PARENTS[i_while];
	if(menu.search.a_matches[i_parentId]!=true){
		menu.search.a_matches[i_parentId]=true;
		menu.search.markAncestors(i_parentId);
	}
}//markAncestors

/**
 * Display the container of childnodes
 */
menu.search.openGeneration=function(i_id){
	var e_wombDiv=menu.view.getWombDiv(0);
	menu.view.openDiv( e_wombDiv);
}//openGeneration

/**
 * Display the containers of childnodes by the all direct ancestors
menu.search.openPreviousGeneration=function(i_id){
  var s_wombId=menu.html.S_WOMB_ID+i_id;
  var e_wombDiv=document.getElementById(s_wombId);
  if(e_wombDiv==null||e_wombDiv.className==menu.html.S_CLASS_BLOCK){return;}
  menu.view.openDiv( e_wombDiv);
  var i_parentId=PARENTS[i_id];
  menu.search.openGeneration(i_parentId);
}//openPreviousGeneration
*/

/**
 * Display all the containers of childnodes
* /
menu.search.openAllGenerations=function(){
    try{
	  if(task.busy()==true){return;}
      var i_while=1;
      var i_wend=PhraseBook.phraseBooks[PhraseBook.currentId]._aCaption.length-1;
      while(i_while<i_wend){
		/*var i_kids=PhraseBook._aTree[i_while].length;
		if(i_kids>0){* /
			menu.view.toMinus(document.getElementById(menu.html.S_SWITCH_KID_ID+i_while));
			menu.search.openGeneration(i_while);
		//}//if(i_kids>0)
        i_while=i_while+1;
      }//while(i_while
    }catch(e_rror){
      Log.showExeption( e_rror, 'menu.openAllGenerations '+i_while);
    }
}//openAllGenerations
*/
