function fileInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id + 
   "passed to fileInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

Stamp = new Date();
today = Stamp.getDate();
function writeQuote() { 
	document.write('<span id="BibleQuotes" class="verse"><script>fileInclude("BibleQuotes", "./BibleQuotes/KT' + today + '.txt");</script></span>');
}

// prevent spam

function writeEmail() {
	document.write('<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;&#105;&#110;&#108;&#97;&#110;&#104;&#46;&#111;&#114;&#103;&#46;&#97;&#117;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;"<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;&#105;&#110;&#108;&#97;&#110;&#104;&#46;&#111;&#114;&#103;&#46;&#97;&#117;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;">Li&#234;n L&#7841c</a>');
}

// Browser Slide-Show script. With image cross fade effect for those browsers
// that support it.
// Script copyright (C) 2004 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
var slideCache = new Array();
function RunSlideShow(pictureName,imageFiles,displaySecs)
{
	var imageSeparator = imageFiles.indexOf(";");
	var nextImage = imageFiles.substring(0,imageSeparator);
	if (document.all)
	{
		document.getElementById(pictureName).style.filter=
			"blendTrans(duration=2)";
		document.getElementById(pictureName).filters.blendTrans.Apply();
	}
	document.getElementById(pictureName).src = nextImage;

	if (document.all)
	{
		document.getElementById(pictureName).filters.blendTrans.Play();
	}
	var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)
		+ ';' + nextImage;
	setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",
		displaySecs*1000);
	// Cache the next image to improve performance.
	imageSeparator = futureImages.indexOf(";");
	nextImage = futureImages.substring(0,imageSeparator);
	if (slideCache[nextImage] == null) {
		slideCache[nextImage] = new Image;
		slideCache[nextImage].src = nextImage;
	}		
}
// Show random images
function showImage(theImages,imgInfo){
	var p = theImages.length;
	var whichImage = Math.round(Math.random()*(p-1));
	document.write('<img src="'+theImages[whichImage]+'" ' + imgInfo + ' >');
}
		
// Cookie ===================================================================================
var now = new Date();
var nextYear = new Date(now.getTime() + 1000 * 60 * 60 * 8760);
var cityName = "";	
function setCookie(cookieName, cookieValue) {
	expires = nextYear;
	document.cookie = escape(cookieName) + '=' + (cookieValue) + (expires ? '; EXPIRES=' + expires.toGMTString() : '');
	getCookie('Weather');
	if (cityName == null){
		alert("Sorry, can not set default due to your browser settings.");
	} else {
		alert("Thank you, your default has been set.");
	}	
}

var bikky = document.cookie;	
function getCookie(name) {
	var index = bikky.indexOf(name + "=");
	if (index == -1) return null;
	index = bikky.indexOf("=", index) + 1;//  first character
	var endstr = bikky.indexOf(";", index);
	if (endstr == -1) endstr = bikky.length;//  last character
	return unescape(bikky.substring(index, endstr-1));
}

// Query String ===============================================================================
function getQueryVariable(variable) { 
	var query = window.location.search.substring(1); 
	var vars = query.split("&"); 
	for (var i=0;i<vars.length;i++) { 
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1]; 
		}
	} 
}
