<%--
  Copyright 2003 Sun Microsystems, Inc. All rights reserved 
  Use is subject to license terms.
 --%>
<%-- RDEditor.jsp --%>

<%@page info="RDEditor" language="java"%>
<%@taglib uri="/WEB-INF/jato.tld" prefix="jato"%>
<%@taglib uri="/WEB-INF/console.tld" prefix="console"%>
<%@taglib uri="/WEB-INF/searchadmin.tld" prefix="searchadmin"%>

<jato:useViewBean className="com.sun.portal.search.admin.RDEditorViewBean" > 
<jsp:useBean id="viewBean" type="com.sun.portal.search.admin.RDEditorViewBean" />
<HTML>
<TITLE><searchadmin:text key="rd.editor"/></TITLE>
<script language="javascript" src="../ps/searchadmin/js/searchadmin.js"></script>

<script>
    function trim(str){
	var i=0,p = str.length-1;
	while(str.charAt(i)==' ') i++;
	while(str.charAt(p)==' ') p--;
	if(i>p) return '';
	return str.substring(i,p+1);
    }
    
    function validSearchText(popup, text) {
	if (isPageCompletelyLoad()) {
	    if (popup.selectedIndex > 2 ) {
		trimed = trim(text.value);
		if (trimed !="") {
		    return true;
		}
		alert("<searchadmin:text key="rd.editor.emptysearch"/>");
	    }
	    else {
		return true;
	    }
	}
	return false;

    }
    function openRDForm(formUrl, url) {
	window.open(formUrl+'?urls=' + url + '&database=<jato:text name="SearchDatabase"/>', '_blank', 'width=800,toolbar=no,scrollbars=yes,resizable=yes');
    }
    
    function batchSelected(f, listname, itemname, urlitemname) {
	var form = document.forms[f];
	urls ="";
	i=0;
	j=0;
	for (;;i++) {
	    var name = f + "." + listname + "[" + i + "]" + "." + itemname;
	    var urlname = f + "." + listname + "[" + i + "]" + "." + urlitemname;
	    var item = form.elements[name];
	    var urlitem = form.elements[urlname];
	    if (!item) {
		break;
	    }
	    if (item.checked) {
		urls = urls + urlitem.value + ".";
		j++;
	    }
	}
	if (j > 0) {
	    window.open('RDForm?urls=' + urls + '&database=<jato:text name="SearchDatabase"/>', '_blank', 'width=800,toolbar=no,scrollbars=yes,resizable=yes');
	}
	else {
	    alert("<searchadmin:text key="rd.noselect"/>");
	}
    }
    function batchAll() {
	window.open('RDForm?query=<jato:text name="QueryText"/>&database=<jato:text name="SearchDatabase"/>', '_blank', 'width=800,toolbar=no,scrollbars=yes,resizable=yes');
    }

    function setFieldChanged(v) {
	var sp = v.name.indexOf("].");
	if (sp > 0) {
	    var ps = v.name.substring(0, sp + 2) + "FieldChanged";
	    document.forms["RDEditor"].elements[ps].value="true";
	}
	
    }
    function toggle_searchtext(popup, searchstr) {
	    popup.form.elements['jato.defaultCommand'].value='/BTNChangeSearchFor';
	    popup.form.submit();
	    return;
	    var status = "hidden";
	if (popup.selectedIndex >2) {
	    status = "visible";
	    searchstr.enabled = true;
	}
	else {
	    searchstr.value = "";
	    searchstr.enabled = false;
	}
	    
        if (isNav) {
            //var sText = eval("document.searchtext");
            //sText.visibility = status;
        }
        else if (isNav6) {
            var aMenuBar = document.getElementById("searchtext");
            aMenuBar.style.visibility = status;
        }
        else {
            var amenubar = eval("document.all.searchtext");
            amenubar.style.visibility = status;
        }

    }
function isEditable(sel) {
    if (sel.selectedIndex <=2) {
	alert("<searchadmin:text key='rd.search.notrequired'/>");
    }
}
    
</script>
<%@include file="/ps/searchadmin/CSHeader.jsp"%>
<script language="javascript">
if (parent.headerFrame) {
    parent.headerFrame.helpDocURL = "<jato:text name="helpDocURL"/>";
    parent.headerFrame.helpPage = "<searchadmin:text key="help.database.rdedit"/>";
}
</script>

<searchadmin:AdminMenu selected="RDEditor" images="../ps/searchadmin/images"/>

<jato:content name="EditorSection">
<console:form name="RDEditor" method="post" defaultCommandChild="SearchButton">

<TABLE border="0" cellpadding="0" cellspacing="10" width="100%">
    <TR> 
      <TD width="50%" height="2"> </TD>
      <TD align="right" width="50%" height="2"> </TD>
    </TR>
    
    <TR>
	<TD class="help-text" colspan="2" height="2"><searchadmin:text key="rd.desc.one"/> <LABEL for="del"><searchadmin:text key="rd.desc.keyworddone"/></LABEL> <searchadmin:text key="rd.desc.two"/></TD>

    </TR>
    <TR>
      <TD colspan="2" height="2"> 
        <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
          <TR> 
            <TD nowrap> 
              <DIV class="properties-level1-label-text"><searchadmin:text key="rd.section.addnew"/></DIV>
            </TD>
            <TD valign="bottom" width="99%"> 
		<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
		    <TR> 
		    <TD valign="bottom" class="properties-separator"><IMG src="../ps/searchadmin/images/blank.gif" width="1" height="2" alt=""></TD>
		    </TR>
		</TABLE>
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
        <TR> 
      <TD align="right" height="2"> 
        <TABLE border="0" cellpadding="0" cellspacing="0">
          <TR> 
            <TD>
		<console:button name="AddNewButton"  type="mini" />
            </TD>
            <TD><IMG src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR>
        <TR>
      <TD colspan="2" height="2"> 
        <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
          <TR> 
            <TD nowrap> 
              <DIV class="properties-level1-label-text"><searchadmin:text key="rd.section.search"/></DIV>
            </TD>
            <TD valign="bottom" width="99%"> 
		<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
		    <TR> 
		    <TD valign="bottom" class="properties-separator"><IMG src="../ps/searchadmin/images/blank.gif" width="1" height="2" alt=""></TD>
		    </TR>
		</TABLE>
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>



    <TR>
	<TD colspan="2" height="2">
	<table border=0>
	    <tr>
	    <td>
	    <LABEL for="schfor"><searchadmin:text key="rd.searchdb"/>&nbsp;:&nbsp;</LABEL>
	    </td>
            <td ><img alt="" border="0" height="5" width="1" src="../ps/searchadmin/images/blank.gif"></td>
	    <td>
	    <jato:comboBox name="SearchDatabase" />
	    </td>
            <td colspans="2"><img alt="" border="0" height="5" width="1" src="../ps/searchadmin/images/blank.gif"></td>
	    </tr>
	    <tr>
	    <td>
	    <LABEL for="schfor"><searchadmin:text key="rd.searchfor"/>&nbsp;:&nbsp;</LABEL>
	    </td>
            <td ><img alt="" border="0" height="5" width="1" src="../ps/searchadmin/images/blank.gif"></td>
	    <td>
	    <jato:comboBox name="SearchBy" onChange="toggle_searchtext(this,  document.forms['RDEditor'].elements['RDEditor.SearchText']);"/>
	    </td>
            <td colspans="2"><img alt="" border="0" height="5" width="1" src="../ps/searchadmin/images/blank.gif"></td>
	    <tr>
	    <td>
		<LABEL for="searchtext"><jato:text name="SearchTextLabel"/></LABEL>
	    </td>
            <td ><img alt="" border="0" height="5" width="1" src="../ps/searchadmin/images/blank.gif"></td>
	    <td>
	    <div id="searchtext">
	    <jato:textField name="SearchText" size="30" elementId="searchtext" fireDisplayEvents="true"/>
	    </div>
	    </td>
            <td ><img alt="" border="0" height="5" width="1" src="../ps/searchadmin/images/blank.gif"></td>
            <td >
		<console:button name="TaxBrowser"  type="mini" fireDisplayEvents="true"/>
	    </td>
	    </tr>


	</table>
	</TD>
    </TR>
    <TR> 
      <TD align="right" height="2"> 
        <TABLE border="0" cellpadding="0" cellspacing="0">
          <TR> 
            <TD> 
		   <console:button name="SearchButton" type="mini" onClick="javascript:return validSearchText(document.forms['RDEditor'].elements['RDEditor.SearchBy'],document.forms['RDEditor'].elements['RDEditor.SearchText']);"/>
            </TD>
            <TD><IMG src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR> 

    
    <jato:content name="ResultSection">
    <!-- Result Section -->
    <TR> 
      <TD colspan="2" height="2"> 

	<jato:content name="NoHitsSection">
	    <searchadmin:text key="rd.nohits"/>
	</jato:content>


	<jato:content name="HitsSection">
    




<!-- Table Title --> 
        <table border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td class="table-title-text"><searchadmin:text key="rd.foundrds"/>&nbsp;:&nbsp;<jato:text name="HitsNum"/></td>
          </tr>
          <tr> 
            <td ><img alt="" border="0" height="5" width="1" src="../ps/searchadmin/images/blank.gif"></td>
          </tr>
	</table>
        <table border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td><img src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></td>
            <td><console:button name="DeleteButton"  type="mini" onClick="return confirmDelete();" /></td>
	    <jato:content name="PageNavSection">
	    <jato:content name="PrevButtonSection">
            <td><img src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></td>
            <td><console:button name="PrevButton"  type="mini" /></td>
	    </jato:content><!-- end of PrevButtonSection -->
	    <jato:content name="NextButtonSection">
            <td><img src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></td>
            <td><console:button name="NextButton"  type="mini" /></td>
	    </jato:content><!-- end of NextButtonSection -->
            <td><img src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></td>
            <td><searchadmin:text key="rd.page"/>:<jato:text name="CurrPage"/>/<jato:text name="TotalPage"/></td>
	    </jato:content><!-- end of PageNavSection -->
            <td><img src="../ps/searchadmin/images/blank.gif" width="100" height="1" alt=""></td>
            <td><a href="javascript:batchAll();">[<searchadmin:text key="rd.editall"/>]</a></td>
            <td><img src="../ps/searchadmin/images/blank.gif" width="10" height="1" alt=""></td>
            <td><a href="javascript:batchSelected('RDEditor', 'HitsView', 'Delete', 'Base64EncodedUrl');">[<searchadmin:text key="rd.editselected"/>]</a></td>
          </tr>
          <tr> 
        </table>
        <!-- End table containing Save and Cancel Buttons --> <!-- Begin outer table -->
	<TABLE class="table-frame" border="0" cellspacing="0" cellpadding="1">
          <TR> 
            <TD> 
		<TABLE class="table-content" border="0" cellspacing="0" cellpadding="0">
		<!-- Top row containing the column headers --> 
                <TR class="table-header-row">
		    <td><img alt="" border="0" height="1" width="10" src="../ps/searchadmin/images/blank.gif"></td>
		    <td align="center"> 
			<table width="100%" border="0" cellspacing="3" cellpadding="0">
			<tr> 
			    <td><a href="javascript:SelectAll('RDEditor', 'HitsView', 'Delete', true);"><img src="../ps/searchadmin/images/select-all-small.gif" width="11" height="13" alt="<searchadmin:text key='select.all'/>" border="0"></a></td>
			    <td><a href="javascript:SelectAll('RDEditor', 'HitsView', 'Delete', false);"><img src="../ps/searchadmin/images/deselect-all-small.gif" width="11" height="13" alt="<searchadmin:text key='deselect.all'/>" border="0"></a></td>
			</tr>
			</table>
		    </td>

		    <td><img alt="" border="0" height="1" width="10" src="../ps/searchadmin/images/blank.gif"></td>
		    <td><div class="table-header-text"><searchadmin:text key="url.text"/>/<searchadmin:text key="rd.field.title"/></div></td>
		    <td><img alt="" border="0" height="1" width="10" src="../ps/searchadmin/images/blank.gif"></td>
		    <td><div class="table-header-text"><searchadmin:text key="action.text"/></div></td>
		    <td><img alt="" border="0" height="1" width="10" src="../ps/searchadmin/images/blank.gif"></td>
		</tr>

		<jato:tiledView name="HitsView">
		<TR> 
		    <td>&nbsp; </td>
		    <TD><jato:checkbox name="Delete" elementId="del" />
			<jato:hidden name="Base64EncodedUrl" />
		    </TD>
		    <td>&nbsp; </td>
		    <TD>
			<jato:text name="Title"/><br>
			<jato:content name="HTTPLink">
			<A HREF="<jato:text name='Url' escape='false'/>" target="_blank"></jato:content><jato:text name="TruncatedUrl"/><jato:content name="HTTPLink"></A></jato:content>
		    </TD>
		    <td>&nbsp; </td>
		    <TD>&nbsp;<font color="#CC6600">
		    <jato:href name="EditAction">
			<searchadmin:text key="edit.action"/>
		     </jato:href>
		    </font>&nbsp;
		    </TD>
		    <td>&nbsp; </td>
                </TR>
		<tr> 
		    <td class="table-separator-row" colspan="7" ><img src="../ps/searchadmin/images/blank.gif" alt="" width="1" height="1" border="0"></td>
                </tr>

		</jato:tiledView>
              </TABLE>
	    </TD>
          </TR>
        </TABLE>

	</jato:content> <!-- end of HitsSection -->
	
	</TD>
    </TR>
    </jato:content> <!-- end of ResultSection -->

   

</TABLE>


</console:form>
</jato:content> <!-- end of EditorSection  -->


<jato:content name="BrowseSection">
<%@include file="/ps/searchadmin/TaxonomyTreeView.jsp"%>
</jato:content>


</BODY>
<script language="javascript">
pageLoaded = 1;
</script>

</HTML>
</jato:useViewBean>
