var ContainerFactory = function() {
};
ContainerFactory.prototype.createEditorContainer = function(header, id,
		containerInfo) {

	var container = document.createElement("div");
	$(container).addClass("containerBox");
	if (id != null) {
		$(container).attr("id", id);
	}
	var containerHeader = document.createElement("p");
	$(containerHeader).addClass("containerHeader");
	$(containerHeader).append(document.createTextNode(header));
	$(container).append(containerHeader);

	for ( var i = 0; i < containerInfo.length; i++) {

		if (containerInfo[i].label == null) {
			containerInfo[i].label = "";
		}
		if (containerInfo[i].name == null) {
			containerInfo[i].name == "";
		}
		if (containerInfo[i].children == null) {
            console.log(containerInfo[i]);
			this.appendEdtiors(container, containerInfo[i].label,
					containerInfo[i].nameCN, containerInfo[i].required, containerInfo[i].name,
					containerInfo[i].paramTypeModel,containerInfo[i].value == null ?"":containerInfo[i].value);
		} else {
			$(container).append(

					this.createEditorContainer(containerInfo[i].nameCN, null,
							containerInfo[i].children));
		}

	}

	return container;

};

ContainerFactory.prototype.appendEdtiors = function(container, label, name, required, id,
		editorInfo, value) {

	var editorFactory = new EditorFactory();

	if (editorInfo.type.toLowerCase() == "field") {
		console.log("required:"+required);
		$(container).append(
				editorFactory.createField(label, name, required, editorInfo.size, id,value));

	} else if (editorInfo.type.toLowerCase() == "nfield") {
		$(container).append(
				editorFactory
						.createMultiField(label, name, required, editorInfo.size, id,value));
	} else if (editorInfo.type.toLowerCase() == "table") {
		$(container).append(
				editorFactory.createTable(label, name, required, editorInfo.cols, id,value));

	} else if (editorInfo.type.toLowerCase() == "file") {
		$(container).append(
				editorFactory.createFile(label, name, required, editorInfo.size, id,value));
	} else if (editorInfo.type.toLowerCase() == "date") {
		$(container).append(
				editorFactory.createDate(label, name, required, editorInfo.size, id,value));
	} else if (editorInfo.type.toLowerCase() == "select") {
		$(container).append(
				editorFactory.createSelect(label, name, editorInfo.size,
						editorInfo.options, id,value));
	} else if (editorInfo.type.toLowerCase() == "checkbox") {
		$(container).append(
				editorFactory.createCheckBox(label, name,
						editorInfo.choiceModels, id,value));
	} else {
		information("no such editor type:" + editorInfo.type);
	}
};
