var BoltApp = {}; // Object definition

// ============================================
// create application
BoltApp.app = function(){
	// ============================================
    // private variables
	var _rootPath, _ajaxTarget;
	var _defaultAJAXPath = "application.Bolt";
	
	// ============================================
    // private functions
	
	// ========================
	var getDefaultAJAXPath = function(){
		return _defaultAJAXPath;
	};
	
	// ============================================
    // public space
    return {
		// ============================================
        // public properties, e.g. strings to translate
		
		examplePublicProp: 0,
 
 		// ============================================
        // public methods
		
		// ========================
        init: function(){
			// called when page has loaded and JQuery is available
			// this can be used for all generic JQuery wire ups
			
		},
		
		// ========================
		setRootPath: function(pPath){
			this._rootPath = pPath;
		},
		// ========================
		setAjaxTarget: function(pPath){
			this._ajaxTarget = pPath;
		},
		// ========================
		getRootPath: function (){
			return this._rootPath;
		},
		// ========================
		getAjaxPath: function(){
			return this._rootPath + this._ajaxTarget;
		},
		
		// ========================
		// constructs a string used in AJAX requests to our remote proxy
		getProxyTarget: function(pMethod, pArgs, pPath, pType){
			if(pArgs == undefined) pArgs = "";
			if(pPath == undefined) pPath = getDefaultAJAXPath();
			if(pType == undefined) pType = "RAW";
			var time = new Date().getTime();
			return this.getAjaxPath() + "?antiCache=" + time + "&method=Response&proxyPath=" + pPath + "&proxyMethod=" + pMethod + "&proxyReturnType=" + pType + "&proxyArgs=" + top.$.toJSON(pArgs);
		},
		
		getObjectProxy: function(pModel, pMethod, pArgs, pType){
			if(pArgs == undefined) pArgs = {};
			if(pType == undefined) pType = "RAW";
			pArgs.proxy_DAO = pModel;
			pArgs.proxy_method = pMethod;
			return this.getProxyTarget("objectProxy", pArgs, getDefaultAJAXPath(), pType);
		},
		
		// ========================
		// returns a string to use for AJAX requests to our remote proxy to call a Service layer method
		getServiceProxy: function(pModel, pMethod, pArgs, pType){
			if(pArgs == undefined) pArgs = {};
			if(pType == undefined) pType = "RAW";
			pArgs.proxy_DAO = pModel;
			pArgs.proxy_method = pMethod;
			return this.getProxyTarget("serviceProxy", pArgs, getDefaultAJAXPath(), pType);
		}
				
		
	};
}(); // end of app

// ==========================
// initiate application variables
BoltApp.app.setAjaxTarget("remote/remoteProxy.cfc"); // target of our remoteProxy handler
BoltApp.app.setRootPath("/"); // path to site root

/*
$(function(){
	BoltApp.app.init();
});*/
