/**
 * FormFieldPageGroup Class
 */

var FormFieldPageGroup = Class.create({
	// Getters & Setters
	getDisplay: function() {
		return this.display;
	},
	setDisplay: function(value) {
		this.display = value;
	},
	getDescription: function() {
		return this.description;
	},
	setDescription: function(value) {
		this.description = value;
	},
	getPages: function() {
		return this.pages;
	},
	setPages: function(value) {
		this.pages = value;
	},
	
	// Constructor
	initialize: function(properties) {
		// Initialize Members
		this.display = null;
		this.description = null;
		this.pages = null;
		
		if (properties !== undefined) {
			if (properties.display !== undefined) {
				this.setDisplay(properties.display);
			}
			if (properties.description !== undefined) {
				this.setDescription(properties.description);
			}
			if (properties.pages !== undefined) {
				this.setPages(properties.pages);
			}
			
			if (properties._display !== undefined) {
				this.setDisplay(properties._display);
			}
			if (properties._description !== undefined) {
				this.setDescription(properties._description);
			}
			if (properties._pages !== undefined) {
				this.setPages(properties._pages);
			}
		}
	},
	
	// Methods
	create: function(container, options) {
		// Create page list container
		if (options.pageListContainer != undefined) {
			if (options.pageListHeaderElement) {
				createExtendedElement(options.pageListHeaderElement, {
					innerHTML: this.getDisplay(),
					parent: options.pageListContainer
				});
			}
			if (options.pageListElement) {
				var pageList = options.pageList = createExtendedElement(options.pageListElement, {
					className: options.pageListClass,
					parent: options.pageListContainer
				});
				options.pageLists.push(pageList);
			}
			if (options.pageListDivider != undefined) {
				$(options.pageListDivider).show();
			}
		}
		
		// Add Field Pages
		if (this.getPages()) {
			$A(this.getPages()).each(function(item) {
				item.create(container, options);
			});
		}
	}
});