
var flashinstalled = false;
var flashversion = 0;
var MSDetect = "false";

function handleClientInfoReport() {
	var clientInfoCookieName = "checkedClientInfo";
	var visitId = GetVisitId();
	if (getCookie(clientInfoCookieName) != visitId) {
		setFlashVersion();
		var screenSize = getScreenSize();

		var now = new Date();
		fixDate(now);
		now.setTime(now.getTime() + 30 * 24 * 60 * 60 * 1000);
		deleteCookie(clientInfoCookieName);
		setCookie(clientInfoCookieName, visitId, now);

		var relativeUrl = "/ClientSettings.aspx";
		var querystring = "?flashenabled=" + flashinstalled + "&flashversion=" + flashversion + "&screen=" + screenSize;
		setPixel(relativeUrl + querystring);
	}
}

function GetVisitId() {
	return getCookie("VisitId");
}

function setPixel(url) {
	var clntSettingsTag = document.getElementById("clientsettings");
	if (clntSettingsTag != null) {
		clntSettingsTag.src = url;
	}
}

function setFlashVersion() {
	if (navigator.plugins && navigator.plugins.length){
		x = navigator.plugins["Shockwave Flash"];

		if (x) {
			flashinstalled = true;
			if (x.description) {
  				y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
	 		}
		}
		else {
			flashinstalled = false;
		}

		if (navigator.plugins["Shockwave Flash 2.0"]) {
			flashinstalled = true;
			flashversion = 2;
		}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length) {
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin){
	 		flashinstalled = true;
		}
		else {
			flashinstalled = false;
		}
	}
	else {
		MSDetect = "true";
		document.write('<script type="text/vbscript"\> \n');
		document.write('on error resume next \n');
		document.write('If MSDetect = "true" Then \n');
		document.write(' For i = 2 to 8 \n');
		document.write('  If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then \n');
		document.write('  Else \n ');
		document.write('   flashinstalled = true \n');
		document.write('   flashversion = i \n');
		document.write('  End If \n ');
		document.write(' Next \n');
		document.write('End If \n');
		document.write('</script\> \n');
	}
}

function getScreenSize() {
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	return screenWidth + "x" + screenHeight;
}

handleClientInfoReport();
