function addLoadEvent(func)
{
  // Script by Simon Willison
  // http:simon.incutio.com/
  
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
  {
    window.onload = func;
  }
  else
  {
    window.onload = function()
    {
      oldonload();
      func();
    }
  }
}


// Hover Tip scripts
//
// Copyright 2006 Professional Website Design.
// For other useful scripts and tutorials, see
// http://www.professorscodingcorner.com/
// You may use or modify the script in any way
// you want, but do not remove the first three
// lines above. Although it's not required, I
// would appreciate an email to let me know
// the URL of the page where you used it.
//
// modified by Andrew Green - www.andrewgreen.biz
//
// This script causes a Hover Tip to appear in
// place of the usual ugly tooltip whenever
// the mouse moves over an element containing 
// a title attribute.
// 
// Note: if an image is used for a link, and
// the anchor and image both have a title,
// only the anchor title will show.
  
var tipdiv, titleobj;
  
function showTip(titleobj, tipdiv)
{
  // Find the actual page coordinates of the bottom-left corner of the
  // titleobject - the offsetParent stuff is only necessary for IE
  // (http://www.webreference.com/dhtml/diner/realpos1/)
  var Left = titleobj.offsetLeft;
  var Top = titleobj.offsetTop;
  var Parent = titleobj.offsetParent;
  while (Parent != null)
  {
    Left += Parent.offsetLeft;
    Top += Parent.offsetTop;
    Parent = Parent.offsetParent;
  }
  
  // Position the tipdiv to the upper-right of the titleobject
  // There should be plenty of space available on top, due
  // to the header, but watch for problems on the right.
  // The titleobject cannot run across two lines. - fix these later!!
  // (Temporary fix: put tipdiv to upper-left)
//  Left = Left + titleobj.offsetWidth;
  Top = Top - tipdiv.offsetHeight;
  tipdiv.style.left = Left + 'px';
  tipdiv.style.top = (Top +65) + 'px';
  
  // Add a 'p' element containing the tip text
  // to the tipdiv, and make it visible
  tipdiv.innerHTML = "<p>"+titleobj.getAttribute('tiptext')+"</p>";
  tipdiv.style.visibility = 'visible';
}


function hoverTip()
{
  if (!document.getElementsByTagName) return false;

  // Create a 'div' element at the end of the body, give it
  // an id to use for styling, and make it invisible for now
  tipdiv = document.createElement('div');
  document.getElementsByTagName('body')[0].appendChild(tipdiv);
  tipdiv.id = 'hoverTip';
  tipdiv.style.top = '0'; // necessary so footer stays on the bottom
  tipdiv.style.visibility = 'hidden';

  // currentObj is an array containing all body elements
  var currentObj = document.body.getElementsByTagName("*");
  for (var i=0; i<currentObj.length; i++)
  { 
    var att = currentObj[i].getAttribute("title");
    
    // If the body element has a title ...
    if (typeof att == "string" && att.length > 0)
    {
      titleobj = currentObj[i];

      // Define a new attribute, 'tiptext' for the titleobject,
      // to use for holding the text in the title
      titleobj.setAttribute('tiptext',titleobj.title);
      
      // Set title="", so it doesn't show alongside the hoverTip
      titleobj.removeAttribute('title');
      
      // Set alt="", so it doesn't show alongside the hoverTip in IE
      // However, it's not empty in the source code, so there will be
      // no validation problems for images with an empty 'alt' tag
      if (titleobj.getAttribute('alt')) // maybe we should do like lines 84-87
      { titleobj.setAttribute('alt',''); }

      // Show the tipdiv on mouse move
      titleobj.onmousemove = function(){ showTip(this, tipdiv); }
      
      // Hide the tipdiv again on mouse out
     titleobj.onmouseout = function(){tipdiv.style.visibility = 'hidden';}

    
    }
  }
  return true;
}

function navLoad(){

//---------------------------------------------------
// Preload images
//---------------------------------------------------

var palm = "../images/palm_tree2.gif";

	//---------------------------------------------------
	// Get the file name of the current page 
	// This will determine the active link
	//---------------------------------------------------

        var filename;
	var loc = document.URL;
	loc = loc.toString();
	var slash = loc.lastIndexOf("/");
	var pound = loc.lastIndexOf("#");
	if (pound < slash)
	  { filename = loc.substring(slash +1 ,100); }
	else
	  { filename = loc.substring(slash +1 ,pound); }
	if (filename == "") {
		filename = "none"
	}
	//---------------------------------------------------
	// Set active image
	//---------------------------------------------------
	if(filename == "index.shtml" || filename == "none") {
		document.getElementById("index").setAttribute("src",palm);
	}
	if(filename == "packages.shtml") {
		document.getElementById("packages").setAttribute("src",palm);
	}
	if(filename == "location.shtml") {
		document.getElementById("location").setAttribute("src",palm);
	}
	if(filename == "about.shtml") {
		document.getElementById("about").setAttribute("src",palm);
	}
	if(filename == "steps.shtml") {
		document.getElementById("steps").setAttribute("src",palm);
	}
	if(filename == "testimonials.shtml") {
		document.getElementById("testimonials").setAttribute("src",palm);
	}
	if(filename == "links.shtml") {
		document.getElementById("links").setAttribute("src",palm);
	}
	if(filename == "contact.shtml") {
		document.getElementById("contact").setAttribute("src",palm);
	}
}




function mailTo()
{
  // Copyright 2006 Professional Website Design.
  // For other useful scripts and tutorials, see
  // http://www.professorscodingcorner.com/
  // You may use or modify the script in any way
  // you want, but do not remove the first three
  // lines above. Although it's not required, I
  // would appreciate an email to let me know
  // the URL of the page where you used it.

  if (!document.getElementById("mailTo")) return false;
  var spanobj = document.getElementById("mailTo");
  var anch = document.createElement("a");
  var email = "colleen@simpleislandweddings.com";
  var mailto = "mailto:" + email;
  anch.setAttribute("href",mailto);
  spanobj.appendChild(anch);
  var txt = document.createTextNode(email);
  anch.appendChild(txt);
  return true;
}



/*addLoadEvent(enterHit);*/
/*addLoadEvent(navLoad);*/
/*addLoadEvent(mailTo);*/
/*addLoadEvent(currentYear);*/
addLoadEvent(hoverTip);


