var incre=i=1;
var publisherCode="";
var istitleChanged=false;
var oFCKeditor;
var intImage=2;
var divCounter="";

/* this function will maintain the zindex for citations and Notes div! */
function divpos(obj){
	i++;
	document.getElementById(obj).style.zIndex=i;
	if (navigator.appName == 'Microsoft Internet Explorer'){
		document.getElementById(obj).style.marginTop  = "29px";
	}	
}

function toggleCitations(id1, id2, statusType){
	
	if(statusType=='minimize'){
		document.getElementById(id1).style.display = "none";
		document.getElementById(id2).style.display = "block";
	} else if(statusType=='restore') {
		document.getElementById(id1).style.display = "block";
		document.getElementById(id2).style.display = "none";
	}
}

function openCitations(publisherCode, callType){
	fetchContentTools();
	this.publisherCode = publisherCode;
	var ReqUrl = "citations.do?random="+Math.random();
  	if(callType=='export'){
		ReqUrl = ReqUrl+"&callFrom=export";
		getCitations(ReqUrl,'export');
	}else{
		if (document.getElementById("contentNotes") != null) {
			document.getElementById("contentNotes").innerHTML='';
		}
		getCitations(ReqUrl);
	}
}

function getCitations(ReqUrl,callType) {
    try{
	    getXmlHTTPRequestObject();
		if(callType=="export"){
			xmlHttp.onreadystatechange = processExportCitations;
		}else{
		    xmlHttp.onreadystatechange = processCitations;
		}
	    xmlHttp.open("POST", ReqUrl, true);
	    xmlHttp.send(null);
		
	}catch (e) {
	    alert(e);
	}
}

function processCitations() {

    if (xmlHttp.readyState == 4) { // Complete
		 if (xmlHttp.status == 200) { // OK response		  
			if (document.getElementById("toolsMenu") != null && 
				document.getElementById("imageIframe") != null) {
				
				document.getElementById("imageIframe").width = "60%";				
			}
			document.getElementById("citations").innerHTML = xmlHttp.responseText;  
      	} else {
			alert(serverResponseMessage + " " + xmlHttp.statusText);
      	}
    }else{		
		var image = publisherCode + "/images/loading.gif";
		document.getElementById("citations").innerHTML = '<table border="0" width="50%"><tr><td valign="top" width="100%" align="center"><img src='+image+' border="0"/></td></tr></table>';
    }
}  

function processExportCitations() {

    if (xmlHttp.readyState == 4) { // Complete
		  if (xmlHttp.status == 200) { // OK response

			var textout = xmlHttp.responseText;
			document.write(textout);
			document.getElementById("citationExport").innerHTML = '';
      } else {
		alert(serverResponseMessage + " " + xmlHttp.statusText);
      }
    }else{
		var image = publisherCode + "/images/loading.gif";
		document.getElementById("citationExport").innerHTML = '<table border="0" width="50%"><tr><td valign="top" width="100%" align="center"><img src='+image+' height="15" width="15" border="0"/></td></tr></table>';
    }
}

function closeCitations(){
	document.getElementById("citations").innerHTML = '';
	if (document.getElementById("toolsMenu") != null && 
		document.getElementById("imageIframe") != null) {
		
		document.getElementById("imageIframe").width = "100%";				
	}
}

function toggle(publisherCode, id, imgId){
	
	this.publisherCode = publisherCode;
	var image = publisherCode;
	if(document.getElementById(id).style.display=='none'){
		document.getElementById(id).style.display = "block";
		image = image + "/images/minus.gif";
		document.getElementById(imgId).src = image;
	} else {
		document.getElementById(id).style.display = "none";
		image = image + "/images/plus.gif";
		document.getElementById(imgId).src=image;
	}
}

function jsTrim(value) {
 	
	var result = "";
    for (i=0; i < value.length; i++) {
        if (value.charAt(i) != ' ') {
            result += value.charAt(i);
        }
	}
	return result;
}

function getChapterNotes(obj){
	var url ='chapterNotes.do?chapterNotesId='+obj;
	getAllNotes(url)
}

function deleteRecord(chapterNotesid, noteId, bukisbn, pagerOffset){
	var url ='chapterNotes.do?noteId='+noteId+'&requestType=delete&chapterNotesId='+chapterNotesid+'&isbn='+bukisbn+'&random='+Math.random()+"&pager.offset="+pagerOffset;
	getAllNotes(url)
}

function getAllNotes(url) {
    rtype="GET";
	if (window.XMLHttpRequest) { // Non-IE browsers
    	req = new XMLHttpRequest();
      	try {
      		if(req){
      			req.onreadystatechange = deletenotes;
       			req.open(rtype, url, true); 
       			req.send(null);
       		}
      	} catch (e) {
			alert(e);
     		//document.getElementById('bodydivs').innerHTML = showErrorPage();
      	}
   	} else if (window.ActiveXObject) { // IE
    	req = new ActiveXObject("Microsoft.XMLHTTP");
      	try{
      		if (req) {
      			req.onreadystatechange = deletenotes;
        		req.open(rtype, url, true);
        		req.send();
        	}
     	}catch(E){
    		//document.getElementById('bodydivs').innerHTML = showErrorPage();
    	}	
   	}
}

function closeContentNotes(){
	try{
		var flag = true;
		oFCKeditor = FCKeditorAPI.GetInstance('MyTextarea') ;
		if(oFCKeditor.IsDirty()|| istitleChanged==true){
			if(confirm(notesConfirmMessage)){
				var stat = saveChanges();
				if(stat){
					try{
						document.getElementById('contentNotes').innerHTML='';
						istitleChanged=false;
						if (document.getElementById("toolsMenu") != null && 
							document.getElementById("imageIframe") != null) {
							
							document.getElementById("imageIframe").width = "100%";				
						}
						return;
					}catch(e){
						alert(e.message);
					}
				}
				flag = false;
			}else{
				istitleChanged=false
				oFCKeditor.ResetIsDirty();
				document.getElementById("contentNotes").innerHTML='';
			}
		}else{
			document.getElementById("contentNotes").innerHTML='';
		}
	
		if (flag && document.getElementById("toolsMenu") != null && 
			document.getElementById("imageIframe") != null) {
			
			document.getElementById("imageIframe").width = "100%";				
		}
	}catch (e){
	  closeContentNotes();	
	}
}

function openContentNotes(publisherCode, callFrom, pageReq){
	
	if (document.getElementById("toolsMenu") != null) {
		document.getElementById("toolsMenu").style.display='none';
	}

	if (document.getElementById("citations") != null) {
		document.getElementById("citations").innerHTML = '';
	}
	
	this.publisherCode = publisherCode;
	var ReqUrl = "notes.do?random="+Math.random();
	if(callFrom=='listing'){
		ReqUrl=ReqUrl+"&callFrom="+callFrom+"&pageReq="+pageReq;
	}
	getNotes(ReqUrl);
}

function getNotes(ReqUrl) {
    try{
	    getXmlHTTPRequestObject();
	    xmlHttp.onreadystatechange = processState;
	    xmlHttp.open("POST", ReqUrl, true);
	    xmlHttp.send(null);
		
	}catch (e) {
	    alert(e);
	}
}

function saveNotes(ReqUrl){
	try{
		document.getElementById('blk').style.display='block';
		var contentNotes=document.getElementById('MyTextarea').value;
		var notesTitle=document.getElementById('title').value;
		oFCKeditor = FCKeditorAPI.GetInstance('MyTextarea') ;
		var textAreaValue = oFCKeditor.GetXHTML();
		
		if (textAreaValue == '<br />' || textAreaValue == '<br type="_moz" />' 
			|| textAreaValue == '&nbsp;') {
			textAreaValue = "";
		} else {
			textAreaValue = textAreaValue.replace('<br type="_moz" />', '');
		}

		if (textAreaValue.length>0 && notesTitle.length>0) {
			getXmlHTTPRequestObject();
			xmlHttp.onreadystatechange = processChange;
			
			var queryString = "notes="+encodeURIComponent(textAreaValue)+"&title="+encodeURIComponent(notesTitle)+"&mode=save";

			xmlHttp.open("POST", ReqUrl, true);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlHttp.setRequestHeader("Content-length", queryString.length);
			xmlHttp.setRequestHeader("Connection", "close");
			xmlHttp.send(queryString);
			return true;
		} else {
			if (textAreaValue.length>0 && notesTitle.length==0) {
				document.getElementById("blk").innerHTML = '<div style="width:200px;color:#ff0000;font-weight:bold;">&bull;&nbsp;' + blankLabelMessage + '</div>';
			} else if (textAreaValue.length==0 && notesTitle.length>0) {
				document.getElementById("blk").innerHTML = '<div style="width:200px;color:#ff0000;font-weight:bold;">&bull;&nbsp;' + blankNoteMessage + '</div>';
			} else if (textAreaValue.length==0 && notesTitle.length==0) {
				document.getElementById("blk").innerHTML = '<div style="width:200px;color:#ff0000;font-weight:bold;">&bull;&nbsp;' + blankLabelMessage + '<br/>&bull;&nbsp;' + blankNoteMessage + '</div>';
			}
		}
	 
	}catch (e) {
		saveNotes(ReqUrl);
	    //alert(e.message);
	}
 }

function updateNotes(ReqUrl){
	try{
		document.getElementById('blk').style.display='block';
		var contentNotes=document.getElementById('MyTextarea').value;
		var notesTitle=document.getElementById('title').value;
		oFCKeditor = FCKeditorAPI.GetInstance('MyTextarea') ;

		var textAreaValue = oFCKeditor.GetXHTML();
	
		if (textAreaValue == '<br />' || textAreaValue == '<br type="_moz" />' 
			|| textAreaValue == '&nbsp;') {
			textAreaValue = "";
		} else {
			textAreaValue = textAreaValue.replace('<br type="_moz" />', '');
		}
		
		if (textAreaValue.length>0 && notesTitle.length>0) {
			getXmlHTTPRequestObject();
			xmlHttp.onreadystatechange = processChange;
			
			var queryString = "notes="+encodeURIComponent(textAreaValue)+"&title="+encodeURIComponent(notesTitle)+"&mode=edit";
			xmlHttp.open("POST", ReqUrl, true);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlHttp.setRequestHeader("Content-length", queryString.length);
			xmlHttp.setRequestHeader("Connection", "close");
			xmlHttp.send(queryString);
		} else {
			if (textAreaValue.length>0 && notesTitle.length==0) {
				document.getElementById("blk").innerHTML = '<div style="width:200px;color:#ff0000;font-weight:bold;">&bull;&nbsp;' + blankLabelMessage + '</div>';
			} else if (textAreaValue.length==0 && notesTitle.length>0) {
				document.getElementById("blk").innerHTML = '<div style="width:200px;color:#ff0000;font-weight:bold;">&bull;&nbsp;' + blankNoteMessage + '</div>';
			} else if (textAreaValue.length==0 && notesTitle.length==0) {
				document.getElementById("blk").innerHTML = '<div style="width:200px;color:#ff0000;font-weight:bold;">&bull;&nbsp;' + blankLabelMessage + '<br/>&bull;&nbsp;' + blankNoteMessage + '</div>';
			}
		}
	}catch (e) {
		updateNotes(ReqUrl);
		//alert(e.message);
	}
}

function processState() {

    if (xmlHttp.readyState == 4) { // Complete
		  if (xmlHttp.status == 200) { // OK response
				if (document.getElementById("toolsMenu") != null && 
					document.getElementById("imageIframe") != null) {
					
					document.getElementById("imageIframe").width = "60%";				
				}
				document.getElementById("contentNotes").style.zIndex=2;
				if (document.getElementById("toolsMenu") != null && 
					navigator.appName == 'Microsoft Internet Explorer'){
					document.getElementById("contentNotes").style.marginTop  = "29px";
				}
				document.getElementById("contentNotes").innerHTML = xmlHttp.responseText;
				oFCKeditor = new FCKeditor('MyTextarea') ;
				var image = publisherCode + "/images/FCKeditor/";
				oFCKeditor.BasePath = image;
				if (document.getElementById("toolsMenu") != null) {
					oFCKeditor.Width = 332;
				} else {
					oFCKeditor.Width = 195;
				}
				oFCKeditor.ReplaceTextarea();				
      } else {
		alert(serverResponseMessage + " " + xmlHttp.statusText);
      }
    }else{
		var image = publisherCode + "/images/loading.gif";
		document.getElementById("contentNotes").innerHTML = '<table border="0" width="50%"><tr><td valign="top" width="100%" align="center"><img src="' + image + '" border="0"/></td></tr></table>';
    }
}

function processChange() {

    if (xmlHttp.readyState == 4) { // Complete
		  if (xmlHttp.status == 200) { // OK response
		  try{
			     oFCKeditor = FCKeditorAPI.GetInstance('MyTextarea') ;
				 oFCKeditor.ResetIsDirty();
				 istitleChanged=false;
				document.getElementById("blk").innerHTML = '<div class="container" style="background:#fff1a8;color:#000; margin:0 15px;"><b class="rtop" style="display:block;background:#fff;"><b class="r1" style="display: block; height: 1px; overflow: hidden; background:#fff1a8;margin: 0 5px"></b><b class="r2" style="display: block; height: 1px; overflow: hidden; background:#fff1a8;margin: 0 3px"></b><b class="r3" style="display: block; height: 1px; overflow: hidden; background:#fff1a8;margin: 0 2px;"></b><b class="r4" style="display: block; height: 1px; overflow: hidden; background:#fff1a8;margin: 0 1px;height: 2px;"></b></b><div align="center"><strong>&nbsp;'+notesSavedMessage+'&nbsp;</strong></div><b class="rbottom" style="display:block;background:#fff;"><b class="r4"style="display: block;	height: 1px; overflow: hidden; background:#fff1a8;margin: 0 1px;height: 2px;"></b><b class="r3"style="display: block; height: 1px; overflow: hidden; background:#fff1a8;margin: 0 2px;"></b><b class="r2"style="display: block;	height: 1px; overflow: hidden; background:#fff1a8;margin: 0 3px"></b><b class="r1" style="display: block; height: 1px; overflow: hidden; background:#fff1a8;margin: 0 5px"></b></b></div>';
		  }catch(e){
		  }
      } else {
		alert(serverResponseMessage + " " + xmlHttp.statusText);
      }
    }else{
		try{
			document.getElementById("blk").innerHTML = '<div class="container" style="background:#fff1a8;color:#000; margin:0 15px;"><b class="rtop" style="display:block;background:#fff;"><b class="r1" style="display: block; height: 1px; overflow: hidden;	background:#fff1a8;margin: 0 5px"></b><b class="r2" style="display: block; height: 1px; overflow: hidden;	background:#fff1a8;margin: 0 3px"></b> <b class="r3" style="display: block;	height: 1px; overflow: hidden; background:#fff1a8;margin: 0 2px;"></b><b class="r4" style="display: block; height: 1px; overflow: hidden; background:#fff1a8;margin: 0 1px;height: 2px;"></b></b><div align="center"><strong>&nbsp;'+notesSavingMessage+'&nbsp;</strong></div><b class="rbottom" style="display:block;background:#fff;"><b class="r4"style="display: block; height: 1px; overflow: hidden; background:#fff1a8;margin: 0 1px;height: 2px;"></b><b class="r3"style="display: block;	height: 1px; overflow: hidden; background:#fff1a8;margin: 0 2px;"></b><b class="r2"style="display: block;	height: 1px; overflow: hidden; background:#fff1a8;margin: 0 3px"></b><b class="r1" style="display: block; height: 1px; overflow: hidden;	background:#fff1a8;margin: 0 5px"></b></b></div>';
		}catch(e){
		}
    }
}

function saveChanges(){
	var reqUrl = "notes.do?random="+Math.random();
	var stat = saveNotes(reqUrl);

	if(stat){
		return true;
	}
}

function updateChanges(){
	var reqUrl = "notes.do?random="+Math.random();
	updateNotes(reqUrl);
	return true;
}

function displayFN(){
	document.getElementById('msg').style.display='none';
	document.getElementById('edtr').style.display='block';
	document.getElementById('editbtn').style.display='block';
}

function titleStatus(){
	istitleChanged=true;
}

function getXmlHTTPRequestObject(){
	if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		isIE = true;
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function historyChange(newLocation, historyData) {
	var historyMsg = (typeof historyData == "object" && historyData != null
		? historyStorage.toJSON(historyData)
		: historyData
	);

	var url = window.location.href;
	if (url.indexOf("&page") != -1) {		
		if (newLocation.length > 0 ) {
			url = url.substring(0, url.indexOf("&page"));
			if (url.indexOf("?")>0) {
				url = url + "&" + newLocation;
			}
		}
		
		url = url.replace("#", "");
		
		if (url.indexOf("?")>0) {
			url = url + "&pageRequested=true";
		}
		
	} else {
		
		if (url.indexOf("?")>0) {
			url = url.replace("#", "&");
			url = url + "&pageRequested=true";
		} else {
			if (url.indexOf("#")>0) {
				url = url.substring(0, url.indexOf("#"));
			}
		}
				
		url = url.replace("&&", "&");	
	}
	
	if (url.indexOf("?")>0) {
		retrieveBookURL(url, "GET");
	}
};

/* Our event handler to add history change events */
function addHistoryEvent(page) {
	dhtmlHistory.add(page, page);
	if (typeof page == "object") {/*stringify this so we can log it better*/
		page = historyStorage.toJSON(page);
	}	
}

function showCancel() {
 	document.getElementById('cancel').style.display='';
 	document.getElementById('show').style.display='none';
}

function showIt() {
	document.getElementById('cancel').style.display='none';
	document.getElementById('show').style.display='';
}

function ShowFeedbackFrame(form_src_url, table_width) {
	var formDiv = document.getElementById('feedbackformdiv');
	if (formDiv.innerHTML == "" ) {
		formDiv.innerHTML ="<iframe src=" + form_src_url + " frameborder=0 " +" scrolling=no id=frameDiv style='background:#ffffff; " +" color:#888888;padding:0px;width:" + table_width + "px;" +" height:0px;'>" +" </iframe> ";
	} 
	formDiv.style.height = 10+"em";
	var frameDiv = document.getElementById('frameDiv');frameDiv.style.height = 23+"em";
}

function HideFeedbackFrame() {
	var formDiv = document.getElementById('feedbackformdiv');
	formDiv.style.height = 1+"px";
	var frameDiv = document.getElementById('frameDiv');
	frameDiv.style.height = 1+"px";
}

function swapImage() {
	switch (intImage) {
 		case 1:

			IMG1.src = "images/zoom_plus.gif"
			intImage = 2
   			return(false);
			
		case 2:

  			IMG1.src = "images/zoom_minus.gif" 
   			intImage = 1
   			return(false);
 	}
}

function getBookPage(url){
	try{
	    callGAnalytics();
	    closeCitations();
		closeContentNotes();
	}catch(e){
	}

	var page = url.substring(url.lastIndexOf("page"), url.length);
	url = url + "&pageRequested=true";
	retrieveBookURL(url, "GET");
	addHistoryEvent(page);	
}

function retrieveBookURL(url, rtype) {
	
	try
    {
	    getXmlHTTPRequestObject();
	
		xmlHttp.onreadystatechange = processStateChangeForBook;
		
		xmlHttp.open("GET", url, true);
	    xmlHttp.send(null);
			
	}
	catch (e) 
	{
	    alert(e);
	}	
}

function processStateChangeForBook() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {			
					
			var resp =  xmlHttp.responseText;
			var objt = new Function("return "+resp)();
			var favoriteUrl = objt.favoriteUrl;
			var favoriteTitle = objt.favoriteTitle;
			var notesData = objt.notesDiv;				
			var bookMark = "javascript:addBookMark('" + favoriteUrl + "','" + favoriteTitle + "');";
			var zoomData = objt.zoomDiv;
			var prevData = objt.prevDiv;
			var pageNumber = objt.pageNumber;
			var nextData = objt.nextDiv;	
			var breadCrumb = objt.breadCrumb;
			var imageData = objt.imageDiv;
			var chapterDoi = objt.chapterDoi;
			
			if (document.getElementById("toolsMenu") != null) {
				
				document.getElementById("toolsMenu").style.display='none';
			}

			if (document.getElementById("bookMark") != null) {
				document.getElementById("bookMark").href = bookMark;
			}			
			
			if (document.getElementById("notesDiv") != null) {
				
				document.getElementById("notesDiv").innerHTML = notesData;
			} 
			
			if (document.getElementById("topZoomPercentage") != null) {
				document.getElementById("topZoomPercentage").value = zoomData;
				document.getElementById("bottomZoomPercentage").value = zoomData;
				
				document.getElementById("topZoomPage").value = pageNumber;
				document.getElementById("bottomZoomPage").value = pageNumber;
			} else {
				if (document.getElementById("topZoomDiv") != null) {
					document.getElementById("topZoomDiv").innerHTML = zoomData;
				}
			
				if (document.getElementById("bottomZoomDiv") != null) {
					document.getElementById("bottomZoomDiv").innerHTML = zoomData;
				}
			}			
			
			if (document.getElementById("topPrevDiv") != null) {
				document.getElementById("topPrevDiv").innerHTML = prevData;
			}
			
			if (document.getElementById("bottomPrevDiv") != null) {
				document.getElementById("bottomPrevDiv").innerHTML = prevData;
			}
			
			if (document.getElementById("topPageNumber") != null) {
				document.getElementById("topPageNumber").value = pageNumber;	
			}
			
			if (document.getElementById("bottomPageNumber") != null) {
				document.getElementById("bottomPageNumber").value = pageNumber;			
			}
			
			if (document.getElementById("topNextDiv") != null) {
				document.getElementById("topNextDiv").innerHTML = nextData;
			}
			
			if (document.getElementById("bottomNextDiv") != null) {
				document.getElementById("bottomNextDiv").innerHTML = nextData;
			}			
			
			if (document.getElementById("imageDiv") != null) {
				
				if (document.getElementById("readerDiv") != null) {
					
					var readerExists = detectAcrobat();		
			
					if (readerExists)
					{
						document.getElementById("readerDiv").style.display='none';
						document.getElementById("imageIframe").style.display='block';
						document.getElementById("imageDiv").innerHTML = imageData;

					} else {
						document.getElementById("imageIframe").style.display='none';
						document.getElementById("readerDiv").style.display='block';
					}	
					
				} else {
					document.getElementById("imageDiv").innerHTML = imageData;
				}
				
			}	
			
			if (document.getElementById("breadCrumbDiv") != null) {
				document.getElementById("breadCrumbDiv").innerHTML = breadCrumb;	
			}
			
			if (document.getElementById("chapterDoi") != null) {
				document.getElementById("chapterDoi").innerHTML = chapterDoi;	
			}
									 			
        } else {
            alert (serverResponseMessage + " " + xmlHttp.statusText);
        }
    }    
}

function addBookMark(url, title) {
	var userAgent = navigator.userAgent.toLowerCase();
	var isSafari = (userAgent.indexOf('webkit')!=-1);
    var isMac = (userAgent.indexOf('mac')!=-1);
    var buttonStr = isMac?'Command/Cmd':'CTRL';
	
	if (isSafari)
	{
		alert(bookmarkMessage1 + " " + buttonStr + " " + bookmarkMessage2);
	}
	else 
	{
		if (window.sidebar) {
			window.sidebar.addPanel(title, url, "");
		} else if (document.all) {
			window.external.AddFavorite(url, title);
		}
	}
}

function fetchContentTools() {
		
	if (document.getElementById("toolsMenu") != null) {	
		if (document.getElementById("toolsMenu").style.display == 'none') {
			document.getElementById("toolsMenu").style.display='block';	
		} else {
			document.getElementById("toolsMenu").style.display='none';
		}	
	}
} 

function detectAcrobat()
{
	var acrobat = new Object();
	var pluginDescription;
	var pluginName;
	
	acrobat.installed = false;
	acrobat.version = '0.0';
	
	if (navigator.plugins && navigator.plugins.length)
	{
		for ( var x = 0, l = navigator.plugins.length; x < l; ++x )
		{
			pluginDescription = navigator.plugins[x].description;
			pluginName = navigator.plugins[i].name.toLowerCase();
			if (pluginDescription.indexOf('Adobe PDF') != -1 ||
				pluginDescription.indexOf('Adobe Acrobat') != -1 ||
				pluginDescription.indexOf('Adobe Reader') != -1 ||
				pluginName.indexOf('pdf') != -1)
			{
				acrobat.version = parseFloat(pluginDescription.split('Version ')[1]);
				if (acrobat.version.toString().length == 1)							
					acrobat.version += '.0';
				acrobat.installed = true;
				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';
				
				}
			}
			catch(e) {}
		}

		try
		{
			oAcro4 = new ActiveXObject('PDF.PdfCtrl.1');
			if (oAcro4)
			{
				acrobat.installed = true;
				acrobat.version = '4.0';
			}
		}
		catch(e) {}

		try
		{
			oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
			if (oAcro7)
			{
				acrobat.installed = true;
				acrobat.version = '7.0';
			}
		}
		catch(e) {}
	}

	return acrobat.installed;	
}
