<!--
// Javascript Api Calls
// Sam McCormick
//global Vars
var introPic=true;
var side_bg_url="img/sidebarback.gif";
var pageToShow="loader.html";
var searchCounter=0;
var screenWidth=0;
var musakPlaying=1;

var fullIcons='<BR><div align=right><a href="javascript:parent.printPage(page);" border=0><img src="/img/print.gif" border=0 alt="Print page"></a>&nbsp;&nbsp;&nbsp;<a href="javascript:window.external.AddFavorite(favurl,favtitle);" border=0><img src="/img/add2fav.gif" border=0 alt="Add to favourites"></a></div>';

var smallIcons='<BR><div align=right><a href="javascript:history.go(-1);" border=0><img src="/img/back_icon.gif" border=0 alt="Go Back"></a>&nbsp;&nbsp;&nbsp;<a href="javascript:parent.printPage(page);" border=0><img src="/img/print_icon.gif" border=0 alt="Print page"></a>&nbsp;&nbsp;&nbsp;<a href="javascript:window.external.AddFavorite(favurl,favtitle);" border=0><img src="/img/add2fav_icon.gif" border=0 alt="Add to favourites"></a></div>';

var articleIcons='<TABLE border=0><TR><TD valign=middle><a href="/articles.html"><font face="Trebuchet MS">Back to Articles</font></a>&nbsp;&nbsp;&nbsp;</td><TD><a href="javascript:parent.printPage(page);" border=0><img src="/img/print_icon.gif" border=0 alt="Print page"></a>&nbsp;&nbsp;&nbsp;<a href="javascript:window.external.AddFavorite(favurl,favtitle);" border=0><img src="/img/add2fav_icon.gif" border=0 alt="Add to favourites"></a></TD></TR></TABLE>';

//sermon vars
var imgNotAvail="<img src='/img/sermons/imagenotavail.gif' border=0 height=100>";
var imgDrDAllen="<img src='/img/sermons/dr_d_allen.jpg' border=0 height=130>";
var imgGBanister="<img src='/img/sermons/g_banister.jpg' border=0 height=130>";
var imgRevSBarnes="<img src='/img/sermons/rev_s_barnes.jpg' border=0 height=130>";
var imgDrCBarrett="<img src='/img/sermons/dr_c_barrett.jpg' border=0 height=130>";
var imgDrMBarrett="<img src='/img/sermons/dr_m_barrett.jpg' border=0 height=130>";
var imgRevJBeggs="<img src='/img/sermons/rev_j_beggs.jpg' border=0 height=130>";
var imgRevDBrame="<img src='/img/sermons/rev_d_brame.jpg' border=0 height=130>";
var imgRevRCranston="<img src='/img/sermons/rev_r_cranston.jpg' border=0 height=130>";
var imgRevLCurran="<img src='/img/sermons/rev_l_curran.jpg' border=0 height=130>";
var imgRevGDane="<img src='/img/sermons/rev_g_dane.jpg' border=0 height=130>";
var imgRevDDiCanio="<img src='/img/sermons/rev_d_dicanio.jpg' border=0 height=130>";
var imgRevADunlop="<img src='/img/sermons/rev_a_dunlop.jpg' border=0 height=130>";
var imgRevGFerguson="<img src='/img/sermons/rev_g_ferguson.jpg' border=0 height=130>";
var imgRevAFoster="<img src='/img/sermons/rev_a_foster.jpg' border=0 height=130>";
var imgRevIFoster="<img src='/img/sermons/rev_i_foster.jpg' border=0 height=130>";
var imgRevPGardiner="<img src='/img/sermons/rev_p_gardiner.jpg' border=0 height=130>";
var imgRevJGreer="<img src='/img/sermons/rev_j_greer.jpg' border=0 height=130>";
var imgRevSHamilton="<img src='/img/sermons/rev_s_hamilton.jpg' border=0 height=130>";
var imgRevJHanna="<img src='/img/sermons/rev_j_hanna.jpg' border=0 height=130>";
var imgRevIHarris="<img src='/img/sermons/rev_i_harris.jpg' border=0 height=130>";
var imgRevRJohnstone="<img src='/img/sermons/rev_r_johnstone.jpg' border=0 height=130>";
var imgRevIKenny="<img src='/img/sermons/rev_i_kenny.jpg' border=0 height=130>";
var imgRevWMcCrea="<img src='/img/sermons/rev_w_mccrea.jpg' border=0 height=130>";
var imgRevCMercer="<img src='/img/sermons/rev_c_mercer.jpg' border=0 height=130>";
var imgTMurray="<img src='/img/sermons/t_murray.jpg' border=0 height=130>";
var imgRevTNelson="<img src='/img/sermons/rev_t_nelson.jpg' border=0 height=130>";
var imgDrIPaisley="<img src='/img/sermons/dr_i_paisley.jpg' border=0 height=130>";
var imgRevKPaisley="<img src='/img/sermons/rev_k_paisley.jpg' border=0 height=130>";
var imgRevAPatterson="<img src='/img/sermons/rev_a_patterson.jpg' border=0 height=130>";
var imgDrSPollock="<img src='/img/sermons/dr_s_pollock.jpg' border=0 height=130>";
var imgRevJPorter="<img src='/img/sermons/rev_j_porter.jpg' border=0 height=130>";
var imgRevJWagner="<img src='/img/sermons/rev_j_wagner.jpg' border=0 height=130>";
var imgRevGAbraham=imgNotAvail;
var imgKBrown=imgNotAvail;
var imgRBurrows=imgNotAvail;
var imgDrACairns=imgNotAvail;
var imgRevAAlvarez=imgNotAvail;
var imgPCange=imgNotAvail;
var imgRevDCreane=imgNotAvail;
var imgRevJGray=imgNotAvail;
var imgMrIHall=imgNotAvail;
var imgRevRHall=imgNotAvail;
var imgNHanna=imgNotAvail;
var imgRevPKyle=imgNotAvail;
var imgMrTLaverty=imgNotAvail;
var imgMrDMartin=imgNotAvail;
var imgRevCMaxwell=imgNotAvail;
var imgMrRMcKee=imgNotAvail;
var imgRevPMillen=imgNotAvail;
var imgDMcComb=imgNotAvail;
var imgRevWMcDermott=imgNotAvail;
var imgRevGMcCammon=imgNotAvail;
var imgMrGQuinn=imgNotAvail;
var imgMrNShields=imgNotAvail;
var imgMrsRSommerville=imgNotAvail;
var imgRevWWhiteside=imgNotAvail;

//update gifs
var updateGif="<img alt=updated src=img/green_ball_small.gif>";
var newGif="<img alt=new src=img/red_ball_small.gif>";
var showUpdPop=false;

//Browser Effects

//updStatus - updStatus(string message)
function updStatus(statMess)
{
  window.status=statMess;
}

//Base Functions
function getObject(obj,frame)
{
  var theObject;
  if (typeof obj == "string")
  {
    if (isIE)
    {
      theObject = eval(ieDocumentObject+"frames[\""+frame+"\"]."+nsDocumentObject+obj+styleObject);
    }
    if (isNS)
    {
      //alert(obj);
      theObject = eval(ieDocumentObject+"frames[\""+frame+"\"].document.getElementById(\""+obj+"\")");
      if (theObject)
      {
       // alert("found at layer 1 OBJE"+" "+ obj);
      }
      else
      {
        //try lower layer
        //alert("no object at layer 1 trying layer 2"+" "+ obj);
        layerArray2 = eval(ieDocumentObject+"frames[\""+frame+"\"].document.layers");
        for (L2=0;L2<layerArray2.length;L2++)
        {
          theObject = eval(ieDocumentObject+"frames[\""+frame+"\"].document.layers[\""+L2+"\"]"+".document.layers[\""+obj+"\"]");
          if (theObject)
          {
            //alert("found at layer 2 OBJE"+" "+ obj);
            break;
          }
          else
          {
            //alert("no object at this point in layer 2 trying layer 3"+" "+ obj);
            layerArray3 = eval(ieDocumentObject+"frames[\""+frame+"\"].document.layers[\""+L2+"\"]"+".document.layers");
            if (layerArray3)
            {
              for (L3=0;L3<layerArray3.length;L3++)
              {
                //alert(L3);
                theObject = eval("layerArray3[\""+obj+"\"]");
                if (theObject)
                {
                  //alert("found at layer 3 OBJE"+" "+ obj);
                  break;
                }
                else
                {
                  //alert("no object at this point in layer 3 trying layer 4"+" "+ obj);
                  layerArray4 = eval(ieDocumentObject+"frames[\""+frame+"\"].document.layers[\""+L2+"\"].document.layers[\""+L3+"\"]"+".document.layers");
                  if (layerArray4)
                  {
                    for (L4=0;L4<layerArray4.length;L4++)
                    {
                      //alert(L4);
                      theObject = eval("layerArray4[\""+obj+"\"]");
                      if (theObject)
                      {
                        //alert("found at layer 4 OBJE"+" "+ obj);
                        break;
                      }
                      else
                      {
                        //alert("no object"+" "+ obj);
                      }
                    }
                    if (theObject)
                    {
                      break;
                    }
                  }
                }
              }
              if (theObject)
              {
                break;
              }
            }
          }
        }
      }
    }
    
    if (theObject)
    {
      //alert("found OBJE"+" "+ obj);
    }
    else
    {
      //alert("not found OBJE"+" "+ obj);
    }
    //alert(theObject +" "+ obj);
  }
  else
  {
    theObject = obj;
  }
  return theObject;
}

function getEventMaker(event)
{
  if (isNS)
  {
    return event.which;
  }
  else
  {
    if (isIE)
    {
      if (event.srcElement.type.indexOf("select") != -1)
      {
        return event.keyCode;
      }
      else
      {
        if (event.srcElement.type == "textarea")
        {
          return event.keyCode;
        }
        else
        {
          if (event.srcElement.type == "button")
          {
            return event.button;
          }
        }
      }
    }
  }
}

function getImgObject(obj,frame)
{
  var theObject;
  if (typeof obj == "string")
  {
    //alert(ieDocumentObject+"frames[\""+frame+"\"]."+nsDocumentImgObject+obj);
    theObject = eval(ieDocumentObject+"frames[\""+frame+"\"]."+nsDocumentImgObject+obj);
  }
  else
  {
    theObject = obj;
  }
  return theObject;
}

//RollOvers
function rollOverGraphic(name,xtn)
{
  this.name=name;
  this.off=new Image();
  this.off.src=imagePath+name+"off."+xtn;
  this.on=new Image();
  this.on.src=imagePath+name+"on."+xtn;
}

function createMenuGraphic(name,xtn)
{
  rollOverGraphic[name]=new rollOverGraphic(name,xtn);
}

function getImagePath(obj,frame)
{
  // loseable????
  var imgString;

  if (isIE)
  {
    imgString="document.frames[\""+frame+"\"]."+obj+".src";
  }

  if (isNS)
  {
    imgString="frames[\""+frame+"\"].document.images[\""+obj+"\"].src";
  }

  return imgString;
}

function chgPicSource(name,path)
{
  //alert("changingh");
  obj = getImgObject("intro_pic","main");
  obj.src=path;
}

function popUp(src,width,height)
{
  winOpen=window.open(src,"winOpen","toolbar=no,width="+width+",height="+height+",scrollbars=no,resize=yes,menubar=yes");
  winOpen.focus();
}

function hideObj(obj,frame)
{
  object = getObject(obj,frame);
  hideObject(object,frame);
}

function showObj(obj,frame)
{
  object = getObject(obj,frame);
  showObject(object,frame);
}

//CSS
function hideObject(obj,frame)
{
  object=getObject(obj,frame);
  //alert(object.visibility);
  //alert(object.style.visibility);
  //object.visibility=HIDDEN;
  //alert("object"+NSstyleObject+".visibility");
  object=eval("object"+NSstyleObject)
  object.visibility=HIDDEN;
}

function showObject(obj,frame)
{
  object=getObject(obj,frame);
  //object.visibility=VISIBLE;
  //object.style.visibility=VISIBLE;
  object=eval("object"+NSstyleObject)
  object.visibility=VISIBLE;
}

function setCookie(name,value)
{
  var expDate=new Date();
  expDate.setTime(expDate.getTime() + (1000*60*60*24*900));
  
  document.cookie=name+"="+escape(value)+((expDate==null) ? "" : ";expires="+expDate.toGMTString());
}

function getCookie(name)
{
  var cookName = name+"=";
  var theCookie = document.cookie;
  if (theCookie.length > 0)
  {
    var start = theCookie.indexOf(cookName);
    if (start != -1)
    {
      //if cookie exists
      start += cookName.length;
      end = theCookie.indexOf(";",start)
      if (end == -1)
      {
        end = theCookie.length;
      }
      return unescape(theCookie.substring(start, end))
    }
  }
  else
  {
    return null;
  }
}

function deleteCookie(name)
{
  var expDate = new Date();
  expDate.setDate(expDate.getDate() -1);
  document.cookie = name+"=; expires="+expDate.toGMTString();
}

function searchCookieText(indexIN,textIN)
{
  indexIN += 2;
  end = textIN.indexOf("|",indexIN);
  if (end == -1)
  {
    end = textIN.length;
  }
  return textIN.substring(indexIN, end);
}

function start()
{
  //parent.main.location="timetable.html";
  now = new Date();
  nowms = now.getTime();
  end = new Date(2010, 06, 06, 20, 00, 00);
  endms = end.getTime();
  if (nowms < endms)
  {
    parent.main.location="considerchrist.html";
  }
  else
  {
    parent.main.location="timetable.html";
  }
  
  if (showUpdPop==true)
  {
    showUpdatePopup();
  }
  showSpecial();
  window.notthere.location="mics_cd/preview.html";
}

function standardStatus()
{
  updStatus("Welcome to Mourne Free Presbyterian Church");
}

function rollOnMenu(obj,frame)
{
  txt=obj;

  updStatus(statusArray[obj]);
 // return "true";
}

function rollOffMenu(obj,frame)
{
  standardStatus();
}

function clickMenu(obj,frame)
{
  txt=obj;
  
  //hide all under text
  hideAllMenus("under",frame);
  
  //show all over text
  showAllMenus("",frame);
  
  //show under text
  showObj(txt+"under",frame);
  if (isIE50)
  {
    ie50Obj=getObject(txt+"under",frame);
    ie50Obj.left=10;
  }
  
  //hide over text
  hideObj(txt,frame);
  
  if (txt.indexOf("newsletterlink") != -1)
  {
    //move items down
    if (isIE)
    {
      p=listArray.length;
      for (q=4;q<p;q++)
      {
        moveObj=getObject(listArray[q],"side");
        moveObj.top=30;
      }
    }
    
    //show ipen index
    showObj("newsletterlinksub","side");
    if (txt.indexOf("newsletterlinksub") != -1)
    {
      hideObj("newsletterlinksub","side");
    }
    else
    {
      //hide under one just incase
      hideObj("newsletterlinksubunder","side");
    }
  }
  else
  {
    //hide ipen index
    hideObj("newsletterlinksub","side");
    hideObj("newsletterlinksubunder","side");
    //move up down
    k=listArray.length;
    for (l=4;l<k;l++)
    {
      moveObj=getObject(listArray[l],"side");
      moveObj.top=0;
    }
  }
}

function hideAllMenus(suffix,frame)
{
  for (m=0; m < listArray.length; m++)
  {
    sam = listArray[m]+suffix;
    hideObj(sam, frame);
  }
}

function showAllMenus(suffix,frame)
{
  for (n=0; n < listArray.length; n++)
  {
    showObj(listArray[n]+suffix, frame);
  }
}

function sidebarLoad()
{
  if (sidebarLoaded != true)
  {
    sidebarLoaded=true;
    if (sidebarLoaded && topbarLoaded)
    {
      parent.main.location=pageToShow;
      loaded();
    }
  }
}

function topbarLoad()
{
  topbarLoaded=true;  if (sidebarLoaded && topbarLoaded)
  {
    parent.main.location=pageToShow;
    loaded();
  }
}

function loaded()
{
  resizeFullScreen();
  standardStatus();
  if (pageToShow.indexOf("ipen") != -1)
  {
    parent.clickMenu(sidebarArray["ipen/ipen.html"],"side");
  }
  else if (pageToShow.indexOf("articles") != -1)
  {
    parent.clickMenu(sidebarArray["articles.html"],"side");
  }
  else
  {
    if (window.location.href.indexOf("?")!=-1)
    {
      //then contains ? done for cairns mission
      parent.clickMenu(sidebarArray[pageToShow],"side");
    }
  }
}

function setIntroPic(bool)
{
  introPic=bool;
}

function updateBgPic(frame,picPath)
{
  eval(frame+"_bg_url=\""+picPath+"\"");
  eval("frames[\""+frame+"\"].document.location.reload();");
}

function showMission()
{
  window.open("/mission.html","mission","toolbar=no,width=600,height=320,status=no,scrollbars=yes,menubar=no");
}

function showSpecial()
{
  //now = new Date();
  //nowms = now.getTime();
  //end = new Date(2006, 02, 25, 20, 00, 00);
  //endms = end.getTime();
  //if (now < end)
  //{
  // window.open("sunday_sch_conf_popup.html","live","toolbar=no,width=600,height=500,status=no,scrollbars=no,menubar=no");
  //}
}

function showUpdatePopup()
{
  if (getCookie('MFPC_upd_pop')!='false')
  {
    window.open("update_popup.html","update","toolbar=no,width=440,height=180,status=no,scrollbars=no,menubar=no");
  }
}

function showPolicy(subSection)
{
  var policyURL="/policy.html#"+subSection;
  policyWin=window.open(policyURL,"policy","toolbar=no,width=700,height=320,status=no,scrollbars=yes,menubar=no");
  setTimeout("policyWin.focus()",800);
}

function printPage(pageToPrint)
{
  printWin=window.open("/"+pageToPrint+"?print=true","print","toolbar=no,width=800,height=640,status=no,scrollbars=yes,menubar=no");
  setTimeout("printWin.focus()",800);
}

function resizeWindow(width,height){
  screenWidth=width;
	if (document.layers) {
		// resizeTo sets inner size, so use this instead
		window.outerWidth = width;
		window.outerHeight = height;
	} else window.resizeTo(width,height);
}
function centerWindow(width,height){
	x = (window.screen.availWidth-width)/2;
	y = (window.screen.availHeight-height)/2;
	resizeWindow(width,height);
	window.moveTo(x,y);
}
function resizeFullScreen() {
	x = screen.availLeft; // ns only
	y = screen.availTop;
	resizeWindow(screen.availWidth,screen.availHeight);
	window.moveTo(x,y);
}
function openFullScreen() {
	w = screen.availWidth - 12; 
	h = screen.availHeight - 48;
	x = screen.availLeft; // ns only
	y = screen.availTop;
	// unlike resize, must allow for chrome
	//bigWin = window.open('http://www.spike.com.au','bigWin','resizable=yes,status=yes,width='+w+',height='+h+',left='+x+',top='+y);
}

function addList(frame,formIn)
{
  mailingForm=eval(ieDocumentObject+"frames[\""+frame+"\"].document.forms[\""+formIn+"\"]");
  if (mailingForm.policyagree.checked==false)
  {
    alert("You must agree to the MFPC policy");
  }
  else
  {
    mailingForm.command.value="add";
    mailingForm.action="/cgi-bin/mfpc_mail_list.pl";
    mailingForm.submit();
  }
}

function remList(frame,formIn)
{
  mailingForm=eval(ieDocumentObject+"frames[\""+frame+"\"].document.forms[\""+formIn+"\"]");
  if (mailingForm.policyagree.checked==false)
  {
    alert("You must agree to the MFPC policy");
  }
  else
  {
    mailingForm.command.value="rem";
    mailingForm.action="/cgi-bin/mfpc_mail_list.pl";
    mailingForm.submit();
  }
}

function addGuest(frame,formIn)
{
  guestForm=eval(ieDocumentObject+"frames[\""+frame+"\"].document.forms[\""+formIn+"\"]");
  if (guestForm.policyagree.checked==false)
  {
    alert("You must agree to the MFPC policy");
  }
  else
  {
    guestForm.submit();
  }
}

function updateSearchCounter()
{
  searchCounter++
  //alert(searchCounter);
}

function resetSearchCounter()
{
  searchCounter=0;
}

function backToSearch()
{
  history.go(-searchCounter);
}

function goTract()
{
  parent.main.location="articles/tracts/howlonghaveItolive.html";
}

function toggleMusak()
{
  if (musakPlaying==1)
  {
    window.notthere.location="blank.html";
    musakPlaying=0;
  }
  else
  {
    window.notthere.location="mics_cd/preview.html";
    musakPlaying=1;
  }
}
