// Support.js
// This file mantains a support object that has imformation pertaining to what browser you are running and what objects it supports.
//

//First a few things that we will need.

if (!window.Node) {
	var Node = {
		ELEMENT_NODE: 1,
		ATTRIBUTE_NODE: 2,
		TEXT_NODE: 3,
		COMMENT_NODE: 8,
		DOCUMENT_NODE: 9,
		DOCUMENT_FRAGMENT_NODE: 11
	};
}

//First define the name space...

var com;
if (!com) { com = {}; }
else if (typeof com != "object") { throw new Error("com: object exists but is not an object."); }

if (!com.jchristy) { com.jchristy = {}; }

//Name space is ready. Now create objects.

com.jchristy.Helper = {};
com.jchristy.Helper.random = function(N1, N2) {
  return (N2 > N1) ? Math.round(Math.random() * (N2 - N1)) + N1 : Math.round(Math.random() * (N1 - N2)) + N2;
}

//main Support object

com.jchristy.Support = {};
com.jchristy.Support.features = (document.implementation && document.implementation.hasFeature) ? {
			LEGACY: false,
			HTML1: document.implementation.hasFeature("HTML", "1.0"),
			HTML2: document.implementation.hasFeature("HTML", "2.0"),
			CSS1: document.implementation.hasFeature("CSS", "2.0"),
			CSS2: document.implementation.hasFeature("CSS2", "2.0"),
			EVENTS: document.implementation.hasFeature("UIEvents", "2.0"),
			EVENTS_MOUSE: document.implementation.hasFeature("MouseEvents", "2.0"),
			EVENTS_HTML: document.implementation.hasFeature("HTMLEvents", "2.0")	 
			} : { LEGACY: true };
	
	
com.jchristy.Support.browser = { name: "Unknown", platform: "Unknown" };
com.jchristy.Support.browser.cookies = Boolean(window.navigator.cookieEnabled);
com.jchristy.Support.browser.test = function(NAME, VALUES) {
	var a = VALUES;
	var n = window.navigator;
	for (var i = 0; i < a.length; i++) {
		if (n.userAgent.indexOf(a[i]) != -1) { 
			this[NAME] = a[i]; 
			break;
		}
	}
}
com.jchristy.Support.browser.test("name", ["MSIE 5", "MSIE 6", "MSIE 7", "Firefox", "Safari", "Netscape", "Opera"]);
com.jchristy.Support.browser.test("platform", ["Windows", "Macintosh", "Linux"]);

com.jchristy.Support.browser.is = function(MATCH) {
	if  (this.name.indexOf(MATCH) != -1) { return true; }
	if  (this.platform.indexOf(MATCH) != -1) { return true; }
	return false;
}
	
com.jchristy.Support.browser.language = (com.jchristy.Support.browser.is("MSIE")) ? window.navigator.userLanguage.substr(0, 2) : window.navigator.language.substr(0, 2);

