	function SizeToFit() {
		var w = 0;
		var h = 0;
		if( typeof(window.innerWidth) == 'number') {
			//Non-IE
			w = window.innerWidth;
			h = window.innerHeight;
		} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
				//IE 6+ in 'standards compliant mode'
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
		} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
				//IE 4 and 5+ non-standard
				w = document.body.clientWidth;
				h = document.body.clientHeight;
		}
		document.LeftImg.height = h - 85;
		document.RightImg.height = h - 85;
	}

	function SwView(side) {
		pg= parseInt(GetPN()) + parseInt(side);
		if (pg > -1 && pg < 226) {
			window.location = "1p.htm?" + pg.toString();		
		}
	}	
	
	function LoadPages(pn) {
		lz = "000";
		pg = lz.substring(0,3 - pn.length) + pn;
		document.LeftImg.src = "img-sm/cp" + pg + ".jpg";
		npn=parseInt(pn) + 1;
		if (npn > 2 && npn < 6) {
			document.RightImg.src = "img-sm/cp006.jpg";
		}
		else if (npn < 226) {
			pg = npn.toString();
			document.RightImg.src = "img-sm/cp" + (lz.substring(0,3 - pg.length) + pg) + ".jpg";
		}
		else {
			document.RightImg.src = "blank-page.gif"
		}
	}
	
	function GetPN(pn) {
		str=window.location.toString();
		x = str.lastIndexOf("?");
		if (x < 0) {
			pn = "0" 
		}
		else {
			pn=str.substring(x + 1,str.length);
			}
		return pn;
	}

	function HidePrevNextBtns(pn) {
		if (document.images) {
			if (pn < 1) {
				document.PrevBtn.width=0;
				document.PrevBtn.height=0;
			}

			if (pn > 223) {
				document.NextBtn.width=0;
				document.NextBtn.height=0;
			}
		}
	}

	function gotopage(pn){
		if (pn < 0 || (pn  > 2 && pn < 6) || pn > 225){
			alert("Please enter a page number between 0-2 or 7-225");
			document.pagenum.focus();
		}
		else {
			window.location = "2p.htm?" + pn;
		}
	}
	
	function trapenterkey(event){
		var keycode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode ? event.charCode : 999;
		if (keycode == 13) {
			gotopage(document.gotoform.pagenum.value);
			return false;
		}
		else {
			return true;
		}
	}

	function NextPage(pn) {
		npn=parseInt(pn) + 2;
		if (npn == 3) {
			window.location = "2p.htm?6";
		}
		else if (npn < 6) {
			window.location = "2p.htm?7";
		}
		else if (npn < 226) {
			window.location = "2p.htm?" + npn;
		}
		else {
			alert ("There is no Next Page");
		}
	}

	function PrevPage(pn) {
		npn=parseInt(pn) - 2;
		if (npn < 1) {
			window.location = "2p.htm?0";
		}
		else if (npn == 5) {
			window.location = "2p.htm?2";
		}
		else if (npn < 5) {
			window.location = "2p.htm?1";
		}
		else if (npn  < 226) {
			window.location = "2p.htm?" + npn;
		}
		else {
			alert ("There is no previous page");
		}
	}
