
oapps=function(A,_version){this.A=A;if(_version!=null)this.A=this.A+'.'+_version;this.F={};this.F[this.A]={};this.I=this.F[this.A];this.H=new oapps.D(this.A);this.K=0;};oapps.prototype={clearRequest:function(){this.F={};this.F[this.A]={};this.I=this.F[this.A];this.K=0;},l:function(B,e){var temp=[];temp.push(this.A);temp.push(B);for(var x in e){temp.push(e[x]);}
var str=temp.join('');return str.substr(0,50)+str.length+''+temp.length;},hasRequest:function(){return this.K;},processRequest:function(B,e,d,f){f=f||{};this.addRequest(B,e,f);this.sendRequest(d,f);},addRequest:function(B,e,f){f=f||{};f.cache=(f.cache==null)?true:f.cache;var k=this.l(B,e);if(oapps.L.has(k)&&f.cache){var dataobj=oapps.L.get(k);this.H.M(B,dataobj);}else{e=e||{};this.I[B]=this.I[B]||[];this.I[B].push(e);this.K+=1;}
return this;},O:function(a){var b=new oapps.D(this.A);b.R(a);b.S();b.U(this.H);this.H.X();return b;},getRequest:function(){return oapps.E.Q(oapps.E.toJSON(this.F));},sendRequest:function(d,f){f=f||{};f.method=f.method||'GET';f.auth=f.auth||'NONE';var x=oapps.c.get('app');var y=this;var isPost=false;var req=f.request||oapps.E.Q(oapps.E.toJSON(this.F));if(req.length>500||f.method=='POST'){isPost=true;}
if(this.K>0||f.request){try{y.clearRequest();switch(oapps.c.get('container'))
{case'HOME':if(isPost){jQuery.post(x,{X:req},function(r){var a=eval('('+r+')');d(y.O(a));});}else{jQuery.get(x+'?X='+req,function(r){var a=eval('('+r+')');d(y.O(a));});}
break;case'OPENSOCIAL':var e={};if(f.auth=='SIGNED')e[gadgets.io.RequestParameters.AUTHORIZATION]=gadgets.io.AuthorizationType.SIGNED;e[gadgets.io.RequestParameters.CONTENT_TYPE]=gadgets.io.ContentType.JSON;if(isPost){e[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;e[gadgets.io.RequestParameters.POST_DATA]='X='+req;gadgets.io.makeRequest(x,function(r){d(y.O(r.data));},e);}else{gadgets.io.makeRequest(x+'?X='+req,function(r){d(y.O(r.data));},e);}
break;default:oapps.log({type:'error'},'1001',oapps.c.get('container'));break;}}catch(e){oapps.log({type:'error'},'1000',e);}}else{d(y.H);y.H.X();}}}
oapps.D=function(A){this.A=A;this.C={};this.C[this.A]={};this.G=this.C[this.A];};oapps.D.prototype={X:function(){this.C={};this.C[this.A]={};this.G=this.C[this.A];},R:function(resObj){this.C=resObj;try{this.G=this.C[this.A];}catch(e){oapps.log({type:'error'},'1003',e,resObj);}},l:function(B,e){var t=[];t.push(this.A);t.push(B);for(var x in e){t.push(e[x]);}
var str=t.join('');return str.substr(0,50)+str.length+''+t.length;},S:function(){for(var B in this.G){try{if(this.G[B]['cacheable']==1){var r=this.G[B]['response'];for(var i in r){var key=this.l(B,r[i]['requestparams']);oapps.L.add(key,r[i]);}}}catch(e){oapps.log({type:'error'},'1001',e);}}},U:function(k){var resObj=k.C;try{if(resObj[this.A]){for(var B in resObj[this.A]){for(var i=0;i<resObj[this.A][B]['response'].length;i++){this.M(B,resObj[this.A][B]['response'][i]);}}}}catch(e){oapps.log({type:'error'},'1002',e);}},M:function(B,k){this.G[B]=this.G[B]||{};this.G[B]['response']=this.G[B]['response']||[];this.G[B]['response'].push(k);},getResponse:function(B){if(this.G[B]){return new oapps.D.g(B,this.G[B]);}else{return false;}}};oapps.D.g=function(B,h){this.h=h;this.B=B;this.w=0;};oapps.D.g.prototype={first:function(){return this.h['response'][0]['data'];},each:function(d){for(var i=0;i<this.h['response'].length;i++){d(this.h['response'][i]['data']);}},getData:function(){if(this.w<this.h['response'].length){return this.h['response'][this.w++]['data'];}else{this.w=0;return null;}},hadError:function(){var errors=this.h['errors']||[];if(errors.length>0){return errors;}else{return false;}},hadSuccess:function(){if(this.h['response'].length>0){return this.h['response'].length;}else{return false;}}};oapps.L={maxSize:100,cache_length:0,keys:[],data:{},add:function(key,obj,persist){if(persist==null)persist=false;if(typeof(obj)!='undefined'){if(typeof(this.data[key])=='undefined'){this.cache_length++;}
if(!persist){this.keys.push(key);}
this.data[key]=obj;if(this.cache_length>this.maxSize){this.removeOldest();}}
return true;},remove:function(pKey){var tmp;if(typeof(this.data[pKey])!='undefined'){this.cache_length--;tmp=this.data[pKey];delete this.data[pKey];}
return tmp;},get:function(key){if(this.data[key]!=undefined)
{var i=0;while(i<this.keys.length){if(this.keys[i]==key){this.keys.splice(i,1);}else{i++;}}
this.keys.push(key);}
return this.data[key];},has:function(key){return typeof(this.data[key])!='undefined';},removeOldest:function(){this.remove(this.keys.shift());},clear:function(){var tmp=this.cache_length;this.keys=[];this.cache_length=0;this.data=[];return tmp;}};oapps.version=2;oapps.appid='oapps';oapps.log=function(){try{var e=[];for(var i=1;i<arguments.length;i++){e.push(arguments[i]);}
var f=arguments[0];f.appid=f.appid||oapps.appid;f.type=f.type||'error';var l=new oapps('logs');l.addRequest('add',{a:f.appid,b:f.type,c:oapps.E.toJSON(e),d:oapps.E.toJSON([navigator.userAgent,navigator.platform])}).sendRequest(function(){});}catch(e){}}
oapps.c={get:function(x){switch(x)
{case'container':oapps.container=oapps.container||'HOME';return oapps.container;break;case'app':oapps.server=oapps.server||'http://'+location.host+'/oajax.php';return oapps.server;break;}}};oapps.E={clone:function(obj){if(obj==null||typeof(obj)!='object')return obj;var temp=new obj.constructor();for(var key in obj)temp[key]=this.clone(obj[key]);return temp;},Q:function(str){var x=this.V.encode(str);x=x.replace(/\+/g,'-');x=x.replace(/\//g,'_');x=x.replace(/\=/g,'.');return x;},V:{J:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=this.W(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
output=output+
this.J.charAt(enc1)+this.J.charAt(enc2)+
this.J.charAt(enc3)+this.J.charAt(enc4);}
return output;},W:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;}}};(function($){function toIntegersAtLease(n){return n<10?'0'+n:n;}
Date.prototype.toJSON=function(date){return date.getUTCFullYear()+'-'+
toIntegersAtLease(date.getUTCMonth()+1)+'-'+
toIntegersAtLease(date.getUTCDate());};var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'}
$.quoteString=function(string){if(escapeable.test(string)){return'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"'}
return'"'+string+'"';}
$.toJSON=function(o,compact){var type=typeof(o);if(type=="undefined")
return"undefined";else if(type=="number"||type=="boolean")
return o+"";else if(o===null)
return"null";if(type=="string"){return $.quoteString(o);}
if(type=="object"&&typeof o.toJSON=="function")
return o.toJSON(compact);if(type!="function"&&typeof(o.length)=="number")
{var ret=[];for(var i=0;i<o.length;i++){ret.push($.toJSON(o[i],compact));}
if(compact)
return"["+ret.join(",")+"]";else
return"["+ret.join(", ")+"]";}
if(type=="function"){throw new TypeError("Unable to convert object of type 'function' to json.");}
ret=[];for(var k in o){var name;var type=typeof(k);if(type=="number")
name='"'+k+'"';else if(type=="string")
name=$.quoteString(k);else
continue;val=$.toJSON(o[k],compact);if(typeof(val)!="string"){continue;}
if(compact)
ret.push(name+":"+val);else
ret.push(name+": "+val);}
return"{"+ret.join(", ")+"}";}
$.compactJSON=function(o){return $.toJSON(o,true);}
$.evalJSON=function(src){return eval("("+src+")");}
$.secureEvalJSON=function(src){var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,'@');filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']');filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered))
return eval("("+src+")");else
throw new SyntaxError("Error parsing JSON, source is not valid.");}})(oapps.E);