﻿window.onload = function ()
{
	for ( var i=0; i < initCalls.length; i++ ) eval ( initCalls [i] );
}
window.onresize = function ()
{
	for ( var i=0; i < resizeCalls.length; i++ ) eval ( resizeCalls [i] );
}

var initCalls = new Array(); 																	
var resizeCalls = new Array(); 		

initCalls [ initCalls.length ]	= " SetMainHeight()";
initCalls [ initCalls.length ]	= " IEContactTableHover()";
resizeCalls [ resizeCalls.length ] 	= " SetMainHeight()";

var onloadPosition = 0;

function FlashDone()
{
	var html = document.getElementById("news").innerHTML;
	if (html.length > 15)
	{
		var movie = document.getElementById("movie");
		movie.className="newsContent";
		movie.innerHTML=html;
	}
}

function IEContactTableHover()
{
	var table = document.getElementById("contactTable");
	if (table)
	{
		var sfEls = table.getElementsByTagName("tr");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className="hover";
			}
			sfEls[i].onmouseout=function() {
				this.className="";
			}
		}
	}
}
function SetMainHeight()
{
	var viewportHeight = pageHeight();
	var footer = document.getElementById('footer');
	var footerHeight = footer.offsetHeight;
	if (onloadPosition == 0)
	{
		onloadPosition = findPosY(footer);
	}
	var bottomDistance = viewportHeight - onloadPosition - (footerHeight);
	if (bottomDistance < 75) bottomDistance = 75;
//	self.status = "footer position: " + onloadPosition + "|viewportHeight: " + viewportHeight + "|footerHeight: " + footerHeight + "|bottomDistance: " + bottomDistance;
	footer.style.marginTop = bottomDistance + 'px';	
}

function pageHeight()
{
	return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function ShowLayer(layerId)
{
	if (sheetHideTimer != null) clearTimeout(sheetHideTimer);
	if (layerId != 'specialists') HideLayer('specialists');
	if (layerId != 'global') HideLayer('global');
	if (layerId != 'independent') HideLayer('independent');

	document.getElementById(layerId).style.display = "block";
	document.getElementById(layerId + "Link").className = "sel";
	document.getElementById("movie").style.top = "-1000px";
}
function HideLayer(layerId)
{
	document.getElementById(layerId).style.display = "none";
	document.getElementById(layerId + 'Link').className = "";
}
function HideAll()
{
	HideLayer('specialists');
	HideLayer('global');
	HideLayer('independent');
	document.getElementById("movie").style.top = "0px";
}
var sheetHideTimer;
function ShowFlash()
{
	sheetHideTimer = setTimeout('HideAll()', 1000);
}
function Sort(obj)
{
	var url = document.location.href;
	if (url.indexOf("?") > 0) url = url.substring(0, url.indexOf("?"));
	document.location = url + "?sort=" + obj.value;
}
function TellAColleague(lastPageTitle)
{
	var path = document.location.href;
	if (path.indexOf('?lastPagePath=') > 0) path = path.substring(0, path.indexOf('?lastPagePath='));
	document.location.href='/Miscellaneous/Tell+a+colleague?lastPagePath=' + escape(path) + '&lastPageTitle=' + escape(lastPageTitle);
}