<?php
$init_script = <<<HTML
	jQuery('[name="number"]').live("change",function(){
		var accordion_number = jQuery(this).val();
		jQuery('.shortcode-item').each(function(i){
			if(i>(1+accordion_number*2)){
				jQuery(this).hide();
			}else{
				jQuery(this).show();
			}
		});
		var select=jQuery('[name="initialNumber"]');
		var selectedOption = select.val();
		jQuery('option', select).remove();
		for (i=1;i<=accordion_number;i++){
			select.append(jQuery("<option></option>").attr("value",i).text(i)); 
		}
		select.val(selectedOption);
	}).trigger("change");
HTML;
$custom_script = <<<HTML
	var number = attrs['number'].value;
	var initialNumber = attrs['initialNumber'].value;
	if(initialNumber != 1){
		initialNumber = ' initialnumber="'+initialNumber+'"';
	}else{
		initialNumber = '';
	}
	var ret = '\\n[accordions'+initialNumber+']\\n';
	for(var i=1;i<=number;i++){
		ret +='[accordion title="'+attrs['tabs','title_'+i].value+'"]\\n'+attrs['tabs','content_'+i].value+'\\n[/accordion]\\n';
	}
	ret +='[/accordions]\\n';
	return ret;
HTML;
return array(
	"title" => __("Accordion",THEME_ADMIN_DOMAIN),
	"type" => 'custom',
	'contentOption' => 'content_1',
	"options" => array(
		array(
			"name" => __("Number of pans",THEME_ADMIN_DOMAIN),
			"id" => "number",
			"min" => "1",
			"max" => "8",
			"step" => "1",
			"default" => "2",
			"type" => "range"
		),
		array(
			"name" => __("Initial Tab",THEME_ADMIN_DOMAIN),
			"id" => "initialNumber",
			"desc" => __("Specifies the accordion that is initially opened when the page loads.",THEME_ADMIN_DOMAIN),
			"options" => array(),
			"default" => "1",
			"type" => "select"
		),
		array(
			"name" => sprintf(__("Accordion %d Title",THEME_ADMIN_DOMAIN),1),
			"id" => "title_1",
			"default" => "",
			"type" => "text"
		),
		array(
			"name" => sprintf(__("Accordion %d Content",THEME_ADMIN_DOMAIN),1),
			"id" => "content_1",
			"default" => "",
			"type" => "textarea"
		),
		array(
			"name" => sprintf(__("Accordion %d Title",THEME_ADMIN_DOMAIN),2),
			"id" => "title_2",
			"default" => "",
			"type" => "text"
		),
		array(
			"name" => sprintf(__("Accordion %d Content",THEME_ADMIN_DOMAIN),2),
			"id" => "content_2",
			"default" => "",
			"type" => "textarea"
		),
		array(
			"name" => sprintf(__("Accordion %d Title",THEME_ADMIN_DOMAIN),3),
			"id" => "title_3",
			"default" => "",
			"type" => "text"
		),
		array(
			"name" => sprintf(__("Accordion %d Content",THEME_ADMIN_DOMAIN),3),
			"id" => "content_3",
			"default" => "",
			"type" => "textarea"
		),
		array(
			"name" => sprintf(__("Accordion %d Title",THEME_ADMIN_DOMAIN),4),
			"id" => "title_4",
			"default" => "",
			"type" => "text"
		),
		array(
			"name" => sprintf(__("Accordion %d Content",THEME_ADMIN_DOMAIN),4),
			"id" => "content_4",
			"default" => "",
			"type" => "textarea"
		),
		array(
			"name" => sprintf(__("Accordion %d Title",THEME_ADMIN_DOMAIN),5),
			"id" => "title_5",
			"default" => "",
			"type" => "text"
		),
		array(
			"name" => sprintf(__("Accordion %d Content",THEME_ADMIN_DOMAIN),5),
			"id" => "content_5",
			"default" => "",
			"type" => "textarea"
		),
		array(
			"name" => sprintf(__("Accordion %d Title",THEME_ADMIN_DOMAIN),6),
			"id" => "title_6",
			"default" => "",
			"type" => "text"
		),
		array(
			"name" => sprintf(__("Accordion %d Content",THEME_ADMIN_DOMAIN),6),
			"id" => "content_6",
			"default" => "",
			"type" => "textarea"
		),
		array(
			"name" => sprintf(__("Accordion %d Title",THEME_ADMIN_DOMAIN),7),
			"id" => "title_7",
			"default" => "",
			"type" => "text"
		),
		array(
			"name" => sprintf(__("Accordion %d Content",THEME_ADMIN_DOMAIN),7),
			"id" => "content_7",
			"default" => "",
			"type" => "textarea"
		),
		array(
			"name" => sprintf(__("Accordion %d Title",THEME_ADMIN_DOMAIN),8),
			"id" => "title_8",
			"default" => "",
			"type" => "text"
		),
		array(
			"name" => sprintf(__("Accordion %d Content",THEME_ADMIN_DOMAIN),8),
			"id" => "content_8",
			"default" => "",
			"type" => "textarea"
		),
	),
	"custom" => $custom_script,
	"init" => $init_script,
);
