<?php
/**
 * @version    $Id$
 * @package    IT_Theme_Framework
 * @author     InnoThemes Team <support@innothemes.com>
 * @copyright  Copyright (C) 2012 InnoThemes.com. All Rights Reserved.
 * @license    GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Websites: http://www.innothemes.com
 */

// Check if this section has own template
$tmpl = IT_Loader::get_path( "form/tmpl/section/{$sid}.php" );

// Check if this section has additional attributes
if ( isset( $section['attributes'] ) ) {
	foreach ( $section['attributes'] as $k => $v ) {
		$section['attributes'][$k] = esc_attr( $k ) . '="' . esc_attr( $v ) . '"';
	}
}
?>
<div id="it-form-section-<?php esc_attr_e( $sid ); ?>" <?php if ( isset( $section['attributes'] ) ) echo '' . implode( ' ', $section['attributes'] ); ?>>
<?php
// Check if a specific section is requested
if ( empty( $section_id ) || $section_id == $sid ) :

if ( ! empty( $tmpl ) ) :
	include $tmpl;
else :
	if ( isset( $section['fields'] ) ) :
		$this->current_fields = $section['fields'];

		// Load fields template
		include IT_Loader::get_path( 'form/tmpl/fields.php' );
	endif;

	if ( isset( $section['fieldsets'] ) ) :
		$this->current_fieldsets = $section['fieldsets'];

		// Load fieldsets template
		include IT_Loader::get_path( 'form/tmpl/fieldsets.php' );
	endif;

	if ( isset( $section['accordion'] ) ) :
		$this->current_accordion = $section['accordion'];

		// Load accordion template
		include IT_Loader::get_path( 'form/tmpl/accordion.php' );
	endif;

	if ( isset( $section['tabs'] ) ) :
		$this->current_tabs = $section['tabs'];

		// Load tabs template
		include IT_Loader::get_path( 'form/tmpl/tabs.php' );
	endif;
endif;

endif;
?>
</div>
