/*! Raygun4js - v1.8.4 - 2014-05-22
* https://github.com/MindscapeHQ/raygun4js
* Copyright (c) 2014 MindscapeHQ; Licensed MIT */
(function(n){function e(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function t(n){return n===undefined}var r={},o=n.TraceKit,a=[].slice,i="?";r.noConflict=function(){return n.TraceKit=o,r},r.wrap=function(n){function e(){try{return n.apply(this,arguments)}catch(e){throw r.report(e),e}}return e},r.report=function(){function t(n){c.push(n)}function o(n){for(var e=c.length-1;e>=0;--e)c[e]===n&&c.splice(e,1)}function i(n,t){var o=null;if(!t||r.collectWindowErrors){for(var i in c)if(e(c,i))try{c[i].apply(null,[n].concat(a.call(arguments,2)))}catch(u){o=u}if(o)throw o}}function u(e){var t=a.call(arguments,1);if(s){if(l===e)return;var o=s;s=null,l=null,i.apply(null,[o,null].concat(t))}var u=r.computeStackTrace(e);throw s=u,l=e,n.setTimeout(function(){l===e&&(s=null,l=null,i.apply(null,[u,null].concat(t)))},u.incomplete?2e3:0),e}var c=[],l=null,s=null,f=n.onerror;return n.onerror=function(n,e,t,o,a){var u=null;if(a)u=r.computeStackTrace(a);else if(s)r.computeStackTrace.augmentStackTraceWithInitialElement(s,e,t,n),u=s,s=null,l=null;else{var c={url:e,line:t,column:o};c.func=r.computeStackTrace.guessFunctionName(c.url,c.line),c.context=r.computeStackTrace.gatherContext(c.url,c.line),u={mode:"onerror",message:n,url:document.location.href,stack:[c],useragent:navigator.userAgent}}return i(u,"from window.onerror"),f?f.apply(this,arguments):!1},u.subscribe=t,u.unsubscribe=o,u}(),r.computeStackTrace=function(){function o(e){function t(){try{return new n.XMLHttpRequest}catch(e){return new n.ActiveXObject("Microsoft.XMLHTTP")}}if(!r.remoteFetching)return"";try{var o=t();return o.open("GET",e,!1),o.send(""),o.responseText}catch(a){return""}}function a(n){if(!e(k,n)){var t="";n=n||"",-1!==n.indexOf(document.domain)&&(t=o(n)),k[n]=t?t.split("\n"):[]}return k[n]}function u(n,e){var r,o=/function ([^(]*)\(([^)]*)\)/,u=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,c="",l=10,s=a(n);if(!s.length)return i;for(var f=0;l>f;++f)if(c=s[e-f]+c,!t(c)){if(r=u.exec(c))return r[1];if(r=o.exec(c))return r[1]}return i}function c(n,e){var o=a(n);if(!o.length)return null;var i=[],u=Math.floor(r.linesOfContext/2),c=u+r.linesOfContext%2,l=Math.max(0,e-u-1),s=Math.min(o.length,e+c-1);e-=1;for(var f=l;s>f;++f)t(o[f])||i.push(o[f]);return i.length>0?i:null}function l(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,"\\$&")}function s(n){return l(n).replace("<","(?:<|&lt;)").replace(">","(?:>|&gt;)").replace("&","(?:&|&amp;)").replace('"','(?:"|&quot;)').replace(/\s+/g,"\\s+")}function f(n,e){for(var t,r,o=0,i=e.length;i>o;++o)if((t=a(e[o])).length&&(t=t.join("\n"),r=n.exec(t)))return{url:e[o],line:t.substring(0,r.index).split("\n").length,column:r.index-t.lastIndexOf("\n",r.index)-1};return null}function g(n,e,t){var r,o=a(e),i=RegExp("\\b"+l(n)+"\\b");return t-=1,o&&o.length>t&&(r=i.exec(o[t]))?r.index:null}function m(e){for(var t,r,o,a,i=[n.location.href],u=document.getElementsByTagName("script"),c=""+e,g=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,m=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,h=0;u.length>h;++h){var p=u[h];p.src&&i.push(p.src)}if(o=g.exec(c)){var d=o[1]?"\\s+"+o[1]:"",v=o[2].split(",").join("\\s*,\\s*");t=l(o[3]).replace(/;$/,";?"),r=RegExp("function"+d+"\\s*\\(\\s*"+v+"\\s*\\)\\s*{\\s*"+t+"\\s*}")}else r=RegExp(l(c).replace(/\s+/g,"\\s+"));if(a=f(r,i))return a;if(o=m.exec(c)){var y=o[1];if(t=s(o[2]),r=RegExp("on"+y+"=[\\'\"]\\s*"+t+"\\s*[\\'\"]","i"),a=f(r,i[0]))return a;if(r=RegExp(t),a=f(r,i))return a}return null}function h(n){if(!n.stack)return null;for(var e,t,r=/^\s*at (?:((?:\[object object\])?\S+) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i,o=/^\s*(\S*)(?:\((.*?)\))?@((?:file|http|https).*?):(\d+)(?::(\d+))?\s*$/i,a=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:ms-appx|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i,l=n.stack.split("\n"),s=[],f=/^(.*) is undefined$/.exec(n.message),m=0,h=l.length;h>m;++m){if(e=o.exec(l[m]))t={url:e[3],func:e[1]||i,args:e[2]?e[2].split(","):"",line:+e[4],column:e[5]?+e[5]:null};else if(e=r.exec(l[m]))t={url:e[2],func:e[1]||i,line:+e[3],column:e[4]?+e[4]:null};else{if(!(e=a.exec(l[m])))continue;t={url:e[2],func:e[1]||i,line:+e[3],column:e[4]?+e[4]:null}}!t.func&&t.line&&(t.func=u(t.url,t.line)),t.line&&(t.context=c(t.url,t.line)),s.push(t)}return s[0]&&s[0].line&&!s[0].column&&f&&(s[0].column=g(f[1],s[0].url,s[0].line)),s.length?{mode:"stack",name:n.name,message:n.message,url:document.location.href,stack:s,useragent:navigator.userAgent}:null}function p(n){for(var e,t=n.stacktrace,r=/ line (\d+), column (\d+) in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i,o=t.split("\n"),a=[],i=0,l=o.length;l>i;i+=2)if(e=r.exec(o[i])){var s={line:+e[1],column:+e[2],func:e[3]||e[4],args:e[5]?e[5].split(","):[],url:e[6]};if(!s.func&&s.line&&(s.func=u(s.url,s.line)),s.line)try{s.context=c(s.url,s.line)}catch(f){}s.context||(s.context=[o[i+1]]),a.push(s)}return a.length?{mode:"stacktrace",name:n.name,message:n.message,url:document.location.href,stack:a,useragent:navigator.userAgent}:null}function d(t){var r=t.message.split("\n");if(4>r.length)return null;var o,i,l,g,m=/^\s*Line (\d+) of linked script ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i,h=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i,p=/^\s*Line (\d+) of function script\s*$/i,d=[],v=document.getElementsByTagName("script"),y=[];for(i in v)e(v,i)&&!v[i].src&&y.push(v[i]);for(i=2,l=r.length;l>i;i+=2){var x=null;if(o=m.exec(r[i]))x={url:o[2],func:o[3],line:+o[1]};else if(o=h.exec(r[i])){x={url:o[3],func:o[4]};var w=+o[1],S=y[o[2]-1];if(S&&(g=a(x.url))){g=g.join("\n");var k=g.indexOf(S.innerText);k>=0&&(x.line=w+g.substring(0,k).split("\n").length)}}else if(o=p.exec(r[i])){var T=n.location.href.replace(/#.*$/,""),b=o[1],R=RegExp(s(r[i+1]));g=f(R,[T]),x={url:T,line:g?g.line:b,func:""}}if(x){x.func||(x.func=u(x.url,x.line));var C=c(x.url,x.line),E=C?C[Math.floor(C.length/2)]:null;x.context=C&&E.replace(/^\s*/,"")===r[i+1].replace(/^\s*/,"")?C:[r[i+1]],d.push(x)}}return d.length?{mode:"multiline",name:t.name,message:r[0],url:document.location.href,stack:d,useragent:navigator.userAgent}:null}function v(n,e,t,r){var o={url:e,line:t};if(o.url&&o.line){n.incomplete=!1,o.func||(o.func=u(o.url,o.line)),o.context||(o.context=c(o.url,o.line));var a=/ '([^']+)' /.exec(r);if(a&&(o.column=g(a[1],o.url,o.line)),n.stack.length>0&&n.stack[0].url===o.url){if(n.stack[0].line===o.line)return!1;if(!n.stack[0].line&&n.stack[0].func===o.func)return n.stack[0].line=o.line,n.stack[0].context=o.context,!1}return n.stack.unshift(o),n.partial=!0,!0}return n.incomplete=!0,!1}function y(n,e){for(var t,o,a,c=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,l=[],s={},f=!1,h=y.caller;h&&!f;h=h.caller)if(h!==x&&h!==r.report){if(o={url:null,func:i,line:null,column:null},h.name?o.func=h.name:(t=c.exec(""+h))&&(o.func=t[1]),a=m(h)){o.url=a.url,o.line=a.line,o.func===i&&(o.func=u(o.url,o.line));var p=/ '([^']+)' /.exec(n.message||n.description);p&&(o.column=g(p[1],a.url,a.line))}s[""+h]?f=!0:s[""+h]=!0,l.push(o)}e&&l.splice(0,e);var d={mode:"callers",name:n.name,message:n.message,url:document.location.href,stack:l,useragent:navigator.userAgent};return v(d,n.sourceURL||n.fileName,n.line||n.lineNumber,n.message||n.description),d}function x(n,e){var t=null;e=null==e?0:+e;try{if(t=p(n))return t}catch(r){if(S)throw r}try{if(t=h(n))return t}catch(r){if(S)throw r}try{if(t=d(n))return t}catch(r){if(S)throw r}try{if(t=y(n,e+1))return t}catch(r){if(S)throw r}return{mode:"failed"}}function w(n){n=(null==n?0:+n)+1;try{throw Error()}catch(e){return x(e,n+1)}return null}var S=!1,k={};return x.augmentStackTraceWithInitialElement=v,x.guessFunctionName=u,x.gatherContext=c,x.ofCaller=w,x}(),function(){var e=function e(e){var t=n[e];n[e]=function(){var n=a.call(arguments),e=n[0];return"function"==typeof e&&(n[0]=r.wrap(e)),t.apply?t.apply(this,n):t(n[0],n[1])}};e("setTimeout"),e("setInterval")}(),r.remoteFetching||(r.remoteFetching=!0),r.collectWindowErrors||(r.collectWindowErrors=!0),(!r.linesOfContext||1>r.linesOfContext)&&(r.linesOfContext=11),n.TraceKit=r})(window),function(n,e){"use strict";if(n){var t=n.event.add;n.event.add=function(r,o,a,i,u){var c;return a.handler?(c=a.handler,a.handler=e.wrap(a.handler)):(c=a,a=e.wrap(a)),a.guid=c.guid?c.guid:c.guid=n.guid++,t.call(this,r,o,a,i,u)};var r=n.fn.ready;n.fn.ready=function(n){return r.call(this,e.wrap(n))};var o=n.ajax;n.ajax=function(t,r){"object"==typeof t&&(r=t,t=void 0),r=r||{};for(var a,i=["complete","error","success"];a=i.pop();)n.isFunction(r[a])&&(r[a]=e.wrap(r[a]));try{return t?o.call(this,t,r):o.call(this,r)}catch(u){throw e.report(u),u}}}}(window.jQuery,window.TraceKit),function(n,e,t){function r(n){var e=n,t=n.split("//")[1];if(t){var r=t.indexOf("?"),o=(""+t).substring(0,r),a=o.split("/").slice(0,4).join("/"),i=o.substring(0,48);e=a.length<i.length?a:i,e!==o&&(e+="..")}return e}function o(n,e,o,a){var i="AJAX Error: "+(e.statusText||"unknown")+" "+(o.type||"unknown")+" "+(r(o.url)||"unknown");D.send(a||n.type,{status:e.status,statusText:e.statusText,type:o.type,url:o.url,ajaxErrorMessage:i,contentType:o.contentType,data:o.data?o.data.slice(0,10240):t})}function a(e,t){n.console&&n.console.log&&R&&(n.console.log(e),t&&n.console.log(t))}function i(){return x&&""!==x?!0:(a("Raygun API key has not been configured, make sure you call Raygun.init(yourApiKey)"),!1)}function u(n,e){var t,r={};for(t in n)r[t]=n[t];for(t in e)r[t]=e[t];return r}function c(n,e){return null!=e?n.concat(e):n}function l(n,e){for(var t=0;n.length>t;t++)e.call(null,t,n[t])}function s(n){for(var e in n)if(n.hasOwnProperty(e))return!1;return!0}function f(){return Math.floor(9007199254740992*Math.random())}function g(){var e=document.documentElement,t=document.getElementsByTagName("body")[0],r=n.innerWidth||e.clientWidth||t.clientWidth,o=n.innerHeight||e.clientHeight||t.clientHeight;return{width:r,height:o}}function m(n){var e=(new Date).toJSON();try{var r="raygunjs="+e+"="+f();localStorage[r]===t&&(localStorage[r]=n)}catch(o){a("Raygun4JS: LocalStorage full, cannot save exception")}}function h(){for(var n in localStorage)"raygunjs="===n.substring(0,9)&&(d(JSON.parse(localStorage[n])),localStorage.removeItem(n))}function p(e,r){var o=[],i={};e.stack&&e.stack.length&&l(e.stack,function(n,e){o.push({LineNumber:e.line,ColumnNumber:e.column,ClassName:"line "+e.line+", column "+e.column,FileName:e.url,MethodName:e.func||"[anonymous]"})}),n.location.search&&n.location.search.length>1&&l(n.location.search.substring(1).split("&"),function(n,e){var t=e.split("=");t&&2===t.length&&(i[decodeURIComponent(t[0])]=t[1])}),r===t&&(r={}),s(r.customData)&&(r.customData="function"==typeof O?O():O),s(r.tags)&&(r.tags=j);var u=n.screen||{width:g().width,height:g().height,colorDepth:8},c=r.customData&&r.customData.ajaxErrorMessage,f=r.customData;try{JSON.stringify(f)}catch(m){var h="Cannot add custom data; may contain circular reference";f={error:h},a("Raygun4JS: "+h)}var p={OccurredOn:new Date,Details:{Error:{ClassName:e.name,Message:c||e.message||r.status||"Script error",StackTrace:o},Environment:{UtcOffset:(new Date).getTimezoneOffset()/-60,"User-Language":navigator.userLanguage,"Document-Mode":document.documentMode,"Browser-Width":g().width,"Browser-Height":g().height,"Screen-Width":u.width,"Screen-Height":u.height,"Color-Depth":u.colorDepth,Browser:navigator.appCodeName,"Browser-Name":navigator.appName,"Browser-Version":navigator.appVersion,Platform:navigator.platform},Client:{Name:"raygun-js",Version:"1.8.4"},UserCustomData:f,Tags:r.tags,Request:{Url:document.location.href,QueryString:i,Headers:{"User-Agent":navigator.userAgent,Referer:document.referrer,Host:document.domain}},Version:S||"Not supplied"}};w&&(p.Details.User=w),d(p)}function d(n){if(i()){a("Sending exception data to Raygun:",n);var e=N+"/entries?apikey="+encodeURIComponent(x);y(e,JSON.stringify(n))}}function v(e,t){var r;return r=new n.XMLHttpRequest,"withCredentials"in r?r.open(e,t,!0):n.XDomainRequest&&(C&&(t=t.slice(6)),r=new n.XDomainRequest,r.open(e,t)),r.timeout=1e4,r}function y(e,r){var o=v("POST",e,r);return"withCredentials"in o?(o.onreadystatechange=function(){4===o.readyState&&(202===o.status?h():E&&403!==o.status&&400!==o.status&&m(r))},o.onload=function(){a("logged error to Raygun")}):n.XDomainRequest&&(o.ontimeout=function(){E&&(a("Raygun: saved error locally"),m(r))},o.onload=function(){a("logged error to Raygun"),h()}),o.onerror=function(){a("failed to log error to Raygun")},o?(o.send(r),t):(a("CORS not supported"),t)}var x,w,S,k,T=TraceKit.noConflict(),b=n.Raygun,R=!1,C=!1,E=!1,O={},j=[],N="https://api.raygun.io";e&&(k=e(document));var D={noConflict:function(){return n.Raygun=b,D},init:function(n,e,t){return x=n,T.remoteFetching=!1,O=t,e&&(C=e.allowInsecureSubmissions||!1,e.debugMode&&(R=e.debugMode)),h(),D},withCustomData:function(n){return O=n,D},withTags:function(n){j=n},attach:function(){return i()?(T.report.subscribe(p),k&&k.ajaxError(o),D):t},detach:function(){return T.report.unsubscribe(p),k&&k.unbind("ajaxError",o),D},send:function(n,e,t){try{p(T.computeStackTrace(n),{customData:"function"==typeof O?u(O(),e):u(O,e),tags:c(j,t)})}catch(r){if(n!==r)throw r}return D},setUser:function(n){return w={Identifier:n},D},setVersion:function(n){return S=n,D},saveIfOffline:function(n){return n!==t&&"boolean"==typeof n&&(E=n),D}};n.Raygun=D}(window,window.jQuery);