<?
#######################################################################
## $ACCORDMODE = 0 ... start / 1 ... end
## $ACCORDAUTOCLOSE = string  True / False
## $ACCORDOPEN = string  True / False
## $ACCORDCAPTION = string
## $ACCORDEFFECT = 0 ... slide 1 ... fade 2 ... show
## $ACCORDCLOSELINK  string  True / False
## $ACCORDID  string  True / False
## $ACCORDSPEED   0 ... slow / 1 || "" ... normal / 2 ... fast
##
## Note: if a contentslider active this will be completly ignored
##
#######################################################################

global $Design;
$Design->RegCss['accordion']['css'] = true;
require_once(DESIGNRENDERSCRIPTS.'accordion.class.php');

if ($ACCORDMODE=="0" && !$wb->Instances->SliderActive()) {
	/* MODE 0 means:normal */

	$open = "";
	if ($ACCORDOPEN == "True")
		$open = "opened";
	$instance =  $wb->Instances->AccordInstance();
	
	if (!$instance) {		
		$accord = $wb->Instances->AccordSetInstance (new AccordionHandler());   
		#$wb->accord = new AccordionHandler();
		$content = $accord->Add(GetHashCode($ACCORDID),VTDPARA::CaptionAdds().quote2entities($ACCORDCAPTION),
			$ACCORDAUTOCLOSE,$ACCORDEFFECT,$ACCORDCLOSELINK,$open,$ACCORDSPEED );  
		if (isset($P['PreSpace']) && $P['PreSpace'] == "True") {    
			$space = $wb->SPACE_VALS[$P['PreSpaceVal']];
			$content .= VTDPARA::GapGen($space);  
		} 
		$fp = fopen(PARAGRAPH_OUTPUT.$P['id'].'.php',"w+");
			fwrite($fp,$wb->SECURE_HEADER.$content);
			fclose($fp);
		$Paragraph->Content['Content'] = 'STR_MakeParagraph(SENTRA_HOME.\'assets/content/'.$ACCORDID.'.php\',true);';	
		$accord->AddData($Paragraph->Content['Content']);
		$Paragraph->Content = array();
		#$wb->Instances->FillData($Paragraph->Content['Content']);	
	} else {
		$accord = $wb->Instances->AccordGetInstance ();
		$content = $accord->Add(GetHashCode($ACCORDID),VTDPARA::CaptionAdds().quote2entities($ACCORDCAPTION),
			$ACCORDAUTOCLOSE,$ACCORDEFFECT,$ACCORDCLOSELINK,$open,$ACCORDSPEED );
		if (isset($P['PreSpace']) && $P['PreSpace'] == "True") {    
			$space = $wb->SPACE_VALS[$P['PreSpaceVal']];
			$content .= VTDPARA::GapGen($space);  
		} 
		$fp = fopen(PARAGRAPH_OUTPUT.$ACCORDID.'.php',"w+");
		fwrite($fp,$wb->SECURE_HEADER.$content);
		fclose($fp);
		$Paragraph->Content['Content'] = 'STR_MakeParagraph(SENTRA_HOME.\'assets/content/'.$ACCORDID.'.php\');';	
		$accord->AddData($Paragraph->Content['Content']);
		$Paragraph->Content = array();
	}
}

if ($ACCORDMODE=="1" && $wb->Instances->AccordInstance() && !$wb->Instances->SliderActive()) {
	$accord = $wb->Instances->AccordGetInstance ();
	$content = $accord->CloseAccords();	
	if (isset($P['PreSpace']) && $P['PreSpace'] == "True") {    
		$space = $wb->SPACE_VALS[$P['PreSpaceVal']];
		$content .= VTDPARA::GapGen($space);  
	} 
	VTDPARA::WriteContent($content,$ACCORDID);
	$Paragraph->Content['Content'] = 'STR_MakeParagraph(SENTRA_HOME.\'assets/content/'.$ACCORDID.'.php\');';
	$accord->AddData($Paragraph->Content['Content']);
	$Paragraph->Content['Content'] = '@include(SENTRA_HOME.\'assets/content/a-'.$ACCORDID.'.php\');';
	$c = $accord->GetData();
	VTDPARA::WriteContent('<?php '.$c.' ?>','a-'.$ACCORDID);
	$wb->Instances->AccordDelInstance ();
	$wb->Instances->FillData($Paragraph->Content['Content']);	
	}

?>