var msie_windows = 0;

if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)){
  msie_windows = 1;
  var vb = "<" + "script type=\"text/vbscript\"" + " language=\"VBScript\"" + " src=\"../content/pdetection_vbs.vbs\"" + "><" + "/script>";
  document.writeln(vb);
}

function verCaps(id) {
  if (typeof(caps) != "undefined" && typeof(caps.id) != "undefined" && typeof(caps.getComponentVersion) != "undefined")
    return caps.getComponentVersion(id, "ComponentID");
  else
    return false;
}

function detect_acrobat() {
	var nope ="<p class=\"redex\">You do not have Adobe Acrobat installed. You may ";
	nope += "<a href=http://www.adobe.com/products/acrobat/readstep2.html target=_blank>download it from the Adobe web site</a>.</p>"
	if (msie_windows != 1) {
		for (var i=0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.toLowerCase().indexOf("adobe acrobat") >= 0) {
				i_acrobatreader = true;
				v_acrobatreader = navigator.plugins[i].description.substring(navigator.plugins[i].description.toLowerCase().lastIndexOf("version ") + 8, navigator.plugins[i].description.toLowerCase().lastIndexOf(" for"));
				return "<p class=\"greencheck\">You have Acrobat version " + v_acrobatreader + " installed.</p>";
			}
		}
	} else {
		vIE_acro = Acrobat_ActiveX();
		if (vIE_acro) {
			return "<p class=\"greencheck\">You have Acrobat version " + vIE_acro + " installed.</p>";
		}
	}
	return nope;
}

function detect_sw() {
	var nope ="<p class=\"redex\">You do not have Shockwave installed. You may ";
	nope += "<a href=http://sdc.shockwave.com/shockwave/download/frameset.fhtml target=_blank>download it from the Macromedia web site</a>.</p>"
	if (msie_windows != 1) {
		for (var i=0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.toLowerCase().indexOf("shockwave for director") >= 0) {
				v_shock = navigator.plugins[i].description.substring(navigator.plugins[i].description.toLowerCase().lastIndexOf("version ") + 8, navigator.plugins[i].description.length);
				return "<p class=\"greencheck\">You have Shockwave version " + v_shock + " installed.</p>";
			}
		}
		return nope;
	} else {
		vIE_shock = Shockwave_ActiveX();
		if (vIE_shock) {
			return "<p class=\"greencheck\">You have Shockwave version " + vIE_shock + " installed.</p>"
		} else {
			return nope;
		}
	}
}

function detect_flash() {
	var fv = verCaps("{D27CDB6E-AE6D-11CF-96B8-444553540000}");
	var a_flash;
	var nope ="<p class=\"redex\">You do not have Flash installed. You may ";
	nope += "<a href=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash target=_blank>download it from the Macromedia web site</a>.</p>"
	if (fv)
		a_flash = fv;
		if (msie_windows != 1) {
			for (var i=0; i < navigator.plugins.length; i++) {
				if (navigator.plugins[i].name.toLowerCase().indexOf("shockwave flash") >= 0) {
					v_flash = navigator.plugins[i].description.substring(navigator.plugins[i].description.toLowerCase().lastIndexOf("flash ") + 6, navigator.plugins[i].description.length);
					if (parseInt(v_flash.substring(0,1)) >= 7) {
						return "<p class=\"greencheck\">You have Flash version " + v_flash + " installed.</p>";
					} else {
						return "<p class=\"redex\">You have Flash version " + v_flash + " installed. You will need to upgrade to the latest version. You may <a href=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash target=_blank>download it from the Macromedia web site</a>.</p>"
					}
				}
			}
			return nope;
		} else {
	}
		if (Flash_ActiveX()) {
			return "<p class=\"purplequestion\">You have Flash installed, but we cannot verify the version. You must verify this manually. Flash 7 or greater is required.</p>";
		} else {
			return nope;
		}
}

function detect_realplayer() {
	var nope ="<p class=\"redex\">You do not have RealPlayer installed. You may ";
	nope += "<a href=http://proforma.real.com/real/player/player1.html?src=downloadr,010524rpchoice_c2&dc=526525524 target=_blank>download RealPlayer here</a>.</p>"
	if (msie_windows != 1) {
		for (var i=0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.toLowerCase().indexOf("realone player") >= 0) {
				v_rp = navigator.plugins[i].description;
				return "<p class=\"greencheck\">You have RealPlayer version " + v_rp + " installed.</p>";
			}
		}
		for (var i=0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.toLowerCase().indexOf("realplayer") >= 0) {
				for (var j=0; j < navigator.plugins.length; j++) {
					if (navigator.plugins[j].name.toLowerCase().indexOf("realplayer version") >= 0) {
						v_rp = navigator.plugins[j].description;
						return "<p class=\"greencheck\">You have RealPlayer version " + v_rp + " installed.</p>";
					}
				}
				return "<p class=\"greencheck\">You have RealPlayer installed.</p>";
			}
		}
	} else {
		vIE_real = Real_ActiveX();
		if (vIE_real) {
			return "<p class=\"greencheck\">You have RealPlayer version " + vIE_real + " installed.</p>"
		} else {
			return nope;
		}
	}
	return nope;
}

function detect_quicktime() {
	var nope ="<p class=\"redex\">You do not have QuickTime installed. You may ";
	nope += "<a href=http://www.apple.com/quicktime/download/ target=_blank>download QuickTime here</a>.</p>"
	if (msie_windows != 1) {
		for (var i=0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.toLowerCase().indexOf("quicktime") >= 0) {
				v_qt = navigator.plugins[i].name.substring(17, navigator.plugins[i].name.length);
				return "<p class=\"greencheck\">You have Quicktime version " + v_qt + " installed.</p>";
			}
		}
	} else {
		vIE_QT = Quicktime_ActiveX();
		if (vIE_QT) {
			return	"<p class=\"greencheck\">You have Quicktime version " + vIE_QT + " installed.</p>"
		}
	}
	return nope;
}

function detect_wmp() {
	var nope ="<p class=\"redex\">You do not have Windows Media Player installed. You may ";
  	nope += "<a href=http://www.microsoft.com/windowsmedia target=_blank>download Windows Media Player here</a>.</p>"
	if (msie_windows != 1) {
		for (var i=0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.toLowerCase().indexOf("windows media player") >= 0) {
	 			return "<p class=\"greencheck\">You have Windows Media Player installed.</p>";
			}
		}
	} else {
		vIE_WMP = WMP_ActiveX();
		if (vIE_WMP) {
			if (vIE_WMP == -1) {
				var yep = "<p class=\"greencheck\">You have Window Media Player installed.</p>"
			} else {
				var yep = "<p class=\"greencheck\">You have Window Media Player version " + vIE_WMP + " installed.</p>"
			}
			return yep;
		} else {
	    	return nope;
		}
	}
	return nope;
}

function detect_plato() {
	var nope ="<p class=\"redex\">You do not have the PLATO SCORM plugin installed. You may ";
  	nope += "<a href=http://www.platoweb.com/pathways/pway_iis.dll/coursewarehelp.html target=_blank>download it from the PLATO web site</a>.</p>"
	if (msie_windows != 1) {
		for (var i=0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.toLowerCase().indexOf("iplato") >= 0) {
				return "<p class=\"greencheck\">PLATO SCORM Plugin is installed.</p>";
			}
		}
	} else {
		if (Plato_ActiveX()) {
			return "<p class=\"greencheck\">PLATO SCORM Plugin is installed.</p>";
		}
	}
	return nope;
}

var detect = navigator.userAgent.toLowerCase();
var OS, browser, version, thestring, place, pass = 0;
function Browser_Type(platform) {
	if (checkIt('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	} else if (checkIt('safari')) browser = "Safari";
	else if (checkIt('omniweb')) browser = "OmniWeb";
	else if (checkIt('opera')) browser = "Opera";
	else if (checkIt('webtv')) browser = "WebTV";
	else if (checkIt('icab')) browser = "iCab"
	else if (checkIt('msie')) browser = "Internet Explorer";
	else if (checkIt('netscape')) browser = "Netscape";
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
		if (typeof(navigator.product) != "undefined") {
			browser = "Mozilla";
			rv = navigator.userAgent.match(/([Mozilla ]?Fire\w+)\/([\w|\+.]+)/);
			if (rv) {
				browser = rv[1];
				version = rv[2];
			} else {
				rv = navigator.userAgent.match(/rv:([\w|\+.]+)/);
				if (rv) {
					rv = rv[0];
					version = rv.substr(3);
				}
			}
		}
	} else browser = "<p class=\"redex\">You are using an unrecognized browser.</p>";
	if (!version) {
		version = detect.charAt(place + thestring.length);
	}
	var browsername = "";
	if (browser == "Internet Explorer" && parseFloat(version) >= 6) pass = 1.
	if (browser == "Internet Explorer" && parseFloat(version) >= 5 && platform == "rotw") pass = 1.
	if (browser == "Netscape Navigator" && parseFloat(version) >= 7) pass = 1.
	if (browser == "Mozilla" && parseFloat(version) >= 1.4) pass = 1.
	if (browser)
		browsername += browser;
	if (version)
		browsername += " " + version;
	if (browsername) {
		pass ? classtype = "greencheck" : classtype = "redex";
		return "<p class=\"" + classtype + "\">You are using " + browsername + ".</p>";
	} else {
		return "<p class=\"redex\">We are unable to detect your browser version!</p>";
	}
}

function checkIt(s) {
	place = detect.indexOf(s) + 1;
	thestring = s;
	return place;
}

function Cookies() {
	(navigator.cookieEnabled) ? msg = "<p class=\"greencheck\">Cookies are Enabled.</p>" : msg = "<p class=\"redex\">Cookies are Disabled.</p>";
	return msg;
}

function detectJava() {
	if (navigator.javaEnabled()) {
		return "<p class=\"greencheck\">Sun Java is installed.</p>";
	} else {
		return "<p class=\"redex\">Java is not installed. You may <a href=http://www.java.com/en/download/manual.jsp target=_blank>download it from the Sun web site</a>.</p>";
	}
}

function OS(platform) {
  var v_os = "";
  var green = "<p class=\"greencheck\">You are using ";
  var red = "<p class=\"redex\">You are using ";
  var agt=navigator.userAgent.toLowerCase();
  if (agt.indexOf("win")!=-1 || agt.indexOf("16bit")!=-1) {
    if (agt.indexOf("win95")!=-1 || agt.indexOf("windows 95")!=-1)
      v_os = red + "Windows 95.</p>";
    if (agt.indexOf("win98")!=-1 || agt.indexOf("windows 98")!=-1)
      v_os = green + "Windows 98.</p>";
    if (agt.indexOf("win 9x 4.90")!=-1)
      v_os = green + "Windows ME.</p>";
    if (agt.indexOf("winnt")!=-1 || agt.indexOf("windows nt")!=-1)
      v_os = red + "Windows NT.</p>";
    if (agt.indexOf("windows nt 5.0")!=-1)
      v_os = green + "Windows 2000.</p>";
    if (agt.indexOf("windows nt 5.1")!=-1)
      v_os = green + "Windows XP.</p>";
    if (v_os == "")
      v_os = red + "an unrecognized Windows operating system.</p>";
  } else {
    if (agt.indexOf("mac")!=-1) {
		if (platform == "rotw") {
			v_os = red + "Apple Macintosh.</p>";
		} else {
      		if (agt.indexOf("os x")!=-1) {
        		v_os = green + "Mac Os X.</p>";
      		} else {
	  			if (platform == "win") {
					v_os = red + "Apple Macintosh.</p>";
				} else {
       				v_os = "<p class=\"purplequestion\">You are using a Mac, but we cannot determine the version. Please verify manually.</p>";
				}
			}
		}
    } else 
      v_os = red + "an unrecognized Operating System.</p>";
  }
  return v_os;
}


