﻿/// <reference path="jquery-1.4.4.js"/>

var Proxiteam = {};
Proxiteam.Util = {};

Proxiteam.Util.Ajax = {};

(function() //Private scope
{
	Proxiteam.Util.Ajax.OnAjaxError = function(request, textStatus, errorThrown)
	{
		/// <summary>
		/// Should be called when there is an jQuery AJAX error, and will show a message box with 
		/// some debugging info
		/// </summary>
		/// <param name="request" type="XMLHttpRequest">
		/// The XMLHttpRequest object used for the AJAX request
		/// </param>
		/// <param name="textStatus" type="String">The jQuery AJAX request status string</param>
		/// <param name="errorThrown">The thrown error or null</param>

		var msg = "Unexpected ajax request error! You probably want to refresh the page and try again (note that you may lose your input, depending on your browser).";
		msg += "\r\njQuery Status: " + textStatus;
		msg += "\r\nRequest Status: " + request.status + " " + request.statusText;
		msg += "\r\nRequest URL: " + this.url;
		msg += "\r\nRequest Data: " + this.data;
		alert(msg);
	};
})();


String.prototype.insert = function(str, index)
{
	/// <summary>
	/// Inserts a string at the specified position in a string and returns the result
	/// <summary>
	/// <param name="str" type="String">The string to insert into</param>
	/// <param name="index" type="int">The index to insert at</param>
	/// <returns type="String">The new string</returns>
	return this.substr(0, index) + str + this.substr(index);
}
