(function(d,c){var b="Telerik.OData.ItemsUrl",f="$callback",e="application/json",a={0:"json",1:"jsonp"};
d.NavigationControlODataSettings=function(h){d.NavigationControlODataSettings.initializeBase(this,[h]);
var g=h.ODataSettings;
this._path=h.Path;
this._odata=true;
this._responseType=g.ResponseType;
this._tree=new d.ODataBinderTree(g.InitialContainerName,g.Entities,g.EntityContainer);
};
d.NavigationControlODataSettings.prototype={get_path:function(){return this._path;
},get_responseType:function(){return this._responseType;
},get_tree:function(){return this._tree;
},get_isEmpty:function(){return false;
}};
d.NavigationControlODataSettings.registerClass("Telerik.Web.UI.NavigationControlODataSettings",d.WebServiceSettings);
d.ODataBinderTree=function(h,i,g){this._entities=i;
this._map=g;
this._tree=this._buildTree(h);
};
d.ODataBinderTree.prototype={get_settingsByDepth:function(g){function h(j,i){if(j==g){return i;
}return h(++j,i.child);
}return h(0,this._tree);
},_buildTree:function(g){var h=!!g?this._getEntitySetByName(g):this._map[0];
return this._buildNode(h,this._findChildCallback);
},_findChildCallback:function(h){if(!h){return;
}var g=this._getEntitySetByName(h);
return this._buildNode(g,this._findChildCallback);
},_buildNode:function(g,k){var h=this._getEntityByName(g.Name),j=this,i={name:g.Name,type:g.EntityType,entity:h,child:k.apply(j,[h.NavigationProperty])};
return i;
},_getByName:function(k,h){for(var j=0;
j<k.length;
j++){var g=k[j];
if(g.Name===h){return g;
}}},_getEntityByName:function(g){return this._getByName(this._entities,this._getEntitySetByName(g).EntityType);
},_getEntitySetByName:function(g){return this._getByName(this._map,g);
}};
d.NavigationControlODataLoader=function(h,g){d.NavigationControlODataLoader.initializeBase(this,[h]);
if(g){this._expandCallback=g;
}else{this._expandCallback=function(){return -1;
};
}};
d.NavigationControlODataLoader.prototype={_createRootUrl:function(h,g){if(h[h.length-1]=="/"){page=h.slice(0,h.length-1);
}return h+"/"+g;
},_getDefferedItemsUrl:function(h){var g=h.get_attributes();
var i=g.getAttribute(b);
g.removeAttribute(b);
return i;
},_appendQueryStringParameters:function(g){return g+"/?$format=json";
},_getAjaxSettings:function(h){h=this._appendQueryStringParameters(h);
var g=this.get_webServiceSettings();
return{url:h,headers:{Accepts:e},dataType:a[g.get_responseType()],jsonp:f};
},get_expandCallback:function(){return this._expandCallback;
},loadData:function(k,l){var j=this.get_webServiceSettings(),g,h,i=false;
if(k.isRootLevel){g=j.get_tree().get_settingsByDepth(0);
h=this._getAjaxSettings(this._createRootUrl(j.get_path(),g.name));
}else{h=this._getAjaxSettings(this._getDefferedItemsUrl(l)),level=l.get_level()+1,g=j.get_tree().get_settingsByDepth(level);
i=true;
}this._sendAjaxRequest(h,l,g.entity,this._onWebServiceSuccess);
if(i){this._raiseEvent("loadingStarted",new Telerik.Web.UI.WebServiceLoaderEventArgs(l));
}},_sendAjaxRequest:function(h,l,g,k){var i=this,j=c.ajax(h);
j.fail(function(n){var m={get_message:function(){return n.statusText;
}};
i._onWebServiceError(m,l);
}).done(function(o){var n=[],m=i._sanitize(o);
c.each(m,function(q,p){n[n.length]={Text:p[g.DataTextField],Value:p[g.DataValueField],ExpandMode:i.get_expandCallback()(g.NavigationProperty),Attributes:(function(){if(g.NavigationProperty&&p[g.NavigationProperty]){return{"Telerik.OData.ItemsUrl":p[g.NavigationProperty].__deferred.uri};
}else{return{};
}})()};
});
k.apply(i,[n,l]);
});
},_sanitize:function(g){var h=g.d.results?g.d.results:g.d;
if(!(h instanceof Array)){h=c.makeArray(h);
}return h;
}};
d.NavigationControlODataLoader.registerClass("Telerik.Web.UI.NavigationControlODataLoader",d.WebServiceLoader);
})(Telerik.Web.UI,$telerik.$);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();
