<?xml version="1.0" encoding="UTF-8"?>
<f:root xmlns:f="http://jsf.exadel.com/template"
        xmlns:vcp=" http://jsf.exadel.com/vcp"
        xmlns:ui=" http://jsf.exadel.com/ui"
        xmlns:x=" http://jsf.exadel.com/vcp"
        xmlns:u="http://jsf.exadel.com/util"
        xmlns:h="http://jsf.exadel.com/header"
        baseclass="org.richfaces.renderkit.html.SimpleTogglePanelRenderer"
        class="org.richfaces.renderkit.html.SimpleToggleControlTemplate"
        >

    <f:clientid var="clientId"/>
    <h:styles>css/simpleTogglePanel.xcss</h:styles>
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
new org.ajax4jsf.javascript.ImageCacheScript(),
/org/ajax4jsf/javascript/scripts/form.js,
/org/richfaces/renderkit/html/scripts/browser_info.js,
scripts/simpleTogglePanel.js
</h:scripts>

    <div id="#{clientId}" x:passThruWithExclusions="id,value,style,styleClass,class"
         class="dr-stglpnl rich-stglpanel #{component.attributes['styleClass']}"
         style="width: #{component.attributes['width']}; #{component.attributes['style']};">

        <script type="text/javascript">
            SimpleTogglePanelManager.add(new SimpleTogglePanel("#{clientId}", 
            													"#{component.attributes['opened']}",{ 
            														<f:call name="writeEventHandlerFunction"><f:parameter value="onexpand" /></f:call>,
            														<f:call name="writeEventHandlerFunction"><f:parameter value="oncollapse" /></f:call>
            													}
            													
            							 ));
        </script>

        <f:call name="utils.encodeBeginFormIfNessesary"/>
        <div id="#{clientId}_header"
             class="dr-stglpnl-h rich-stglpanel-header #{component.attributes['headerClass']}"
             onclick="#{this:getOnClick(context,component)}">
					
			<div class="dr-stglpanel-marker rich-stglpanel-marker">
            	<div id="#{clientId}_switch_on" style="display: #{this:getSwitchOnStatus(context, component)};" class="dr-stglpnl-m rich-stglpnl-marker">
	                <jsp:scriptlet><![CDATA[
	                	if(component.getFacet("closeMarker")!=null && component.getFacet("closeMarker").isRendered()) {
	               	 ]]></jsp:scriptlet>
	               	     <u:insertFacet name="closeMarker" />
	               	 <jsp:scriptlet><![CDATA[
	                    } else {
	                      writer.write("&#171;");
	                    }
	                ]]></jsp:scriptlet>
	            	</div>
	            	<div id="#{clientId}_switch_off"
	                 style="display: #{this:getSwitchOffStatus(context, component)};" class="dr-stglpnl-m rich-stglpnl-marker">
	                <jsp:scriptlet><![CDATA[
	                    if(component.getFacet("openMarker")!=null && component.getFacet("openMarker").isRendered()) {
	                ]]></jsp:scriptlet>
	                    <u:insertFacet name="openMarker" />
	                <jsp:scriptlet><![CDATA[
	                    } else {
	                       writer.write("&#187;");
	                    }
	                ]]></jsp:scriptlet>
            	</div>
            </div>
            
            <jsp:scriptlet><![CDATA[
            	if(component.getFacet("header")!=null && component.getFacet("header").isRendered()) {
            	]]></jsp:scriptlet>
                	<u:insertFacet name="header" />
            	<jsp:scriptlet><![CDATA[
            	} else {
            	]]></jsp:scriptlet>
            	#{component.attributes['label']}
            	<jsp:scriptlet><![CDATA[
                	writer.write("&#160;");
            	}
           	]]></jsp:scriptlet>
        </div>
        
        <jsp:scriptlet>
            <![CDATA[if((component.getSwitchType()!=null) && (component.getSwitchType().equals(component.CLIENT_SWITCH_TYPE)==true)){]]>
        </jsp:scriptlet>

        <div style="display: none;">
            <input type="hidden" id="#{clientId}_input" name="#{clientId}"
                   value="#{component.attributes['opened']}"/>
        </div>
        <jsp:scriptlet>
            <![CDATA[}]]>
        </jsp:scriptlet>
        <f:call name="utils.encodeEndFormIfNessesary"/>

        <div id="#{clientId}_body"
       		 class="dr-stglpnl-b rich-stglpanel-body #{component.attributes['bodyClass']}"
             style="display : #{this:getdivdisplay(context, component)};
             height: #{component.attributes['height']};">

            <vcp:body>
                <f:call name="renderChildren" />
            </vcp:body>
        </div>
    </div>

</f:root>
