// <![CDATA[ 


function f_init() 
{
  //statusMsg();
	convertExternalLinks();
}


function statusMsg() 
{
  window.defaultStatus="";
}


function convertExternalLinks() 
{
 if (!document.getElementsByTagName) return;
 
 var anchorAry = document.getElementsByTagName("a");
 for (var i = 0; i < anchorAry.length; i++) 
 {
   var anch = anchorAry[i];
   if (anch.getAttribute("href") && anch.getAttribute("rel") == "external")
     anch.target = "_blank";
 }
}


function getObj(obj_id) 
{ 
	return (document.getElementById)?document.getElementById(obj_id):(document.all)?document.all[obj_id]:(document.layers)?document.layers[obj.id]:document[obj_id]; 
} 


function hideObj(obj)
{
  obj.style.display = "none";
}


function showObj(obj)
{
  obj.style.display = "block";
  obj.style.visibility = "visible";
}


function hideDiv(divName)
{
  var d = document.getElementById(divName);
  hideObj(d);
}


function toggleView(elName, visibilityType)
{
	visibilityType = (visibilityType == 'block')? 'block' : 'inline'; 
  var obj = document.getElementById(elName);
  obj.style.display = (obj.style.display == "none" || obj.style.display == '') ? visibilityType : "none";
  //return false;
}


function findXPos(obj) 
{
  var x = 0;
  while (obj) 
  {
    x += obj.offsetLeft
    obj = obj.offsetParent; 
  }
  return x;
}


function findYPos(obj) 
{
  var y = 0;
  while (obj) 
  {
    y += obj.offsetTop
    obj = obj.offsetParent; 
  }
  return y;
}


function repositionDiv(divObj, relativeObj)
{
  var x = findXPos(relativeObj);
  var y = findYPos(relativeObj);

  divObj.style.left = (parseInt(x) - 10) + "px";
  divObj.style.top = (parseInt(y) - 130) + "px";
}

function showDocInfo(linkName, containerName, docID)
{  
  var containerObj = document.getElementById(containerName);
  var linkObj = document.getElementById(linkName);
  
  repositionDiv(containerObj, linkObj);
  showObj(containerObj);
    
  var text  = '<p>Loading document info...</p>';
  document.getElementById("docInfoContent").innerHTML = text;
  
  var url = 'http://benefits.stanford.edu/cgi-bin/ajax/get_document_info/?did=' + docID;
  
  var ajaxRequest = new AjaxRequest(url); //Create AjaxRequest object
  ajaxRequest.sendRequest();  //Send the request  

  return false;
}

//function hideDiv()
//
//{
//  var isIE = (window.ActiveXObject)?true:false;
//  var attributeClass = (isIE)?"className":"class";
//  var element = document.getElementById("hiddenDiv");
// if(element==null)
//   return;
//   if(element.getAttribute(attributeClass)=="hidden")
//        element.setAttribute(attributeClass, "visible");
//   else
//        element.setAttribute(attributeClass, "hidden");
//}

// ]]> 
