//window.onload = email_formatter();

function email_formatter() {
    if (document.getElementsByClassName){
        email_links = document.getElementsByClassName('email_link');                
        email_links.each(function(email_link){
            tag_content = email_link.innerHTML;
            name = tag_content.substring(0, tag_content.indexOf("[at]"));
            domain = tag_content.substring(tag_content.indexOf("[at]")+4, tag_content.length);
            email_link.innerHTML = '<a href="mailto:'+name+'@'+domain+'">'+name+'@'+domain+'</a>';
        });
    }else{
        //alert('Prototype is not found. Can\'t do anything!');
    }
}

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function showLayer(which) {
  hideLayer("about-sub");
  hideLayer("programs-sub");
  hideLayer("invest-sub");
  hideLayer("community-sub");
  hideLayer("news-sub");
  hideLayer("uncorked-sub")
  if (!(which == "home-sub" || which == "blog-sub"))
  {
   which_div = document.getElementById(which);
   which_div.style.visibility = "visible";
  }
}

function hideLayer(which) {
  which_div = document.getElementById(which);
  which_div.style.visibility = "hidden";
}

function timedHide(which) {
  if (which == "about-sub")
    setTimeout("hideLayer('about-sub')",5000);
  else if (which == "programs-sub")
    setTimeout("hideLayer('programs-sub')",5000);
  else if (which == "programs-sub")
    setTimeout("hideLayer('programs-sub')",5000);
  else if (which == "community-sub")
    setTimeout("hideLayer('community-sub')",5000);
  else if (which == "news-sub")
    setTimeout("hideLayer('news-sub')",5000);
  else if (which == "uncorked-sub")
    setTimeout("hideLayer('uncorked-sub')",5000);
}

document.write("<style type='text/css'>#photoholder2 {visibility:hidden;}</style>");
function initImage() {
	imageId = 'photoholder2';
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = "visible";
	fadeIn(imageId,0);
}
function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		}
	}
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
 // IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox 
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}
window.onload = function() {initImage()}