<?xml version="1.0" encoding="ISO-8859-1"?>

<jsp:root
	xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:rbs="http://www.rbs.com.br/core"
	xmlns:t="http://www.rbs.com.br/xparser"
	xmlns:a="http://www.rbs.com.br/actions"
	xmlns:x="http://java.sun.com/jsp/jstl/xml"
	version="2.0">
	
	<c:set var="oracle.jsp.tags.reuse" value="${false}"/>
	<jsp:directive.page isELIgnored="false" contentType="text/html; charset=ISO-8859-1"/>

	<rbs:setHeader name="Surrogate-Control" value='content="ESI/1.0"' />
	
    <jsp:scriptlet>
    <![CDATA[
		System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
		System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
		System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");

		String siteStr = request.getLocalName().trim().toLowerCase();
		String idmenu = "";
		String capaId = "";
		String runtime = System.getenv("COM_RBS_RUNTIME");
		
		if(siteStr.contains("hagah")){
			siteStr = "hagah";
			
			if ( "1".equals(request.getParameter("uf"))  ){
				idmenu = "D".equals(runtime) ? "5850" : ( "H".equals(runtime) ? "5789" : "707" );
				capaId = "D".equals(runtime) ? "871" : ( "H".equals(runtime) ? "1100" : "3913" );
			} else if ( "2".equals(request.getParameter("uf"))  ){
				idmenu = "D".equals(runtime) ? "5929" : ( "H".equals(runtime) ? "5842" : "752" );
				capaId = "D".equals(runtime) ? "923" : ( "H".equals(runtime) ? "1192" : "4620" );
			} else if ( "3".equals(request.getParameter("uf"))  ){
				idmenu = "D".equals(runtime) ? "5930" : ( "H".equals(runtime) ? "5843" : "753" );
				capaId = "D".equals(runtime) ? "926" : ( "H".equals(runtime) ? "1193" : "4621" );
			} else if ( "26".equals(request.getParameter("uf"))  ){
				idmenu = "D".equals(runtime) ? "6071" : ( "H".equals(runtime) ? "5967" : "979" );
				capaId = "D".equals(runtime) ? "1009" : ( "H".equals(runtime) ? "1395" : "8765" );
			}
		}else if(siteStr.contains("clic") && !siteStr.contains("zerohora")){
			siteStr = "clic";
			
			if ( "1".equals(request.getParameter("uf"))  ){
				idmenu = "D".equals(runtime) ? "5851" : ( "H".equals(runtime) ? "5790" : "706" );
				capaId = "D".equals(runtime) ? "916" : ( "H".equals(runtime) ? "1101" : "3910" );
			} else if ( "2".equals(request.getParameter("uf"))  ){
				idmenu = "D".equals(runtime) ? "5928" : ( "H".equals(runtime) ? "5841" : "751" );
				capaId = "D".equals(runtime) ? "922" : ( "H".equals(runtime) ? "1191" : "4622" );
			}
		}else if(siteStr.contains("zerohora")){	
			siteStr = "zerohora";
			idmenu = "D".equals(runtime) ? "5852" : ( "H".equals(runtime) ? "5791" : "" );
		}else{
			siteStr = "hagah";
			idmenu = "D".equals(runtime) ? "5850" : ( "H".equals(runtime) ? "5789" : "707" );
			capaId = "D".equals(runtime) ? "871" : ( "H".equals(runtime) ? "1100" : "3913" );
		}
		
		pageContext.setAttribute("siteStr", siteStr);
		pageContext.setAttribute("idmenu", idmenu);
		pageContext.setAttribute("capaId", capaId);
		pageContext.setAttribute("runtime", runtime);
		]]>	
	</jsp:scriptlet>

	<!--  
	*****************************
	DEFAULT NÃO AMIGAVEL  
	***************************** -->
                 
	<c:set var="uf"				value="${param.uf}" />
	<c:set var="local"			value="${param.local}" />
	<c:set var="regionId"		value="${param.regionId}" />
	<c:set var="section"		value="${param.secao}" />
	<c:set var="secao"			value="${param.secao}" />
	<c:set var="site"			value="${siteStr}"/>
	<c:set var="idmenu"			value="${idmenu}" />
	<c:choose>
		<c:when test="${empty param.capaId}">
			<c:set var="congenitid" 	value="${capaId}" />
		</c:when>
		<c:otherwise>
			<c:set var="congenitid" 	value="${param.capaId}" />
		</c:otherwise>
	</c:choose>

	<c:set var="static"			value="static" />
	<c:set var="subdomain"		value="www" />
	
	<c:set var="hasSubDomain" 	value="false"/>
	<c:set var="host"			value="${fn:split(header['host'],'.')[0]}" />
	
	
	<jsp:include page="actions.jspx" />

	<c:if test="${empty applicationScope.enclosingTemplate}">
		<c:set var="enclosingTemplate" value="moldura.xsl" scope="application" />
	</c:if>
	
	<c:if test="${empty applicationScope['com.rbs.template.root']}">
		<c:set var="com.rbs.template.root" value="/shared/clicrbs/celular/xsl" scope="application" />
	</c:if>
	
	<c:if test="${empty applicationScope['com.rbs.template.datasource.rootFileFolder']}">
		<c:set var="com.rbs.template.datasource.rootFileFolder" value="/shared/html" scope="application" />
	</c:if>

	<c:set var="action" value="${applicationScope.actions[param.action]}" scope="request" />
	<c:set var="template">
		${requestScope.action.template}
	</c:set>

	<c:set var="sourceTitle" value="${action.source}" />
	
	<c:set var="source">
		<c:choose>
			<c:when test="${param.action ne 'news'}">
				<c:set var="newsID" value="${fn:split(action.source, ',')}" />
				<c:choose>
					<c:when test="${fn:length(newsID) gt 1}">
						<c:set var="com.rbs.template.fragment.legacymethod" value="${newsID[1]}" />
						${newsID[0]}
					</c:when>
					<c:otherwise>${newsID[0]}</c:otherwise>
				</c:choose>
			</c:when>
			<c:otherwise>${param.source}</c:otherwise>
		</c:choose>
	</c:set>

	<c:if test="${empty param.action}">
		<c:set var="capaCgit" value="true" />
	</c:if>


	<c:choose>
		<c:when test="${empty param.xdebug or param.xdebug eq 'xml'}">
			<c:choose>		
				<c:when test="${capaCgit}">
							
					<c:import url="http://www.clicrbs.com.br/jsp/cgit_default.jsp">
						<c:param name="uf"		value="${uf}" />
						<c:param name="local"	value="${local}" />
						<c:param name="regionId" value="${regionId}" />
						<c:param name="id"		value="${congenitid}" />
						<c:param name="section"	value="${section}" />
						<c:param name="site" 	value="${site}" />
						<c:param name="static" 	value="${static}" />
						<c:param name="subdomain" 	value="${subdomain}" />
						<c:param name="hasSubDomain" 	value="${hasSubDomain}" />
						<c:param name="host" 	value="${host}" />
					</c:import> 
							
				</c:when>
				<c:otherwise>
					<t:parser source="${source}" template="${template}">
						<c:if test="${fn:contains(header['user-agent'], 'MSIE 6.')}">
							<t:output-property name="omit-xml-declaration" value="yes" />
						</c:if>
						<c:set var="com.rbs.xparser.silent" value="${param.silent}" />
						<!-- <t:output-property name="omit-xml-declaration" value="yes" /> -->
						<t:output-property name="method" value="html" />
						<t:output-property name="encoding" value="ISO-8859-1" />
						<c:choose>
							<c:when test="${not empty param.omit}">
								<t:output-property name="doctype-public" value="" />
								<t:output-property name="doctype-system" value="" />
							</c:when>
							<c:otherwise>
								<t:output-property name="doctype-public" value="-//W3C//DTD XHTML 1.0 Transitional//EN" />
								<t:output-property name="doctype-system" value="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
							</c:otherwise>
						</c:choose>
					</t:parser>
				</c:otherwise>
			</c:choose>
		</c:when>
	</c:choose>
</jsp:root>