// JavaScript Document
// Detect the Version of Adobe Reader.

// Add this to head of html
// <script src="../includes/detect_adobe_reader.js" language="javascript" type="text/javascript">

// Add this to the body of html
// <script type="text/javascript">if (displayString) {document.write("<strong>",displayString," Detected </strong>");}


//Script type required to validate
var displayReader;
var acrobat=new Object();

acrobat.installed=false;
acrobat.version='0.0';

if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x<navigator.plugins.length;x++) {
		if (navigator.plugins[x].description.indexOf('Adobe Acrobat')!= -1){
			acrobat.version=parseFloat(navigator.plugins[x].description.split('Version ')[1]);
			if (acrobat.version.toString().length == 1) acrobat.version+='.0';
			acrobat.installed=true;
			displayReader = 'Adobe Reader Version: ' + acrobat.version + ' Detected';
			break;
		}
	}
}else if (window.ActiveXObject){
	for (x=2; x<10; x++){
		try{
			oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
			if (oAcro){
				acrobat.installed=true;
				acrobat.version=x+'.0';
			displayReader = 'Adobe Reader Version: ' + acrobat.version + ' Detected';
			}
		}
		catch(e) {}
	}
	try{
		oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
		if (oAcro4){
			acrobat.installed=true;
			acrobat.version='4.0';
			displayReader = 'Adobe Reader Version: ' + acrobat.version + ' Detected';
		}
	}
	catch(e) {}
	try{
		oAcro7=new ActiveXObject('AcroPDF.PDF.1');
		if (oAcro7){
			acrobat.installed=true;
			acrobat.version='7.0';
			displayReader = 'Adobe Reader Version: ' + acrobat.version + ' Detected';
		}
	}
	catch(e) {}
}

// Always do SOMETHING in case it goes wrong
if (! displayReader) { displayReader = 'Adobe Reader Installed: Information Not Available'; }

// this alert is just to test if document.write doesn't work
//alert(displayString);