// Javascript for Launde Abbey 

// main javascript functions for Elysian films web site



/* ***********************************************************
Example 4-5 (DHTMLapi.js)
"Dynamic HTML:The Definitive Reference"
by Danny Goodman
Published by O'Reilly & Associates  ISBN 1-56592-494-0
http://www.oreilly.com
Copyright 1998 Danny Goodman.  All Rights Reserved.
************************************************************ */
// DHTMLapi.js custom API for cross-platform
// object positioning by Danny Goodman (http://www.dannyg.com)

// Global variables
var isNav, isIE
var coll = ""
var styleObj = ""
if (parseInt(navigator.appVersion) >= 4) {
  if (navigator.appName == "Netscape") {
    isNav = true
  } else {
    isIE = true
    coll = "all."
    styleObj = ".style"
  }
}

// Convert object name string or object reference
// into a valid object reference
function getObject(obj) {
  var theObj
  if (typeof obj == "string") {
    theObj = eval("document." + coll + obj + styleObj)
  } else {
    theObj = obj
  }
  return theObj
}

// Positioning an object at a specific pixel coordinate
function shiftTo(obj, x, y) {
  var theObj = getObject(obj)
  if (isNav) {
    theObj.moveTo(x,y)
  } else {
    theObj.pixelLeft = x
    theObj.pixelTop = y
  }
}

// Moving an object by x and/or y pixels
function shiftBy(obj, deltaX, deltaY) {
  var theObj = getObject(obj)
  if (isNav) {
    theObj.moveBy(deltaX, deltaY)
  } else {
    theObj.pixelLeft += deltaX
    theObj.pixelTop += deltaY
  }
}

// Setting the z-order of an object
function setZIndex(obj, zOrder) {
  var theObj = getObject(obj)
  theObj.zIndex = zOrder
}

// Setting the background color of an object
function setBGColor(obj, color) {
  var theObj = getObject(obj)
  if (isNav) {
    theObj.bgColor = color
  } else {
    theObj.backgroundColor = color
  }
}

// Setting the visibility of an object to visible
function show(obj) {
  var theObj = getObject(obj)
  theObj.visibility = "visible"
}

// Setting the visibility of an object to hidden
function hide(obj) {
  var theObj = getObject(obj)
  theObj.visibility = "hidden"
}

// Retrieving the x coordinate of a positionable object
function getObjectLeft(obj)  {
  var theObj = getObject(obj)
  if (isNav) {
    return theObj.left
  } else {
    return theObj.pixelLeft
  }
}

// Retrieving the y coordinate of a positionable object
function getObjectTop(obj)  {
  var theObj = getObject(obj)
  if (isNav) {
    return theObj.top
  } else {
    return theObj.pixelTop
  }
}

// Utility function returns the available content width space in browser window
function getInsideWindowWidth(){
  if (isNav) {
    return window.innerWidth
  } else {
    return document.body.clientWidth
  }
}
// Utility function returns the available content height space in browser window
function getInsideWindowHeight() {
  if (isNav) {
    return window.innerHeight
  } else {
    return document.body.clientHeight
  }
}


// mta stuff
function spacer(x,y){
  document.write("<img src='imgs/1x1.gif' width=" + x + " height=" + y + ">");
}
function spacer2(x,y){
  document.write("<img src='img/1x1.gif' width=" + x + " height=" + y + ">");
}






/* *********************************************************** */
// MTA new stuff



// procs fo allow pages wrongly called outside of frames to reposition themselves

function BreakOutOfFrames(){
  if (window != top) top.location.href = location.href;
}




// function to force very soft reloading of pages when browser resizes

function onResizeProc(){window.history.go(0);}




// function to get the width of an element by using its ID
// (e.g.   <div class=menu2 id=menuitem2> becomes getWidthOfID("menuitem2")


function getWidthOfID(ID){
  return(document.getElementById(ID).offsetWidth);
}





// function to get the height of an element by using its ID
// (e.g.   <div class=menu2 id=menuitem2> becomes getHeightOfID("menuitem2")

function getHeightOfID(ID){
  if(arguments.length!=1)alert("Wrong number of arguments to getHeightOfID()");
  var retval=document.getElementById(ID).offsetHeight;
  if(retval==0)alert("Height of " + ID + "returning as zero");
  return(retval);
}



// function to get the offsetLeft of an element by using its ID
// (e.g.   <div class=menu2 id=menuitem2> becomes getoffsetLeftOfID("menuitem2")

function getoffsetLeftOfID(ID){
  if(arguments.length!=1)alert("Wrong number of arguments to getoffsetLeftOfID()");
  var ns6=document.getElementById&&!document.all
  var ie=document.all

  if((!ie)&&(!ns6)){
    var AlertStr="Alert you appear to be running an outdated browser. ";
    AlertStr=AlertStr+"Please upgrade to a more recent browser. ";
    AlertStr=AlertStr+"Some things on this site will not work properly with your current browser.";
    alert(AlertStr);
  }

  if(ns6){
    return(document.getElementById(ID).offsetLeft);
  }

  if(ie){
    return(eval("document.all." + ID + ".offsetLeft"));
  }

  return(50);
}



// function to get the offsetTop of an element by using its ID
// (e.g.   <div class=menu2 id=menuitem2> becomes getoffsetTopOfID("menuitem2")

function getoffsetTopOfID(ID){
  if(arguments.length!=1)alert("Wrong number of arguments to getoffsetTopOfID()");
  var ns6=document.getElementById&&!document.all
  var ie=document.all

  if((!ie)&&(!ns6)){
    var AlertStr="Alert you appear to be running an outdated browser. ";
    AlertStr=AlertStr+"Please upgrade to a more recent browser. ";
    AlertStr=AlertStr+"Some things on this site will not work properly with your current browser.";
    alert(AlertStr);
  }

  if(ns6){
    return(document.getElementById(ID).offsetTop);
  }

  if(ie){
    return(eval("document.all." + ID + ".offsetTop"));
  }

  return(50);
}






function getInnerHTML(ID){
  if(arguments.length!=1)alert("getInnerHTML needs 1 argument");

  var ns6=document.getElementById&&!document.all
  var ie=document.all

  if(ie){
    return(eval("document.all." + ID + "innerHTML"));
    }
  else{
    if(ns6){
      return(document.getElementById(ID).innerHTML);
    }
  }
}



function skin_content(page){
  if(arguments.length!=1)alert("skin_content needs 1 argument");

  var ns6=document.getElementById&&!document.all
  var ie=document.all

  if(ie){
    document.all.col2.innerHTML=skincontent["p" + page + "col2"];
    document.all.col3.innerHTML=skincontent["p" + page + "col3"];
    }
  else{
    if(ns6){
      document.getElementById("col2").innerHTML=skincontent["p" + page + "col2"];
      document.getElementById("col3").innerHTML=skincontent["p" + page + "col3"];
    }
  }
}



function blat(classdesc){
  if(arguments.length==0)alert("blat must be called with a class descriptor or empty string argument");
  str="ton" + "y@e" + "lysia" + "nfil" + "ms." + "com";
  document.write("<A class=" + classdesc + " href='mailto:" + str + "'>" + str + "</a>");
}

function blatm(classdesc){
  if(arguments.length==0)alert("blat must be called with a class descriptor or empty string argument");
  str="marg" + "are" + "t@b" + "ardent" + "ertai" + "nment" + "s.c" + "o.uk";
  document.write("<A class=" + classdesc + " href='mailto:" + str + "'>" + str + "</a>");
}


function blatg(classdesc){
  if(arguments.length==0)alert("blat must be called with a class descriptor or empty string argument");
  str="Gen" + "eviev" + "e@m" + "oonl" + "ightin" + "g.c" + "o.za";
  document.write("<A class=" + classdesc + " href='mailto:" + str + "'>" + str + "</a>");
}





function blatl(classdesc){
  if(arguments.length==0)alert("blat must be called with a class descriptor or empty string argument");
  str="lst" + "ille" + "@p" + "aradi" + "gm-a" + "gency.c" + "om";
  document.write("<A class=" + classdesc + " href='mailto:" + str + "'>" + str + "</a>");
}





// function to turn visibility on and off for a given element
// syntax: setvisibility([element id] [visibility status (hidden|visible)]))

function setvisibility(element,status){
//alert("setvisibility: element " + element + ", status: " + status);
  if(arguments.length!=2)alert("two arguments needed: [element id] [visibility status (hidden|visible)]");
  var ns6=document.getElementById&&!document.all
  var ie=document.all
  var ele;

  if(ie){
    ele=(eval("document.all." + element));
    }
  else{
    if(ns6){
      ele=(document.getElementById(element));
    }
  }
  ele=ele.style;
  ele.visibility=status;
}


// function to set color for a given element
// syntax: setcolor ([element id] [color]

function setcolor(element,color){
//alert("setcolor: element " + element + ", color: " + color);
  if(arguments.length!=2)alert("two arguments needed: [element id] [color]");
  var ns6=document.getElementById&&!document.all
  var ie=document.all
  var ele;

  if(ie){
    ele=(eval("document.all." + element));
    }
  else{
    if(ns6){
      ele=(document.getElementById(element));
    }
  }
  ele=ele.style;
  ele.color=color;
}




// proc to set innerhtml of an element

function setInnerHTML(ID,str){
  var ns6=document.getElementById&&!document.all
  var ie=document.all
  var objfound;

  if((!ie)&&(!ns6)){
    var AlertStr="Alert you appear to be running an outdated browser. ";
    AlertStr=AlertStr+"Please upgrade to a more recent browser. ";
    AlertStr=AlertStr+"Some things on this site will not work properly with your current browser.";
    alert(AlertStr);
  }


  if(ns6){
    objfound=document.getElementById(ID);
  }

  if(ie){
    objfound=eval("document.all." + ID);
  }
  objfound.innerHTML=str;
}


var smenuarray=new
Array("redevelopmentcontent","forgroupscontent","forindividualscontent","aboutcontent");



function resetproc(){
  var i;
  for(i in smenuarray){setvisibility(smenuarray[i],"hidden");}
}


function homeproc(){resetproc();}

function aboutproc(){resetproc();}

function appealproc(){resetproc();}

function theteamproc(){resetproc();}

function programmeproc(){resetproc();}

function whatsproc(){resetproc();}




function redevelopmentproc(){
  resetproc();
  setvisibility("redevelopmentcontent","visible");
}

function forgroupsproc(){
  resetproc();
  setvisibility("forgroupscontent","visible");
}

function forindividualsproc(){
  resetproc();
  setvisibility("forindividualscontent","visible");
}

function aboutproc(){
  resetproc();
  setvisibility("aboutcontent","visible");
}

function concertsproc(){resetproc();}

function photosproc(){resetproc();}

function friendsproc(){resetproc();}

function stretchersproc(){resetproc();}

function articlesproc(){resetproc();}

function f50thproc(){resetproc();}

function linksproc(){resetproc();}

function conferenceproc(){resetproc();}

function prayer_rproc(){resetproc();}

function contactproc(){resetproc();}




var navigation_col_width=160;

function block_setup(){
  var max_width_available=1;

  if(navigator.appName.indexOf("Microsoft")>-1){
    var MSIEind=navigator.appVersion.indexOf("MSIE ");
    if(MSIEind<0)max_width_available=0;
    var vnum=navigator.appVersion.substring(MSIEind+5, MSIEind+6);
    if(vnum<7){max_width_available=0;alert("less");}
  }

  if(max_width_available==0){
    var colwidth=document.body.clientWidth-arguments[0]-20;
    var margins=Math.round((colwidth-400)/2);
    if(margins>0){
      if(colwidth>400)colwidth=400;
      var marginsplus20=margins+20;

      document.write("<style>.block0{margin-left:" + margins + "px; margin-right: " + margins + "px;}</style>")
      document.write("<style>.block1{margin-left:" + margins + "px; margin-right: " + margins + "px;}</style>")
      document.write("<style>.block0ind20{margin-left:" + marginsplus20 + "px; margin-right: " + margins + "px;}</style>")
      document.write("<style>.block1ind20{margin-left:" + marginsplus20 + "px; margin-right: " + margins + "px;}</style>")
      document.write("<style>.blocklink{margin-left:" + margins + "px; margin-right: " + margins + "px;}</style>")
      document.write("<style>.blockunpad{margin-left:" + margins + "px; margin-right: " + margins + "px;}</style>")
      document.write("<style>.blockrightit{margin-left:" + margins + "px; margin-right: " + margins + "px;}</style>")
      document.write("<style>.retreattitle{margin-left:" + margins + "px; margin-right: " + margins + "px;}</style>")
      }
    }
  else{
    document.write("<style>.block0{max-width:30em; min-width:24em;}</style>");
    document.write("<style>.block1{max-width:30em; min-width:24em;}</style>");
    document.write("<style>.block0ind20{max-width:28em; min-width:22em;}</style>");
    document.write("<style>.block1ind20{max-width:28em; min-width:22em;}</style>");
    document.write("<style>.blocklink{max-width:30em; min-width:24em;}</style>");
    document.write("<style>.blockunpad{max-width:30em; min-width:24em;}</style>");
    document.write("<style>.blockrightit{max-width:30em; min-width:24em;}</style>");
    document.write("<style>.retreattitle{max-width:30em; min-width:24em;}</style>");
  }
}




// function to open window for flowers

var lastimgwin=null;

//function openimg(url,width,height){
//  var openwidth=width+40;
//  var openheight=height+70;
//  var args="height=" + openheight + ",width=" + openwidth + ",screenX=0,screenY=0,location=no,left=0,top=0,resizable=yes,status=no,toolbar=no,scrollbars=yes";
//  if(lastimgwin!=null)lastimgwin.close();
//  lastimgwin=open(url,"imgwin",args);
//}

var lastimgwin=null;


function openimg(path,w,h){
  var wval=w+20;
  var hval=h+50;
  if(navigator.appName.indexOf("Microsoft Internet Explorer")>-1){
    wval=wval+20;
    hval=hval+20;
  }

  var args="height=" + hval + ",width=" + wval + ",screenX=0,screenY=0,location=no,left=0,top=0,resizable=yes,status=no,toolbar=no,scrollbars=yes";

  if(lastimgwin!=null){
    lastimgwin.resizeTo(wval,hval);
  }

  lastimgwin=open("","imgwin",args);
  lastimgwin.focus();
  sstr="";
  sstr+="<html><head>";
  sstr+="<body  style='padding:0; margin:0px auto 0px auto; text-align:center;'>";
  sstr+="<style>";
  sstr+="a{";
  sstr+="  font-size:14px;";
  sstr+="  padding-top:4px;";
  sstr+="  font-family: goudy old style, palatino, book antiqua, times, serif;";
  sstr+="  text-decoration: none;";
  sstr+="  color: #672c00;";
  sstr+="}";
  sstr+="";
  sstr+="a:hover{color: #07612c;}";
  sstr+="p{padding:6px 0px 0px 0px; margin: 0px;}";
  sstr+="</style>";
  sstr+="<img src='" + path + "'><p>";
  sstr+="<a href='javascript:self.close();'>click here to close</a>";
  sstr+="</body></html>";

  lastimgwin.document.write(sstr);
  lastimgwin.focus();
  lastimgwin.document.close();
//alert(sstr);
}


var mstr0="";
mstr0+="laun";
mstr0+="deab";
mstr0+="bey@";
mstr0+="leic";
mstr0+="este";
mstr0+="r.an";
mstr0+="glic";
mstr0+="an.o";
mstr0+="rg";

var mstr1="";
mstr1+="War";
mstr1+="de";
mstr1+="n@lau";
mstr1+="nde.o";
mstr1+="rg.uk";


var mstr2="";
mstr2+="ti";
mstr2+="m@lau";
mstr2+="nde.o";
mstr2+="rg.uk";


var mstrs=new Array();
mstrs["launde"]=mstr0;
mstrs["warden"]=mstr1;
mstrs["wardenword"]=mstr1;


function blat(){
  if(arguments.lenght<1)alert("blat needs one argument");
  var str1=mstrs[arguments[0]];
  var str2=mstrs[arguments[0]];
  if(str1.indexOf("arden")>0)str1=mstr2;
  if(arguments[0].indexOf("wardenword")>-1)str2="Warden";
  document.write("<a href='mailto:" + str1 + "'>" + str2 + "</a>");
}



var formblatstrs=new Array();
formblatstrs[0]="<form action";
formblatstrs[1]="='mailto:";
formblatstrs[2]="laundeabb";
formblatstrs[3]="ey@leices";
formblatstrs[4]="ter.angli";
formblatstrs[5]="can.org?s";
formblatstrs[6]="ubject=Pr";
formblatstrs[7]="iceEnquir";
formblatstrs[8]="y' 'encty";
formblatstrs[9]="pe='text/";
formblatstrs[10]="plain' me";
formblatstrs[11]="thod='post'>";


function formblat(){
  var i;
  for(i=0;i<formblatstrs.length;i++){document.write(formblatstrs[i]);}
}


var lastsmallwin=null;

function openarticle(surl){
  var url= "articles/" + surl;
  var wwidth=width_of_1em*40; // allow width of 30 em
  wwidth+=40; // allow for 2 lots of padding

  if(wwidth>(screen.availWidth*0.7))wwidth=Math.round(screen.availWidth*0.7); // stop it getting too large

  var xpos=screen.availWidth-wwidth-10;

  var flist="directories=no,location=no,menubar=no,scrollbars=yes";
  flist +=",width=" + wwidth;
  flist +=",top=0, screenY=0"
  flist +=",left=" + xpos ;
  flist +=",screenX=" + xpos +"";
  if(lastsmallwin!=null)lastsmallwin.close();
  lastsmallwin=open(url,"article",flist);
}





// function to print up a notice if an article appears out of context

function checkarticlefile(){
  if(self.name.indexOf("content")!=0){
    var wstr="";
    wstr+="<div class=articlefooter>";
    wstr+="This article forms part of the Launde Abbey site";
    wstr+="<br>";
    wstr+="<span class='checkarticlefile'>To visit the main web site, <a href='javascript:openhome();'>";
    wstr+="click here</a></span>";
    wstr+="</div>";
    wstr+="<p>";
    document.write(wstr);
  }
}

// function to open home page
function openhome(){
  var flist="directories=yes,location=yes,menubar=yes,scrollbars=yes";
  flist +=",width=" + Math.round(screen.availWidth*0.7);
  flist +=",top=0, screenY=0 left=0 screenX=0";
  open("../index.htm","launde",flist);
}


function closer(){
  document.write("<div class=closer><i>to close <a href='javascript:self.close();'>click here</a></i></div>");
}



function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}





// function to delete an element after a specified date (used in Concerts and Events page)

function DeleteByDate(tag,year,month,day){
  var timenow=new Date();
  var jsmonth=month-1;
  var duedate=new Date(year,jsmonth,day);
  if(timenow>duedate){
    document.getElementById(tag).innerHTML="";
  }
}

