/*
 Copyright 1999-2011 RewardStream Inc. All rights reserved.
*/
var l=!0,o=null;
(function(){function w(a){for(var b="",c=0;c<a.length;c++)b+=a[c],c<a.length-1&&(b+=", ");return b}function k(a,b){a||(a={});b||(b={});for(var c in a){var f=a[c];if(0==c.indexOf("__"))switch(c){case "__Type__":this.__Type__=f;break;case "__DesignId__":this.__DesignId__=f;break;case "__TypeCode__":this.__TypeCode__=f}else b[c]&&(this[c]=new d(f,b[c]))}}function d(a,b){this.a=a;this.b=b}function i(a,b){this.r=a;this.f=b}function q(){}function t(){}k.prototype.attributes=function(a){var b=[],c;for(c in this){var f=
this[c];0!=c.indexOf("__")&&f instanceof d&&(a||!f.i())&&b.push(f)}return b};k.prototype.keys=function(a){var b=[],c;for(c in this){var f=this[c];0!=c.indexOf("__")&&f instanceof d&&(a||!f.i())&&b.push(c)}return b};k.prototype.toJSON=function(){var a={},b=this.keys(l),c;for(c in b){var f=b[c];0!=f.indexOf("__")&&(a[f]=this[f])}return a};window.RsValueObject=k;k.prototype.attributes=k.prototype.attributes;k.prototype.keys=k.prototype.keys;k.prototype.toJSON=k.prototype.toJSON;d.prototype.toString=
function(){if(this.b){var a;switch(this.b.AtTp){case "List":a=this.b.CdSt[this.a];break;case "Id":a=this.b.Desc;if(!a)a=this.a;break;case "MultipleChoice":a=w(this.selected());break;case "IdList":a=w(this.selected());break;case "Date":return(new Date(this.a)).toString()}if(!a)a=this.a;"object"==typeof a&&(a=a[e.d].toString());return a.toString()}return this.a.toString()};d.prototype.F=function(a){if(void 0!==a)switch(this.b.AtTp){case "List":if(this.b.NtInCdSt||a in this.b.CdSt){this.a=a;break}else throw new q;
case "MultipleChoice":if(!(a instanceof Array))throw new TypeError("Attribute.value called with non-array");if(!this.b.NtInCdSt)for(var b=0;b<a.length;b++)if(!(a[b]in this.b.CdSt))throw new q;this.a=a;break;default:this.a=a}switch(this.b.AtTp){case "Date":return new Date(this.a);default:return this.a}};d.prototype.name=function(){var a="",b=this.b.Nm;if(b)(a=b[e.d])||(a=b.en);return a};d.prototype.all=function(){var a=this.b.AtTp;if("List"==a||"MultipleChoice"==a){var a=[],b;for(b in this.b.CdSt)a.push(new i(b,
this.b.CdSt[b]));return a}return o};d.prototype.selected=function(){var a,b,c;switch(this.b.AtTp){case "List":return new i(this.a,this.toString());case "Id":return new i(this.a,this.toString());case "MultipleChoice":a=[];for(b=0;b<this.a.length;b++)c=this.a[b],a.push(new i(c,this.b.CdSt[c]));return a;case "IdList":a=[];for(b=0;b<this.a.length;b++)c=this.a[b],a.push(new i(c,this.b.Desc[c]));return a;default:return o}};d.prototype.i=function(){return this.b.Hd};d.prototype.type=function(){return this.b.AtTp};
d.prototype.toJSON=function(){return this.a&&"function"===typeof this.a.toJSON?this.a.toJSON():this.a};window.RsAttribute=d;d.prototype.val=d.prototype.F;d.prototype.name=d.prototype.name;d.prototype.all=d.prototype.all;d.prototype.selected=d.prototype.selected;d.prototype.hidden=d.prototype.i;d.prototype.type=d.prototype.type;d.prototype.toString=d.prototype.toString;d.prototype.toJSON=d.prototype.toJSON;i.prototype.toString=function(){return this.o()};i.prototype.o=function(){return"object"==typeof this.f?
this.f[e.d]:this.f};i.prototype.code=function(){return this.r};window.RsCode=i;i.prototype.desc=i.prototype.o;i.prototype.code=i.prototype.code;i.prototype.toString=i.prototype.toString;q.prototype=Error();window.RsInvalidCodeError=q;t.prototype=Error();window.RsInternalError=t;var r=window.RS,e={k:"/api/v1/",s:"https://"+location.host+this.k,l:!1,d:"en",call:function(a,b,c,f,n,d,m){if(e.l){a=(m?e.s:e.k)+a;m="";if(b){var m=m+"?",u=l,j;for(j in b)!u&&(m+="&"),u&&(u=!1),m+=j+"="+encodeURIComponent(b[j]);
a+=m}var g=e.u();f?(g.open("POST",a,l),g.setRequestHeader("Content-Type","application/json; charset=UTF-8")):n?(g.open("POST",a,l),g.setRequestHeader("Content-Type","text/xml; charset=UTF-8")):d?(g.open("POST",a,l),g.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")):g.open("GET",a,l);g.setRequestHeader("Accept","application/json, text/plain");e.n&&g.setRequestHeader("Authorization","OAuth "+e.n);g.setRequestHeader("Referrer",window.location.href);g.onreadystatechange=
function(){if(4==g.readyState){var a;try{a=JSON.parse(g.responseText)}catch(b){c&&c(o,{e:"Internal server error",H:"invalid_response"},o);return}if(a.Error){if("error.system.UserSessionRequired"==a.Error.Code){e.h("token.expired");return}if("WebForward"==a.Error.Code){e.h("web.forward");window.location=a.Error.Forward;return}}c&&c(e.g(a.Response),a.Error,a)}};f?"String"==typeof f?g.send(f):g.send(JSON.stringify(f)):n?g.send(n):d?g.send(d):g.send()}else console.error("API not initialized")},get:function(a,
b,c,f){e.call(a,b,c,o,o,o,f)},p:function(a,b,c,f,n){e.call(a,b,f,c,o,o,n)},C:function(a,b,c,f,n){e.call(a,b,f,o,c,o,n)},g:function(a){if(a&&"object"==typeof a){var b=a.__Type__,c,f;if("Vo"==b)return new k(a,a.__Metadata__);if("VoList"==b){for(var n=[],d=a.List,m=0;m<d.length;m++)b=d[m],c=b.__DesignId__,f=b.__TypeCode__,b.__Metadata__=a.__Metadata__[c?c:f],n[m]=e.g(b);return n}if("VoMap"==b){n={};d=a.Map;for(f in d)b=d[f],(c=b.__DesignId__)||(c=b.__TypeCode__),b.__Metadata__=a.__Metadata__[c],n[f]=
e.g(b);return n}}return a},t:function(a){for(var b="",a=a.elements,c=0;c<a.length;c++){var f=a[c],e=f.type.toLowerCase();"submit"!=e&&"image"!=e&&!f.disabled&&f.name&&(b+="&"+f.name+"="+f.value)}return 0==b.length?b:b.substr(1)},B:function(a,b,c,f){var d=r(a)[0];if(d){c||(c={});if(!c.G)c.G=d.getAttribute("data-formid");e.call(f?f:d.getAttribute("data-method"),c,function(a,c){function e(a){for(g=0;g<a.length;g++)a[g].className=a[g].className.replace(" hasValidationException","")}for(var f=d.getElementsByTagName("div"),
g=0;g<f.length;g++)"validationException"==f[g].className&&f[g].parentNode.removeChild(f[g]);e(d.getElementsByTagName("input"));e(d.getElementsByTagName("textarea"));if(c&&c.FieldExceptions){for(var f=[],i=[],g=0;g<c.FieldExceptions.length;g++){var h=c.FieldExceptions[g],p=d.elements[h.AttributeCode];if(p&&0<p.offsetHeight&&0<p.offsetWidth){i.push(h);var k=document.createElement("div");k.className="validationException";k.innerHTML=h.e;p.nextSibling?p.parentNode.insertBefore(k,p.nextSibling):p.parentNode.appendChild(k);
p.className+=" hasValidationException"}else f.push(h)}c.J=f;c.I=i}b(a,c)},o,o,e.t(d),"true"==d.getAttribute("data-ssl"))}else b(o,{e:"Form not found"})},u:function(){try{return new XMLHttpRequest}catch(a){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(b){for(var c=0;4>c;c++)try{return new ActiveXObject(0<"MSXML2.XMLHTTP"+c?"."+(c+2)+".0":"")}catch(f){}alert("XMLHttpRequest browser support required")}}},q:{K:"/images/loading.gif"},z:function(a){window.RS.addCss("/includes/css/gwt.css");e.q["popup.error.page"]=
a.popup_error_page;e.n=a.access_token;if(a.lang)e.d=a.lang;e.l=l},A:function(a){e.call("me",o,function(b){window.RS.Api.me=b;a&&a(b)},void 0,void 0,void 0,void 0)},c:{},D:function(a,b){e.c[a]instanceof Array||(e.c[a]=[]);b instanceof Function&&e.c[a].push(b)},h:function(a){for(var b in e.c[a])e.c[a][b](Array.prototype.slice.call(arguments,1))},m:function(a,b,c,f){e.get(a,{name:c},function(a,c){var e=r(b),d,j;if(a){var g=document.createDocumentFragment();j=document.createElement("div");j.innerHTML=
a.Html;var i=r("script",j),h,k=[],s=[];for(d=0;d<i.length;d++)if(h=i[d],"SCRIPT"!=h.tagName)s.push(h.cloneNode(l));else if(h.src){if(0==r('script[src="'+h.getAttribute("src")+'"]').length){var q=document.createElement("script");q.src=h.src;q.type=h.type;s.push(q)}}else k.push(h.text);for(;0<j.childNodes.length;)g.appendChild(j.childNodes[0]);if(j=a.ExternalScripts)for(d=0;d<j.length;d++)if(0==r('script[src="'+j[d]+'"]').length)h=document.createElement("script"),h.src=j[d],h.type="text/javascript",
s.push(h);if(j=a.ScriptBlocks)for(d=0;d<j.length;d++)h=document.createElement("script"),h.text=j[d],h.type="text/javascript",s.push(h);if(j=a.ExternalCss)for(d=0;d<j.length;d++)if(0==r('link[href="'+j[d]+'"]').length)h=document.createElement("link"),h.href=j[d],h.type="text/css",h.rel="stylesheet",s.push(h);for(d=0;d<e.length;d++)j=e[d],j.innerHTML="",j.appendChild(g);e=r("head")[0];e||(e=document.createElement("head"),document.appendChild(e));for(d=0;d<s.length;d++)e.appendChild(s[d]);for(d=0;d<
k.length;d++)eval(k[d])}else for(d=0;d<e.length;d++)e[d].innerHTML='<span class="error">'+c.e+"</span>";f&&f(a,c)},o)},copy:function(a,b,c){e.m("copy",a,b,c)},v:function(a,b,c){e.m("clientCopy",a,b,c)},j:function(a,b,c,d,i){if(!(a instanceof k))throw new TypeError("Parameter not instance of RsValueObject");if(b)b="recordCreateForm";else if(c)b="recordEditForm";else throw new t;e.p(b,{designId:a.__DesignId__,typeCode:a.__TypeCode__},a,d,i)},create:function(a,b,c){a.Id=o;e.j(a,l,!1,b,c)},update:function(a,
b,c){e.j(a,!1,l,b,c)},w:function(a,b,c,d){a={typeCode:a};b&&(a.designId=b);e.get("recordCreateForm",a,c,d)}};window.RS.Api={};window.RS.Api.init=e.z;window.RS.Api.call=e.call;window.RS.Api.get=e.get;window.RS.Api.postJson=e.p;window.RS.Api.postXML=e.C;window.RS.Api.postForm=e.B;window.RS.Api.copy=e.copy;window.RS.Api.clientCopy=e.v;window.RS.Api.subscribe=e.D;window.RS.Api.fire=e.h;window.RS.Api.loadMe=e.A;window.RS.Api.update=e.update;window.RS.Api.create=e.create;window.RS.Api.describe=e.w;var v=
window.RS.Log.deprecated;window.RS.Api.query=function(a){v("RS.Api.query");return window.RS.query(a)};window.RS.Api.setCookie=function(a,b,c,d){v("RS.Api.setCookie");return window.RS.setCookie(a,b,c,d)};window.RS.Api.getCookie=function(a){v("RS.Api.getCookie");return window.RS.getCookie(a)}})();
