var fields; var content; var options; $(document).ready(function(){ var path = getConfigPath(); fields = loadJson(path + "config/rules.obj"); content = loadJson(path + "config/content-fields.obj"); options = loadJson(path + "config/options.obj"); }); // end document ready //----------------------------------------------------------- // loadJson(path) // - returns a json object based on the path // var sent //----------------------------------------------------------- function loadJson(path){ var myJson; jQuery.ajax({ url: path, success: function(fields) { myJson = $.parseJSON(fields); }, error: function(fields) { window.location.href = getConfigPath() + 'apply.cgi/error?eid=050&emsg=Q291bGQgbm90IGxvYWQgY29uZmlnIGZpbGUu'; }, async: false }); return myJson; } //--------------------------------------------------------- // getConfigPath() // - converts the query string into the config // directory path //--------------------------------------------------------- function getConfigPath(){ // convert current href into path for config files var path = window.location.href; path = path.replace(/(.*\.cgi).*/, "$1"); path = path.replace(/(^.*\/).*/, "$1"); path = path.replace(/^.*(\/cgi-bin.*)/, "$1"); return path; }