//Begin

//Select stylesheet

function style() {
	if (document.all) {
		document.write('<link rel=stylesheet type=text/css href=../knot/scripts/docs/style.css>');
	}
	else {
		document.write('<link rel=stylesheet type=text/css href=../knot/scripts/docs/styleNS.css>');
	}
}

//DW functions

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_findObj(n, d) { //v3.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
	var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
	var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }
}

function MM_validateForm() { //v3.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		if (val) { nm=val.name; if ((val=val.value)!="") {
				if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
					} else if (test!='R') { num = parseFloat(val);
					if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
						min=test.substring(8,p); max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
	} if (errors) alert('The following error(s) occurred:\n'+errors);
	document.MM_returnValue = (errors == '');
}

//Opens a new window of specified size

function popupWindow(url) {
	var width = 500;
	var height = 450;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
	newWin = window.open(url, "FHDetails", "width="+width+", height="+height+", status=no, scrollbars, resizable=no, screenX=20, screenY=40, left="+left+", top="+top);
}

//Breadcrumbs

function writeBreadcrumbs() {
	document.write(document.title);
}

//Add to favs

function addFav(){
	window.external.AddFavorite('http://www.tanglemedia.com','Tangle Media - website design')
}

//Dates

	var aDay = 24*60*60*1000;
	var now = new Date();
	var minute = now.getMinutes();
	var hour = now.getHours();
	var day = now.getDay();
	var date = now.getDate();
	var month = now.getMonth();
	var year = now.getFullYear();
	var dayname = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var monthname = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var todaysDate = (dayname[day] +' ' +date +' ' +monthname[month] +' ' +year);
	var christmasDay = new Date(2003,11,25);     // 25th December 2003

function writeDate() {
	document.write(todaysDate);
}

//Countdown to Christmas

function christmas() {
	var aDay = 24*60*60*1000;
	var days = 0;
	for (i=now.getTime(),n=christmasDay.getTime();i<n;i=i+aDay) {
		days++;
	}
	if (days>1) document.write(days +' days left to Christmas');
	else if (days==1) document.write(days +' day left to Christmas');
	else if (days==0) document.write('Merry Christmas!');
	else if (days1) document.write('');
}

// Clear search input

function clearSearch() {
	document.forms[0].q.value="";
} 

//Get x,y co-ordinates

function mouseXY()
{
var X = event.clientX;
var Y = event.clientY;

document.getElementById("describeDiv").style.top=X;
document.getElementById("describeDiv").style.left=Y;
}

//Write mouseover text

function setTextOfLayer(newText) {
	if (document.layers) {
		return true;
	}
	else if (document.all) {
		document.all['describeDiv'].innerHTML=newText;
	}
	else {
		document.getElementById('describeDiv').innerHTML=newText;
	}
}

var divBlank='<font color="#006699"></font>';
var divAvalon='<font color="#006699"><strong>Avalon Solutions</strong><br />I proofread, prepare pdfs and maintain this site for a  Surrey-based professional coach.</font>';
var divNO2IDBham='<font color="#006699"><strong>NO2IDBham</strong><br />A single-issue campaigning group focused on the threat to liberty and privacy posed by the rapid growth of the database state. I was the Birmingham Co-ordinator between 2008 and 2009 and set up and edited the Birmingham blog.</font>';
var divMartin='<font color="#006699"><strong>Martin Graham</strong><br />I set up and maintained the original site for this Paris-based professional development business in 2007.</font>';
var divWoodbrooke='<font color="#006699"><strong>Woodbrooke Quaker Study Centre</strong><br />Woodbrooke is the only Quaker Study Centre in Europe. I proofread their large programmes of year-round short courses in 2005 and 2006.</font>';

//		Write layers
//		Param 'input'=layer text variable name

function show(input) {
	if (document.layers) {
		document.layers['describeDiv'].document.open();
		document.layers['describeDiv'].document.write(input);
		document.layers['describeDiv'].document.close();
	}
	else if (document.all) {
		document.all['describeDiv'].innerHTML=input;
	}
	else {
		document.getElementById('describeDiv').innerHTML=input;
	}
}

//		Write empty layer

function hide() {
	if (document.layers) {
		document.layers['describeDiv'].document.open();
		document.layers['describeDiv'].document.write('');
		document.layers['describeDiv'].document.close();
	}
	else if (document.all) {
		document.all['describeDiv'].innerHTML='';
	}
	else {
		document.getElementById('describeDiv').innerHTML='';
	}
}

//Calculator functions

function selectChange(){
	d=document.calcForm;
	if(d.selectAll.value=="Select All"){
		selectOptions()
	}
	else if(d.selectAll.value=="Deselect"){
		deselectOptions()
	}
}

function changeSelect(){
	d=document.calcForm;
	if(d.selectAll.value=="Deselect"){
		d.selectAll.value="Select All";
	}
}

function selectOptions(){
	d=document.calcForm;
	for(i=0;i<d.length;i++){
		if(d.elements[i].type=='checkbox'){
			d.elements[i].checked=true;
			d.selectAll.value="Deselect";
		}
	}
}

function deselectOptions(){
	d=document.calcForm;
	for(i=0;id.length;i++){
		if(d.elements[i].type=='checkbox'){
			d.elements[i].checked=false;
			d.selectAll.value="Select All";
		}
	}
}

function calculate(){
	total=0;
	for(i=0;i<document.calcForm.length-3;i++){
		if(document.calcForm.elements[i].checked){
			total+=parseInt(document.calcForm.elements[i].value);
		}
	}
	document.calcForm.total.value='£'+total;
}

//Quotes/authors function/array

function quotation(quote,author) {
	this.quote=quote;
	this.author=author;
}

var quotes=new Array();
quotes[0]=new quotation("A thing of beauty is a joy for ever.","John Keats")
quotes[1]=new quotation("Your clear eye is the one aboslutely beautiful thing.","Sylvia Plath")
quotes[2]=new quotation("But I, being poor, have only my dreams.","W B Yeats")
quotes[3]=new quotation("Will Time say nothing but I told you so?","W H Auden")
quotes[4]=new quotation("Do not go gentle into that good night.","Dylan Thomas")
quotes[5]=new quotation("Come. And be my baby.","Maya Angelou")
quotes[6]=new quotation("You were wrong, Narcissus.","R S Thomas")
quotes[7]=new quotation("Tomorrow, do thy worst, for I have lived today.","John Dryden")
quotes[8]=new quotation("Nothing after was quite the same.","Louis MacNeice")
quotes[9]=new quotation("I shouldered a kind of manhood.","Seamus Heaney")

var a=Math.random() + ""
var rand1=a.charAt(9)

//Random quotes/authors

function randQuote() {
	document.write(quotes[rand1].quote+'<br />');
	document.write('<em>'+quotes[rand1].author+'</em>');
}

function randQuoteAuthor() {
	document.write(quotes[rand1].author);
}

//Daily quotes

function dailyQuote() {
	date=new Date();
	b=date.getDay();
	document.write(quotes[b]);
}

//Tryit functions

function changeBgImage(image) {
	document.body.background=image;
}

function changeImage(image) {
	mainPic.src=image;
}

function changeColor(colorblock) {
	document.all('td0').bgColor=colorblock;
	document.all('td1').bgColor=colorblock;
	document.all('td2').bgColor=colorblock;
	document.all('td3').bgColor=colorblock;
	document.all('td4').bgColor=colorblock;
}

function changeFgColor(foreground) {
	document.all('tdCentre').style.color=foreground;
	document.all('td5').style.color=foreground;
	document.all('td6').style.color=foreground;
}

//Construct table of symbols

//Variable for symbol
 
ax=0;

function writeTable() {
	ax=Math.round(Math.random()*26);
	alphaArray=new Array("a", "n", "b", "d", "f", "h", "{", "i", "l", "v", "x", "z", "I", "J", "M", "N", "o", "O", "R", "S", "T", "U", "m", "6", "^", "u", "_", "[", "]")
	table="table width=350 border=0 cellspacing=1 cellpadding=0 align=center><tr>"
	j=1;
	for (i=99;i>=0;i--) {
		a=Math.round(Math.random()*26);
		if (i%9==0&&i<89)
		a=ax;
		table+="<td class='numtd' align=right>"+i+"</td><td class='symtd' align=center>"+alphaArray[a]+"</td>"
		if (j%10==0)
		table+="</tr><tr>"
		j++
	}
	table+="</table>"
	sym.innerHTML=table
	sh.innerHTML=" "
}

//Show symbol

function showAnswer() {
	sh.innerHTML=alphaArray[ax]
	sym.innerHTML="<a href='javascript:writeTable()'>Again?</a>"
}

//eMail Obfuscator Script 1.3 by Tim Williams - freeware

function eMail() {
     document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,
109,105,99,104,101,108,108,101,103,114,97,104,97,109,64,116,97,110,103,108,101,109,101,100,105,97,46,99,111,109,
34,62,32,84,97,110,103,108,101,32,77,101,100,105,97,60,47,97,62))
}

//End
