RichFaces modalPanel

Estou tendo problemas com o modal panel,tenho um modal em uma pagina que somente se fecha qdo seja satisfeita uma funcao javaScript windowClose(),mas na mesma pagina tenho outro modal que exibem mensagens de erro da pagina e nao do modal,só que quando eu tento salvar um registro no modalPanel e o form contenha erros ele renderiza e mostra o erro no modal,mas porem o modal se fecha como posso resolver isso?
segue o codigo:

<code>

<a4j:outputPanel ajaxRendered=“true” >
<rich:modalPanel id=“error” autosized=“true”
showWhenRendered="#{facesContext.maximumSeverity !=null }" >
<f:facet name=“header”>
<h:outputText value="#{msg.erros}"></h:outputText>
</f:facet>
<f:facet name=“controls”>
<h:graphicImage value="/images/BOTOES/cancel.png" width=“20” height=“20"styleClass=“imagem”
style=“cursor:pointer” ‘error’)” />
</f:facet>
<table class=“blank” style=“font-size: 10pt; white-space: nowrap”>
<nobr>
<rich:messages showDetail=“true” showSummary=“true”>
<f:facet name=“errorMarker”>
<h:graphicImage value="/images/stop.png" width=“15” height=“15"styleClass=“imagem”>
</h:graphicImage>
</f:facet>
<f:facet name=“warnMarker”>
<h:graphicImage value=”/images/info.png"
width=“20” height=“20"styleClass=“imagem” />
</f:facet>
<f:facet name=“infoMarker”>
<h:graphicImage value=”/images/newButtons/exclamacao.gif"
width=“20” height="20"styleClass=“imagem” />
</f:facet>
</rich:messages>
</nobr>
</table>
</rich:modalPanel>
</a4j:outputPanel>

<a4j:region renderRegionOnly=“true”>
<rich:modalPanel id=“loadEstado” autosized=“true”>
<f:facet name=“header”>
<h:outputLabel value="#{msg.cadastrarestado}"/>
</f:facet>
<f:facet name=“controls”>
<h:graphicImage value="/images/BOTOES/cancel.png" width=“20” height=“20"styleClass=“imagem”
style=“cursor:pointer” ‘loadEstado’)” />
</f:facet>
<c:import url="/view/estado/modal.jsp"></c:import>

</rich:modalPanel>
</a4j:region>

<a4j:region renderRegionOnly=“true”>
<rich:modalPanel id=“loadCidade” autosized=“true”>
<f:facet name=“header”>
<h:outputLabel value="#{msg.cadastarcidade}"/>
</f:facet>
<f:facet name=“controls”>
<h:graphicImage value="/images/BOTOES/cancel.png" width=“20” height=“20"styleClass=“imagem”
style=“cursor:pointer” ‘loadCidade’)” />
</f:facet>
<center>
<c:import url="/view/cidade/modal.jsp"></c:import>
</center>
</rich:modalPanel>
</a4j:region>

 	&lt;script type="text/javascript"&gt;
function windowcloseCidade(){
			if (document.getElementById('erroCidade')==null){
				javascript:Richfaces.hideModalPanel('loadCidade');
			};
				
		};
		
		function windowcloseEstado(){
			if (document.getElementById('erroEstado')==null){
				javascript:Richfaces.hideModalPanel('loadEstado');
			};
			
		};
		&lt;/script&gt;         

</code>