var o = cc = new Object();
o.about = "Makeni ClientCaps 2.0.1 (2004-12-06), Copyright Makeni Ltd, www.makeni.com";
o.internetExplorerUrl = "http://www.microsoft.com/ie";
o.netscapeUrl = "http://channels.netscape.com/ns/browsers/default.jsp";
o.mozillaUrl = "http://www.mozilla.org";
o.flashUrl = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
o.windowsMediaUrl = "http://www.microsoft.com/windows/windowsmedia/download";
o.realPlayerUrl = "http://www.real.com";
o.quicktimeUrl = "http://www.apple.com/quicktime/download";
o.officeAnimationUrl = "http://www.microsoft.com/downloads/details.aspx?FamilyId=4033A84A-24C7-40B2-8783-D80ADA33CFF8&displaylang=en";
o.flag1=false;
o.flag2=false;
o.flag3=false;
o.flag4=false;
o.init = function(io) {
	var o = cc;
	o._io = io ? io : new Object();
	o._e = window.onerror;
	window.onerror = function(m, u, l) {
		alert("An error was thrown and caught.\n\nError: " + m + "\n\nLine: " + l + "\n\nURL: " + u);
		if (o._e != null) o._e(m, u, l);
		return false;
	};
	function D(v) {
		return typeof(v) !== "undefined";
	}
	function D2(v) {
		return D(v) && (v !== null);
	}
	function D3(v) {
		return D2(v) && (v !== "");
	}
	function D4(v) {
		return D3(v) && (v !== false);
	}
	function G(v) {
		if (document.getElementById) return document.getElementById(v);
		else if (document.all) return document.all[v];
	}
	o._c = new Object();
	var n = o._n = "TwofourClientCaps", c = document.cookie, r = o._io.clearCookie, myBitRate1 = (o._io.bitRate1 * 1024) + 102400, myBitRate2 = (o._io.bitRate2 * 1024) + 102400, i;
	if (D(c) && c.length > 0 && (i = c.indexOf(n)) != -1) {
		if (D(r) && r) document.cookie = n + "=";		
		else {
			i += n.length + 1;
			var j = c.indexOf(";", i);
			c = unescape(c.substring(i, j != -1 ? j : c.length));
			for (i = 0, c = c.split("&"); i < c.length; i++) o._c[(j = c[i].split("="))[0]] = unescape(j[1]);
		}
	}
	o.toString = function(e) {
		return "";
	};
	o.report = function(f) {
		if (document.getElementsByTagName || document.all) {
			var a = document.all ? document.all : document.getElementsByTagName("*");
			for (var i = 0; i < a.length; i++) {
				var e = a[i], v = e.id.split("_");				
				if (v[0] == "cc" && v.length > 1) {
					if (!D(v = o[v[1]])) {
						v = "Please wait...";
					}
					e.innerHTML = ""; //for mac ie 5
					e.innerHTML = v;
					e.value = v;
				}
			}
		}
		else if (f == "bandwidth") {
			var m = "This browser has basic functionality and is unable to update the web page.\nWe advice you to update this browser.\n\n";
			for (var n in o) {
				if (n.indexOf("Description") != -1 && n.indexOf("ShortDescription") == -1) m = m + n + " = " + o[n] + "\n";
			}
			alert(m);
		}

		var v = o.toString(false), c = document.cookie, d = G(n = "cc_Field");
		if (D(c) && v.length > 0) {
			c = o._io.writeCookie;
			if (!D(c) || c) document.cookie = o._n + "=" + escape(v);
		}
		if (d) {
			d.value = v;
		}
		for (var i = 0, f = document.forms; i < f.length; i++) {
			for (var j = 0, e = f[i].elements; j < e.length; j++) {
				if ((d = e[j]).name == n) {
					d.value = v;
				}
			}
		}
		if (D(f) && typeof(o.onReport) == "function") {
			o.onReport(f);
		}
	};
	o.i = function() {
		o.userAgent = navigator.userAgent.toLowerCase();
		function T(p, t) {
			return (new RegExp(p)).test(t ? t : o.userAgent);
		}
		function E(p) {
			return (new RegExp(p)).exec(o.userAgent);
		}
		function R(p) {
			p = E(p + "[\\s/]*([^;)[]*)"), l = p.length;
			if (l && l > 0) return p[1];
		}
		function C(v) {
			if (v && v!="") return v.replace(/,/g, ".");
		}
		function V(i, m, d, s, v, a, x) {
			o[i + "Vendor"] = m;
			if (v === true) {
				m = 1;
				v = "1.0";
			}
			else if (v === false || v === null) {
				m = -1;
				v = "0.0";
			}
			var t = o[i + "Version"] = String(v), n;
			t = t.split(".");
			o[i + "Major"] = isNaN(n = parseInt(t[0])) ? 0 : n;
			o[i + "Minor"] = isNaN(n = parseInt(t[1])) ? 0 : n;
			if (typeof(d) == "function") {
				d = d();
			}
			if (D(a)) {
				o[i] = a;
				m = 1;
			}
			else if (m == -1) {
				v = "not detected";
			}
			else {
				if (m == 1) {
					v = "detected";
				}
				m = 1;
			}
			o[i + "Detected"] = (m == 1); 
			o[i + "Description"] = d + (x ? "" : " " + v);
			o[i + "ShortDescription"] = (D2(s) ? s : d) + (x ? "" : " " + v);
			
			o.report();
		}
		function U(p, i, m, d, s, v, f, g, h, y, t) { //test pattern, browser, vendor, description, short description, version, family, family description, family short description, family version, string to test p in
			if (!D2(p) || T(p, t)) {
				if (!D3(v)) v = y;
				if (!D3(v)) v = R(p);
				V("browser", m, d, s, v, i);
				V("browserFamily", m, D2(g) ? g : d, D2(h) ? h : s, D3(y) ? y : v, D2(f) ? f : i);
				return true;
			}
		}
		function UI(v) {
			return U("msie", "internetExplorer", "Microsoft", "Internet Explorer", "IE", v);
		}
		function UK(p, i, m, d, s, v, t) {
			return U(p, i, m, d, s, v, "konqueror", "Konqueror", null, null, t);
		}
		function UG(p, i, d, t) {
			return U(p, i, navigator.vendor, d, null, navigator.vendorSub, "gecko", "Gecko", null, R("rv:"), t);
		}
		function UGV(p, i, d) {
			return UG(p, i, d, navigator.vendor.toLowerCase());
		}
		if (!U("opera", "opera", "Opera", "Opera") && !UI() && !UK("konqueror", "konqueror", "KDE", "Konqueror") && !UK("safari", "safari", "Apple", "Safari")) {
			if (navigator.product && (navigator.product.toLowerCase() == "gecko")) {
				if (!UGV("netscape", "netscape6", "Netscape") && !UGV("firefox", "firefox", "Mozilla FireFox")) UG(null, "mozilla", "Mozilla");
			}
			else {
				var v = navigator.appVersion.toLowerCase();
				U(null, "Netscape", "netscape", "Netscape", null, v.substr(0, v.indexOf(" ")));
			}
		}
		function O(p, i, m, d, s, v, f, g, h, q, r) { //pattern, id, vendor, description, short description, version, family, family description, family short description, platform, platform description
			if (!D2(p) || T(p)) {
				V("operatingSystem", m, d, s, v, i, true);
				o.operatingSystemFamily = f;
				o.operatingSystemFamilyDescription = g;
				o.platform = q = (D2(q) ? q : navigator.platform);
				o.platformDescription = D2(r) ? r : q;
				return true;
			}
		}
		function OW(p, i, d, v, q, r) {
			return O(p, i, "Microsoft", "Windows " + d, "Win" + d, v, "windows", "Windows", "Win", q, r);
		}
		function O3(p, i, d, v) {
			return OW(p, i, d, v, "win32", "32bit");
		}
		function ON(p, d, v) {
			return O3(p, "windowsNT", d ? d : "NT", v);
		}
		function O9(p, d, v) {
			return O3(p, "windows9x", d ? d : "9x", v);
		}
		function OM(p, i, d, v, q, r) {
			if (!D(d)) {
				d = "";
			}
			return O(p, i, "Apple", "Mac OS" + (d != "" ? " " + d : ""), "MacOS" + d, v, "macos", "Mac OS", "MacOS", q, r);
		}
		function OP(p, i, d, v) {
			return OM(p, i, d, v, "ppc", "PowerPC");
		}
		function OU(p, i, d, s, v, l, ld){
			return O(p, i, null, d, v, "unix", "Unix", l, ld);
		}
		function OO(p) {
			return O(p, "os2", "IBM", "OS/2", null, null, "os2", "OS/2");
		}
		function OS(p, l, ld) {
			return OU(p, "sun", "Sun", "SunOS", null, null, l, ld);
		}
		function OL() {
			var p = E("i(\\d)?86"), q = (p ? p[0] : null), r = (q ? "Intel " + (p[1] ? p[1] : "x") + "86" : null);
			return O("linux", "linux", "GNU", "Linux", null, null, "unix", "Unix", null, q, r);
		}
		if (!ON("windows (nt )?(5.0|2000)", "2000", "5.0") && !ON("windows (nt )?(5.1|xp)", "XP", "5.1") && !ON("windows (nt )?5.2", "2003", "5.2") && !ON("winnt", null, "4.0") && !ON("win32|32bit", "NT", "3.0") && !O9("win 9x 4.90", "ME", "4.9") && !O9("win(dows )?98", "98", "4.5") && !O9("win(dows )?95", "95", "4.0") && !OW("win(dows 3.1|16|dows 16-bit)", "w16", "3.1", "3.1", "w16", "16bit") && !OP("mac os x", "macosx", "X", "10") && !OP("mac.*p(ower)?pc", "macos") && !OM("mac", "macos", null, null, "m68000", "Motorola 68000") && !OS("sun.*i86", "i86", "Intel x86") && !OS("sun4u", "ultra", "Ultra") && !OS("sun") && !OL() && !OU("irix", "irix", "Irix") && !OU("hp-ux", "hpux", "HPUX") && !OU("aix", "aix", "AIX") && !OU("sco|unix_sv", "sco", "SCO") && !OU("ncr", "ncr", "NCR") && !OU("reliantunix", "reliant", "Reliant Unix") && !OU("dec|osf1|dec_alpha|alphaserver|ultrix|alphastation", "dec", "DEC Unix") && !OU("sinix", "sinix", "Sinix") && !OU("lanix", "lanix", "lanix") && !OU("freebsd", "freebsd", "FreeBSD") && !OU("bsd", "bsd", "BSD") && !OU("x11", "x11", "Unix X11") && !OO("os/2|ibm-webexplorer") && !O("vms", "vax", "vms", "Vax VMS")) { //lanix is for evidence of theft
			if (navigator.platform == "Win32") ON(null, null, "3.0");
			else if(navigator.appVersion.indexOf("OS/2") != -1) OO();
			else O();
		}
		function F(t) {
			function Z(s){
				return ((s = new String(s)).length == 1 ? "0" : "") + s;
			}
			return t.getFullYear() + "-" + Z(t.getMonth() + 1) + "-" + Z(t.getDate()) + " " + Z(t.getHours()) + ":" + Z(t.getMinutes()) + ":" + Z(t.getSeconds());
		};
		
		var t = new Date();
		o.clientTime = F(t);
		o.timezone = t.getTimezoneOffset();
		o.timezoneDescription = o.timezone + " minutes from UTC";
		o.utcTime = F(new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate(), t.getUTCHours(), t.getUTCMinutes(), t.getUTCSeconds()));	
		o.screenWidth = screen.width;
		o.screenWidthDescription = o.screenWidth + " pixels";
		o.screenHeight = screen.height;
		o.screenHeightDescription = o.screenHeight + " pixels";
		o.screenResolutionDescription = o.screenWidth + " x " + o.screenHeight + " pixels";
		o.colorDepth = screen.colorDepth;
		o.colorDepthDescription = o.colorDepth + " bits";
		o.culture = navigator.userLanguage ? navigator.userLanguage : navigator.language;		
		o.cookies = checkCookies() ? "Enabled" : "Disabled";
		o.cookiesResult = o.cookies == "Enabled" ? "Your browser has cookies enabled": "<span class=\"red\"><strong>Your browser must allow cookies to use this service</strong></span>";
		var f = null, w = null, d = null, r = null, q = null, a = null;
		if (o.browser == "internetExplorer" && o.browserMajor >= 5 && o.operatingSystemFamily == "windows") {
			var b = document.body;
			b.addBehavior("#default#clientCaps");
			function Y(i) {
				return C(b.getComponentVersion(i, "ComponentID"))
			}
			UI(Y("{89820200-ECBD-11CF-8B85-00AA005B4383}"));
			f = Y("{D27CDB6E-AE6D-11CF-96B8-444553540000}");
			w = Y("{22D6F312-B0F6-11D0-94AB-0080C74C7E95}");
			b.insertAdjacentHTML("afterBegin", "<object id=\"MSOTIME\" classid=\"clsid:A4639D29-774E-11D3-A490-00C04F6843FB\" style=\"display:none\"></object>");
			b.addBehavior("#MSOTIME");
			a = typeof(b.localtime) == "number";
		}
		
		var g = window.GeckoActiveXObject;
		if ((window.ActiveXObject && ScriptEngine && ScriptEngineMajorVersion() >= 5) || g) {
			var k = o._c, a;
			function X(i) {
				return (a = eval("try { new " + (g ? "Gecko" : "") + "ActiveXObject(\"" + i + "\") } catch (e) { null }")) != null;
			}
			if (!w && !D(w = k.windowsMediaVersion)) {
				if (X("WMPlayer.OCX.7"))w = a.versionInfo;
				else if (X("MediaPlayer.MediaPlayer.1"))w = 6.4;
			}
			if (X("DRM.GetLicense")) d = a.GetDRMSecurityVersion();
		}
		//V("windowsMediaDrm", "Microsoft", "Windows Media DRM Security", "WMRM", d);
		
		if(d != null) o.flag4 = true;
		o.hasDRM = (d == null) ? "<span class=\"red\"><strong>Your system requires Internet Explorer 5.5 or later to use Windows Media DRM Security</strong></span>" : "Your system has <strong>Windows Media DRM Security version " + d + "</strong>";
		
		function W(v, g) {
			if (v && g) o.windowsMediaGeckoActiveX = true;
			//V("windowsMedia", "Microsoft", "Windows Media", "WMP", v);
			//What media version is it
		    if(parseInt(v) >= 7)
		    { 
		        o.flag3= true;
                o.hasWindowsMedia = "Your system has <strong>Windows Media Player version " + v + "</strong>";
            }else
            {
                o.hasWindowsMedia = "Your system requires <strong>Windows Media Player version 7 or higher to use this service</strong>";
            }
		}
		W(w, g);
		if (!f || !w || !r || !q) {
			var g = navigator.plugins, t=navigator.mimeTypes;
			for (var i = 0; i < g.length; i++) {
				var p = g[i], s = p.name.toLowerCase(), e = p.description.toLowerCase();
				function P(b) {
					return T(b, s);
				}
				if (!w && P("windows media.*plug")) {
					p = t[o.operatingSystemFamily == "windows" ? "application/x-drm-v2" : "application/x-ms-wmd"];
					if (p && p.enabledPlugin) {
						w = "7.0 or above";
					}
					else if ((t["video/x-ms-wm"] && t["video/x-ms-wmv"]) || t["video/ms-wmv"]){ //video/ms-wmv is for evidence of theft
						w = 6.4;
					}
					else if (t["video/x-ms-asf"]) {
						w = 6.3;
					}
					else if ((p = t["application/x-mplayer2"]) && p.enabledPlugin) {
						w = 5.2;
					}
				}
			}
		}
		function B(v) {
			/*o.bandwidthCheck1 = o.bandwidthCheck2 = msgPos;
			o.flag1 = true;	 o.flag2 = true;
			return;*/
			
			o.bandwidth = v;
			if (v == 0) o.bandwidthDescription = "Not detected";
			else {
				var i, s;
				if ((i = v / 1048576) > 1) s = "M";
				else if ((i = v / 1024) > 1) s = "K";
				else i = v;
				o.bandwidthDescription = Math.round(i) + " " + s + "bps";
			}
			
			var msgPos = "Your system is capable of playing back a <strong>";
			var msgNeg = "Your system <strong>might not</strong> be capable of playing back a <strong>";
			var msg = "k stream</strong>";
			
			//Detect first bandwidth speed	
			if(v > myBitRate1) o.flag1 = true;		
            o.bandwidthCheck1 = v > myBitRate1 ? msgPos : msgNeg;
			o.bandwidthCheck1+= o._io.bitRate1 + msg;
			
			//Detect second bandwidth speed
			if(v > myBitRate2) o.flag2 = true;
			o.bandwidthCheck2 = v > myBitRate2 ? msgPos : msgNeg;
			o.bandwidthCheck2+= o._io.bitRate2 + msg;
  
            //o.checkResult = o.flag1 + " " + o.flag2 + " " + o.flag3 + " " + o.flag4;
            if((o.flag1 || o.flag2) && o.flag3 && o.flag4){
                o.checkResult = "<span class=\"blue\"><strong>Your system meets the minimum requirements</strong></span>";
                o.checkResultValue = "1";
			}else{
                o.checkResult = "<span class=\"red\"><strong>Your system does not meet the minimum requirements</strong></span>";
                o.checkResultValue = "0";
			}
			document.forms[0][CC_resultField].value = o.checkResultValue;
			o.report("bandwidth");
		}
		o.report("init");
		if (o._c.bandwidth && o._c.bandwidth > 0) {
			B(o._c.bandwidth);
		}
		else {
			var i = new Image();
			i.s = (new Date).getTime();
			i.onload = function(){
				clearTimeout(o._bh);
				delete o._bh;
				B(Math.round(261439488 / ((new Date).getTime() - i.s)));
			};
			o._bf = B;
			o._bh = setTimeout("cc._bf(0); delete cc._bf", 60000);
			i.src = CC_imageLocation + "?r=" + Math.random();
		}
	};
	o.report();
	setTimeout("cc.i()", 1);
};