text: //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
  //>>description: Creates collapsible content blocks.
  //>>label: Collapsible
  //>>group: Widgets
  //>>css.structure: ../css/structure/jquery.mobile.collapsible.css
  //>>css.theme: ../css/themes/default/jquery.mobile.theme.css
  
  define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.buttonMarkup" ], function( $ ) {
  //>>excludeEnd("jqmBuildExclude");
  (function( $, undefined ) {
  
  $.widget( "mobile.collapsible", $.mobile.widget, {
  	options: {
  		expandCueText: " click to expand contents",
  		collapseCueText: " click to collapse contents",
  		collapsed: true,
  		heading: "h1,h2,h3,h4,h5,h6,legend",
  		theme: null,
  		contentTheme: null,
  		inset: true,
  		mini: false,
  		initSelector: ":jqmData(role='collapsible')"
  	},
  	_create: function() {
  
  		var $el = this.element,
  			o = this.options,
  			collapsible = $el.addClass( "ui-collapsible" ),
  			collapsibleHeading = $el.children( o.heading ).first(),
  			collapsedIcon = $el.jqmData( "collapsed-icon" ) || o.collapsedIcon,
  			expandedIcon = $el.jqmData( "expanded-icon" ) || o.expandedIcon,
  			collapsibleContent = collapsible.wrapInner( "<div class='ui-collapsible-content'></div>" ).children( ".ui-collapsible-content" ),
  			collapsibleSet = $el.closest( ":jqmData(role='collapsible-set')" ).addClass( "ui-collapsible-set" );
  
  		// Replace collapsibleHeading if it's a legend
  		if ( collapsibleHeading.is( "legend" ) ) {
  			collapsibleHeading = $( "<div role='heading'>"+ collapsibleHeading.html() +"</div>" ).insertBefore( collapsibleHeading );
  			collapsibleHeading.next().remove();
  		}
  
  		// If we are in a collapsible set
  		if ( collapsibleSet.length ) {
  			// Inherit the theme from collapsible-set
  			if ( !o.theme ) {
  				o.theme = collapsibleSet.jqmData( "theme" ) || $.mobile.getInheritedTheme( collapsibleSet, "c" );
  			}
  			// Inherit the content-theme from collapsible-set
  			if ( !o.contentTheme ) {
  				o.contentTheme = collapsibleSet.jqmData( "content-theme" );
  			}
  
  			// Get the preference for collapsed icon in the set
  			if ( !o.collapsedIcon ) {
  				o.collapsedIcon = collapsibleSet.jqmData( "collapsed-icon" );
  			}
  			// Get the preference for expanded icon in the set
  			if ( !o.expandedIcon ) {
  				o.expandedIcon = collapsibleSet.jqmData( "expanded-icon" );
  			}
  			// Gets the preference icon position in the set
  			if ( !o.iconPos ) {
  				o.iconPos = collapsibleSet.jqmData( "iconpos" );
  			}
  			// Inherit the preference for inset from collapsible-set or set the default value to ensure equalty within a set
  			if ( collapsibleSet.jqmData( "inset" ) !== undefined ) {
  				o.inset = collapsibleSet.jqmData( "inset" );
  			} else {
  				o.inset = true;
  			}
  			// Gets the preference for mini in the set
  			if ( !o.mini ) {
  				o.mini = collapsibleSet.jqmData( "mini" );
  			}
  		} else {
  			// get inherited theme if not a set and no theme has been set
  			if ( !o.theme ) {
  				o.theme = $.mobile.getInheritedTheme( $el, "c" );
  			}
  		}
  		
  		if ( !!o.inset ) {
  			collapsible.addClass( "ui-collapsible-inset" );
  		}
  		
  		collapsibleContent.addClass( ( o.contentTheme ) ? ( "ui-body-" + o.contentTheme ) : "");
  
  		collapsedIcon = $el.jqmData( "collapsed-icon" ) || o.collapsedIcon || "plus";
  		expandedIcon = $el.jqmData( "expanded-icon" ) || o.expandedIcon || "minus";
  
  		collapsibleHeading
  			//drop heading in before content
  			.insertBefore( collapsibleContent )
  			//modify markup & attributes
  			.addClass( "ui-collapsible-heading" )
  			.append( "<span class='ui-collapsible-heading-status'></span>" )
  			.wrapInner( "<a href='#' class='ui-collapsible-heading-toggle'></a>" )
  			.find( "a" )
  				.first()
  				.buttonMarkup({
  					shadow: false,
  					corners: false,
  					iconpos: $el.jqmData( "iconpos" ) || o.iconPos || "left",
  					icon: collapsedIcon,
  					mini: o.mini,
  					theme: o.theme
  				});
  
  		if ( !!o.inset ) {				
  			collapsibleHeading
  				.find( "a" ).first().add( ".ui-btn-inner", $el )
  					.addClass( "ui-corner-top ui-corner-bottom" );
  		}
  
  		//events
  		collapsible
  			.bind( "expand collapse", function( event ) {
  				if ( !event.isDefaultPrevented() ) {
  					var $this = $( this ),
  						isCollapse = ( event.type === "collapse" ),
  						contentTheme = o.contentTheme;
  
  					event.preventDefault();
  
  					collapsibleHeading
  						.toggleClass( "ui-collapsible-heading-collapsed", isCollapse)
  						.find( ".ui-collapsible-heading-status" )
  							.text( isCollapse ? o.expandCueText : o.collapseCueText )
  						.end()
  						.find( ".ui-icon" )
  							.toggleClass( "ui-icon-" + expandedIcon, !isCollapse )
  							.toggleClass( "ui-icon-" + collapsedIcon, isCollapse )
  						.end()
  						.find( "a" ).first().removeClass( $.mobile.activeBtnClass );
  
  					$this.toggleClass( "ui-collapsible-collapsed", isCollapse );
  					collapsibleContent.toggleClass( "ui-collapsible-content-collapsed", isCollapse ).attr( "aria-hidden", isCollapse );
  
  					if ( contentTheme && !!o.inset && ( !collapsibleSet.length || collapsible.jqmData( "collapsible-last" ) ) ) {
  						collapsibleHeading
  							.find( "a" ).first().add( collapsibleHeading.find( ".ui-btn-inner" ) )
  							.toggleClass( "ui-corner-bottom", isCollapse );
  						collapsibleContent.toggleClass( "ui-corner-bottom", !isCollapse );
  					}
  					collapsibleContent.trigger( "updatelayout" );
  				}
  			})
  			.trigger( o.collapsed ? "collapse" : "expand" );
  
  		collapsibleHeading
  			.bind( "tap", function( event ) {
  				collapsibleHeading.find( "a" ).first().addClass( $.mobile.activeBtnClass );
  			})
  			.bind( "click", function( event ) {
  
  				var type = collapsibleHeading.is( ".ui-collapsible-heading-collapsed" ) ? "expand" : "collapse";
  
  				collapsible.trigger( type );
  
  				event.preventDefault();
  				event.stopPropagation();
  			});
  	}
  });
  
  //auto self-init widgets
  $( document ).bind( "pagecreate create", function( e ) {
  	$.mobile.collapsible.prototype.enhanceWithin( e.target );
  });
  
  })( jQuery );
  //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
  });
  //>>excludeEnd("jqmBuildExclude");
  