//<script type="text/javascript">

//=============================================================================
// The Doodle class provides the framework that binds the application's 
// components together
Doodle = JSX.Class.create({
	name: 'Doodle',
	constructor: function(divCanvas) {
		// create the document
		this.doc = new Doodle.Doc;
		
		// create any views
		this.views = new Array;
		this.views.push(new Doodle.Canvas(divCanvas, this));
		
		// create control container
		this.controls = new Array;
		
		// default input shape
		this.shapeType = Doodle.Doc.Shape.Types.LINE;
	},
	statics: {
		ControlType: {
			SHAPE_TYPE: 1
		}
	},
	members: {
		getDocument: function() {
			return this.doc;
		},

		bindControl: function(controlType, control) {
			if ( !this.controls[controlType] ) {
				this.controls[controlType] = new Array;
			}
			this.controls[controlType].push(control);
		},
		updateControls: function(valueType) {
			// loop through all shape type controls and update
			var shapeControls = this.controls[valueType];
			if ( shapeControls ) {
				for ( var i in shapeControls ) {
					shapeControls[i].onUpdate(valueType);
				}
			}
		},

		getShapeType: function() {
			return this.shapeType;
		},
		setShapeType: function(value) {
			this.shapeType = value;
			this.updateControls(Doodle.ControlType.SHAPE_TYPE);
		},

		/*
		Doodle.UpdateHint = {
			DOC_READY: 1,
			DOC_SHAPE_NEW: 2,
			DOC_SHAPE_CHANGE: 3
		}
		updateAllViews: function(data, hint) {
		},
		*/

		newDocument: function() {
			this.doc.init();
		}
	}
});

//</script>