// zooloo container superclass
function ZoolooContainer() {
	var _tabName = '';
	var _tabProperties = {};
	var _tabDeletable = false;
	this.actions = {ADD_ELEMENT:'add element'};
	this.setTabName = function(tabName) { _tabName = tabName; };
	this.getTabName = function() { return (typeof _tabProperties === 'object' && _tabProperties.page_name) ? _tabProperties.page_name : ''; };
	this.getTabId = function() { return (typeof _tabProperties === 'object' && _tabProperties.page_id) ? _tabProperties.page_id : ''; };
	this.setTabProperties = function(tabProperties) { if(typeof tabProperties === 'object') { _tabProperties=tabProperties; } };
	this.getTabProperties = function() { return _tabProperties; };
	this.nameTab = function(tabContainer) {};
	this.processTab = function(tabId,tab,temp) {};
	this.renameTab = function(tabId,tabName,successCallback,failureCallback) {};
	this.addTab = function() {};
	this.moveTab = function(tabId,posConf,successCallback,failureCallback) {};
	this.addElement = function(tabId,typeId,elementId,elConf,parentId,posConf,iSuccessCallback,failureCallback) {};
	this.updateElement = function(elementId,elConf,iSuccessCallback,failureCallback) {};
	this.moveElement = function(tabId,elementId,newParentId,posConf,iSuccessCallback,failureCallback) {};
	this.removeElement = function(elementId,iSuccessCallback,failureCallback) {};
	this.makeAcceptPageElements = function(selector) {};
	this.makeAcceptSiteLayoutElements = function(selector) {};
	this.makeSortable = function(selector,fromOtherSelector) {};
	this.setSiteStyle = function(styleElementId,styleConf) {};
	this.setupElementContainer = function(elementId,elementClass) {};
	this.updateElementContainerTitle = function(elementId,title) {};
	this.isValidTabName = function(tabName) { return (!tabName.match(/\S+/) || !tabName.match(/^[^_\\\\<>][^\\\\<>]*$/)) ? 0 : 1; };
	this.setTabDeletable = function(deletable) { if(typeof deletable==='boolean') _tabDeletable = deletable; };
	this.isTabDeletable = function() { return _tabDeletable; };

	// for blocking certain actions while performing a specific action
	var _blockedActions = [];
	this.blockActions = function(actions) {
		_blockedActions = $.makeArray(actions);
	};
	this.clearBlockedActions = function() { _blockedActions = []; };
	this.isActionBlocked = function(action) {
		return ($.inArray(action,_blockedActions)>=0) ? 1 : 0;
	};

	// elements setup
	var _elementSetupConfs = {};	// by id
	var _elementByClassSetupConfs = {};	// by class

	this.init = function() { };
    this.getElementSetupConf = function(elementId) {
    	// get basic conf
      	var conf = _elementSetupConfs[elementId];
    	// get additional conf
    	if(conf) { conf.elConf = conf.elClass.getConf(elementId); }
    	return conf;
    };
    this.getByClassElementSetupConf = function(element) {
    	var conf;
    	var elementId = element.attr('id');
    	for(var cl in _elementByClassSetupConfs) {
	    	if(element && element.hasClass(cl)) {
	    		conf = _elementByClassSetupConfs[cl];
	    		if(conf && elementId) {
	    			conf.elConf = conf.elClass.getConf(elementId);
	    			return conf;
	    		}
	    	}
	    }
    	return conf;
    };
    // element templates
    var _elementTemplates = {};
	this.setElementTemplate = function(elementId,template) { _elementTemplates[elementId] = template; };
	this.hasElementTemplate = function(elementId,setupConf) {
		// some elements always need template
		var template = _elementTemplates[elementId];
		return (!template || typeof template != 'string' || template==='') ? 0 : 1;
	};
	this.createElement = function(elementId,elementGUID) {
		var el;
		var template = _elementTemplates[elementId];
		if(template && typeof template == 'string') { el = $(template.replace(/__ELEMENTID__/g,elementGUID)); }
		return el;
	};
}
