function MISModel() {
	this.name = "MISModel";
	this.main = "MISView";
	
	this.__construct = function __construct() {		
		CMgr.getMODEL().getMain();
		CMgr.getMODEL().abortRetrieveInput();
	}
	
	this.setNavContainer = function setNavContainer(p_html) {
		Browser.getElementById('navContainer').innerHTML = p_html;
	}
	
	this.setConfig = function setConfig(p_configName) {
		Browser.getElementById("Model_config").innerHTML = p_configName;
	}
	
	this.setUser = function(p_user) {
		Browser.getElementById("Model_user").innerHTML = p_user;
	}
	
	this.setComp = function setComp(p_prop,p_value) {
		Cookie.create(CMgr.getMODEL().__toString()+"_"+p_prop,p_value);
	}
	
	this.getComp = function getComp(p_prop) {
		return Cookie.read(CMgr.getMODEL().__toString()+"_"+p_prop);
	}
	
	this.__toString = function __toString() {
		return CMgr.getMODEL().name;
	}
	
	// @params: string:component, [string:params for component] 
	this.getLeftbar = function getLeftbar() {
		var callStack 	= new Object();
		callStack.comp 	= CMgr.getMODEL().__toString();
		callStack.method= "getLeftbar";
		callStack.args 	= new Array();
		callStack.cbObject = new Object();

		for(var i=0;i<arguments.length;i++) {
			callStack.args[i] = arguments[i];
		}
		
		if(callStack.args.length > 0) {
			p_comp = callStack.args[0];
			if(p_comp != CMgr.getAUTH().__toString() && p_comp != CMgr.getModel().__toString()) 
				CMgr.getMODEL().setComp("leftbar",p_comp);
		} else {
			var cObj = CMgr.getMODEL().getComp("leftbar");
			if(cObj != null) {
				if(typeof cObj == 'string'){
					p_comp = callStack.args[0] = cObj;
				}else{
					callStack.args = cObj;
					p_comp = callStack.args[0];
				}	
			}else{
				p_comp = null;
			}
		}
		if(p_comp == null) {
			CMgr.getMODEL().setComp("leftbar",this.leftbar);
			p_comp = this.leftbar;
			callStack.args[0] = p_comp;
		}

		callStack.cbObject.callback = CMgr.getMODEL().getLeftbarCb;
		
		if(!CMgr.isCompStarted(p_comp)) {
			eval('CMgr.start(p_comp,callStack)');
		}else{
			var argsStr = callStack.args.join('","');
			if(argsStr != "") argsStr = ',"'+argsStr+'"';
			eval('Ajax.request(callStack.comp,callStack.method'+argsStr+',callStack.cbObject)');
		}
	}
	
	this.getLeftbarCb = function getLeftbarCb(p_cb) {
		Browser.getElementById("navContainer").innerHTML = p_cb[0];
		eval(p_cb[1]);
	}
	
	// @params: string:component, [string:params for component] 
	this.getMain = function getMain() {
		var callStack 	= new Object();
		callStack.comp 	= CMgr.getMODEL().__toString();
		callStack.method= "getMain";
		callStack.args 	= new Array();
		callStack.cbObject = new Object();

		for(var i=0;i<arguments.length;i++) {
			callStack.args[i] = arguments[i];
		}
		
		if(callStack.args.length > 0) {
			p_comp = callStack.args[0];
			if(p_comp != CMgr.getAUTH().__toString() && p_comp != CMgr.getMODEL().__toString()) {
				var cObj = callStack.args; 
				CMgr.getMODEL().setComp("main",cObj);
			}
		} else {
			var cObj = CMgr.getMODEL().getComp("main");
			if(cObj != null) {
				if(typeof cObj == 'string'){
					p_comp = callStack.args[0] = cObj;
				}else{
					callStack.args = cObj;
					p_comp = callStack.args[0];
				}	
			}else{
				p_comp = null;
			}
		}
		if(p_comp == null) {
			var cObj = new Array(this.main);
			CMgr.getMODEL().setComp("main",cObj);
			p_comp = this.main;
			callStack.args[0] = p_comp;
		}
		callStack.cbObject.callback = CMgr.getMODEL().getMainCb;

		if(!CMgr.isCompStarted(p_comp)) {
			eval('CMgr.start(p_comp,callStack)');
		}else{
			var argsStr = callStack.args.join('","');
			if(argsStr != "") argsStr = ',"'+argsStr+'"';
			eval('Ajax.request(callStack.comp,callStack.method'+argsStr+',callStack.cbObject)');
		}
	}
	
	this.getMainCb = function getMainCb(p_cb) {
		Browser.getElementById("main").innerHTML = p_cb[0];
		eval(p_cb[1]);	
	}
	
	this.getRetrieveInput = function getRetrieveInput() {
		var callStack 	= new Object();
		callStack.comp 	= CMgr.getMODEL().__toString();
		callStack.method= "getRetrieveInput";
		callStack.args 	= new Array();
		callStack.cbObject = new Object();

		for(var i=0;i<arguments.length;i++) {
			callStack.args[i] = arguments[i];
		}
		
		if(callStack.args.length > 0) {
			p_comp = callStack.args[0];
			if(p_comp != CMgr.getAUTH().__toString() && p_comp != CMgr.getMODEL().__toString()) {
				var cObj = callStack.args; 
				CMgr.getMODEL().setComp("retrieveInput",cObj);
			}
		} else {
			var cObj = CMgr.getMODEL().getComp("retrieveInput");
			if(cObj != null) {
				if(typeof cObj == 'string'){
					p_comp = callStack.args[0] = cObj;
				}else{
					callStack.args = cObj;
					p_comp = callStack.args[0];
				}	
			}else{
				p_comp = null;
			}
		}
		callStack.cbObject.callback = CMgr.getMODEL().getRetrieveInputCb;
		
		if(p_comp!=null && CMgr.isCompStarted(p_comp)) {
			var argsStr = callStack.args.join('","');
			if(argsStr != "") argsStr = ',"'+argsStr+'"';
			eval('Ajax.request(callStack.comp,callStack.method'+argsStr+',callStack.cbObject)');
		}else if(p_comp!=null){
			eval('CMgr.start(p_comp,callStack)');
		}else{
			return false;
		}
	}
	
	this.getRetrieveInputCb = function getRetrieveInputCb(p_cb) {
		var rInp = Browser.getElementById("retrieveInput");
		var rInpCont = Browser.getElementById("retrieveInputContent");
		Browser.setDisplay(rInp,true);
		Browser.setZIndexToMax(rInp);
		rInpCont.innerHTML = p_cb[0];
		eval(p_cb[1]);
	}

	this.abortRetrieveInput = function abortRetrieveInput() {
		var rInp = Browser.getElementById("retrieveInput");
		var rInpCont = Browser.getElementById("retrieveInputContent");
		var firstChild;
		while(firstChild = rInpCont.firstChild) {
			firstChild.parentNode.removeChild(firstChild);
		}
		Browser.setDisplay(rInp,false);
	}
	
	this.setRightHead = function setRightHead(p_content) {
		Browser.getElementById("userinfo").innerHTML = p_content;
	}
	
	this.setLeftToolbar = function setLeftToolbar(p_content) {
		Browser.getElementById("leftToolbar").innerHTML = p_content;
	}
	
	this.setLeftFootbar = function setLeftFootbar(p_content) {
		Browser.getElementById("leftFootbar").innerHTML = p_content;
	}
	
	this.setMainToolbar = function setMainToolbar(p_content) {
		Browser.getElementById("mainToolbar").innerHTML = p_content;
	}
	
	this.setMainFootbar = function setMainFootbar(p_content) {
		Browser.getElementById("mainFootbar").innerHTML = p_content;
	}
	
	this.setRightFootbar = function setRightFootbar(p_content) {
		Browser.getElementById("rightFootbar").innerHTML = p_content;
	}
	
	this.setRightToolbar = function setRightToolbar(p_content) {
		Browser.getElementById("rightToolbar").innerHTML = p_content;
	}
	
	this.setLocationName = function setLocationName(p_locationName) {
		Browser.getElementById("head_location").innerHTML = p_locationName;
	}
	this.setMainHead = function setMainHead(p_locationName) {
		Browser.getElementById("head_main").innerHTML = p_locationName;
	}
}

var MISModel = new MISModel();

