var Sajara={Managers:{},Widgets:{},Config:{Client:{}}};(function(A){A.Util={};A.Util.path="";A.Util.ready=function(C){if(C&&typeof C==="function"){if(window.jQuery){jQuery(document).ready(C)}else{if(window.Ext){Ext.onReady(C)}else{window.onload=C}}}};A.Util.extend=function(){if(window.jQuery){return jQuery.extend.apply(this,arguments)}else{if(window.Ext){return Ext.apply.apply(this,arguments)}else{var D=false,H={},E=[];var I=0;if(arguments.length>0&&typeof arguments[0]==="boolean"){D=arguments[0];I++}if(arguments.length>I){H=arguments[I]}I++;var F,C;if(arguments.length>I){C=arguments.length;for(F=I;F<C;F++){E.push(arguments[F])}}C=E.length;for(F=0;F<C;F++){for(var G in E[F]){if(E[F].hasOwnProperty(G)){if(D&&typeof E[F][G]==="object"){H[G]=A.Util.extend(true,{},E[F][G])}else{H[G]=E[F][G]}}}}return H}}};A.Util.isArray=function(C){return Object.prototype.toString.call(C)==="[object Array]"};A.Util.each=function(F,G){if(window.jQuery){jQuery.each(F,G)}else{if(window.Ext&&A.Util.isArray(F)){Ext.each(F,function(I,H){return G.call(this,H,I)===false})}else{if(A.Util.isArray(F)){for(var D=0,C=F.length;D<C;D++){if(G.call(F[D],D,F[D])===false){break}}}else{if(typeof F==="object"){for(var E in F){if(F.hasOwnProperty(E)){if(G.call(F[E],E,F[E])===false){break}}}}}}}};A.Util.ajax=function(C){if(window.jQuery){jQuery.ajax({url:A.Util.path+C.url,data:C.data,dataType:C.dataType||"json",type:C.method||"GET",success:C.success||function(E){},cache:false,error:function(E){if(window.console){console.log(E.responseText)}if(C.error&&typeof C.error==="function"){C.error.call(this,E)}}})}else{if(window.Ext){var D;if(C.success&&typeof C.success==="function"){if(C.dataType&&typeof C.dataType==="string"&&C.dataType.toLowerCase()==="json"){D=function(E){var F=Ext.decode(E.responseText);C.success.call(this,F)}}else{D=C.success}}else{D=function(){}}Ext.Ajax.request({url:A.Util.path+C.url,params:C.data,method:C.method||"GET",success:D,failure:function(E){if(window.console){console.log(E.responseText)}if(C.error&&typeof C.error==="function"){C.error.call(this,arguments)}}})}else{throw new Error({message:"No suitable library to handle XHR."})}}};A.Util.format=function(H,E){if(!E){E="string"}var G=H;switch(E.toLowerCase()){case"date":if(G.getDate){G=(G.getMonth()+1)+"/"+G.getDate()+"/"+G.getFullYear()}break;case"time":if(G.getDate){var F=H.getMinutes(),C=H.getHours(),D="AM";if(F<10){F="0"+F}if(C===0){C=12}else{if(C>=12){if(C>12){C-=12}D="PM"}}return C+":"+F+" "+D}break;case"datetime":G=A.Util.format(H,"date")+" "+A.Util.format(H,"time");break;case"number":break;case"money":break;default:break}return G};var B={};A.Util.bind=function(D,E){if(window.jQuery){jQuery(B).bind(D,E)}else{var C=B[D]||[];C.push(E);B[D]=C}};A.Util.unbind=function(D,F){if(window.jQuery){jQuery(B).unbind(D,F)}else{if(B[D]){if(F){for(var E=0,C=B[D].length;E<C;E++){if(B[D][E]===F){B[D].splice(E,1);break}}}else{delete B[D]}}}};A.Util.trigger=function(G){var J=this;if(G){var F=[];for(var E=1,D=arguments.length;E<D;E++){F.push(arguments[E])}if(window.jQuery){jQuery(B).trigger(G,F)}else{if(B[G]){var I={type:G};F.splice(0,0,I);for(var H=0,C=B[G].length;H<C;H++){B[G][H].apply(J,F)}}}}};A.Util.jsonEncode=function(C){if(window.Ext){return Ext.encode(C)}throw new Error("Ext is required for json serialization.")};A.Util.jsonDecode=function(C){if(window.Ext){return Ext.decode(jsObj)}throw new Error("Ext is required for json serialization.")}})(Sajara);(function(A){A.Data={};A.Data.getCollections=function(B,C){var D={};if(B){D.limited=true}A.Util.ajax({url:"Collections.ashx",data:D,dataType:"json",method:"GET",success:function(E){if(C&&typeof C==="function"){C.call(A,E)}}})};A.Data.getFavorites=function(C,B){A.Util.ajax({url:"Members/FavoriteData.ashx",data:B,dataType:"json",success:function(D){if(C&&typeof C==="function"){C.call(A,D)}}})};A.Data.getFavoritesGeo=function(B){A.Util.ajax({url:"Members/FavoriteData.ashx",data:{request:"maplist"},dataType:"json",success:function(C){if(B&&typeof B==="function"){B.call(A,C)}}})};A.Data.deleteFavorite=function(B,C){A.Util.ajax({url:"Members/FavoriteActions.ashx",data:{id:C,action:"deleteFavorite"},dataType:"html",method:"POST",success:function(D){if(B&&typeof B==="function"){B.call(A,D)}}})};A.Data.addTag=function(C,B){A.Util.ajax({url:"Members/FavoriteActions.ashx",data:{id:B,action:"saveTag"},dataType:"html",method:"POST",success:function(D){if(C&&typeof C==="function"){C.call(A,D)}}})};A.Data.deleteTag=function(C,B){A.Util.ajax({url:"Members/FavoriteActions.ashx",data:{id:B,action:"deleteTag"},dataType:"html",method:"POST",success:function(D){if(C&&typeof C==="function"){C.call(A,D)}}})};A.Data.editTag=function(D,C,B){A.Util.ajax({url:"Members/FavoriteActions.ashx",data:{id:C,newName:B,action:"editTag"},dataType:"html",method:"POST",success:function(E){if(D&&typeof D==="function"){D.call(A,E)}}})};A.Data.addTagToFavorite=function(C,B,D){A.Util.ajax({url:"Members/FavoriteActions.ashx",data:{id:D,tag:B,action:"addTag"},dataType:"html",method:"POST",success:function(E){if(C&&typeof C==="function"){C.call(A,E)}}})};A.Data.deleteTagFromFavorite=function(C,B,D){A.Util.ajax({url:"Members/FavoriteActions.ashx",data:{id:D,tag:B,action:"removeTag"},dataType:"html",method:"POST",success:function(E){if(C&&typeof C==="function"){C.call(A,E)}}})};A.Data.getFeedback=function(C,B){A.Util.ajax({url:"Feedback.ashx",data:B,dataType:"json",success:function(D){if(C&&typeof C==="function"){C.call(A,D)}}})};A.Data.updateFeedbackStatus=function(C,D,B){A.Util.ajax({url:"Feedback.ashx",data:{Id:D,Status:B},dataType:"json",method:"POST",success:function(E){if(C&&typeof C==="function"){C.call(A,E)}}})};A.Data.batchUpdateFeedbackStatus=function(D,C,B){A.Util.ajax({url:"Feedback.ashx",data:{Ids:C.join(","),Status:B},dataType:"json",method:"POST",success:function(E){if(D&&typeof D==="function"){D.call(A,E)}}})};A.Data.deleteFeedback=function(C,B){A.Util.ajax({url:"Feedback.ashx",data:{Ids:B.join(","),_method:"DELETE"},dataType:"json",method:"POST",success:function(D){if(C&&typeof C==="function"){C.call(A,D)}}})};A.Data.getMember=function(B){A.Util.ajax({url:"Members/Account.ashx",dataType:"json",method:"GET",success:function(C){if(B&&typeof B==="function"){B.call(A,C)}}})};A.Data.saveMember=function(C,B){if(C.Preferences){C.Preferences=A.Util.jsonEncode(C.Preferences)}A.Util.ajax({url:"Members/Account.ashx",data:C,dataType:"json",method:"POST",success:function(D){if(B&&typeof B==="function"){B.call(A,D)}}})};A.Data.registerMember=function(D,C,B){D._method="PUT";D.register=true;A.Util.ajax({url:"Register.ashx",data:D,dataType:"json",method:"POST",success:function(E){if(C&&typeof C==="function"){C.call(A,E)}},error:function(E){if(B&&typeof B==="function"){B.call(A,E)}}})}})(Sajara);