+
+//Execute or select from functions in a given structure of options
+function ajax_selectOrExecute( structure , s ) {
+
+ var dataTypes = s.dataTypes,
+ transportDataType,
+ list,
+ selected,
+ i,
+ length,
+ checked = {},
+ flag,
+ noSelect = structure !== "transports";
+
+ function initSearch( dataType ) {
+
+ flag = transportDataType !== dataType && ! checked[ dataType ];
+
+ if ( flag ) {
+
+ checked[ dataType ] = 1;
+ transportDataType = dataType;
+ list = s[ structure ][ dataType ];
+ i = -1;
+ length = list ? list.length : 0 ;
+ }
+
+ return flag;
+ }
+
+ initSearch( dataTypes[ 0 ] );
+
+ for ( i = 0 ; ( noSelect || ! selected ) && i <= length ; i++ ) {
+
+ if ( i === length ) {
+
+ initSearch( "*" );
+
+ } else {
+
+ selected = list[ i ]( s , determineDataType );
+
+ // If we got redirected to another dataType
+ // Search there (if not in progress or already tried)
+ if ( typeof( selected ) === "string" &&
+ initSearch( selected ) ) {
+
+ dataTypes.unshift( selected );
+ selected = 0;
+ }
+ }
+ }
+
+ return noSelect ? jQuery.ajax : selected;
+}
+
+// Add an element to one of the structures in ajaxSettings
+function ajax_addElement( structure , args ) {
+
+ var i,
+ start = 0,
+ length = args.length,
+ dataTypes = [ "*" ],
+ dLength = 1,
+ dataType,
+ functors = [],
+ first,
+ append,
+ list;
+
+ if ( length ) {
+
+ first = jQuery.type( args[ 0 ] );
+
+ if ( first === "object" ) {
+ return ajax_selectOrExecute( structure , args[ 0 ] );
+ }
+
+ structure = jQuery.ajaxSettings[ structure ];
+
+ if ( first !== "function" ) {
+
+ dataTypes = args[ 0 ].toLowerCase().split(/\s+/);
+ dLength = dataTypes.length;
+ start = 1;
+
+ }
+
+ if ( dLength && start < length ) {
+
+ functors = sliceFunc.call( args , start );
+
+ for( i = 0 ; i < dLength ; i++ ) {
+
+ dataType = dataTypes[ i ];
+
+ first = /^\+/.test( dataType );
+
+ if (first) {
+ dataType = dataType.substr(1);
+ }
+
+ if ( dataType !== "" ) {
+
+ append = Array.prototype[ first ? "unshift" : "push" ];
+ list = structure[ dataType ] = structure[ dataType ] || [];
+ append.apply( list , functors );
+ }
+ }
+ }
+ }
+
+ return jQuery.ajax;
+}
+
+// Install prefilter & transport methods
+jQuery.each( [ "prefilter" , "transport" ] , function( _ , name ) {
+ _ = name + "s";
+ jQuery.ajax[ name ] = function() {
+ return ajax_addElement( _ , arguments );
+ };
+} );
+
+// Utility function that handles dataType when response is received
+// (for those transports that can give text or xml responses)
+function determineDataType( s , ct , text , xml ) {
+
+ var contents = s.contents,
+ type,
+ regexp,
+ dataTypes = s.dataTypes,
+ transportDataType = dataTypes[0],
+ response;
+
+ // Auto (xml, json, script or text determined given headers)
+ if ( transportDataType === "*" ) {
+
+ for ( type in contents ) {
+ if ( ( regexp = contents[ type ] ) && regexp.test( ct ) ) {
+ transportDataType = dataTypes[0] = type;
+ break;
+ }
+ }
+ }
+
+ // xml and parsed as such
+ if ( transportDataType === "xml" &&
+ xml &&
+ xml.documentElement /* #4958 */ ) {
+
+ response = xml;
+
+ // Text response was provided
+ } else {
+
+ response = text;
+
+ // If it's not really text, defer to converters
+ if ( transportDataType !== "text" ) {
+ dataTypes.unshift( "text" );
+ }
+
+ }
+
+ return response;
+}
+
+/*
+ * Create the request object; Microsoft failed to properly
+ * implement the XMLHttpRequest in IE7 (can't request local files),
+ * so we use the ActiveXObject when it is available
+ * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
+ * we need a fallback.
+ */
+if ( window.ActiveXObject ) {
+ jQuery.ajaxSettings.xhr = function() {
+ if ( window.location.protocol !== "file:" ) {
+ try {
+ return new window.XMLHttpRequest();
+ } catch( xhrError ) {}
+ }
+
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch( activeError ) {}
+ };
+}
+
+var testXHR = jQuery.ajaxSettings.xhr();
+
+// Does this browser support XHR requests?
+jQuery.support.ajax = !!testXHR;
+
+// Does this browser support crossDomain XHR requests
+jQuery.support.cors = testXHR && "withCredentials" in testXHR;
+
+})( jQuery );