// JavaScript Document

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

// Modified by Redhill, 2005

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function closeBio(e){
	hotDog=isIE ? event.srcElement : e.target;
	if (hotDog.id!="bioname" && hotDog.id!="maillink" && hotDog.id!="vcard" && hotDog.id!="vcardimg"){
		hideMe();
	}
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function findPosX(name)
{
	var obj = isIE ? document.getElementById(name) : document.getElementById(name);
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(name)
{
	var obj = isIE ? document.getElementById(name) : document.getElementById(name);
	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 setName(aname,title,ename){
//	whichName=isIE ? document.all.titlename : document.getElementById("titlename");
//	whichName.innerHTML = aname;
	if(ename == "careers")
	{
		myname = aname;
		whichBio=isIE ? document.all.bioframe : document.getElementById("bioframe");  
		whichBio.src = title + "/" + aname + ".htm";
		whichDog.innerHTML = whichBio.innerHTML;
	}
	else
	{
		myname = aname;
		mytitle = title;
		myename = ename;
		myemail = ename + "@" + domain;
	//	whichemail=isIE ? document.all.emailaddr : document.getElementById("emailaddr");
	//	whichemail.innerHTML = "<a href='mailto:" + emailaddr + "'>" + emailaddr + "</a>";
		whichBio=isIE ? document.all.bioframe : document.getElementById("bioframe");  
		whichBio.src = "profiles/" + ename + ".htm";
		whichDog.innerHTML = whichBio.innerHTML;
	}
}

function copyBody(obj)
{
	document.all[obj].innerHTML=parent.frames['bioframe'].document.body.innerHTML
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function reposition()
{
	offsetL = findPosX('nameCell') - bioSize + 150;
	offsetT = findPosY('nameCell');
	whichDog.style['left'] = offsetL;
	whichDog.style['top'] = offsetT;
}

function showMe(aname,title,ename){
  if (isIE||isNN){
	  if (whichDog.style.visibility=="visible")
	  {
		if(aname == myname)
		  	hideMe();
		else
			setName(aname,title,ename);
	  }
	  else{
		  setName(aname,title,ename);
		  whichDog.style.visibility="visible";
	  }
  }
  else if (isN4){
	  if (document.theLayer.visibility=="show")
	  {
		if(aname == myname)
		  	hideMe();
		else
			setName(aname,title,ename);
	  }
	  else{
		  setName(aname,title,ename);
		  document.theLayer.visibility="show";
	  }
  }
}

document.onmousedown=ddInit;
document.onmouseup=closeBio;


