
bbcjs.trace('<b style="color:Green">jst_cgi.js was included.</b>',2);new function(){function extendOpts(options,internalHandler){var opts=(typeof(options)=='object')?options:{onLoad:options};var exts={};for(var prop in opts){if(typeof opts[prop]!='function')exts[prop]=opts[prop];else{exts[prop]=(function(_prop){return function(cgi){internalHandler(cgi);opts[_prop](cgi);}})(prop);}}
return exts;}
var cgi=bbcjs.cgi={};cgi.GenericApp=function(path,method){bbcjs.trace('new bbcjs.cgi.GenericApp()',5);this.path=path||'';this.method=method||'POST';this.output={};this.error=false;var __self__=this;var params={OutputFormat:'JSON'};var defaultOptions={onLoad:function(request){bbcjs.trace('bbcjs.cgi.GenericApp.onLoad() called',5);__self__.output=eval('('+request.text()+')');},onError:function(request){bbcjs.trace('bbcjs.cgi.GenericApp.onError() called',1);__self__.error=true;},onInit:function(request){bbcjs.trace('bbcjs.cgi.GenericApp.onInit() called',5);}};this.submitParams=function(options){bbcjs.trace('bbcjs.cgi.GenericApp.submitParams('+(options?'<code>options</code>':'')+') called',4);var opts=(typeof(options)=='object')?options:{onLoad:options};var defs=defaultOptions;bbcjs.extend(opts,{params:params,method:this.method});for(var prop in opts){if(typeof(opts[prop])=='function'&&typeof(defs[prop])=='function'){(function(){var _prop=opts[prop];var _def=defs[prop];opts[prop]=function(o){_def(o);_prop(__self__);};})();}}
var req=new bbcjs.http.Request(opts);req.send(this.path);if(!req.options.async)defs.onLoad(req);};this.submitForm=function(form,options){var data=bbcjs.forms.form2object(form);for(var i in data)this.setParam(i,data[i]);this.submitParams(options);};this.setParam=function(key,value){params[key]=value;};this.getParam=function(key){return params[key];};this.getAllParams=function(){return params;};this.unsetParam=function(key){delete params[key];};this.unsetAllParams=function(){params={OutputFormat:'JSON'};};delete this.__super__;};cgi.IDStore=function(path,method,keyValueMode){bbcjs.trace('new bbcjs.cgi.IDStore("'+path+'", "'+method+'")');this.__super__=cgi.GenericApp;this.__super__('/apps/ifl'+path+'/idstore',method);var __self__=this;var idstoreHandler=null;this.keyValueMode=(keyValueMode!='undefined'&&keyValueMode==true)?true:false;this.id=null;function internalHandler(cgi){if(!cgi.keyValueMode){cgi.output.Data=bbcjs.lib.string.string2obj(cgi.output.Data);}
if(__self__.output.Id){__self__.id=__self__.output.Id;}
__self__.unsetAllParams();}
this.store=function(data,options){var opts=extendOpts(options,internalHandler);if(this.keyValueMode){for(var i in data)this.setParam(i,data[i]);}
else{this.setParam('Data',escape(bbcjs.lib.string.obj2string(data)));}
if(this.id)this.setParam('Id',this.id);this.setParam('Mode','store');this.submitParams(opts);if(!opts.onLoad)internalHandler(this);};this.fetch=function(options){if(this.id){var opts=extendOpts(options,internalHandler);this.setParam('Id',this.id);this.setParam('Mode','fetch');this.submitParams(opts);if(!opts.onLoad)internalHandler(this);}
else{this.error=true;bbcjs.trace('Warning - No id for bbcjs.cgi.IDStore.fetch()',1);}};this.touch=function(options){if(this.id){var opts=extendOpts(options,internalHandler);this.setParam('Id',this.id);this.setParam('Mode','touch');this.submitParams(opts);if(!opts.onLoad)internalHandler(this);}
else{this.error=true;bbcjs.trace('Warning - No id for bbcjs.cgi.IDStore.fetch()',1);}};this.status=function(status,options){if(this.id){var opts=extendOpts(options,internalHandler);this.setParam('Id',this.id);this.setParam('Mode','status');this.setParam('Status',status);this.submitParams(opts);if(!opts.onLoad)internalHandler(this);}
else{this.error=true;bbcjs.trace('Warning - No id for bbcjs.cgi.IDStore.fetch()',1);}};};cgi.IDStore.prototype=new cgi.GenericApp;cgi.UserData=function(path,method){bbcjs.trace('new bbcjs.cgi.UserData("'+path+'", "'+method+'")');this.__super__=cgi.GenericApp;this.__super__('/apps/ifl'+path+'/userdata',method);var __self__=this;var userdataHandler=null;function internalHandler(cgi){__self__.unsetAllParams();}
this.store=function(data,options){if(!data)throw"bbcjs.cgi.UserData.store: null value for 'data'";var opts=extendOpts(options,internalHandler);for(var i in data)this.setParam(i,data[i]);this.setParam('Mode','store');this.submitParams(opts);if(!opts.onLoad)internalHandler(this);};this.fetch=function(options){var opts=extendOpts(options,internalHandler);this.setParam('Mode','fetch');this.submitParams(opts);if(!opts.onLoad)internalHandler(this);};this.touch=function(options){var opts=extendOpts(options,internalHandler);this.setParam('Mode','touch');this.submitParams(opts);if(!opts.onLoad)internalHandler(this);};this.remove=function(data,options){if(!data){throw"bbcjs.cgi.UserData.remove(): null value for 'data'";}
var opts=extendOpts(options,internalHandler);var key=new Array();key["Key"]=data;for(var i in key)this.setParam(i,key[i]);this.setParam('Mode','delete');this.submitParams(opts);if(!opts.onLoad)internalHandler(this);};this.isSignedIn=function(){if(this.output.NOT_LOGGED_IN)
return false;return true;};this.getFetchedData=function(){return this.output.primary_user.fetched;};this.hadErrors=function(){if(this.error||this.output.ERROR)
return true;return false;};this.getErrorMsg=function(){var errMsg="No errors occurred";if(this.error){errMsg="A transport error occurred while trying to communicate with UserData";}
else if(this.output.ERROR){errMsg=this.output.ERROR;}
return errMsg;};this.hadValidationErrors=function(){if(this.output.VALIDATION_ERRORS)
return true;return false;};this.getValidationErrors=function(){return this.output.VALIDATION_ERRORS;};this.getSSOUsername=function(){return this.output.primary_user.username;};this.getSSOId=function(){return this.output.primary_user.userid;};this.clientIsBBC=function(){if(this.output.CLIENT_IS_BBC==1)
return true;return false;};this.getUserDataVersion=function(){return this.output.VERSION;};};cgi.UserData.prototype=new cgi.GenericApp;cgi.QueryEngine=function(path,method){bbcjs.trace('new bbcjs.cgi.QueryEngine("'+path+'", "'+method+'")');this.__super__=cgi.GenericApp;this.__super__('/apps/ifl'+path+'/queryengine',method);this.config='';this.filters=[];this.sorts=[];};cgi.QueryEngine.prototype=bbcjs.extend(new cgi.GenericApp,{addFilter:function(attrib,oper,val){this.filters.push({attrib:attrib,oper:oper,val:val});},resetFilters:function(){this.filters=[];},addSort:function(sort,sortsense){this.sorts.push({sort:sort,sortsense:sortsense});},resetSorts:function(){this.sorts=[];},setPage:function(page,pagesize){this.setParam('page',page);if(pagesize)this.setPageSize(pagesize);},setPageSize:function(pagesize){this.setParam('pagesize',pagesize);},query:function(options){var y;bbcjs.forEach(this.filters,function(f,i){y=i+1;this.setParam('attrib_'+y,f.attrib);this.setParam('oper_'+y,f.oper);this.setParam('val_'+y+'_1',f.val);},this);bbcjs.forEach(this.sorts,function(s,i){y=i+1;this.setParam('sort_'+y,s.sort);this.setParam('sortsense_'+y,s.sortsense);},this);if(this.config)this.setParam('config',this.config);this.submitParams(options);}});cgi.ShowRecord=function(path,method){bbcjs.trace('new bbcjs.cgi.ShowRecord("'+path+'", "'+method+'")');var __self__=this;this.__super__=cgi.GenericApp;this.__super__('/apps/ifl'+path+'/showrecord',method);this.config='';this.Id=null;};cgi.ShowRecord.prototype=bbcjs.extend(new cgi.GenericApp,{setId:function(id){this.Id=id;},getRecord:function(options){options=bbcjs.extend({repeatKeys:true},options||{});this.setParam('Id',this.Id);if(this.config)this.setParam('config',this.config);this.submitParams(options);}});cgi.Log2Results=function(path){bbcjs.trace('new bbcjs.cgi.Log2Results("'+path+'")');this.__super__=cgi.GenericApp;this.__super__('/apps/ifl'+path+'/log2results','GET');this.setParam('L2REndPage','/cs/jst/cgi_end.js');};cgi.Log2Results.prototype=bbcjs.extend(new cgi.GenericApp,{store:function(data,options){for(var i in data)this.setParam(i,data[i]);this.submitParams(options);}});cgi.Post2Log=function(path){bbcjs.trace('new bbcjs.cgi.Post2Log("'+path+'")');this.__super__=cgi.GenericApp;this.__super__('/apps/ifl'+path+'/post2log','POST');this.setParam('L2REndPage','/cs/jst/cgi_end.js');};cgi.Post2Log.prototype=bbcjs.extend(new cgi.GenericApp,{store:function(data,options){for(var i in data)this.setParam(i,data[i]);this.submitParams(options);}});cgi.SendEmail=function(path,method){bbcjs.trace('new bbcjs.cgi.SendEmail("'+path+'", "'+method+'")');this.__super__=cgi.GenericApp;this.__super__('/apps/ifl'+path+'/sendemail',method);var __self__=this;var sendemailHandler=null;function internalHandler(cgi){__self__.unsetAllParams();}
this.send=function(data,options){if(!data){throw"bbcjs.cgi.SendEmail.send(): null value for 'data'";}
var opts=extendOpts(options,internalHandler);for(var i in data)this.setParam(i,data[i]);this.submitParams(opts);if(!opts.onLoad)internalHandler(this);};this.getEmail=function(){return this.output.Email;};this.hadErrors=function(){if(this.output.ERROR)
return true;return false;};this.getErrorMsg=function(){var errMsg="No errors occurred";if(this.output.ERROR){errMsg=this.output.ERROR;}
return errMsg;};this.hadValidationErrors=function(){if(this.output.VALIDATION_ERRORS)
return true;return false;};this.getValidationErrors=function(){return this.output.VALIDATION_ERRORS;};this.clientIsBBC=function(){if(this.output.CLIENT_IS_BBC==1)
return true;return false;};this.getSendEmailVersion=function(){return this.output.VERSION;};};cgi.SendEmail.prototype=new cgi.GenericApp;}();