<!--
/*
  Copyright (c) 2005 Dotty Products
  Sitewide code
  
  Probably wont work with Firefox.
*/

var ith="th";
dw = document.write;
td = top.document;
seasons = new Array('Autumn','Winter','Spring','Summer','Christmas','Halloween'); // used to change image path
rmonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
rdays = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
tts = new Date(); // tis the season (tts)
months = tts.getMonth();
days = tts.getDate();
daya = tts.getDay();
function  updpage(){
	// function to update prev-next and qlinks
	// copy to onload for all internal pages
	pnxt(); // updating prev-next links
	td.getElementById("qlinks").src="qlinks.html"; // reload qlinks using DOM compliant code!!!
//	td.frames[2].src="qlinks.html";
//	top.document.all.qlinks.src="qlinks.html"; // reload qlinks file
}

function pnxt(){ // Draw previous or next buttons on the page
	var pid=td.userdetails.pageid.value;//userdetails.pageid.value;
	td.getElementById("pnxts").innerHTML="";
//	top.document.all.pnxts.innerHTML=""; // blank out old prevnext details
		pid--;
		if(pid>=0 && !isNaN(pid)) 
// top.document.all.pnxts.innerHTML
 td.getElementById("pnxts").innerHTML+="<a href='"+pid+".html' target='contents'><font color=white>Previous</font></a> - ";
	pid++;
//	top.document.all.pnxts.innerHTML
	td.getElementById("pnxts").innerHTML+="<a href='JavaScript:history.go(-1)'><font color=white>Back</font></a>";
		pid++;
		if(pid<ql.length-1 && !isNaN(pid)) 
// top.document.all.pnxts.innerHTML
 td.getElementById("pnxts").innerHTML+=" - <a href='"+pid+".html' target='contents'><font color=white>Next</font></a>";
}

/***********************	Secret     Words	***********************/

var pw = "IBelongHere", pn = 0;

function getpass(){}				// Dummy function so secret word doesn't cause an error on regular pages
function getKey(inp){				// Grab keyboard input from the website
	var isNS=(document.layers);		// Check if a Netscape browser
	var pick = (isNS) ? inp.which : event.keyCode;	// Choose which method to use to grab keyboard input depending on browser type
	var let = String.fromCharCode(pick);	// Convert keycode into its associated character
	if(let == pw.charAt(pn)){		// Check if the letter pressed is the next letter in a word chosen
		pn++;				// Increase letter position in the word given
		if(pn == pw.length){		// Test if all letters in the word given have been typed
			getpass();		// Run getpass function (Located only in private/index.html)
		}
	}
	else pn2 = 0;				// A wrong key was pressed, reset the counter to the beginning of the word given
}
document.onkeypress = getKey;			// Run getKey() function when pressing a key on the keyboard

/***********************	E       n       d	***********************/

/***********************	Cookies  and  IDs	***********************/

function getCookieVal(offset){			// Grab value from a cookie
	var endstr = document.cookie.indexOf (";", offset);	// Grab end of cookie string
	if(endstr == -1)			// Check if end of cookie string exists
		endstr = document.cookie.length;		// Set end of cookie string to end of cookie if it doesn't exist
	return unescape(document.cookie.substring(offset, endstr));	// Decode the characters in the string
}

function GetCookie(name){			// Get cookie from users PC
	var arg = name + "=";			// Grab name from cookie
	var alen = arg.length;			// Grab length of cookie
	var clen = document.cookie.length;	// Grab total amount of cookies available
	var i = 0;				// Loop variable
		while(i < clen){		// Loop through total amount of cookies
			var j = i + alen;	// Set j to current i position plus length of cookie
			if(document.cookie.substring(i, j) == arg)	// Check if cookie value is cookie to grab from users PC
				return getCookieVal (j);		// If so, grab text from it
			i = document.cookie.indexOf(" ", i) + 1;	// Check next cookie
			if(i == 0) break;	// Check if i=0, if so stop function
		}
	return null;				// Return null value
}

function SetCookie(name, value){		// Set a cookie on the users PC
	var argv = SetCookie.arguments;		// Grab arguments to put in cookie
	var argc = SetCookie.arguments.length;	// Grab number of arguments to put in cookie
	var expires = (argc > 2) ? argv[2] : null;	// Set expiry date of cookie
	var path = (argc > 3) ? argv[3] : null;	// Set working path for cookie
	var domain = (argc > 4) ? argv[4] : null;	// Set domain cookie comes from
	var secure = (argc > 5) ? argv[5] : false;	// Set if cookie is secure or not (not supported?)
	document.cookie = name + "=" + escape (value) +
	 ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	 ((path == null) ? "" : ("; path=" + path)) +
	 ((domain == null) ? "" : ("; domain=" + domain)) +
	 ((secure == true) ? "; secure" : "");	// Write the cookie to the users PC
}

function lout(){ // deletes cookie and refreshes page
	var deldate = new Date();
	deldate.setTime(deldate.getTime() +  (24 * 60 * 60 * 1000 * 365));
	SetCookie('id','-1',deldate,'/');
	SetCookie('ipw','',deldate,'/');
	location=location;
}

function readID(){				// Read cookie ID from hidden boxes
	var expDays = 365;			// Number of days the cookie should last
	var expDate = new Date();		// Create expiry date for cookie
	expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays));	// Set time from now in Milliseconds until expiry time elapses
	var id = GetCookie('id');		// Grab id value from cookie
	var hashword = GetCookie('ipw');		// Grab password value from cookie
	if(id == null || id == "-1"){	// No id or id is a guest
		if(document.userdetails.id.value>=0){
			id=document.userdetails.id.value;
		}
		else 
			id = "-1";		// Set id to a guest logged in
		if (id != GetCookie('id')) SetCookie('id', id, expDate, "/");	// If cookie doesn't exist, write it
		if (hashword != GetCookie('ipw')) SetCookie('ipw', hashword, expDate, "/");	// If cookie doesn't exist, write it
	}
	if(id>=0&&hashword.length>=0){
		cp=mn[id].substring(0,mn[id].indexOf(' ')+1); // grab encrypted password from member list
		cmn=mn[id].substring(mn[id].indexOf(' ')+1,mn[id].length); // grab encoded string from rest of this member
		cmn=encrypt(cmn,hashword,0); // decrypt current member's code
		if(hashword==cp){ // check password name is correct for this user (could be duplicate passwords)
			tmn=cmn.split('¬'); // split this user into it's parts
			flag=id; // current user in members array is correct one
		}else{
			tmn=new Array("guest","none","guest","N/A","N/A","N/A","N/A");
		}
		document.userdetails.username.value=tmn[0]; // set page username to this user's name from member list
		document.userdetails.pw.value=hashword; // set page password to hashword for password from cookie
		if(tmn[3].indexOf('@')>0)document.userdetails.useremail.value=tmn[3]; // set page email to email from member list
		document.getElementById("menu").src=document.getElementById("menu").src; // reload menu page (members links)
	}else{
		document.userdetails.username.value="";
		document.userdetails.pw.value="";
		document.userdetails.useremail.value="";
	}
	document.userdetails.id.value = id;		// Put id into hidden box (used to be userID)
}

/***********************	E       n       d	***********************/

/***********************	Seasonal Graphics	***********************/

var icss="SummerStyle.css";
function innerstyle(){
	if(top.css){
		switch(top.css){
			case "Autumn.css": icss="AutumnStyle.css"; break;
			case "Spring.css": icss="SpringStyle.css"; break;
			case "Summer.css": icss="SummerStyle.css"; break;
			case "Winter.css": icss="WinterStyle.css"; break;
			case "Christmas.css": icss="WinterStyle.css"; break;
			case "Halloween.css": icss="AutumnStyle.css"; break;
		}
	}
}

function findseason(m,d){ // Grab the current season for seasonal graphics (will change css sheet instead of images)
	var i=-1;
	if(m<2||m>=10){i=1; if(m==1&&d==14){i=1;}if(m==11){if(d>5)i=4;}} // valentines uses normal winter for now
	else if(m>=2&&m<5){i=2;}
	else if(m>=5&&m<8){i=3;}
	else if(m>=8&&m<10){i=0; if(m==9&&d>25){i=5;}}
	css=""+seasons[i]+".css";
}

findseason(months,days);

/***********************	E       n       d	***********************/
/*
function rmonths(m){ // display months as names not numbers
	switch(m){
		case 0: return "January"; break;
		case 1: return "February"; break;
		case 2: return "March"; break;
		case 3: return "April"; break;
		case 4: return "May"; break;
		case 5: return "June"; break;
		case 6: return "July"; break;
		case 7: return "August"; break;
		case 8: return "September"; break;
		case 9: return "October"; break;
		case 10: return "November"; break;
		case 11: return "December"; break;
		default: return ""; break;
	}
}

function rdays(d){ // display days as names not numbers
	switch(d){
		case 0: return "Sunday"; break;
		case 1: return "Monday"; break;
		case 2: return "Tuesday"; break;
		case 3: return "Wednesday"; break;
		case 4: return "Thursday"; break;
		case 5: return "Friday"; break;
		case 6: return "Saturday"; break;
		default: return ""; break;
	}
}
*/

function iths(d){
	switch(d){ // display dates as 1st, 2nd, 3rd, 4th etc.
		case 1:	case 21: case 31: return "st"; break;
		case 2:	case 22: return "nd"; break;
		case 3:	case 23: return "rd"; break;
		default: return "th"; break;
	}
}

function thedate(){ // Returns the day, date and month in a text string - eg Sunday, 26th March
	ith = iths(days);
	months = rmonths[months];
	daya = rdays[daya];
	return ""+daya+", "+days+ith+" "+months+"";
}
document.title += " - "+thedate();

/***********************	Dreamweaver Code	***********************/
/*
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_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_findObj(n, d) { //v4.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&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

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_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();
}
MM_reloadPage(true);
*/
/***********************	E       n       d	***********************/
//-->
