var searchPage;
var word;
var numOfResult;

function searchIt(searchWord){
	searchPage = 1;
	word = searchWord;
	
	if(trim(searchWord).length ==0){
		alert(STRINGS["ALERT_INPUT_SEARCH_WORD"]);
		return;
	}
	
	numOfResult = 0;
	progressLayer.style.visibility = "visible";
	
	top.progressFrame.document.open();
	top.progressFrame.document.writeln("<font size=2>searching...</font>");	
	
	top.resultFrame.document.open();
	top.resultFrame.document.writeln("<head>");
	top.resultFrame.document.writeln("	<style type='text/css'>");
	top.resultFrame.document.writeln("<!--");
	top.resultFrame.document.writeln("body { font-size:9pt; font-family:±¼¸²; SCROLLBAR-FACE-COLOR: #f6f6f6; SCROLLBAR-HIGHLIGHT-COLOR: #d5d5d5; SCROLLBAR-SHADOW-COLOR: #d5d5d5; SCROLLBAR-3DLIGHT-COLOR: #ffffff; SCROLLBAR-ARROW-COLOR: #d5d5d5; SCROLLBAR-TRACK-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #ffffff;filter: Chroma(Color=#000001)}");	
	top.resultFrame.document.writeln("//-->");
	top.resultFrame.document.writeln("</style>");
	top.resultFrame.document.writeln("</head>");
	top.resultFrame.document.writeln("<table width='135' style=' font-size: 11px;'>");
	top.resultFrame.document.writeln("<tr>");
	top.resultFrame.document.writeln("<td align='center' width='30'><b>num</b></td>");
	top.resultFrame.document.writeln("<td align='center' width='30'><b>page</b></td>");
	top.resultFrame.document.writeln("<td align='right'	width='75'><b>result</b></td>");
	top.resultFrame.document.writeln("</tr>");		
	
	top.searchFrame.location.href="search/00000.htm?page=0&word="+word;

}

function trim(str) 
{ 
	ereg=new RegExp("^( )+"); 
	str=str.replace(ereg,""); 
	ereg=new RegExp("( )+$"); 
	str=str.replace(ereg,""); 
	return str; 
} 

function searchResult(page, result){
	if(result){
		var eachResult;
		var inx;
		while(result.length>0){
			inx = eachResult = result.indexOf('\n');
			eachResult = result.substring(0,inx);
			result = result.substring(inx+1,result.length);
			numOfResult++;
/*
			if((numOfResult%2)==0){
				resultFrame.document.writeln("<tr onClick='top.goPage("+page+")' style='cursor:hand' bgcolor='#eeeeff'>");
			}else{
				resultFrame.document.writeln("<tr onClick='top.goPage("+page+")' style='cursor:hand' bgcolor='#ffeeee'>");
			}
*/
			resultFrame.document.writeln("<tr onClick='top.goPage("+page+")' style='cursor:hand'>");
			
			resultFrame.document.writeln("<td align='center' width='30'><b>"+numOfResult+"</b></td>");
			resultFrame.document.writeln("<td align='center' width='30'><b>"+eval(eval(page)+1-top.coverPages)+"</b></td>");
			resultFrame.document.writeln("<td align='right'	width='75'>"+eachResult+"</td>");
			resultFrame.document.writeln("</tr>");			
		}
	}
	page++;
	
	if(page>=maxPage)
	{
		resultFrame.document.writeln("</table>");		
		top.progressFrame.document.clear();
		top.progressFrame.document.writeln("<font size=2>searching....</font>");
		progressLayer.style.visibility = "hidden";		
		
		if(numOfResult==0) alert(STRINGS["ALERT_NO_SEARCH_RESULT"]);
		return;
	}
	top.searchFrame.location.href=makePageNumber(""+page)+".htm?page="+page+"&word="+word;
}

function makePageNumber(pageNumber){
	while(pageNumber.length<5){
		pageNumber = "0"+pageNumber;
	}
	return pageNumber;
}

