<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<c:set var="codeEcran" scope="request"><bean:message key="search.codeEcran"/></c:set>
<c:set var="titreEcran" scope="request"><bean:message key="search.titreEcran" arg0="${documentTitle}"/></c:set>
<%@ include file="/WEB-INF/jsp/include/entete.jsp" %>
  <!--[if IE 6]>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/ie6.css" type="text/css"/>
  <![endif]-->
  <!--[if IE 5]>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/ie6.css" type="text/css"/>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/ie5.5.css" type="text/css"/>
  <![endif]-->

<script type="text/javascript" src="${pageContext.request.contextPath}/js/sarissa/sarissa-compressed.js"></script>
<script>
    var xsl = Sarissa.getDomDocument();
    xsl.async = false;
    xsl.load(contextPath+"/js/search/searchArray.xsl");
        var xsltProcessor = new XSLTProcessor();
        xsltProcessor.importStylesheet(xsl);
        var xml = null;
        
        function sort(sortIndex, sortOrder) {
            document.getElementById("resultTableContainer").innerHTML = "<center><img src=\"" + contextPath + "/img/searching.gif\"/></center>";
            xsltProcessor.clearParameters();
            xsltProcessor.setParameter(null, "sortIndex", sortIndex);
            xsltProcessor.setParameter(null, "sortOrder", sortOrder);
            document.getElementById("resultTableContainer").innerHTML = new XMLSerializer().serializeToString(xsltProcessor.transformToDocument(xml));
        }
        
        function transformXml(xmlToTransform) {
            xml = new DOMParser().parseFromString(xmlToTransform, "text/xml");
            return new XMLSerializer().serializeToString(xsltProcessor.transformToDocument(xml));
        }
        function setPointer(theRow, thePointerColor) {
            if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
                return false;
            }
            if (typeof(document.getElementsByTagName) != 'undefined') {
                var theCells = theRow.getElementsByTagName('td');
            }
            else if (typeof(theRow.cells) != 'undefined') {
                var theCells = theRow.cells;
            }
            else {
                return false;
            }
            
            var rowCellsCnt  = theCells.length;
            for (var c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = thePointerColor;
            }
            
            return true;
        } // end of the 'setPointer()' function
        function doClickOnRow(row,documentId,etatId,elementId,collCode,collLib,budgCode,budgLib) {
            try {
                bFound=false;
                cells = row.getElementsByTagName("td");
                var s="";
                var docId="";
                var additionalParams = "";
                for(i=0;i<cells.length;i++) {
                    var cellName=cells[i].attributes["name"].value;
                    if(cellName=="docId") {
                        //alert("click: "+cells[i].innerHTML);
                        docId = cells[i].innerHTML;
                        bFound=true;
                    } else if(cellName.substr(0,10)=="xsl-param:") {
                        additionalParams += "&"+cellName+"="+cells[i].innerHTML;
                    }
                }
                s="docId="+docId+
                    "\r\ndocumentId="+documentId+
                    "\r\netatId="+etatId+
                    "\r\nelementId="+elementId+
                    "\r\ncollCode="+collCode+
                    "\r\ncollLib="+collLib+
                    "\r\nbudgCode="+budgCode+
                    "\r\nbudgLib="+budgLib;
                var url = contextPath+"/displayDocument.do?coll-code="+collCode+
                    "&coll-lib="+collLib+
                    "&budg-code="+budgCode+
                    "&budg-lib="+budgLib+
                    "&documentId="+documentId+
                    "&etatId="+etatId+
                    "&elementId="+elementId+
                    "&docId="+docId+
                    additionalParams;
                encodedUrl = encodeUrl(url);
                window.open(encodedUrl);
            } catch(e) {
                alert(e.description);
        }
    }
    function encodeUrl(url) {
        if (url.indexOf("?")>0) {
            encodedParams = "?";
            parts = url.split("?");
            params = parts[1].split("&");
            for(i = 0; i < params.length; i++) {
                if (i > 0) {
                    encodedParams += "&";
                }
                if (params[i].indexOf("=")>0) {
                    //Avoid null values
                    p = params[i].split("=");
                    encodedParams += (p[0] + "=" + escape(encodeURI(p[1])));
                } else {
                    encodedParams += params[i];
                }
            }
            url = parts[0] + encodedParams;
        }
        return url;
    }

    function showPj(collectivite,pjName) {
        var url = "<%=request.getContextPath()%>/attachment.do?collectivite="+collectivite+"&pjId="+pjName;
        window.open(url);
    }
    function downloadUrl(url) {
        window.location.href=url;
    }
//    function simpleExport() {
//        searchSessionId = "1";
//        document.location = "<%=request.getContextPath()%>/simpleExport.do?searchSessionId="+searchSessionId;
//    }
</script>
<style>
    body { overflow: hidden }
    
    .imageButton a:hover {
        border: 1px outset #000000;
    }
    
    .imageButton a {
        border: 1px outset;
    }
    
    .imageButton a img {
        margin: 0px;
        border: 0px;
    }
    .lighRow {
        background-color: #DDDDEE;
    }
    .darkRow {
        background-color: #EEEEFF;
    }
    </style>
<table left="0" border="0" width="100%" height="100%" style="margin:0; padding:0; border-spacing:0;">
    <tr>
        <td devInfo="Widget GWT pour la recherche" valign="top" width="100%" id="criteriaContainer" documentId="${documentId}" etatId="${etatId}" elementId="${elementId}"></td>
    </tr>
</table>
<script language="javascript" src="${pageContext.request.contextPath}/fr.gouv.finances.dgfip.xemelios.web.gwt.Main/fr.gouv.finances.dgfip.xemelios.web.gwt.Main.nocache.js"></script>
<iframe src="javascript:''" id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
<%@ include file="/WEB-INF/jsp/include/pied.jsp" %>