var prescan = {

	// Element id's.
	activeX: "activexPreScan",
	java: "javaPreScan",
	pluginMissing: "pluginMissingPreScan",
	notSupported: "notSupportedPreScan",
	scanLink1: "frontScanLink",
	scanLink2: "frontScanLink2",
	
	init: function() {
	
		// User agent.
		var ua = navigator.userAgent;
	
		// Only for windows.
		if (ua.indexOf("Windows") == -1) {
			this.showElement(this.notSupported);
			return false;
		}

		// On IE, show active x.
		if (ua.indexOf("MSIE") != -1) {
			// IE 7 64-bit version is not supported
			if( ( ua.indexOf("7.0") != -1 || ua.indexOf("8.0") != -1 ) && ua.indexOf("Win64") != -1 && ua.indexOf("WOW64") == -1 ) {
				this.showElement(this.notSupported);
				return false;	
			}
			this.showElement(this.activeX);
			this.showLink(this.scanLink1,"scan-activex.action");
			this.showLink(this.scanLink2,"scan-activex.action");
			return true;
		}
		
		if (this.isJavaSupported()) {
			this.showElement(this.java);
			this.showLink(this.scanLink1,"scan-java.action");
			this.showLink(this.scanLink2,"scan-java.action");
				
		} else {
			this.showElement(this.pluginMissing);
		}
		
	},
	
	isJavaSupported: function() {
		
		// Plugins is false => go away.
		if (typeof(navigator.plugins) == "undefined") {
			return false;
		}
		
		// Opera is a special case.
		if (navigator.userAgent.toLowerCase().indexOf("opera") != -1) {
			return navigator.javaEnabled();
		}
		
		// Look for plugins. 		
		for (i=0; i < navigator.plugins.length; i++)	{
			for (j = 0; j < navigator.plugins[i].length; j++) {
				if(navigator.plugins[i][j].type.indexOf("application/x-java-applet") != -1) {
					return true;
				}
			}
		}
		return false;
		
	},
	
	showElement: function(id) {
		var element = document.getElementById(id);
		if (typeof(element) == "object" && element != null) {
			element.style.display = "block";
		} else {
			//alert("Warning: Element " + id + " missing.");
		}
	},
	
	showLink: function(id,url) {
		var element = document.getElementById(id);
		if (typeof(element) == "object" && element != null) {
			document.getElementById(id).href = url;
		} else {
			//alert("Warning: Element " + id + " missing.");
		}	
	}

};

