/* Copyright 2009: Thomson Reuters Global Resources. All Rights Reserved. Proprietary and Confidential information of TRGR. Disclosure, Use or Reproduction without the written authorization of TRGR is prohibited. */
Type.registerNamespace("Westlaw.Core");Type.registerNamespace("Westlaw.Core.Analytics");Sys.Application.add_init(initCore);var WestlawUser;function initCore(){overrideXhr();WestlawUser=$create(Westlaw.Core.WestlawUser);WestlawUser.set_feature(Westlaw.Core.Feature.ErrorLogging,$create(Westlaw.Core.ErrorLogger,{id:"errorLogger",mode:logMode}));window.onerror=WestlawUser.Log.GeneralError;var jQueryBind=jQuery.fn.bind;jQuery.fn.bind=function(type,data,fn){if(!fn&&data&&typeof data=="function"){fn=data;data=null}if(fn){var origFn=fn;var wrappedFn=function(){try{origFn.apply(this,arguments)}catch(ex){var logger=$find("errorLogger");if(!logger.get_rethrowing()){logger.GeneralError(ex.message)}}};fn=wrappedFn}return jQueryBind.call(this,type,data,fn)}}function overrideXhr(){$.ajaxSetup({xhr:function(){if(window.XMLHttpRequest){return new XMLHttpRequest()}else{var progIDs=["Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(var i=0;i<progIDs.length;i++){try{var xmlHttp=new ActiveXObject(progIDs[i]);return xmlHttp}catch(ex){}}return null}}})}Westlaw.Core.Feature=function(){throw Error.notImplemented()};Westlaw.Core.Feature.prototype={Analytics:1,ErrorLogging:2};Westlaw.Core.Feature.registerEnum("Westlaw.Core.Feature");Westlaw.Core.LogMode=function(){throw Error.notImplemented()};Westlaw.Core.LogMode.prototype={Off:1,LogAndHandle:2,LogOnly:3};Westlaw.Core.LogMode.registerEnum("Westlaw.Core.LogMode");Westlaw.Core.WestlawUser=function(){Westlaw.Core.WestlawUser.initializeBase(this);this.Log=null;this.Analytics=null};Westlaw.Core.WestlawUser.prototype={initialize:function(){Westlaw.Core.WestlawUser.callBaseMethod(this,"initialize")},dispose:function(){Westlaw.Core.WestlawUser.callBaseMethod(this,"dispose")},set_feature:function(feature,obj){switch(feature){case Westlaw.Core.Feature.Analytics:this.Analytics=obj;break;case Westlaw.Core.Feature.ErrorLogging:this.Log=obj;break}}};Westlaw.Core.WestlawUser.registerClass("Westlaw.Core.WestlawUser",Sys.Component);Westlaw.Core.ErrorLogger=function(){Westlaw.Core.ErrorLogger.initializeBase(this);this.mode=false;this.rethrowing=false};Westlaw.Core.ErrorLogger.prototype={initialize:function(){Westlaw.Core.ErrorLogger.callBaseMethod(this,"initialize");if(this.mode==="off"){this.mode=Westlaw.Core.LogMode.Off}else{if(this.mode==="logAndHandle"){this.mode=Westlaw.Core.LogMode.LogAndHandle}else{if(this.mode==="logOnly"){this.mode=Westlaw.Core.LogMode.LogOnly}else{throw Error.invalidOperation()}}}},dispose:function(){Westlaw.Core.ErrorLogger.callBaseMethod(this,"dispose")},AppError:function(ex){if(this.mode!==Westlaw.Core.LogMode.Off){WestlawUser.Log._logError(ex.message,"","")}if(this.mode===Westlaw.Core.LogMode.Off||this.mode===Westlaw.Core.LogMode.LogOnly){this._set_rethrowing(true);throw (ex);this._set_rethrowing(false)}},GeneralError:function(msg,url,lineNo){if(this.mode!==Westlaw.Core.LogMode.Off){WestlawUser.Log._logError(msg,url,lineNo)}return(this.mode===Westlaw.Core.LogMode.LogAndHandle)},CobaltError:function(eventName,publisherData,subscriberData){WestlawUser.Log._logError(publisherData.Data.Message)},_logError:function(errorMsg,url,lineNo){var info=errorMsg+"|"+document.title+"|"+window.location;if(url!=="undefined"){info+="|"+url}if(lineNo!=="undefined"){info+="|"+lineNo}var data={msg:info};var serializer=Sys.Serialization.JavaScriptSerializer;var json=serializer.serialize(data);try{$.ajax({type:"POST",url:"/ClientErrorLogger.svc/V1/LogError",data:json,contentType:"application/json; charset=utf-8"})}catch(e){}},get_rethrowing:function(){return this.rethrowing},_set_rethrowing:function(flag){this.rethrowing=flag}};Westlaw.Core.ErrorLogger.registerClass("Westlaw.Core.ErrorLogger",Sys.Component);function $$(id,context){var el=$("#"+id,context);if(el.length<1){el=$("[id$=_"+id+"]",context)}return el}if(typeof(Sys)!=="undefined"){Sys.Application.notifyScriptLoaded()};
