/**
 * title: cons.js
 * purpose: Implement a class to set contants
 * licenses: 
 * This script uses jQuery 1.3.2 under the MIT License:
 * Copyright (c) 2009 John Resig, http://jquery.com/
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 * 
 * This script uses jQuery UI 1.7.1 under the MIT License:
 * Copyright (c) 2009 Paul Bakaus, http://jqueryui.com/
 *
 * This software consists of voluntary contributions made by many
 * individuals (AUTHORS.txt, http://jqueryui.com/about) For exact
 * contribution history, see the revision history and logs, available
 * at http://jquery-ui.googlecode.com/svn/
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
function cons() {
	// properties
	this.cons = {};
	// methods
	this.load = cons_load;
	this.gerr = cons_gerr;
}
function cons_load() {
	var _obj = this;
	// erro
	{
		jQuery.each(
			{
				"ERRO" : 
					{
						"none" : { "ecod" : 0   , "erro" : "Success" },
						"ajax" : { "ecod" : 1 	, "erro" : "An error has occurred. Please try again later." },
						"pdat" : { "ecod" : 2 	, "erro" : "An error has occcured. Please try again later." },
						"mkey" : { "ecod" : 3 	, "erro" : "The requested data is invalid" },
						"mdat" : { "ecod" : 4 	, "erro" : "The requested data is invalid" },
						"json" : { "ecod" : 5 	, "erro" : "An error has occurred. Please try again later." }
					},
				"URLX" : location.href.substring(0,location.href.indexOf("/ecs") + 4),
				"XSES" : 
					{
						"vars" : "1953"
					}
			},
			function(_k,_v) {
				_obj.cons[_k] = _v;
			}
		);
	}
}
function cons_gerr(_erro,_type) {
	if(array_key_exists(_erro,this.cons["ERRO"])) {
		switch(_type) {
			case "c" :
				return this.cons["ERRO"][_erro]["ecod"];
				break;
			case "m" :
				return this.cons["ERRO"][_erro]["erro"];
				break;
		}
	}
}
