<%@ page language="VB" autoeventwireup="false" inherits="HHFeditor_page_Tool_findr19830130, HHFeditor" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>查找与替换</title>
    <style type="text/css">
    body{
margin: 0px;
}
body, a, table, div, span, td, th, input, select{font-size:9pt;font-family: "宋体", Verdana, Arial, Helvetica, sans-serif;}
table{
	font-size: 9pt;
	font-family: 宋体;
}
#face_yulan
{
	border-left-color: #6699cc;
	border-bottom-color: #6699cc;
	width: 75px;
	border-top-style: double;
	border-top-color: #6699cc;
	border-right-style: double;
	border-left-style: double;
	height: 75px;
	border-right-color: #6699cc;
	border-bottom-style: double;
	overflow: hidden;
}
.an_k
{
	border-right: #6699cc 1px solid;
	padding-right: 1px;
	border-top: #6699cc 1px solid;
	padding-left: 1px;
	border-left: #6699cc 1px solid;
	padding-top: 3px;
	border-bottom: #6699cc 1px solid;
	color: #333333;
	background-color: #ffffcc;
	cursor:hand;
}
.an_l
{
	border-right: #6699cc 1px solid;
	padding-right: 1px;
	border-top: #6699cc 1px solid;
	padding-left: 1px;
	border-left: #6699cc 1px solid;
	padding-top: 3px;
	border-bottom: #6699cc 1px solid;
	color: #0099ff;
	background-color: #ffffff;
	cursor:hand;
}
.listtable
{
	border-right: #000033 1px solid;
	border-top: #000033 1px solid;
	border-left: #000033 1px solid;
	border-bottom: #000033 1px solid;
	margin-top: 1px;
	margin-left: -2px;
}
.wbk
{
	border-right: #7F9DB9 1px solid;
	border-top: #7F9DB9 1px solid;
	border-left: #7F9DB9 1px solid;
	border-bottom: #7F9DB9 1px solid;
}
.txtk
{
	border-right: #6699cc 1px solid;
	padding-right: 1px;
	border-top: #6699cc 1px solid;
	padding-left: 1px;
	padding-bottom: 1px;
	border-left: #6699cc 1px solid;
	padding-top: 1px;
	border-bottom: #6699cc 1px solid;
	font-size: 9pt;
}
.bbr
{
	border-bottom: #cccc99 1px solid;
	color: #ff6600;
}
    </style>
</head>
<body class="alertbgc">


<script language="JavaScript" type="text/javascript">
var oSelection;
oSelection = parent.document.selection.createRange();

function searchtype(){
    var retval = 0;
    var matchcase = 0;
    var matchword = 0;
    if (document.frmSearch.blnMatchCase.checked) matchcase = 4;
    if (document.frmSearch.blnMatchWord.checked) matchword = 2;
    retval = matchcase + matchword;
    return(retval);
}

function checkInput(){
    if (document.frmSearch.strSearch.value.length < 1) {
        alert("请输入查找内容");
        return false;
    } else {
        return true;
    }
}

function findtext(){
    if (checkInput()) {
        var searchval = document.frmSearch.strSearch.value;
        oSelection.collapse(false);
        if (oSelection.findText(searchval, 1000000000, searchtype())) {
            oSelection.select();
        } else {
            var startfromtop = confirm("搜索完成，是否要从顶部开始重新搜索？");
            if (startfromtop) {
                oSelection.expand("textedit");
                oSelection.collapse();
                oSelection.select();
                findtext();
            }
        }
    }
}

function replacetext(){
    if (checkInput()) {
        if (document.frmSearch.blnMatchCase.checked){
            if (oSelection.text == document.frmSearch.strSearch.value) oSelection.text = document.frmSearch.strReplace.value
        } else {
            if (oSelection.text.toLowerCase() == document.frmSearch.strSearch.value.toLowerCase()) oSelection.text = document.frmSearch.strReplace.value
        }
        findtext();
    }
}

function replacealltext(){
    if (checkInput()) {
        var searchval = document.frmSearch.strSearch.value;
        var wordcount = 0;
        var msg = "";
        oSelection.expand("textedit");
        oSelection.collapse();
        oSelection.select();
        while (oSelection.findText(searchval, 1000000000, searchtype())){
            oSelection.select();
            oSelection.text = document.frmSearch.strReplace.value;
            wordcount++;
        }
        if (wordcount == 0) msg = "要查找的内容没有找到"
        else msg = wordcount + " 处文本被替换成功";
        alert(msg);
    }
}
</script>
    <form id="frmSearch" runat="server"  class="alertbgc">
<TABLE CELLSPACING="0" cellpadding="5" border="0"  class="wbk">
<TR><TD VALIGN="top" align="left" nowrap>
    <label for="strSearch">查找内容</label><br>
    <INPUT TYPE=TEXT SIZE=40 NAME=strSearch id="strSearch" style="width : 200px;" onmouseover="this.focus();"><br>
    <label for="strReplace">替换内容</label><br>
    <INPUT TYPE=TEXT SIZE=40 NAME=strReplace id="strReplace" style="width : 200px;" onmouseover="this.focus();"><br>
    <INPUT TYPE=Checkbox SIZE=40 NAME=blnMatchCase ID="blnMatchCase"><label for="blnMatchCase">区分大小写</label><br>
    <INPUT TYPE=Checkbox SIZE=40 NAME=blnMatchWord ID="blnMatchWord"><label for="blnMatchWord">全部匹配</label>
</td>
<td rowspan="2" valign="top">
    <input type=button style="width:80px;margin-top:15px" name="btnFind" onClick="findtext();" value="查找下一个"><br>
    <input type=button style="width:80px;margin-top:5px" name="btnCancel" onClick="parent.cleartools2()" value="关闭"><br>
    <input type=button style="width:80px;margin-top:5px" name="btnReplace" onClick="replacetext();" value="替换"><br>
    <input type=button style="width:80px;margin-top:5px" name="btnReplaceall" onClick="replacealltext();" value="全部替换"><br>
</td>
</tr>
</table>
    </form>
</body>
</html>
