/*
 * Requires: jquery, profile.js, phones.js, address.js, section.js
 */
var Plants = {};

function Plant(id, name, edit) {
	this.name = name;
	this.id = id;
	this.edit = edit;
}
Plant.prototype = {
	info: function() {
		var self = this;
		if (this.edit) {
			if (Profiles[this.getId()] && Profiles[this.getId()].setUpdate) {}
			else Profiles[this.getId()] = this;

			Phones[this.getId()] = new Contact('phone', this.getId());
			Addresses[this.getId()] = new Contact('address', this.getId());

			$(document).ready(function(){
				self.date = self.getElt('productiondate').datepicker();
				if (self.edit == true) {
					var description = $(document.createElement('div'));
					description.addClass('description');
					description.html('The first image you upload will be used as the profile picture.');
					$('div#' + self.getId() + " h5:contains('Documents')").after(description);
				}
			});
		}
		else Profiles[this.getId()] = this;

		Sections[this.getId() + 'contact'] = new Section('contact', this.getId());
		Emails[this.getId()] = new Email(this.getId());
	}
};
Plant.prototype = jQuery.extend(Plant.prototype, Profile.prototype);