

// Define generic Document object , browser independent

if (document.all) {
	docObj = "document.all.";
	styleObj = ".style"
}
else {
	docObj = "document.";
	styleObj = ""
}





function top_of_page () {
	t = 
            '<body bgcolor="#fffbdc" lang="EN-GB"> '  
	  + '<A NAME="top"></a>'
	  + '<SCRIPT>WarnNoFrame();</SCRIPT>'  
	  + '<CENTER><TABLE width=98%><TR><TD>'
	;
	document.write(t);
}



function bot_of_page () {

	bot1=

  '<CENTER>'
+ '<TABLE width=80% border="1" borderwidth="2"><TR><TD ALIGN=CENTER><FONT SIZE=2>'

+ '<B>The Community of Interbeing Manual of Practice</B> '

+ 'is published by the Community of Interbeing UK (registered charity number 1096680 and company limited by guarantee number 4623280), the organisation which follows the Buddhist teachings and practice of Zen Master, Thich Nhat Hanh.'

+ '<HR>'
+ '<FONT SIZE=1>'

+ "We will review and revise the manual from time to time, "
+ "so please be patient if you spot errors and omissions. "
+ "Your comments will help the revision process."
+ "If your feedback is essentially technical - about the files or computer difficulties - "
+ "please e-mail <A HREF=\"mailto:manual.help@interbeing.org.uk\"> manual.help@interbeing.org.uk.</A>"
+ "If you have editorial comments to offer - ie about the text, formatting or content for instance - "
+ "please e-mail <A HREF=\"mailto:manual.editor@interbeing.org.uk\"> manual.editor@interbeing.org.uk.</A>"
+ '</font>'

	bot1P = "<CENTER><SMALL>Published by the UK Community of Interbeing - registered charity number 1096680 and company limited by guarantee number 4623280</SMALL></CENTER>"


	// This table
	 + "</TD></TR></TABLE>";


	// From top_of_page TABLE
	 bot2= "</TD></TR></TABLE>" ;

	bot3="<SCRIPT>javascript:window.print()</SCRIPT>"

	if (  IsPrintPage() ) {
	document.write(bot1P);
	}
	else {
	document.write(bot1);
	}
	
	document.write(bot2);

	if ( IsPrintPage() ) document.write(bot3);
	
//	alert (" Please use your browser's File Menu \n or Print button to Print this page. \n\n Return to the Print Menu window \n to select further pages for printing. ");

	

}



function MakeFrame (sn) {

	// Prevent frame stealing
	if (window != top) top.location.href = location.href;

	// Get section number
        FcallingURL=document.location.href;
	Finq = FcallingURL.indexOf("?"); 

	// if no reference given default to  
	if ( Finq == -1) { 
		// Define start page here
		section_num = "0_1";
//		Asection_num = "?start";
		Asection_num = "";
	}
	else {	
	     Flen=FcallingURL.length ;
	     section_num = FcallingURL.substring(Finq+1, Flen);
	     Asection_num = "#" + section_num;
	}

//	alert(section_num + " Z " + Asection_num)

	// OVERWRITE WITH PASSED IN PARAMETER
	if (sn != "null" ) section_num=sn;	

	
	var leftcol = 200,
	    lefttoprow  = 120,
	    toprow = 90;

	if (window.navigator.appName == "Netscape") toprow=95;

	frame  = ' <FRAMESET cols="' + leftcol + ',*"> ';
	frame += ' <FRAMESET rows="' + lefttoprow + ',*">  ';
	frame += '      <FRAME NAME="left1"  target="main" src="top_left.html?contents"  ';
	frame += '                           scrolling="auto" frameborder="1" frameborderwidth="1" marginheight="0" marginwidth="0">  ';
	frame += '      <FRAME NAME="left2"  target="main" src="contents_l2.html' + Asection_num + '"  ';
	frame += '                           scrolling="auto" frameborder="1" frameborderwidth="1" marginheight="0" marginwidth="2">  ';
	frame += ' </FRAMESET> ';
	frame += ' <FRAMESET rows="' + toprow + ',*">  ';
	frame += '      <FRAME NAME="alpha" target="main" src="header.html?' + section_num + '"  ';
	frame += '                          scrolling="no" frameborder="0" marginheight="0" marginwidth="2">  ';
	frame += '      <FRAME NAME="beta"  target="main" src="' + section_num + '.html"  ';
	frame += '                          scrolling="auto" frameborder="0" >  ';
	frame += ' </FRAMESET> ';
	frame += ' </FRAMESET> ';

//	document.write(frame);

	return (frame);

}


function IsPrintPage () {
	

	//callingURL="/a/b/c/d/2_1.html?P";
	callingURL=document.location.href;

	Clen = callingURL.length;	

	if ( (callingURL.charAt(Clen-2) == "?") &&
	     (callingURL.charAt(Clen-1)   == "P") ) {
//		alert ("IS P");
		return 1;
	}
	else {
//		alert("Is NOT P");
		return 0;
	}

}


function WarnNoFrame () {

	// OK if in correct frame
	if (self.name == "beta" ) return 0;

	if ( IsPrintPage() ) return 0;

	//callingURL="/a/b/c/d/2_1.html";
	callingURL=document.location.href;

	Clen = callingURL.length;	
	// find final / or \ character
	slash = 0;
	for (i = 0; i < Clen ; i++) {
		ch = callingURL.charAt(i);
		if ( ch == "\/" || ch == "\\") slash=i;
		//alert(i + " " + ch + " " + slash);
	} 

	//alert(self.name + " : " + window.name);

	Nlen = Clen - slash;
	// Strip down to name
	Nname = callingURL.substring(slash+1,Clen);

	// Netscape fails line above ????
	//alert(Clen + " " + slash + " " + Nlen + " " + Nname);

	//alert(self.name);

	// Get dot
	dot = 0;
	for (j = 0; j < Nlen ; j++) {
		if ( Nname.charAt(j) == "." ) dot=j;
	}

	section_num = Nname.substring(0, dot);

	// alert (dot + " " + callingURL + "\n" + Nname + "\n" + section_num);

	linktofullmanual='' ;
	// Content should be in beta frame

	fullframe = "index.html?" + section_num;
	//alert(fullframe);
	top.location.href = fullframe;
	return 0;

	// Start code generation - define default font
	lk = "<font face=\"tahoma\" size=1>" ;
		
	lk += "<CENTER><TABLE width=80% borderwidth=4 border=1><TR><TD width=70%>";
	lk += "<font size=-1>You have probably found this page by a search engine. "; 
	lk += "It is a section of the Community of Interbeing Manual of Practice. ";
	lk += "This is a large document, best viewed from under its home page, ";
	lk += "which provides a full contents list and navigation tools.   ";
	lk += "To view from the home page <BR>";
	lk += ' <A HREF="index.html?' + section_num + '" TARGET="_top">Click here</A><BR> ';
	lk += 'This, your selected page will be displayed within the navigation environment</font>';
	lk += "</TD><TD ALIGN = CENTER VALIGN = MIDDLE>"
	lk += "<img src=\"monk.gif\" alt=\"A happy monk\" ";
	lk += "border=\"0\"  hspace=\"0\" width=\"71\" height=\"85\"> ";
	lk += "</TD></TR></TABLE></CENTER><P>"
	
	document.write (lk);
} 


function linkover (which,color){

	size="12pt";
	fgc="Green";

	if (document.all||document.getElementById)  {
//		alert(which);
		which.style.backgroundColor=color;
		which.style.fgColor=fgc;
//		which.style.face="Arial";
//		which.style.font-size=size;
//		which.style.foregroundColor=fgcolor;
	}
}


function index_line (first, prettynum, title, section, subref) {
	
	i = "";
        if (first) i += "<BR>"; else i += ", ";

	// 1*Spaces 
	i += " &nbsp; ";

	i += "<A HREF=\"Javascript: conlink('" + section + "','" + subref + "')\" " ;
	i += "class='button' ";
	i += "onMouseover=\"Javascript: linkover(this,'#99FFFF')\" " ;
	i += "onMouseout=\"Javascript: linkover(this,document.bgColor)\" " ; 
	i += ">";

	if (first) i += title;
	i += "<B> " + prettynum + " </B>";	
	i += "</A>" ;

	return i;
}

function topl_line (ref, name) {
	t  = " ";
	t += "<A HREF=\"" + ref + "\" TARGET=\'left2\' " ;
	t += "class='topl' ";
	t += "onMouseover=\"Javascript: linkover(this,'#99FFFF')\" " ;
	t += "onMouseout=\"Javascript: linkover(this,document.bgColor)\" " ; 
	t += ">";
	t += name;
	t += "</A> " ;
	return t;
}


function topl_frame_link (ref, name) {
	t  = "";
	t += "<A HREF=\"" + ref + "\" TARGET=\'_top\' " ;
	t += "class='button' ";
	t += "onMouseover=\"Javascript: linkover(this,'#99FFFF')\" " ;
	t += "onMouseout=\"Javascript: linkover(this,document.bgColor)\" " ; 
	t += ">";
	t += name;
	t += "</A> " ;
	return t;
}





function newWindow(file,window,X,Y,W,H,S,T,TT,M) {

	params = '" ' ;
	if (S) params +=    'scrollbars=yes';   else 'scrollbars=0' ;
	if (T) params +=    ', toolbar=yes';    else ', toolbar=0' ;
	if (TT) params +=   ', titlebar=yes';   else ', titlebar=0' ;
	if (M) params +=    ', menubar=yes';    else ', menubar=0' ;
        params += ', left='   + X     ;
        params += ', top='    + Y     ;
        params += ', width='  + W     ;
	params += ', height=' + H     ;
	params += ' " ';

//	alert (params);

    msgWindow=open(file,window,params);
    if (msgWindow.opener == null) msgWindow.opener = self;
}


function linkOLD(sectnum, aname) {

//	Hinq = top.left2.location.href.indexOf("#");
//	if (Hinq == -1) Hinq = top.left2.location.href.length;
//	Qinq = top.left2.location.href.indexOf("?"); 
//	if (Qinq == -1) Qinq=-1;
//	Qtag = top.left2.location.href.substring(Qinq+1, Hinq);
//	alert(top.left2.location.href + " " + Qtag + " " + section_num);

	newleft2 = "contents_l4.html#" + sectnum;

//	if ( Qtag == "start" ) {
//		// Special case for switching content depth
//		reloadframe=MakeFrame(sectnum);
//		alert(reloadframe);
//		top.location.replace("Javascript: self.reloadframe");
//	};


	if ((aname != "") && (aname != " ")  ) aname = "#" + aname;
	
	// The main content load
	top.alpha.location.href = "header.html?" + sectnum;
	top.beta.location.href = sectnum + ".html" + aname;

	// Re-instate contents when ordinary link
	top.left1.location.href = "top_left.html?contents "; 
	top.left2.location.href = newleft2;

	//alert(self.name + " : " + sectnum + ".html" + aname); 
	//alert(sectnum + ".html" + aname); 
}



function conlink(sectnum, aname) {

	

	if ((aname != "") && (aname != " ")  ) aname = "#" + aname;

//	alert("conlink : aname = " + aname + "||");	

	// The main content load
	newleft2 = "contents_l4.html#" + sectnum;

	// Test added for Print page windows
	if (! ((self.name == "beta") || (self.name == "alpha") || (self.name == "left1") || (self.name == "left2") ) ){
		self.location.href = sectnum + ".html" + aname;
		return 0;
	}

	top.alpha.location.href = "header.html?" + sectnum;
	top.beta.location.href = sectnum + ".html" + aname;
	top.left2.location.href = newleft2;

}


function link(sectnum, aname) {
	// Re-instate contents when ordinary link
	top.left1.location.href = "top_left.html?contents "; 
	
	// Do REST
	conlink(sectnum,aname);
}







