//////////////////////////////
// KMC JavaScript Document // 
// Last Updated: 28/01/06 //
// By: Dan Marks         //
// Copyright Dan Marks  //
/////////////////////////
<!--
//pop up script//
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// Preload Script
function Preload()
{ 
  var args = Preload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}
function setStatusBar(msgStr) { self.status = msgStr; }
function printPage() { print(document); }
function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}


// Cookie Script
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
    if(cookieValue== null) 
  { document.writeln ("<a href='remember.php'>Click Here To Be Remembered</a>");
  } else {
	  document.writeln ('Welcome to Kingswood Methodist, <a class="remember" href="remember.php">');
	  return cookieValue;
	  	  document.writeln ('</a>');

  }
}
// Write Cookie Script
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

// Navigation Script
  content = new Array ();
  
  // Adjustable params
  content [0] = new Array (
  false, 							// opening status in the first page viewing
  new Array('sub_0_2','sub_0_3')  // subitems, note! the first index is the same as in content []
  );
  content [1] = new Array (
  false, 							// opening status in the first page viewing
  new Array('sub_1_1','sub_1_2')  // subitems, note! the first index is the same as in content []
  );
    content [2] = new Array (
  false, 							// opening status in the first page viewing
  new Array('sub_2_1','sub_2_2','sub_2_3','sub_2_4','sub_2_5','sub_2_7','sub_2_8','sub_2_9')  // subitems, note! the first index is the same as in content []
  );
	    content [3] = new Array (
  false, 							// opening status in the first page viewing
  new Array('sub_3_2','sub_3_3','sub_3_4','sub_3_5','sub_3_6','sub_3_7')  // subitems, note! the first index is the same as in content []
  );
			    content [4] = new Array (
  false, 							// opening status in the first page viewing
  new Array('sub_4_1')  // subitems, note! the first index is the same as in content []
  );
  // --------------------------------------------------------------------------------------------
  
  isOPERA = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
  isIE    = (document.all && !isOPERA)? true : false;
  isDOM   = (document.getElementById && !isIE && !isOPERA)? true : false;
  
  
  function processTree (id)
  {
  	if (content [id][0])
  	{
  		for (i = 0; i < content [id][1].length; i++)
  			hide (content [id][1][i]);
  
  		content [id][0] = false;
  	}
  	else
  	{
  		for (i = 0; i < content [id][1].length; i++)
  			show (content [id][1][i], 'table-row');
  
  		content [id][0] = true;
  	}
  
  	return false;
  }
  
  function show (id, displayValue)
  {
  	if (isDOM)
  		document.getElementById(id).style.display = (displayValue)? displayValue : "block";
  	else if (isIE)
  		document.all[id].style.display = "block";
  }
  
  function hide (id)
  {
  	if (isDOM)
  		document.getElementById(id).style.display = "none";
  	else if (isIE)
  		document.all[id].style.display = "none";
  }
  if (isDOM || isIE)
  {
  	document.writeln('<style type="text/css">');
  	document.writeln('.SubItemRow \{ display: visibility; \}');
  	document.writeln('</style>');
  }
  function pop()
{
document.getElementById("a").setattribute.style.visibility = "visible";
}

// * Dependencies * 
// this function requires the following snippet:
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}
// JavaScript/readable_MM_functions/findObj
function setColor(objName, fg)
{
  obj = findObj(objName);
  if (obj.style)
  {
    obj.style.display = fg;
  }
}

// image slide show script
function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}
function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}
// <img src="originalImage1.gif" name="slide1">
// <img src="originalImage2.gif" name="slide2">
//
// SCRIPT Example:

// var mySlideList2 = ['image4.gif', 'image5.gif', 'image6.gif'];
// var mySlideShow2 = new SlideShow(mySlideList2, 'slide2', 1000, "mySlideShow2");
function SlideShow(slideList, image, speed, name)          
{
  this.slideList = slideList;
  this.image = image;
  this.speed = speed;
  this.name = name;
  this.current = 0;
  this.timer = 0;
}
SlideShow.prototype.play = SlideShow_play;  
function SlideShow_play()       
{
  with(this)
  {
    if(current++ == slideList.length-1) current = 0;
    switchImage(image, slideList[current]);
    clearTimeout(timer);
    timer = setTimeout(name+'.play()', speed);
  }
}

// pop up windows
// policy
function pop1()
{
	if (window.open('popup_policy.html','_blank','toolbar=no,titlebar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,fullscreen=no,scrollbars=yes,width=570,height=500'))
	{
		pop6 = 1;
	}
	else {
		window.location.replace('policy.html');
	}
}
//access
 function pop2()
{
	if (window.open('popup_access.html','_blank','toolbar=no,titlebar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,fullscreen=no,scrollbars=yes,width=570,height=500'))
	{
		pop7 = 1;
	}
	else {
		window.location.replace('access.html');
	}
}
// sitemap
function pop3()
{
	if (window.open('popup_sitemap.html','_blank','toolbar=no,titlebar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,fullscreen=no,scrollbars=yes,width=570,height=500'))
	{
		pop6 = 1;
	}
	else {
		window.location.replace('sitemap.html');
	}
}
  // -->
  
