var cDataSheet = Class.create({
	initialize: function(_container) {
		this.type = '';
		this.id = 0;
		this.subPage = '';
		this.container = _container;
		this.views = null;
		this.activeSubView = null;
		this.resetViews();
	},
	/* override */
	resetViews: function() {
	},
	showDataSheet: function(type, id) {
		this.type = type;
		this.id = id;
		// remove cached data
		this.resetViews();
		this.changeSubView('');
	},
	callBackLink: function() {
		universe.activeView().callBackLink();
		return false;
	},
	callChangeSubView: function(subPage) {
		this.changeSubView(subPage);
		// kill a href
		return false;
	},
	activateSubView: function(view) {
		view.activate();
		this.activeSubView = view;
	},
	/* override */
	changeSubView: function(subPage) {
	},
	/* override */
	bindMenu: function() {
		//templater.bindElements($$('a.datasheetBackLink'), this.callBackLink.bind(this));
		universe.activeView().bindBack();
	},
	processLinking: function(params) {
		if (params.length > 1) {
			if (this.type != params[0] || this.id != params[1]) {
				this.showDataSheet(params[0], params[1]);
			} else if (params.length <= 2) {
				this.changeSubView('');
			}		
			if (params.length > 2) {
				this.changeSubView(params[2]);
			}
		}
	}
	,refresh: function() {
		this.activeSubView.refresh();
	}
	,refreshData: function() {
		for (view in this.views) {
			this.views[view].refreshData();
		}
	}
});

