﻿/// <reference path="jquery-1.6.2.js" />

/*
*	Code Dependencies:
*	- "jquery-1.6.2.js"
*/

// This is a Self-Executing Anonymous Function
// "dc" is the namespace for all of our code
// There should be no global "window" variables,
// they should all be created under the "dc" namespace. 
(function (dc, $, undefined) {

	// Create the "dc" namespace if it does not exist
	dc = (function (dc) {

		//#region jQuery Selector Caching Function

		// Private Method/Object
		var _jquerySelectorCaching = function (jQuerySelector0, jQuerySelector1) {
			/// <summary>
			///		1: Accepts a string containing a CSS selector which is then used to match
			///		a set of elements.  The selected jQuery object will then be cached in a
			///		container object.  Subsequent calls with the same selector string will be
			///		returned from the cache.
			/// </summary>
			/// <param name="jQuerySelector" type="String">
			///     A string containing a jQuery selector expression
			/// </param>
			/// <returns type="jQuery" />
			if (arguments.length === 1) {
				if (_jquerySelectorCaching.cache[jQuerySelector0]) {
					return _jquerySelectorCaching.cache[jQuerySelector0];
				} else {
					return _jquerySelectorCaching.cache[jQuerySelector0] = $(jQuerySelector0);
				}
			} else {
				if (_jquerySelectorCaching.cache[jQuerySelector0 + jQuerySelector1]) {
					return _jquerySelectorCaching.cache[jQuerySelector0 + jQuerySelector1];
				} else {
					return _jquerySelectorCaching.cache[jQuerySelector0 + jQuerySelector1] = $(jQuerySelector0, jQuerySelector1);
				}
			} 
		}
		_jquerySelectorCaching.cache = {}; // Cache container object for the jQuery "$$()" caching function

		// Public Method
		dc.$$ = _jquerySelectorCaching;

		//#endregion

		//#region Browser Version

		dc.BrowserIsIE6 = false;
		dc.BrowserIsIPhone = false;

		if ($.browser.msie && $.browser.version <= 6) {
			dc.BrowserIsIE6 = true;
		}
		if (navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad)/)) {
			dc.BrowserIsIPhone = true;
		}

		//#endregion

		// Return this instance of dc
		return dc;
	})(window.dc = window.dc || {});

})(window.dc = window.dc || {}, jQuery);
