var GeigerAccount;
var GeigerUserData = '';
var GeigerURL = 'http://www.geigerteller.nl/geiger.asp?';
function addURL(v, d) {
	GeigerURL += '&'+v+'='+d;
}

function Geiger() {
	if (document.location.hostname == 'www.wadigirecords.com') {
//		document.body.innerHTML = '<em>Deze tekst is zonder toestemming overgenomen van www.zaph.nl.</em>'+document.body.innerHTML;
		return;
	}
	GeigerURL += 'account='+GeigerAccount;
	addURL('Protocol', document.location.protocol);
	addURL('Hostname', document.location.hostname);
	addURL('Path', document.location.pathname);
	addURL('Search', document.location.search.replace(/&/g, '~!~'));
	addURL('Referer', document.referrer.replace(/&/g, '~!~'));
	if (self.screen) {
		addURL('Width', window.screen.width);
		addURL('Height', window.screen.height);
		addURL('Colordepth', window.screen.colorDepth);
	} else if (self.java) {
		var j=java.awt.Toolkit.getDefaultToolkit();
		var s=j.getScreenSize();
		addURL('Width', s.width);
		addURL('Height', s.height);
	}
	addURL('Browser', navigator.appName);
	addURL('UserAgent', navigator.appVersion);
	addURL('UserData', GeigerUserData);

	if(canDetectPlugins()) {
		addURL('Director', detectPlugin('SWCtl.SWCtl.1', 'Shockwave', 'Director'));
		//addURL('PDF', detectPlugin('PDF.PdfCtrl.5', 'Adobe Acrobat', 'Adobe Acrobat'));
		addURL('Flash', detectPlugin('ShockwaveFlash.ShockwaveFlash.1', 'Shockwave', 'Flash'));
		addURL('QT', detectPlugin('QuickTimeCheckObject.QuickTimeCheck.1', 'Quicktime'));
		addURL('RM', (detectPlugin('rmocx.RealPlayer G2 Control', 'RealPlayer') || detectPlugin('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)', 'RealPlayer')));
		addURL('RV',detectPlugin('RealVideo.RealVideo(tm) ActiveX Control (32-bit)', 'RealPlayer'));
		addURL('WM',detectPlugin('MediaPlayer.MediaPlayer.1', 'Windows Media'));
		addURL('Java', detectJava());
	}

	var gi = document.getElementById('GeigerImage');
	if (!gi) {
		GeigerURL += '&image=no';
		gi = document.body;
	}
	var a = document.createElement("A");
	a.href='http://www.geigerteller.nl';
	a.target='nw';
	var im = document.createElement("IMG");
	im.src = GeigerURL;
	im.border=0;
	a.appendChild(im);
	gi.appendChild(a);
}

function GeigerOutLinks() {
	var a = document.getElementsByTagName('A');
	var b;
	for (var i=0; i<a.length; i++) {
		if (!a[i].onclick) {
			b = true;
			if (a[i].href.indexOf('http://')==-1)
				b = false;
			if (a[i].href.indexOf(document.location.protocol+'//'+document.location.hostname)==0)
				b = false;
			if (b) {
				a[i].onclick=function sendOut() {
					this.href = 'http://www.geigerteller.nl/redirect.asp?account='+GeigerAccount+'&path='+this.href;
					return true;
				}
			}
		}
	}
}

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;


function canDetectPlugins() {
    return (detectableWithVB || (navigator.plugins && navigator.plugins.length > 0));
}

function detectFlash() {
    pluginFound = detectPlugin('Shockwave','Flash'); 
    if(!pluginFound && detectableWithVB) {
	for (var i=8; i>0; i++) {
		if (detectActiveXControl('ShockwaveFlash.ShockwaveFlash.'+i)) {
			pluginFound = i;
			break;
		}
	}
    }
    return pluginFound
}

function detectJava() {
	return (navigator.javaEnabled());
}

function detectPlugin() {
    var p = detectPlugin.arguments;
    if (p.length == 2) {
	    pluginFound = dodetectPlugin(p[1]);
	} else {
	    pluginFound = dodetectPlugin(p[1], p[2]); 
	}
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl(p[0]);
    }
    return pluginFound
}

function dodetectPlugin() {
var plugIns = '';
	    var numFound = 0;
    // allow for multiple checks in a single pass
    var daPlugins = dodetectPlugin.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
	    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
plugIns += navigator.plugins[pluginsArrayCounter].name+' - '+navigator.plugins[pluginsArrayCounter].description+'<br>\n';
		    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;//+plugIns;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script 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('  Dim o');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     Set o = CreateObject(activeXControlName)');
    document.writeln('     If IsObject(o) Then');
    document.writeln('         detectActiveXControl = True');
    document.writeln('     End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}


