document.onclick = function(e)
{
  var target = e ? e.target : window.event.srcElement;

  while (target && !/^(a|body)$/i.test(target.nodeName))
  {
    target = target.parentNode;
  }

  if (target && target.getAttribute('rel')
      && target.rel == 'external')
  {
    var external = window.open(target.href);

    return external.closed;
  }
return e;
}

function addLoadListener(fn)
{
	if (typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load', fn, false);
	}
	else if (typeof document.addEventListener != 'undefined')
	{
		document.addEventListener('load', fn, false);
	}
	else if (typeof window.attachEvent != 'undefined')
	{
		window.attachEvent('onload', fn);
	}
	else
	{
		var oldfn = window.onload;
		if (typeof window.onload != 'function')
		{
			window.onload = fn;
		}
		else
		{
			window.onload = function()
			{
				oldfn();
				fn();
			};
		}
	}
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

	//determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(var i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function shiftOpacity(id, millisec) { 
    //if an element is invisible, make it visible, else make it ivisible 
    if(document.getElementById(id).style.opacity == 0) { 
        opacity(id, 0, 100, millisec); 
    } else { 
        opacity(id, 100, 0, millisec); 
    } 
}

function makeOpacityZero(id) {
	var thisZero = document.getElementById(id);
	thisZero.style.opacity = (0 / 100); 
	thisZero.style.MozOpacity = (0 / 100); 
	thisZero.style.KhtmlOpacity = (0 / 100); 
	thisZero.style.filter = "alpha(opacity=0)";
}

function resizeText(size) {
  var myObj = document.getElementById("content");
  if (myObj){	  
	  if (myObj.style.fontSize == "") {
    	myObj.style.fontSize = "1.0em";
  	}
	myObj.style.fontSize = size + "em";
  }
  Cufon.replace('h1, h2, h3, h4, h5');
}

function deleteConfirm() {

	confirm_message = "Are you sure you want to delete?";

	if (confirm(confirm_message)) {
		return true;
	}

	return false;
}

function showcaseForm(id) {
	//if (document.getElementById(id).style.display == "block")
	window.scroll(0, document.getElementById(id).offsetTop);
}

//Used in the search.php page.
function toggleLayer( whichLayer )
{
  var full, small, visF, visS;
  if( document.getElementById ) // this is the way the standards work
  {
    full = document.getElementById( "full_" + whichLayer );
    small = document.getElementById( "small_" + whichLayer );
  }
  else if( document.all ) // this is the way old msie versions work
  {
	  full = document.all( "full_" + whichLayer );
      small = document.all( "small_" + whichLayer );
  }
  visF = full.style;
  visS = small.style;
  if (visF.display==''||visF.display=='block')
  {
	  visF.display='none';
	  visS.display='block';
  }
  else
  {
	  visF.display='block';
	  visS.display='none';
  }
  
}