//
// After changes are made to this file, minimize it:
//   java -jar tools/yuicompressor.jar -o public/javascript/Statistics.min.js public/javascript/Statistics.js
//

//http://www.featureblend.com/license.txt
var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){}
return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){}
return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};}
return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i<len;i++){if(properties[i]>=arguments[i]){if(i+1<len&&properties[i]==arguments[i]){continue;}else{return true;}}else{return false;}}};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i<activeXDetectRules.length&&version==-1;i++){var obj=getActiveXObject(activeXDetectRules[i].name);if(!obj.activeXError){self.installed=true;version=activeXDetectRules[i].version(obj);if(version!=-1){var versionObj=parseActiveXVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revision=versionObj.revision;self.revisionStr=versionObj.revisionStr;}}}}}();};FlashDetect.JS_RELEASE="1.0.4";

//
// Mallgrodan
//
function detectFlash() {
	if (FlashDetect.installed)
		return FlashDetect.major + "." + FlashDetect.minor + "." + FlashDetect.revision;
	else
		return "0";
}

function trim(string) {
	return string.replace(/^\s+|\s+$/g, '');
}

var nonIEPlugins = {}

function addNonIEPlugin(pluginName, version) {
	if (trim(pluginName).length == 0)
		return;
	if ((typeof nonIEPlugins[pluginName] == "undefined")
	    || (version > nonIEPlugins[pluginName])) {
		if (!version)
			version = "";
		nonIEPlugins[pluginName] = version;
	}
}

function detectNonIEPlugins() {
	if (!window.ActiveXObject) {
		for (var i in navigator.plugins) {
			if (typeof navigator.plugins[i].name == "undefined")
				continue;
			var name = navigator.plugins[i].name.toLowerCase();
			if ((name.indexOf("adobe acrobat") != -1)
			    || ((name.indexOf("adobe pdf plug-in") != -1))) {
				//alert(name + ":" + navigator.plugins[i].description);
				// adobe acrobat
				// 
				var regexp = new RegExp(/([\d\.]+)/);
				var version = regexp.exec(name);
				if (version != null)
					version = version[1];
				addNonIEPlugin("Adobe Reader", version);
			}
			else if (name.indexOf("quicktime plug-in") != -1) {
				//alert(name + ":" + navigator.plugins[i].description);
				// quicktime plug-in 7.2.0
				// quicktime plug-in 7.4.5
				var regexp = new RegExp(/([\d\.]+)/);
				var version = regexp.exec(name);
				if (version != null)
					version = version[1];
				addNonIEPlugin("QuickTime", version);
			}
			else if (name.indexOf("realplayer") != -1) {
				//alert(name + ":" + navigator.plugins[i].description);
				// realplayer 9
				var regexp = new RegExp(/([\d\.]+)/);
				var version = regexp.exec(name);
				if (version != null)
					version = version[1];
				addNonIEPlugin("RealPlayer", version);
			}
			else if (name.indexOf("shockwave for director") != -1) {
				//alert(name + ":" + navigator.plugins[i].description);
				// 
				var regexp = new RegExp(/([\d\.]+)/);
				var version = regexp.exec(name);
				if (version == null)
					version = regexp.exec(navigator.plugins[i].description);
				if (version != null)
					version = version[1];
				addNonIEPlugin("Shockwave Player", version);
			}
			else if (name.indexOf("windows media") != -1) {
				//alert(name + ":" + navigator.plugins[i].description);
				// windows media player plug-in 10 (compatible; totem)
				// windows media player plug-in
				var regexp = new RegExp(/([\d\.]+)/);
				var version = regexp.exec(name);
				if (version != null)
					version = version[1];
				addNonIEPlugin("Windows Media Player", version);
			}
			else {
				//alert(name + ":" + navigator.plugins[i].description);
				addNonIEPlugin(name, "");
			}
		}
	}
}

function detectAdobeReader() {
	var isInstalled = false;
	var version = null;
	if (window.ActiveXObject) {
		var control = null;
		try {
			// AcroPDF.PDF is used by version 7 and later
			control = new ActiveXObject('AcroPDF.PDF');
		} catch (e) {
			// Do nothing
		}
		if (!control) {
			try {
				// PDF.PdfCtrl is used by version 6 and earlier
				control = new ActiveXObject('PDF.PdfCtrl');
			} catch (e) {
				return false;
			}
		}
		if (control) {
			isInstalled = true;
			version = control.GetVersions().split(',');
			version = version[0].split('=');
			version = parseFloat(version[1]);
		}
	} else {
		// Check navigator.plugins for "Adobe Acrobat" or "Adobe PDF Plug-in"*
		if (typeof (version = nonIEPlugins['Adobe Reader']) != "undefined")
			isInstalled = true;
	}

	if (isInstalled)
		return trim("Adobe Reader " + version);
	else
		return false;
}

function detectQuickTime() {
	var isInstalled = false;  
	var version = "";
	if (window.ActiveXObject) {  
		var control = null;  
		try {  
			control = new ActiveXObject('QuickTime.QuickTime');  
		} catch (e) {  
			// Do nothing  
		}  
		if (control) {  
			// In case QuickTimeCheckObject.QuickTimeCheck does not exist  
			isInstalled = true;  
		}  

		// this code shows a popup dialog on IE7 and IE8; we can't have that
		/*
		try {  
			// This generates a user prompt in Internet Explorer 7  
			control = new ActiveXObject('QuickTimeCheckObject.QuickTimeCheck');  
		} catch (e) {  
			return false;
		}  
		if (control) {  
			// In case QuickTime.QuickTime does not exist  
			isInstalled = true;  

			// Get version  
			version = control.QuickTimeVersion.toString(16); // Convert to hex  
			version = version.substring(0, 1) + '.' + version.substring(1, 3);  
			version = parseFloat(version);  
		}
		*/ 
	} else {  
		// Check navigator.plugins for "QuickTime Plug-in"
		if (typeof (version = nonIEPlugins['QuickTime']) != "undefined")
			isInstalled = true;
	}

	if (isInstalled)
		return trim("QuickTime " + version);
	else
		return false;
}

function detectRealPlayer() {
	var isInstalled = false;  
	var version = null;  
	if (window.ActiveXObject) {  
		var definedControls = [  
		    'rmocx.RealPlayer G2 Control',  
		    'rmocx.RealPlayer G2 Control.1',  
		    'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)',  
		    'RealVideo.RealVideo(tm) ActiveX Control (32-bit)',  
		    'RealPlayer'  
		];  

		var control = null;  
		for (var i = 0; i < definedControls.length; i++) {  
			try {  
				control = new ActiveXObject(definedControls[i]);  
			} catch (e) {  
				continue;  
			}  
			if (control) {  
				break;  
			}  
		}  
		if (control) {  
			isInstalled = true;  
			version = control.GetVersionInfo();  
			version = parseFloat(version);  
		}  
	} else {  
		// Check navigator.plugins for "RealPlayer" and "RealPlayer Version"  
		if (typeof (version = nonIEPlugins['RealPlayer']) != "undefined")
			isInstalled = true;
	}

	if (isInstalled)
		return trim("RealPlayer " + version);
	else
		return false;
}

function detectShockwavePlayer() {
	var isInstalled = false;  
	var version = null;  
	if (window.ActiveXObject) {  
		var control = null;  
		try {  
			control = new ActiveXObject('SWCtl.SWCtl');  
		} catch (e) {  
			return false;
		}  
		if (control) {  
			isInstalled = true;  
			version = control.ShockwaveVersion('').split('r');  
			version = parseFloat(version[0]);  
		}
	} else {  
		// Check navigator.plugins for "Shockwave for Director"  
		if (typeof (version = nonIEPlugins['Shockwave Player']) != "undefined")
			isInstalled = true;
	}

	if (isInstalled)
		return trim("Shockwave Player " + version);
	else
		return false;
}

function detectWindowsMediaPlayer() {
	var isInstalled = false;  
	var version = null;  
	if (window.ActiveXObject) {  
		var control = null;  
		try {  
			control = new ActiveXObject('WMPlayer.OCX');  
		} catch (e) {  
			return false;
		}  
		if (control) {  
			isInstalled = true;  
			version = parseFloat(control.versionInfo);  
		}  
	} else {  
		// Check navigator.plugins for "Windows Media"--this also detects the Flip4Mac plugin  
		if (typeof (version = nonIEPlugins['Windows Media Player']) != "undefined")
			isInstalled = true;
	}

	if (isInstalled)
		return trim("Windows Media Player " + version);
	else
		return false;
}

function getPlugins() {
	var pluginsList = [];
	var plugin;
	detectNonIEPlugins()
	if ((plugin = detectAdobeReader()))
		pluginsList.push(plugin);
	if ((plugin = detectQuickTime()))
		pluginsList.push(plugin);
	if ((plugin = detectRealPlayer()))
		pluginsList.push(plugin);
	if ((plugin = detectShockwavePlayer()))
		pluginsList.push(plugin);
	if ((plugin = detectWindowsMediaPlayer()))
		pluginsList.push(plugin);

	var plugins = "";
	for (var i in pluginsList) {
		if (plugins.length > 0)
			plugins += "#=#";
		plugins += pluginsList[i];
	}

	return plugins;
}

function checkPlugins() {
	if (typeof jQuery == 'undefined') {  // wait until available
		setTimeout(checkPlugins, 1000);
		return;
	}
	var screenSize = screen.width + "x" + screen.height;
	var screenColors = screen.colorDepth;
	var plugins = getPlugins();
	var flash = detectFlash();
	if (flash != "0") {
		if (plugins.length > 0)
			plugins += "#=#";
		plugins += "Shockwave Flash " + flash;
	}
	//alert(plugins);
	var cookiesEnabled = navigator.cookieEnabled;
	// if not IE4+ nor NS6+
	if ((typeof navigator.cookieEnabled == "undefined") && (!cookiesEnabled)) {
		document.cookie = "testcookie"
		cookiesEnabled = (document.cookie.indexOf("testcookie") != -1);
	}
	cookiesEnabled = cookiesEnabled ? "Y" : "N";
	var vendor = navigator.vendor;
	if (typeof vendor == "undefined")
		vendor = "";
	var vendorSub = navigator.vendorSub;
	if (typeof vendorSub == "undefined")
		vendorSub = "";
	var geolocation = !!navigator.geolocation ? "Y" : "N";

	var args = {func: "ajaxStatistics",
	            sessionId: sessionId, rowid: visitorClientId,
	            screenSize: screenSize, screenColors: screenColors, flash: flash,
	            plugins: plugins, cookiesEnabled: cookiesEnabled,
	            vendor: vendor, vendorSub: vendorSub, geolocation: geolocation};
	$.post(ajaxServerUrl, args, function(data) { /*alert("Finished: "+data);*/ }, "html");
}

if (typeof visitorClientId != 'undefined')
	checkPlugins();

