var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function createRequestObject(){
	var req;
	if(window.XMLHttpRequest){
		// Firefox, Safari, Opera...
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject){
		// Internet Explorer 5+
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return req;
}

envokeTracker();
function envokeTracker(autonum){
	try{
		var flaver = FlashVersion();
		if (flaver){
			document.cookie = "flaver=" + flaver;
		}
	}catch(er){
		
	}
	try{
		document.cookie = "cookiesenabled=1";
		var d = new Date();
		var pid = String(d.getFullYear()) + String(d.getMonth()+1) + String(d.getDate()) + String(d.getHours()) + String(d.getMinutes()) + String(d.getSeconds());
		var thttp = createRequestObject();
		if (autonum){
			thttp.open('get', '/track.php?self=' + escape(location.href) + '&autonum=' + autonum + '&pid=' + pid);
		}else{
			thttp.open('get', '/track.php?self=' + escape(location.href) + '&pid=' + pid);
		}
		thttp.onreadystatechange = function(){
			if(thttp.readyState == 4 && thttp.status == 200){
				var response = thttp.responseText;
				if(response){
					var RExp = /^([0-9]+)$/gi;
					if (RExp.test(response)){
						setTimeout('envokeTracker("' + response + '");', 30000);
					}
				}
			}
		};
		thttp.send(null);
	}catch(er){
		
	}
}

function FlashVersion(){
	var flashVer = false;
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "," + versionMinor + "," + versionRevision;
		}
	}
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = '4,x,x';
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = '3,x,x';
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = '2,x,x';
	else if ( isIE && isWin && !isOpera ) {
		for (var i=0; i<15; i++){
			try{
				ver = 15-i;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + ver.toString());
				version = axo.GetVariable("$version");
				if (version){
					flashVer = version;
				}
			}catch(er){
				
			}
		}
	}
	var RegEx = /([\d]{1,2}[,]{1}([\d]{1,2}|[x]{1})[,]{1}([\d]{1,2}|[x]{1})([,]{1}[\d]{1,2})?)$/i;
	var matches = RegEx.exec(flashVer);
	if (matches[1]){
		return matches[1];
	}else{
		return false
	}
}