<!--
/* banner tracking function */
function trackBanner(sID, bID) {
	
	var url = "http://www.fakt.fi/BannerTracker?INSERT&sID="+sID+"&bID="+bID;
	var iframe;
	if (frames['bannerIframe']) 
		iframe = frames['bannerIframe'];
	else {
		iframe = document.createElement("iframe");
		iframe.setAttribute("id", "bannerIframe");
	    iframe.setAttribute("name", "bannerIframe");
   	    iframe.setAttribute("width", "0");
   	    iframe.setAttribute("height", "0");
    	iframe.style.display = "none";
    	iframe.style.visibility = "hidden";
    	
	    
	    document.body.appendChild(iframe);	
	}
	
    try {
		iframe.setAttribute("src", url);
	}
	catch (exception){
		frames['bannerIframe'].location.href = url;
	}
}

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;

function goURL(daURL) {
    // if the browser can do it, use replace to preserve back button
    if(javascriptVersion1_1) {
	window.location.replace(daURL);
    } else {
	window.location = daURL;
    }
    return;
}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if( redirectURL && ((pluginFound && redirectIfFound) ||
	(!pluginFound && !redirectIfFound)) ) {
	// go away
	goURL(redirectURL);
	return pluginFound;
    } else {
	// stay here and return result of plugin detection
	return pluginFound;
    }
}

function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
	return true;
    } else {
	return false;
    }
}

function detectFlash(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Flash');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectDirector(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Director');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('SWCtl.SWCtl.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('QuickTime');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectQuickTimeActiveXControl();
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectReal(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('RealPlayer');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
		       detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
		       detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectWindowsMedia(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Windows Media Player');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	    // loop through all desired names and check each against the current plugin name
	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
		// if desired plugin name is found in either plugin name or description
		if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
		}
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) {
		pluginFound = true;
		// if we've found the plugin, we can stop looking through at the rest of the plugins
		break;
	    }
	}
    }
    return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<scr' + 'ipt language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}
function detectJava(){
    if (window.navigator.javaEnabled()) {
        //document.write("Your browser is Java-enabled");
        return true;
    }
    else {
        //document.write("Your browser is not Java-enabled");
        return false;
    }
}
var hasSVGSupport = false;
var useVBMethod = false;
function detectSvg(){


	// Internet Explorer returns 0 as the number of MIME types,
	// so this code will not be executed by it. This is our indication
	// to use VBScript to detect SVG support.
	if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0) {
	    if (navigator.mimeTypes["image/svg-xml"] != null) {
	        hasSVGSupport = true;
	    }
	}
	else {
	    useVBMethod = true;
	}
	if(useVBMethod == true){
		document.writeln('<scr' + 'ipt language="VBScript">');
        document.writeln('On Error Resume Next');
        document.writeln('If useVBMethod = true Then');
        document.writeln('    hasSVGSupport = IsObject(CreateObject("Adobe.SVGCtl"))');
        document.writeln('End If');
        document.writeln('</scr' + 'ipt>');
	}
	return hasSVGSupport;
}

function detectImages(){
	if(document.images){
		return true;
	}
	else {
		return false;
	}
}

function detectLayers(){
	if(document.layers || document.all){
		return true;
	}
	else {
		return false;
	}
}

function detectFrames(){
	if(document.frames || frames){
		return true;
	}
	else {
		return false;
	}
}

function detectForms(){
	if(document.forms){
		return true;
	}
	else {
		return false;
	}
}

function detectAcrobat(){

	var hasAA=false;
    document.writeln('<SCR' + 'IPT LANGUAGE="VBScript" TYPE="text/vbscript">');
	document.writeln('on error resume next');
	document.writeln('set AAControl=CreateObject("PDF.PdfCtrl.1")');
	document.writeln('set AAControl5=CreateObject("Pdf.PdfCtrl.5")');
	document.writeln('if (IsObject(AAControl)) then');
	document.writeln('hasAA=true');
	document.writeln('End if');
	document.writeln('if (IsObject(AAControl5)) then');
	document.writeln('hasAA=true');
	document.writeln('End if');
	document.writeln('</SCR' + 'IPT>');

	if (navigator.mimeTypes['application/pdf']){
		hasAA=true;
	}

	if (hasAA){
		return true;
	}
	else {
		return false;
	}
}

function detectCSS(){
	if (document.styleSheets){
		return true;
	}
	else {
		return false;
	}
}

var acrobatVersion = 0;
function getAcrobatVersion() {
	var agent = navigator.userAgent.toLowerCase();

	// NS3+, Opera3+, IE5+ Mac, Safari (support plugin array):  check for Acrobat plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
      for (i=0; i < navigator.plugins.length; i++ ) {
         var plugin = navigator.plugins[i];
         if (plugin.name.indexOf("Adobe Acrobat") > -1) {
            acrobatVersion = parseFloat(plugin.description.substring(30));
         }
      }
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
    else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	    document.write('<scr' + 'ipt language="VBScript"\> \n');
	    document.write('on error resume next \n');
		document.write('dim obAcrobat \n');
		document.write('set obAcrobat = CreateObject("PDF.PdfCtrl.5") \n');
		document.write('if IsObject(obAcrobat) then \n');
		document.write('acrobatVersion = 5 \n');
		document.write('else set obAcrobat = CreateObject("PDF.PdfCtrl.1") end if \n');
		document.write('if acrobatVersion < 5 and IsObject(obAcrobat) then \n');
		document.write('acrobatVersion = 4 \n');
		document.write('end if');
		document.write('</scr' + 'ipt\> \n');
    }

	// Can't detect in all other cases
	else {
		acrobatVersion = acrobatVersion_DONTKNOW;
	}

	return acrobatVersion;
}

acrobatVersion_DONTKNOW = -1;



/**
* DETECT FLASH
*/
var flashinstalled 	= 0;
var flashversion 	= 0;
function getFlash(){
	// Jos plugins array on asetettu
	if (navigator.plugins && navigator.plugins.length){
		x = navigator.plugins["Shockwave Flash"];
		if (x){
			flashinstalled = 2;
			if (x.description){
				y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
		else {
			flashinstalled = 1;
		}
		if (navigator.plugins["Shockwave Flash 2.0"]){
			flashinstalled = 2;
			flashversion = 2;
		}
	}
	// Jos mimeTypes array on asetettu
	else if (navigator.mimeTypes && navigator.mimeTypes.length){
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin)
			flashinstalled = 2;
		else
			flashinstalled = 1;
	}
	// Muuten on ie ja tutkitaan vbscriptill�
	else {
		//MSDetect = true;

		document.writeln('<SCR' + 'IPT LANGUAGE="VBScript">');
		document.writeln('on error resume next');
		//document.writeln('If MSDetect = "true" Then');
		document.writeln('	For i = 2 to 6');
		document.writeln('		If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then');
		document.writeln('		Else');
		document.writeln('			flashinstalled = 2');
		document.writeln('			flashversion = i');
		document.writeln('		End If');
		document.writeln('	Next');
		//document.writeln('End If');
		document.writeln('If flashinstalled = 0 Then');
		document.writeln('	flashinstalled = 1');
		document.writeln('End If');
		document.writeln('</scr' + 'ipt>');
	}

	return flashversion;
}

/** JS VERSION DETECT */
document.writeln('<scr' + 'ipt language=\"JavaScript\"><!--');
document.writeln('var javascriptVersion = \"1.0\";');
document.writeln('var javascriptVersion1_1 = false;');
document.writeln('// --></scr' + 'ipt>');
document.writeln('<scr' + 'ipt language=\"JavaScript1.1\"><!--');
document.writeln('var javascriptVersion = \"1.1\";');
document.writeln('var javascriptVersion1_1 = true;');
document.writeln('// --></scr' + 'ipt>');
document.writeln('<scr' + 'ipt language=\"JavaScript1.2\"><!--');
document.writeln('var javascriptVersion = \"1.2\";');
document.writeln('// --></scr' + 'ipt>');
document.writeln('<scr' + 'ipt language=\"JavaScript1.3\"><!--');
document.writeln('var javascriptVersion = \"1.3\";');
document.writeln('// --></scr' + 'ipt>');
document.writeln('<scr' + 'ipt language=\"JavaScript1.4\"><!--');
document.writeln('var javascriptVersion = \"1.4\";');
document.writeln('// --></scr' + 'ipt>');
document.writeln('<scr' + 'ipt language=\"JavaScript1.5\"><!--');
document.writeln('var javascriptVersion = \"1.5\";');
document.writeln('// --></scr' + 'ipt>');
document.writeln('<scr' + 'ipt language=\"JavaScript1.6\"><!--');
document.writeln('var javascriptVersion = \"1.6\";');
document.writeln('// --></scr' + 'ipt>');

/** GET FLASH VERSION */
getFlash();
if(flashinstalled == 2){flashVersion = flashversion;}
else if(flashinstalled == 1){flashVersion = 0;}
else {flashVersion = -1;}

/* Get stuff from functions */
var now                         = new Date();
//date.toGMTString();
var requestURI					= 'requestURI='+escape(window.location);
var queryString				    = 'queryString='+window.location.search;
var screenSize					= 'screenSize='+screen.width+'x'+screen.height;
var colorDepth					= 'colorDepth='+screen.colorDepth;
var docTitle					= 'docTitle='+escape(document.title)+'';
var flashVersion				= 'flashVersion='+flashVersion;
var userLang					= 'userLang='+navigator.userLanguage;
var sysLang					    = 'sysLang='+navigator.systemLanguage;
var cookies					    = 'cookies='+navigator.cookieEnabled;
var jsVersion					= 'jsVersion='+javascriptVersion;
var cpuClass					= 'cpuClass='+navigator.cpuClass;
var referer					    = 'referer='+escape(document.referrer);
var quickTimeIsInstalled     	= 'quicktimeInstalled='+detectQuickTime();
var directorIsInstalled      	= 'shockwaveInstalled='+detectDirector();
var windowsMediaIsInstalled  	= 'winMediaInstalled='+detectWindowsMedia();
var realPlayerIsInstalled    	= 'realInstalled='+detectReal();
var javaIsInstalled          	= 'javaInstalled='+detectJava();
var acrobatInstalled			= 'acrobatInstalled='+getAcrobatVersion();
var svgSupported				= 'svgSupported='+detectSvg();
var imagesSupported			    = 'imagesSupported='+detectImages();
var layersSupported			    = 'layersSupported='+detectLayers();
var framesSupported			    = 'framesSupported='+detectFrames();
var formsSupported				= 'formsSupported='+detectFrames();
//var jpgSupported				= 'jpgSupported="+this.jpgSupported+"';
//var gifSupported				= 'gifSupported="+this.gifSupported+"';
//var pngSupported				= 'pngSupported="+this.pngSupported+"';
//var bmpSupported				= 'bmpSupported="+this.bmpSupported+"';
var cssSupported				= 'cssSupported='+detectCSS();
var timeZone					= 'timeZone='+now.getTimezoneOffset();
var antiAliasing				= 'antiAliasing='+window.screen.fontSmoothingEnabled;// -->
var target      = 'http://www.fakt.fi/detect/servlet/dbInsert?';
var serverName  = 'serverName=www.fakt.fi';
var serverPort  = 'serverPort=80';
var platform    = 'platform=Other';
var browser     = 'browser=Other+';
var ip          = 'ip=38.107.191.102';
var host        = 'host=38.107.191.102';
var sessionID   = 'sessionID=AF2172D12F3863AD35FB90A718B09BA2';
var siteID      = 'siteID=731'
var countryName = 'countryName=UNITED STATES';
var alterSessionCounter	= 'alterSessionCounter=false';
document.write('<img src="'+target+'&'+serverName+'&'+serverPort+'&'+requestURI+'&'+queryString+'&'+screenSize+'&'+colorDepth+'&'+docTitle+'&'+platform+'&'+browser+'&'+ip+'&'+host+'&'+referer+'&'+flashVersion+'&'+cookies+'&'+jsVersion+'&'+directorIsInstalled+'&'+windowsMediaIsInstalled+'&'+realPlayerIsInstalled+'&'+javaIsInstalled+'&'+svgSupported+'&'+imagesSupported+'&'+layersSupported+'&'+framesSupported+'&'+formsSupported+'&'+acrobatInstalled+'&'+cssSupported+'&'+sessionID+'&'+siteID+'&'+cpuClass+'&'+userLang+'&'+sysLang+'&'+quickTimeIsInstalled+'&'+windowsMediaIsInstalled+'&'+timeZone+'&'+antiAliasing+'&'+countryName+'&'+alterSessionCounter+'" border=0 height=1 width=1>');
