function BookReaderC() {
	
	
	this.pages = Array();
	this.pages["image"] = Array();
	this.pages["title"] = Array();
	this.pages["image"][1] = "003.gif";
	this.pages["title"][1] = "Table of Contents [p3]";
	this.pages["image"][2] = "004.gif";
	this.pages["title"][2] = "Preface [p4]";
	this.pages["image"][3] = "005.gif";
	this.pages["title"][3] = "Introduction [p5]";
	this.pages["image"][4] = "006.gif";
	this.pages["title"][4] = "Introduction [p6]";
	this.pages["image"][5] = "011.gif";
	this.pages["title"][5] = "Gastro-intestinal System [ch1/p11]";
	this.pages["image"][6] = "013.gif";
	this.pages["title"][6] = "Gastro-intestinal System [ch1/p13]";
	this.pages["image"][7] = "059.gif";
	this.pages["title"][7] = "Respiratory System [ch2/p59]";
	this.pages["image"][8] = "060.gif";
	this.pages["title"][8] = "Bronchial asthma [ch2/p60]";
	this.pages["image"][9] = "063.gif";
	this.pages["title"][9] = "Respiratory System [ch2/p63]";
	this.pages["image"][10] = "079.gif";
	this.pages["title"][10] = "Antihistamines, hyposensitisation, allergy remedies [ch2/p79]";
	this.pages["image"][11] = "101.gif";
	this.pages["title"][11] = "Eye [ch3/p101]";
	this.pages["image"][12] = "103.gif";
	this.pages["title"][12] = "Eye [ch3/p103]";
	this.pages["image"][13] = "109.gif";
	this.pages["title"][13] = "Ear, Nose, Oropharynx and Dental [ch4/p109]";
	this.pages["image"][14] = "112.gif";
	this.pages["title"][14] = "Ear, Nose, Oropharynx and Dental [ch4/p112]";
	this.pages["image"][15] = "131.gif";
	this.pages["title"][15] = "Urinary System [ch5/p131]";
	this.pages["image"][16] = "141.gif";
	this.pages["title"][16] = "Urinary System [ch5/p141]";
	this.pages["image"][17] = "155.gif";
	this.pages["title"][17] = "Skin [ch6/p155]";
	this.pages["image"][18] = "157.gif";
	this.pages["title"][18] = "Skin [ch6/p157]";
	this.pages["image"][19] = "181.gif";
	this.pages["title"][19] = "Musculoskeletal and Joint System [ch7/p181]";
	this.pages["image"][20] = "189.gif";
	this.pages["title"][20] = "Musculoskeletal and Joint System [ch7/p189]";
	this.pages["image"][21] = "211.gif";
	this.pages["title"][21] = "Detoxifying and environmental remedies [ch8/p211]";
	this.pages["image"][22] = "217.gif";
	this.pages["title"][22] = "Detoxifying and environmental remedies [ch8/p217]";
	this.pages["image"][23] = "251.gif";
	this.pages["title"][23] = "Cardiovascular system [ch9/p251]";
	this.pages["image"][24] = "263.gif";
	this.pages["title"][24] = "Cardiovascular system [ch9/p263]";
	this.pages["image"][25] = "273.gif";
	this.pages["title"][25] = "Preventative Medicine [ch10/p273]";
	this.pages["image"][26] = "276.gif";
	this.pages["title"][26] = "Preventative Medicine [ch10/p276]";
	this.pages["image"][27] = "289.gif";
	this.pages["title"][27] = "Nervous System, Psychiatry, Psychology and Psychosomatics [ch11/p289]";
	this.pages["image"][28] = "290.gif";
	this.pages["title"][28] = "Nervous System, Psychiatry, Psychology and Psychosomatics [ch11/p290]";
	this.pages["image"][29] = "295.gif";
	this.pages["title"][29] = "Antidepressant drugs [ch11/p295]";
	this.pages["image"][30] = "335.gif";
	this.pages["title"][30] = "Endocrine System [ch12/p335]";
	this.pages["image"][31] = "339.gif";
	this.pages["title"][31] = "Endocrine System [ch12/p339]";
	this.pages["image"][32] = "359.gif";
	this.pages["title"][32] = "Gynaecology and Obstetrics [ch13/p359]";
	this.pages["image"][33] = "363.gif";
	this.pages["title"][33] = "Gynaecology and Obstetrics [ch13/p363]";
	this.pages["image"][34] = "389.gif";
	this.pages["title"][34] = "Benign and Malignant Tumours [ch14/p389]";
	this.pages["image"][35] = "390.gif";
	this.pages["title"][35] = "Benign and Malignant Tumours [ch14/p390]";
	this.pages["image"][36] = "405.gif";
	this.pages["title"][36] = "Nutrition and Blood [ch15/p405]";
	this.pages["image"][37] = "406.gif";
	this.pages["title"][37] = "Nutrition and Blood [ch15/p406]";
	this.pages["image"][38] = "415.gif";
	this.pages["title"][38] = "Infections [ch16/p415]";
	this.pages["image"][39] = "420.gif";
	this.pages["title"][39] = "Infections [ch16/p420]";
	this.pages["image"][40] = "437.gif";
	this.pages["title"][40] = "Immune and Lymphatic System [ch17/p437]";
	this.pages["image"][41] = "445.gif";
	this.pages["title"][41] = "Immune and Lymphatic System [ch17/p445]";
	this.pages["image"][42] = "461.gif";
	this.pages["title"][42] = "Trauma and Sports Medicine [ch18/p461]";
	this.pages["image"][43] = "466.gif";
	this.pages["title"][43] = "Trauma and Sports Medicine [ch18/p466]";
	this.pages["image"][44] = "469.gif";
	this.pages["title"][44] = "Metabolic Disorders [ch19/p469]";
	this.pages["image"][45] = "470.gif";
	this.pages["title"][45] = "Metabolic Disorders [ch19/p470]";
	this.pages["image"][46] = "489.gif";
	this.pages["title"][46] = "Nosodes [ch20/p489]";
	this.pages["image"][47] = "497.gif";
	this.pages["title"][47] = "Nosodes [ch20/p497]";
	

	this.onLoad = function(x) {
			if (!document.BookReaderForm) return;
			if (x < 1 || x > this.pages["image"].length) x = 1;
			this.pageHeight = 1130;
			this.frameHeight = 400;
			this.firstPage = x;
			this.lastPage = x;
			this.currentPage = x;
			this.BookContainer = document.getElementById("BookContainer");
			this.Book = document.getElementById("Book");
			this.SelectPage = document.getElementById("SelectPage");
			var newPage = document.createElement('div');
			this.Book.appendChild(newPage);
			var newImage = document.createElement('img');
			newImage.src = "pages/"+this.pages["image"][this.firstPage];
			newPage.appendChild(newImage);
			document.getElementById("button_up").disabled = false;
			document.getElementById("button_down").disabled = false;
			var newSelectOption;
			for (var i=1; i < this.pages["image"].length; i++) {
				newSelectOption = document.createElement('option');
				newSelectOption.value = i;
				newSelectOption.innerHTML = this.pages["title"][i];
				this.SelectPage.appendChild(newSelectOption);
			}
			this.PageInfo = document.getElementById("PageInfo");
			this.PageInfo.div = this.PageInfo.getElementsByTagName("div")[0];
			this.PageInfo.span = this.PageInfo.div.getElementsByTagName("span")[0];
			this.updatePageInfo(true,false);
		}
	
	
	this.moveUp = function() {
			var x = this.BookContainer.scrollTop;
			this.BookContainer.scrollTop -= 10;
			this.addPage(x, this.BookContainer.scrollTop);
			this.updatePageInfo(false,false);
		}
	
	
	this.scrollUp = function() {
			this.Timer = setInterval('BookReader.moveUp()', 10);
		}
	
	
	this.moveDown = function() {
			var x = this.BookContainer.scrollTop;
			this.BookContainer.scrollTop += 10;
			this.addPage(x, this.BookContainer.scrollTop);
			this.updatePageInfo(false,false);
		}
	
	
	this.scrollDown = function() {
			this.Timer = setInterval('BookReader.moveDown()', 10);
		}


	this.stopScroll = function() {
			clearInterval(this.Timer);
		}
	
	
	this.addPage = function(x,y) {
			if (x != y) return false;
			if (x != 0 && this.lastPage < this.pages["image"].length-1) {
					this.lastPage++;
					var newPage = document.createElement('div');
					this.Book.appendChild(newPage);
					var newImage = document.createElement('img');
					newImage.src = "pages/"+this.pages["image"][this.lastPage];
					newPage.appendChild(newImage);
			} else if (this.firstPage > 1) {
					this.firstPage--;
					var newPage = document.createElement('div');
					this.Book.insertBefore(newPage,this.Book.firstChild);
					var newImage = document.createElement('img');
					newImage.src = "pages/"+this.pages["image"][this.firstPage];
					newPage.appendChild(newImage);
					this.BookContainer.scrollTop += this.pageHeight;
			}
		}
	
	
	this.clearPageInfo = function() {
			this.PageInfo.div.style.display = 'none';
		}
	
	
	this.updatePageInfo = function(firstTime,justPageInfo) {
			var currentPage = (this.firstPage-1)+Math.ceil((this.BookContainer.scrollTop+Math.floor(this.frameHeight/2))/this.pageHeight);
			if (firstTime) {
				this.SelectPage.value = (currentPage > this.firstPage) ? currentPage : this.firstPage;
			} else {
				if (currentPage < this.firstPage) currentPage = this.firstPage;
				if (this.currentPage != currentPage) {
					this.clearPageInfo();
					if (!justPageInfo) this.SelectPage.value = (currentPage > this.firstPage) ? currentPage : this.firstPage;
					this.PageInfo.span.innerHTML = this.SelectPage.options[this.SelectPage.selectedIndex].text;
					this.PageInfo.div.style.display = '';
					setTimeout('BookReader.clearPageInfo()',2000);
				}
			}
			this.currentPage = currentPage;
		}
	
	
	this.goToPage = function() {
			if (this.firstPage <= this.SelectPage.value && this.SelectPage.value <= this.lastPage) {
				this.BookContainer.scrollTop = (this.SelectPage.value-this.firstPage) * this.pageHeight;
				this.updatePageInfo(false,true);
			} else if (this.firstPage-1 == this.SelectPage.value) {
				this.firstPage--;
				var newPage = document.createElement('div');
				this.Book.insertBefore(newPage,this.Book.firstChild);
				var newImage = document.createElement('img');
				newImage.src = "pages/"+this.pages["image"][this.firstPage];
				newPage.appendChild(newImage);
				this.BookContainer.scrollTop = 0;
				this.updatePageInfo(false,true);
			} else if (this.lastPage+1 == this.SelectPage.value) {
				this.lastPage++;
				var newPage = document.createElement('div');
				this.Book.appendChild(newPage);
				var newImage = document.createElement('img');
				newImage.src = "pages/"+this.pages["image"][this.lastPage];
				newPage.appendChild(newImage);
				this.BookContainer.scrollTop = (this.lastPage-this.firstPage) * this.pageHeight;
				this.updatePageInfo(false,true);
			} else {
				document.BookReaderForm.submit();
			}
		}

}

var BookReader = new BookReaderC()

function displayChapter(id){
	var list_of_chapters = document.getElementsByName("chapter");
	for(var i=0; i < list_of_chapters.length; i++)
		list_of_chapters[i].style.display = 'none';
	document.getElementById(id).style.display = 'block';
}
