/*
Tabs Menu (mouseover)- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/
// main nav scripts //

var submenu=new Array()
//submenu contents NB make sure it remains on one line
 
submenu[0]='&nbsp;<a href="/our-church/anglican-church.php" class="menu">Our Approach</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/our-church/parish-life.php" class="menu">Parish Life</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/our-church/staff.php" class="menu">Clergy</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/our-church/location.php" class="menu">Location</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/our-church/contact.php" class="menu">Contact&nbsp;Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/our-church/links.php" class="menu">Links</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/our-church/st-giles.php" class="menu">St Giles</a>&nbsp;&nbsp;|'

submenu[1]='<img src="/images/shim.gif" width="114" height="1">|&nbsp;&nbsp;<a href="/prayers/prayers.php" class="menu">Prayers</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/prayers/prayer-week.php" class="menu">Prayer of the Week</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/prayers/prayer-requests.php" class="menu">Prayer Requests</a>&nbsp;&nbsp;|'

submenu[2]='<img src="/images/shim.gif" width="236" height="1">|&nbsp;&nbsp;<a href="/services/services.php" class="menu">Services</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/services/special-services.php" class="menu">Special Services</a>&nbsp;&nbsp;|'

submenu[3]='<img src="/images/shim.gif" width="290" height="1">|&nbsp;&nbsp;<a href="/calendar/thisweek.php" class="menu">This Week</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/calendar/events.php" class="menu">Forthcoming Events</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/calendar/news.php" class="menu">News</a>'

submenu[4]='<img src="/images/shim.gif" width="435" height="1">|&nbsp;&nbsp;<a href="/music/music.php" class="menu">Concerts and Recitals</a>'

//Set delay before submenu disappears after mouse moves out of it (in milliseconds)
var delay_hide=500000000

function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}

function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}

function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

// left-hand menus

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

var menuLayers = {
  timer: null,
  activeMenuID: null,
  offX: 4,   // horizontal offset 
  offY: 6,   // vertical offset 
  show: function(id, e) {
    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    viewport.getAll();
    this.position(mnu,e);
  },
  
  hide: function() {
    this.clearTimer();
    if (this.activeMenuID && document.getElementById) 
      this.timer = setTimeout("document.getElementById('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200);
  },
  
  position: function(mnu, e) {
    var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
    var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
    
    if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX )
      x = x - mnu.offsetWidth - this.offX;
    else x = x + this.offX;
  
    if ( y + mnu.offsetHeight + this.offY > viewport.height + viewport.scrollY )
      y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )? y - mnu.offsetHeight - this.offY : viewport.height + viewport.scrollY - mnu.offsetHeight;
    else y = y + this.offY;
    
    mnu.style.left = x + "px"; mnu.style.top = y + "px";
    this.timer = setTimeout("document.getElementById('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200);
  },
  
  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
  },
  
  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode ) 
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    if (menuLayers.timer) clearTimeout(menuLayers.timer);
  }
  
}


viewport = {
  getWinWidth: function () {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
  	else if (document.documentElement && document.documentElement.clientHeight) 
  		this.height = document.documentElement.clientHeight;
  	else if (document.body && document.body.clientHeight) 
  		this.height = document.body.clientHeight;
  },
  
  getScrollX: function () {
    this.scrollX = 0;
  	if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		this.scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		this.scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) this.scrollX = window.scrollX;
  },
  
  getScrollY: function () {
    this.scrollY = 0;    
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
  		this.scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		this.scrollY = document.body.scrollTop; 
  	else if (window.scrollY) this.scrollY = window.scrollY;
  },
  
  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }
  
}


// pop windows
leftPos = 0 ;
rightPos = 0 ;
if (screen) {
    leftPos = screen.width/2-150;
    rightPos = screen.height/2-85;
}

// privacy policy
function ppWindow() {
    ppWin = window.open('/privacy-policy.html','','width=300,height=200,left='+leftPos+',top='+rightPos+'');
    ppWin.focus();
}

// useReview window
function formWindow() {
    formWin = window.open('/giving/giftAidForm.pdf','form','width=400,height=500,left=200,top=10,scrollbars=yes');
    formWin.focus();
}  


