
	/** Wolstanton JavaScript Library */
	
	// ===== Screen Quality Detection =======================
	var vdu_width = screen.width;
	var vdu_height = screen.height;
	var vdu_colorDepth = screen.colorDepth;
	var vdu_pixelDepth = screen.pixelDepth;

	// ===== Select Picture of Appropriate Size =============		
	function altpic (pic,ext,alt) {
		// Relies on naming convention 
		// _b for largest images on high resolution screens: landscape 750; portrait 500
		// _m for low res 800x600 screens: landscape 450; portrait 300
		// _s for hand held devices: landscape 300; portrait 150
		
		//alert("Got here"); //Debug code
		pic = "../images/" + pic; 
		if (vdu_width >= 1100) {pic = pic + "_b." + ext;}
		if (vdu_width < 1100 & vdu_width >=500) {pic = pic + "_m." + ext;}
		if (vdu_width < 500) {pic = pic + "_s." + ext;}
		//alert(pic); //Debug code
		document.write("<img src = " + pic + " alt = " + alt + "/>");				
	}
	
	function weatherpic (pic,ext,alt) {
		// Relies on naming convention 
		// _b for largest images on high resolution screens: landscape 750; portrait 500
		// _m for low res 800x600 screens: landscape 450; portrait 300
		// _s for hand held devices: landscape 300; portrait 150
		
		//alert("Got here"); //Debug code
		pic = "../images_weather/" + pic; 
		if (vdu_width >= 1100) {pic = pic + "_b." + ext;}
		if (vdu_width < 1100 & vdu_width >=500) {pic = pic + "_m." + ext;}
		if (vdu_width < 500) {pic = pic + "_s." + ext;}
		//document.writeln("<div class='center80'>");
		document.writeln("<img class='spacer' src = " + pic + " alt = " + alt + " />");		
		//document.writeln("</div>");
	}
	
	// ===== Change contents of a block element ===========
	// Used to place place titletext into banner div
	// Source: http://www.sitepoint.com/article/layers-content-javascript
	function WriteLayer(ID,parentID,sText) { 
 		if (document.layers) { 
   			var oLayer; 
   			if(parentID){ 
     			oLayer = eval('document.' + parentID + '.document.' + ID + '.document'); 
   			}else{ 
     			oLayer = document.layers[ID].document; 
   			} 
  			oLayer.open(); 
   			oLayer.write(sText); 
   			oLayer.close(); 
 		} 
 		else if (parseInt(navigator.appVersion)>=5&&navigator. 
			appName=="Netscape") { 
   			document.getElementById(ID).innerHTML = sText; 
 		} 
 		else if (document.all) document.all[ID].innerHTML = sText;		
	}
	
	
	// To return to the previous page
	function goBack() {
		javascript:history.go(-1);
	}
	
	//Used to display email addresses on browser - should fool mailbots hopefully
	function send(ename, extension,target) {	
		var linker = "@";
		target = "Email " + target;	
		document.write("<a href=" + "mail" + "to:" + ename +
		linker + extension + ">" + target + "</a>");
	}



/*
CHANGES FONT COLOR AND BACKGROUND ON CALLING EVENT
works on ordinary HTML text 
*/
 function setcol(f,g) {
    var eSrc = window.event.srcElement;
    eSrc.style.color = f;   
    eSrc.style.background = g;     
    //window.status = x;
	return true   
 }
 
 //Copies of FrontPage2003 utilities
 function FP_changeProp() {//v1.0
 var args=arguments,d=document,i,j,id=args[0],o=FP_getObjectByID(id),s,ao,v,x;
 d.$cpe=new Array(); if(o) for(i=2; i<args.length; i+=2) { v=args[i+1]; s="o"; 
 ao=args[i].split("."); for(j=0; j<ao.length; j++) { s+="."+ao[j]; if(null==eval(s)) { 
  s=null; break; } } x=new Object; x.o=o; x.n=new Array(); x.v=new Array();
 x.n[x.n.length]=s; eval("x.v[x.v.length]="+s); d.$cpe[d.$cpe.length]=x;
 if(s) eval(s+"=v"); }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

function FP_changePropRestore() {//v1.0
 var d=document,x; if(d.$cpe) { for(i=0; i<d.$cpe.length; i++) { x=d.$cpe[i];
 if(x.v=="") x.v=""; eval("x."+x.n+"=x.v"); } d.$cpe=null; }
}

//Shows or hides layers depending on argument passed
function showHide(subMenu) {
//PJS function
//Hide all sub-menus first
	FP_changeProp(/*id*/'Youth',0,'style.visibility','hidden','visibility','hide');
	FP_changeProp(/*id*/'Prayer',0,'style.visibility','hidden','visibility','hide');	
	FP_changeProp(/*id*/'Calendar',0,'style.visibility','hidden','visibility','hide');	
	FP_changeProp(/*id*/'Organisations',0,'style.visibility','hidden','visibility','hide');	
	FP_changeProp(/*id*/'Links',0,'style.visibility','hidden','visibility','hide');
	FP_changeProp(/*id*/'Schools',0,'style.visibility','hidden','visibility','hide');		
	FP_changeProp(/*id*/'Community',0,'style.visibility','hidden','visibility','hide');		
	FP_changeProp(/*id*/'Prayer',0,'style.visibility','hidden','visibility','hide');		
//Reveal selected menu
	if (subMenu != 'All') {
		FP_changeProp(/*id*/subMenu,0,'style.visibility','visible','visibility','show');
	}	
}


function FP_callJS() {//v1.0
 eval(arguments[0]);
}

function FP_goToURL(url) {//v1.0
 window.location=url;
}

function Jump(where)
{
	window.location.href = where;
}

// -----------------------------------------
//			isNumeric										
//  Ensures that only positive numbers can be returned
//	Returns false if not
// -----------------------------------------

function isNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
};

// -----------------------------------------
//			isPhoneNumber									
//  Ensures that only acceptable numbers and characters can be returned
//	Returns false if not
// -----------------------------------------

function isPhoneNumber(sText)
{
   var ValidChars = "0123456789-#*";
   var IsPhoneNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsPhoneNumber = false;
         }
      }
   return IsPhoneNumber;   
};


// -----------------------------------------
//			isEmpty
//	Returns true if a field is empty
// -----------------------------------------

function isEmpty(textObject) {
   if ((textObject.value.length==0) ||
   (textObject.value==null)) {
      return true;
   }
   else { return false; }
};


// -----------------------------------------
//                  validate()
// Validates any object passed as an argument and displays 
// a message if current is set to true;
// Returns false if data is missing, else true
// -----------------------------------------		
	
	function validate(object, current) {				
		//if (isEmpty(object)==true) 
		if (isEmpty(object)==true || object.value == "-1") 
		{		 
			object.focus();
			object.style.background =  "#ffff88";
			if (current==true) alert("Please enter missing data in the highlighted field.");
			return false;
		}		
		 else
		{
			 object.style.background =  "#ffffff";
			 return true;
		 }		 
	}
// ------------------------------------------

// -----------------------------------------
//                  validateLength()
// Validates any object passed as an argument and displays 
// a message if current is set to true;
// Returns false if data is missing, else true
// -----------------------------------------		
	
	function validateLength(object, current, len) {				
		
		if ((object.value.length < len) || (object.value==null)) {
			object.focus();
			object.style.background =  "#ffff88";
			if (current==true) alert("Please enter missing data in the highlighted field.");
			return false;
		}		
		 else
		{
			 object.style.background =  "#ffffff";
			 return true;
		 }		 
	}
// ------------------------------------------

// -----------------------------------------
//                  checkField()
// Checks whether a field is completed,
// if not then false returned
// and colour of background is made yellow
// -----------------------------------------		
	function checkField(field)	{
		with (field)	{
    		if (value==null||value=="")	{
				field.style.background =  "#ffff00";    		    
				return false;
    		}
  			else	{
				field.style.background =  "#ffffff";
    			return true;
    		}
  		}
	}
	
// -----------------------------------------
//                  checkEmpty()
// As above but no value is returned
// -----------------------------------------			
	
	
	function checkEmpty(field)	{
		with (field)	{
    		if (value==null||value=="")	{
				field.style.background =  "#ffff00";
				field.focus();				
    		}
  			else	{
				field.style.background =  "#ffffff";    			
    		}
  		}
	}

//	------------------------------------------
//			validUKShortDate(text)
//	Validates a string to see if represents a
//	short date in UK format: dd/mm/yyyy
//	------------------------------------------

	function validUKShortDate(stext) {
		var valid = true;
		var len;
		var Char;
		var ValidChars = "0123456789/";
		var i
		
		//	Check string length
		if (sText.length != 10) {
			valid= false;
   		}
   		
   		//	Check for valid characters
		for (i = 0; i < sText.length && IsNumber == true; i++) 
      	{ 
      		Char = sText.charAt(i); 
      		if (ValidChars.indexOf(Char) == -1)	{
        		 valid = false;
        	}
      	}
      	
      	//	Check Year range
      	
      	//	check Month range
      	
      	//	Check Day range
		
		
		return valid;
	}
	
	
	function tester() {
		alert("JavaScript Library Linked Successfully");
	}
	
//###### AJAX ###### AJAX ###### AJAX ###### AJAX ###### AJAX ###### AJAX ###### AJAX ###### AJAX 	
	
//Uses Ajax to trace existing database records
var xmlHttp;
var formObject;

function getDetails(str, divtag, handler)
{
formObject = divtag;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
//var url="download_handler.php";
var url=handler;
url=url+"?q="+str; //str is the value to be searched for in the database
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged; 
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById(formObject).innerHTML=xmlHttp.responseText ;
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

 
/* --------Finding the Position of the Cursor --------

IE stores this offset in its document.documentElement.clientLeft and document.documentElement.clientTop properties. This code should calculate the correct cursor position in all current browsers:

*/

function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}


/* ------------------------------ Floating a layer at cursor position -------------------------*/

<!-- Copyright 2006,2007 Bontrager Connection, LLC
// http://bontragerconnection.com/ and http://www.willmaster.com/
// Version: July 28, 2007
var winW = 0, winH = 0;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth-16;
  winH = window.innerHeight-16;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}



var cX = 0; var cY = 0; var rX = 0; var rY = 0;

function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}

function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}

if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(d) {
	if(self.pageYOffset) {
		rX = self.pageXOffset;
		rY = self.pageYOffset;
	}
	else if(document.documentElement && document.documentElement.scrollTop) {
		rX = document.documentElement.scrollLeft;
		rY = document.documentElement.scrollTop;
	}
	else if(document.body) {
		rX = document.body.scrollLeft;
		rY = document.body.scrollTop;
	}
	if(document.all) {
		cX += rX; 
		cY += rY;
	}
	
	//Test for nearness to right edge of screen - PJS amendment
	rDiff = winW - cX;
	if(rDiff<200)	{
		cX = cX-200;	//Create a minimum potential width of 200
	}
	//End of test
	
	d.style.left = (cX+10) + "px";
	d.style.top = (cY+10) + "px";
	
	
}

function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	dd.style.display = "block";
}

function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}

/*
<a 
   onmouseover="ReverseContentDisplay('uniquename1'); return true;"
   href="javascript:ReverseContentDisplay('uniquename1')">
[show on mouseover, hide on mouse over - toggle]
</a>
<div 
   id="uniquename1" 
   style="display:none; 
      position:absolute; 
      border-style: solid; 
      background-color: white; 
      padding: 5px;">
Content goes here.
</div>



<a 
   onmouseover="ShowContent('uniquename2'); return true;"
   href="javascript:ShowContent('uniquename2')">
[show, content has "hide" link]
</a>
<div 
   id="uniquename2" 
   style="display:none; 
      position:absolute; 
      border-style: solid; 
      background-color: white; 
      padding: 5px;">
Content goes here. 
<a 
   onmouseover="HideContent('uniquename2'); return true;"
   href="javascript:HideContent('uniquename2')">
[hide]
</a>
</div>

<a 
   onmouseover="ShowContent('uniquename3'); return true;"
   onmouseout="HideContent('uniquename3'); return true;"
   href="javascript:ShowContent('uniquename3')">
[show on mouseover, hide on mouseout]
</a>
<div 
   id="uniquename3" 
   style="display:none; 
      position:absolute; 
      border-style: solid; 
      background-color: white; 
      padding: 5px;">
Content goes here.
</div>
*/


/* ------------------------------ END of Floating a layer at cursor position -------------------------*/
