<!--

if ((parent.frames.length != "0") || (parent.location.href != this.location.href))
{
   // remove any frames
   parent.location.href = this.location.href;
}
else {
   javascript:void(0);
}

function confirmDel(url)
{
   if(confirm("Are you sure you want to delete this?\n\nThis cannot be undone."))
   {
      window.location.href = url;
   }
}

function contains(password, validChars) { 
 
    count = 0; 
 
    for (i = 0; i < password.length; i++) { 
        var char = password.charAt(i); 
        if (validChars.indexOf(char) > -1) { 
            count++; 
        } 
    } 
 
    return count; 
}

/*
google.load("jquery", "1");

function sticky_relocate() {
  // sidebar on subpages
  var window_top = $(window).scrollTop();
  var div_top = $('#sticky-anchor').offset().top - 60;
  
  var sb = $('#sidebar');
  
  // get left offset so that fixed
  // positioning works properly (paulfp / caeus.com 2/9/11)
  // must be done here not inside the if/else, otherwise it's the wrong value
  var offset = sb.offset();
  var leftpos = offset.left;
    
  if (window_top > div_top)
  {
	sb.addClass('stick');
	sb.css("left", leftpos+"px");
  } else {
    sb.removeClass('stick');
  }

  // top menu
  var window_top = $(window).scrollTop();
  var nav_top = $('#nav-anchor').offset().top;

  var nav = $('#nav');
  
  if (window_top > nav_top)
  {
	nav.addClass('navstick');
  } else {
    nav.removeClass('navstick');
  }
}

google.setOnLoadCallback(function() {
  $(window).scroll(sticky_relocate);
  sticky_relocate();
  });*/
  

  
  //function getoffset() {
  //var sb = document.getElementById("sidebar");
  //alert("offset: " + sb.y);
  //alert("helo");
  //}
  //getoffset();

// Copyright © caeus.com Ltd.
// www.caeus.com
// 0800 970 2955
// All Rights Reserved
// These scripts must not be reproduced in any way without permission.
// Please, however, feel free to link to the page from your web site.

function analyse(pwd) {

var points = 0;

var numbers = "0123456789"; 
var lowercase = "abcdefghijklmnopqrstuvwxyz"; 
var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var punctuation = "!.@$£#*()%~<>{}[]_\"^&-+=/\€";

var containsNumbers = contains(pwd, numbers);
var containsLowerCase = contains(pwd, lowercase);
var containsUpperCase = contains(pwd, uppercase);
var containsPunctuation = contains(pwd, punctuation);
var containsAlpha = contains(pwd, alpha);

//assess makeup of password, add points for each specific character type it contains
if((containsLowerCase) && (containsUpperCase)) { points += 15; }
if((containsNumbers) && (containsAlpha)) { points += 10; }
if((containsNumbers) && (containsPunctuation)) { points += 20; }

if((pwd.length >= 1) && (pwd.length < 8)) { points += 1; }
if((pwd.length >= 8) && (pwd.length < 10)) { points += 5; }
if((pwd.length >= 10) && (pwd.length < 15)) { points += 10; }
if((pwd.length >= 15) && (pwd.length < 20)) { points += 12; }
if(pwd.length >= 20) { points += 15; }

// maximum total points is 60

if(points == 0) { makebar("silver",5); clearwords(); }
if((points >= 1) && (points < 5)) { makebar("red",1); clearwords(); document.getElementById("r1").innerHTML = "Useless!"; }
if((points >= 5) && (points < 10)) { makebar("red",2); clearwords(); document.getElementById("r2").innerHTML = "Weak"; }
if((points >= 10) && (points < 20)) { makebar("orange",3); clearwords(); document.getElementById("r3").innerHTML = "Medium"; }
if((points >= 20) && (points < 45)) { makebar("green",4); clearwords(); document.getElementById("r4").innerHTML = "Strong"; }
if(points >= 45) { makebar("lime",5); clearwords(); document.getElementById("r5").innerHTML = "Very Strong";  }

   document.getElementById("result").innerHTML = points;
}

function makebar(colour,height) {

// first, make them all silver
   for(i=1;i<=5;i++)
   {
      var storeyname = "number" + i;
      var progressBar = document.getElementById(storeyname); 
      progressBar.style.backgroundColor = "silver";
   }

// then colour the right ones
   for(i=1;i<=height;i++)
   {
      var storeyname = "number" + i;
      var progressBar = document.getElementById(storeyname); 
      progressBar.style.backgroundColor = colour;
   }

}

function clearwords() {

   for(i=1;i<=5;i++)
   {
      var txtcat = "r" + i;
      var wordings = document.getElementById(txtcat); 
      wordings.innerHTML = "&nbsp;";
   }

}

function validate() {
	   if(document.econtact.txtname.value == "") {
	      alert("Please enter your name.");
	      document.econtact.txtname.focus();
	   }
	   else if(document.econtact.email.value == "") {
	      alert("Please enter your email address.");
	      document.econtact.email.focus();
	   }
	   else if(document.econtact.message.value == "") {
	      alert("Please enter a message.");
	      document.econtact.message.focus();
	   }
	   else if(document.econtact.code.value == "") {
	      alert("Please enter the Authorisation Code.");
	      document.econtact.code.focus();
	   }
	   else {
	      document.econtact.submit();
	   }
}

function agree()
{
   if(document.signup.read.checked)
   {
      document.signup.submit();
   }
   else {
      alert("You must read and agree to the Terms & Conditions before using this web site.\n\nPlease make sure you have ticked the box to indicate your agreement.");
   }
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setReason(neg) {
   if(neg == "1")
   {
      document.getElementById('reason').style.display = "inline";
   }
   else if(neg == "0") {
      document.getElementById('reason').style.display = "none";
   }
}

function toggle(theElement, theWord) {
   if(theElement.style.display == "none")
   {
      theElement.style.display = "inline";
      theWord.innerHTML = "hide";
   }
   else {
      theElement.style.display = "none";
      theWord.innerHTML = "show";
   }
}

function showTab(tabid) {

   // first define list of tabs
   var tabs = new Array(
	"custnotes",
	"custaccount"
   );

   count = 0;

   while (count<tabs.length) {
      if(tabs[count] == tabid)
      {
         document.getElementById(tabs[count]).style.display = "block";
      }
      else {
         document.getElementById(tabs[count]).style.display = "none";
      }
   count++;
   }

}

function confirmDelCust(username, custID) {
   if(document.custdel.username.value != username) 
   {
      alert("Please enter this customer's username.");
      document.custdel.username.focus();
   }
   else if(document.custdel.custID.value != custID) {
      alert("Please enter this customer's account number.");
      document.custdel.custID.focus();
   }
   else if(document.custdel.password.value == "") {
      alert("Please enter your own password to authorise account deletion.");
      document.custdel.password.focus();
   }
   else if(confirm("Are you sure you want to delete this user's account? This is irreversible.\n\nUsername: " + username + "\nAcc Number: "+custID + "\n\nClick OK to delete the account. This action cannot be undone.\nIf you are unsure, click Cancel now."))
   {
      document.custdel.submit();
    }
   else {
      javascript:void(0);
    }
}

function delConfirm(url) {

   if(confirm("Are you sure you want to delete this item from the list?"))
   {
      window.location.href = url;
   }
   else {
      javascript:void(0);
   }

}

function QtyNum() {
   if((isNaN(document.qtyspec.howmany.value)) || (document.qtyspec.howmany.value == ""))
   {
      alert("Please enter a number.");
	  document.qtyspec.howmany.value = ""
	  document.qtyspec.howmany.focus();
   }
   else {
      document.qtyspec.submit();
   }
}

function validateItemPost(desc) {
   if(document.ItemFormPost.title.value == "")
   {
      alert("Please enter a title for the " + desc + ".");
	  document.ItemFormPost.title.focus();
   }
   else {
      document.ItemFormPost.submit();
   }
}

function scrollBack(qty, speed)
{
   clearInterval(interval);
   clearTimeout(animateTimeout);
   interval = setInterval("move("+qty+", "+speed+", 'forward')", speed);
   move(qty, speed, "backward");
}

function scrollForward(qty, speed)
{
   clearInterval(interval);
   clearTimeout(animateTimeout);
   interval = setInterval("move("+qty+", "+speed+", 'forward')", speed);
   move(qty, speed, "forward");
}

function showButtons()
{
   document.getElementById("back").style.visibility = "visible";
   document.getElementById("forward").style.visibility = "visible";
}

function hideButtons()
{
   document.getElementById("back").style.visibility = "hidden";
   document.getElementById("forward").style.visibility = "hidden";
}

function move(qty, speed, direction)
{
   // This function is the work of caeus.com Ltd. and is protected by Copyright.
   // Copyright © caeus.com Ltd. and Paul Freeman-Powell.
   // This function, including derivatives herein, may not be used without permission.
   
   var qty = parseInt(qty);
   var position = parseInt(document.getElementById("currentitem").value);

   if((position == (qty + 1)) && (direction == "forward") )
   {
      document.getElementById("currentitem").value = "1";
	  var finalpos = parseInt(0);
   }
   else if(direction == "forward")
   {
      // going forward, so place at 600 x current position
	  var finalpos = parseInt(position * 600);
	  document.getElementById("currentitem").value = parseInt(position) + 1;
   }
   else if((direction == "backward") && (position == 1 ) )
   {
      var finalpos = parseInt((position-1) * 600) - 600;
	  document.getElementById("currentitem").value = 1;
   }
   else if(direction == "backward")
   {
      // going forward, so place at 600 x current position
	  var finalpos = parseInt((position-1) * 600) - 600;
	  document.getElementById("currentitem").value = parseInt(position) - 1;
   }
   
   if((position != 1) && (direction != "backward") )
   {
      var currentpos = (position - 1) * 600;
   }
   else if(position != 1)
   {
      var currentpos = (position) * 600;
   }
   else {
      var currentpos = 0;
   }
   
   var fraction = Math.abs(Math.round((parseInt(finalpos) - parseInt(currentpos)) / 15));
   
   // Uncomment for testing.
   //alert("Current Pos: "+currentpos+",\n\nFinal Pos: "+finalpos+",\n\nFraction: "+fraction+",\n\nDirection: "+direction);
   
   if(position == (qty + 1))
   {
      document.getElementById("items").style.left = "0px";
	  clearInterval(interval);
	  move(qty, speed, direction);
	  interval = setInterval("move("+qty+", "+speed+", '"+direction+"')", speed);
   }
   else {
      animateTimeout = setTimeout("animate("+currentpos+", "+finalpos+", "+fraction+", '"+direction+"')", 40);
   }
   
}

function animate(currentpos, finalpos, fraction, direction)
{
   // This function is the work of caeus.com Ltd. and is protected by Copyright.
   // Copyright © caeus.com Ltd. and Paul Freeman-Powell.
   // This function, including derivatives herein, may not be used without permission.
   
     
   if(direction == "forward")
   {
      var newpos = parseInt(currentpos) + parseInt(fraction);
   }
   else if(direction == "backward")
   {// Uncomment for testing.
   //alert("Current Pos: "+currentpos+",\n\nFinal Pos: "+finalpos+",\n\nFraction: "+fraction+",\n\nDirection: "+direction);
      var newpos = parseInt(currentpos) - parseInt(fraction);
   }
   
   if ( (newpos >= finalpos) && (direction == "forward") )
   {
      finalpospx = "-" + finalpos + "px";
      document.getElementById("items").style.left = finalpospx;
	  return;
   }  
   else if ( (newpos <= finalpos) && (direction == "backward") )
   {
      finalpospx = "-" + finalpos + "px";
      document.getElementById("items").style.left = finalpospx;
	  return;
   }  
   
   newpos = newpos.toString();
   
   newpospx = "-" + newpos + "px";
  
   document.getElementById("items").style.left = newpospx;
   
   animateTimeout = setTimeout("animate("+newpos+", "+finalpos+", "+fraction+", '"+direction+"')", 40);
   
}

function checkDocumentForm()
{
   if (document.adddocuments.document.value == "")
   {
      alert("Please specify a Document file to upload.");
   }
   else if (document.adddocuments.description.value == "")
   {
      alert("Please enter a description for the Document.\n\nThis is an internal description for reference which is viewable within the admin area only.");
   }
   else {
      document.adddocuments.submit();
      document.adddocuments.uploadbutton.disabled=true;
      document.all.pleasewait.style.display='';
   }

}

function delDocConfirm(url) {

   if(confirm("Are you sure you want to delete this Document?"))
   {
      window.location.href = url;
   }
   else {
      javascript:void(0);
   }

}

function emailCycleVer(qty) {

   for(i=0;i<qty;i++)
   {
   
     var cycleno = i.toString();
	 
	 var long = cycleno.length;
	 
	 var lastChar = cycleno.substr(long-1, long);
   
      if(lastChar == 0)
	  {
	     var numid = "st";
	  }
	  else if(lastChar == 1) {
	     var numid = "nd";
	  }
	  else if(lastChar == 2) {
	     var numid = "rd";
	  }
	  else {
	     var numid = "th";
	  }
	  
	  var anumber = i + 1;
   
      if(document.getElementById('txtName'+i).value == "")
	  {
	     alert("Please fill in the " + anumber + numid + " person's name.");
		 document.getElementById('txtName'+i).focus();
		 return;
	  }
	  else if(document.getElementById('position'+i).value == "") 
	  {
	     alert("Please fill in the " + anumber + numid + " person's position.");
		 document.getElementById('position'+i).focus();
		 return;
	  }
	  else if(document.getElementById('email'+i).value == "") 
	  {
	     alert("Please fill in the " + anumber + numid + " person's email address.");
		 document.getElementById('email'+i).focus();
		 return;
	  }
	  
   }
   
   // if execution reaches here, it means no error msgs so submit form
   document.emailform.submit();

}

function delButton(tickbox) {
   if(tickbox)
   {
      document.getElementById('delbutton').disabled = false;
   }
   else {
      document.getElementById('delbutton').disabled = true;
   }
}

function checkLength(item, value, max)
{
   var charsleft;
   charsleft = max - value.length;
   
   if(charsleft <= 1)
   {
      // remove extra characters
	  item.value = item.value.substr(0, max);
   }
   
   if (charsleft < 0) {
      charsleft = 0;
	  // prevent -1 being shown
   }
   
   if (charsleft <= 25) {
      document.getElementById("remaining").style.color = "red";
	  document.getElementById("remaining").style.fontWeight = "bold";
   }
   else {
      document.getElementById("remaining").style.color = "black";
	  document.getElementById("remaining").style.fontWeight = "normal";
   }
   
   document.getElementById("remaining").innerHTML = charsleft;
}

function validatePrayer() {
	   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	   
	   if(document.prayerreq.yourname.value == "") {
	      alert("Please enter your name.\n\nIf you don't want your name to be shown, just check the box to make this request anonymous.");
	      document.prayerreq.yourname.focus();
	   }
	   else if(document.prayerreq.email.value == "") {
	      alert("Please enter your email address.\n\nThis will NOT be shown, but we need it in case you want to delete the prayer request.");
	      document.prayerreq.email.focus();
	   }
	   else if(!emailPattern.test(document.prayerreq.email.value)) {
	      alert("Invalid email address entered.\nPlease enter your email address.\n\nThis will NOT be shown, but we need it in case you want to delete the prayer request.");
	      document.prayerreq.email.focus();
	   }
	   else if(document.prayerreq.prayer.value == "") {
	      alert("Please enter a prayer request message.");
	      document.prayerreq.prayer.focus();
	   }
	   else if(document.prayerreq.delpwd.value == "") {
	      alert("Please enter a password in case you want to delete this prayer request later.");
	      document.prayerreq.delpwd.focus();
	   }
	   else if(document.prayerreq.delpwd2.value == "") {
	      alert("Please re-enter your password to confirm.");
	      document.prayerreq.delpwd2.focus();
	   }
	   else if(document.prayerreq.delpwd.value != document.prayerreq.delpwd2.value) {
	      alert("The passwords do not match. Please re-enter both passwords, being careful to ensure that they match.");
	      document.prayerreq.delpwd.value = "";
		  document.prayerreq.delpwd2.value = "";
		  document.prayerreq.delpwd.focus();
	   }
	   else if(document.prayerreq.code.value == "") {
	      alert("Please enter the Authorisation Code.");
	      document.prayerreq.code.focus();
	   }
	   else {
	      document.prayerreq.submit();
	   }
}

function openPopup(prayerID)
{
   document.getElementById('prayerID').value = prayerID;
   document.getElementById('popup').style.visibility = 'visible'; 
}

function openMugshotPopup(contactID)
{
   document.getElementById('contactID').value = contactID;
   document.getElementById('popup').style.visibility = 'visible';
   document.getElementById('deleteMugshotButton').style.visibility = 'inherit'; 
   document.getElementById('mugshotDiv').innerHTML = "<img src=\"/images/contacts/thumbnail/" + contactID + ".jpg\" onerror=\"noimg("+contactID+", this);\" onabort=\"noimg("+contactID+", this);\" />";
}

function noimg(contactID, Img)
{
   document.getElementById('mugshotDiv').innerHTML = "<img src=\"/images/contacts/noimg.jpg\" />";
   document.getElementById('deleteMugshotButton').style.visibility = 'hidden'; 
}

function closePopup()
{
   document.getElementById('popup').style.visibility = 'hidden'; 
}

function delPrayer()
{
   if(confirm("Are you sure you want to delete this prayer request?\n\nThis cannot be undone. To confirm, click OK."))
   {
      document.prayerdel.submit();
   }
}

function setStartTime(switchValue)
{
   if(switchValue)
   {
      document.getElementById('lblstarttime').style.display = "block";
	  document.getElementById('lblspecifyendtime').style.display = "block";
   }
   else {
      document.getElementById('lblstarttime').style.display = "none";
	  document.getElementById('lblspecifyendtime').style.display = "none";
   }
}

function setEndDate(switchValue)
{
   if(switchValue)
   {
      document.getElementById('lblenddate').style.display = "block";
	  document.getElementById('lblspecifyendtime').style.display = "block";
   }
   else {
      document.getElementById('lblenddate').style.display = "none";
   }
}

function setEndTime(switchValue)
{
   if(switchValue)
   {
      document.getElementById('lblendtime').style.display = "block";
	  document.getElementById('specifystarttime').checked = true;
	  setStartTime(true);
   }
   else {
      document.getElementById('lblendtime').style.display = "none";
   }
}

function setPrices(switchValue)
{
   if(!switchValue)
   {
      document.getElementById('lblcostadults').style.display = "block";
	  document.getElementById('lblcostconcessions').style.display = "block";
   }
   else {
      document.getElementById('lblcostadults').style.display = "none";
	  document.getElementById('lblcostconcessions').style.display = "none";
   }
}

function onlyNumbers(formElement, valueEntered)
{
   if((isNaN(valueEntered)) || (valueEntered.indexOf(" ") != -1))
   {	  
	  var nansRemoved = "";
	  
	   for (i = 0; i < valueEntered.length; i++) 
	   { 
          var char = valueEntered.charAt(i); 
		  
           if ((!isNaN(char)) && (char != " ") || (char == ".") || (char == ","))
		   { 
              nansRemoved = nansRemoved + char;
           } 
       }

       formElement.value = nansRemoved;
   }
}

function copyToClipboard(text)
{
//set path
ZeroClipboard.setMoviePath('ZeroClipboard.swf');

//create client
var clip = new ZeroClipboard.Client();


clip.setText(text);


//glue it to the button
clip.glue('copy');
}

//-->
