function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    
    if(styleObject) { styleObject.visibility = newVisibility;

	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function toggleObjectDisplay(objectId) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);   
    if(styleObject) 
    { 
       if (styleObject.display=='none')              
           { 
             styleObject.display = '';
           } 
            else
           {
              styleObject.display = 'none';
           }
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} 

function OverviewInitialize()
{
	var divOverview = document.getElementById("divOverview");
	if (divOverview)
	{
		var height = parseInt(divOverview.offsetHeight);
		if (!isNaN(height) && (height > 168)) //  + 50))
		{
			OverviewToggle()
		}
		else
		{
			divOverview.style.height = "192px"; // 168 + 24 for missing Expand
		}
	}
}
OverviewInitialize();

function expand2(divPanelID, pThis)
{
	// 2010-06-21: Added Google Analytic tracking

	// Part1: Track with Google Analytics
	// 1. Currently only applies to AOERepwork-More, AOEPub-More   BioRepwork-More, BioPub-More.
	// 2. Allows multiple Mores and Hides.
	// 3. Using Google Event tracking, not fake pages (which impact page count).
	//    _trackEvent(category, action, opt_label, opt_value)
	//    http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

	var gCategory = "";   // always window.location.pathname. i.e. /AreaOfExpertise/Competition_Antitrust.aspx. Want these grouped into pages.
	var gAction = "";   // Either Repwork or Publication
	var gOpt_label = "";   // Either More or Hide
	
	gCategory = window.location.pathname;

	var googleTrack = "";
	if (
		(window.location.pathname.toLowerCase().indexOf("/people/") > -1)
		|| (window.location.pathname.toLowerCase().indexOf("/areaofexpertise/") > -1)
	)
	{
		// Biography:Repwork:ctl01_ctl02_TabsControl_tabpage_   RepWBulletListExt_pnlExtention
		// Biography:Pub:    ctl01_ctl02_TabsControl_tabpage_   PubBulletListExt_pnlExtention
		// AOE:Repwork:      rAreaOfExpertiseRepWork_           RWBulletListExt_pnlExtention
		// AOE:Pub:          rAreaOfExpertiseRPublication_      PubBulletListExt_pnlExtention

		if ((divPanelID.indexOf("_RepWBulletListExt") > -1) || (divPanelID.indexOf("_RWBulletListExt") > -1))
		{
			gAction = "Representative Work";
		}
		else if ((divPanelID.indexOf("_PubBulletListExt") > -1) || (divPanelID.indexOf("_PubBulletListExt") > -1))
		{
			gAction = "Publications";
		}
		
		if (gAction != "")
		{
			if (document.getElementById(divPanelID).style.display=='none') { gOpt_label = "More"; } else { gOpt_label = "Hide"; }
			try {var pageTracker = _gat._getTracker("UA-7436662-1");pageTracker._trackEvent(gCategory, gAction, gOpt_label); } catch(err) {};
			// alert(gCategory + "\n" + gAction + "\n" + gOpt_label + "!!!");
		}
	}	

	// Part2: Hide/How the appropriate DIV
	var divPanel = document.getElementById(divPanelID);
	if (pThis.className == "link-expand")
	{
		divPanel.style.display = "";  // displays it
		pThis.className = "link-hide";
	}
	else
	{
		divPanel.style.display = "none"; // hides it
		pThis.className = "link-expand";
	}			
}

/*
// Google Expand: Removed 2010-09-09 (replaced by new type of Expand image)
function expand(panelFull,imgLess,imgMore ) {
	// 2010-06-21: Added Google Analytic tracking

	// Part1: Track with Google Analytics
	// 1. Currently only applies to AOERepwork-More, AOEPub-More   BioRepwork-More, BioPub-More.
	// 2. Allows multiple Mores and Hides.
	// 3. Using Google Event tracking, not fake pages (which impact page count).
	//    _trackEvent(category, action, opt_label, opt_value)
	//    http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

	var gCategory = "";   // always window.location.pathname. i.e. /AreaOfExpertise/Competition_Antitrust.aspx. Want these grouped into pages.
	var gAction = "";   // Either Repwork or Publication
	var gOpt_label = "";   // Either More or Hide
	
	gCategory = window.location.pathname;

	var googleTrack = "";
	if (
		(window.location.pathname.toLowerCase().indexOf("/people/") > -1)
		|| (window.location.pathname.toLowerCase().indexOf("/areaofexpertise/") > -1)
	)
	{
		// Biography:Repwork:ctl01_ctl02_TabsControl_tabpage_   RepWBulletListExt_pnlExtention
		// Biography:Pub:    ctl01_ctl02_TabsControl_tabpage_   PubBulletListExt_pnlExtention
		// AOE:Repwork:      rAreaOfExpertiseRepWork_           RWBulletListExt_pnlExtention
		// AOE:Pub:          rAreaOfExpertiseRPublication_      PubBulletListExt_pnlExtention

		if ((panelFull.indexOf("_RepWBulletListExt") > -1) || (panelFull.indexOf("_RWBulletListExt") > -1))
		{
			gAction = "Representative Work";
		}
		else if ((panelFull.indexOf("_PubBulletListExt") > -1) || (panelFull.indexOf("_PubBulletListExt") > -1))
		{
			gAction = "Publications";
		}
		
		if (gAction != "")
		{
			if (document.getElementById(panelFull).style.display=='none') { gOpt_label = "More"; } else { gOpt_label = "Hide"; }			
			try {var pageTracker = _gat._getTracker("UA-7436662-1");pageTracker._trackEvent(gCategory, gAction, gOpt_label); } catch(err) {};
			// alert(gCategory + "\n" + gAction + "\n" + gOpt_label + "!!!");
		}
	}	

	// Part2: Hide/How the appropriate DIV
	styleObj=document.getElementById(panelFull).style;
	styleObjLess=document.getElementById(imgLess).style;
	styleObjMore=document.getElementById(imgMore).style;
	
	if (styleObj.display=='none')
	{
		styleObj.display='block';
		styleObjLess.display='block';
		styleObjMore.display='none';
	}
	else
	{
		styleObj.display='none';
		styleObjLess.display='none';
		styleObjMore.display='block';
	}
}
*/

/*
// Original Expand: 2010-06-21
function expand(panelFull,imgLess,imgMore ) {
	   styleObj=document.getElementById(panelFull).style;
	   styleObjLess=document.getElementById(imgLess).style;
	   styleObjMore=document.getElementById(imgMore).style;

	   if (styleObj.display=='none')
	   {
	   	styleObj.display='block';
	   	styleObjLess.display='block';
	   	styleObjMore.display='none';
	   }
	   else {
	   	styleObj.display='none';
	   	styleObjLess.display='none';
	   	styleObjMore.display='block';
	    }
}
*/

// open the client email with the specified address
function showCont(encodedCont)
{
  // do the mailto: link
  location.href = "mailto:" + decodeCont(encodedCont);
}

// display the email address in the statusbar
function displayStatus(encodedCont)
{
  window.status = "mailto:" + decodeCont(encodedCont);
}

// clear the statusbar message
function clearStatus()
{
  window.status = "";
}

// return the decoded email address
function decodeCont(encodedCont)
{
  var cont = "";
  for (i=0; i < encodedCont.length;)
  {
    // holds each letter (2 digits)
    var letter = "";
    letter = encodedCont.charAt(i) + encodedCont.charAt(i+1)

    // build the real email address
    cont += String.fromCharCode(parseInt(letter,16));
    i += 2;
  }
  
  return cont;
}

var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);

function FireDefaultButton(event, target) {
var element = event.target || event.srcElement;
if (event.keyCode == 13 && !(element && (element.tagName.toLowerCase() == "textarea"))) 
    {
        var defaultButton=null;
        if (__nonMSDOMBrowser) 
        {
            defaultButton = document.getElementById(target);           
            var evObj = document.createEvent('MouseEvents');
            evObj.initEvent( 'click', true, true );
            defaultButton.dispatchEvent(evObj);
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return false;
                
        }
        else 
        {
            defaultButton = document.all[target];
            if (defaultButton && typeof(defaultButton.click) != "undefined") 
            {
                defaultButton.click();
                event.cancelBubble = true;
                if (event.stopPropagation) event.stopPropagation();
                return false;
                }
        }

    }
return true;
}

function FireDefaultButtonMultiSource(event, targetArray, sourceMultiArray) {
var element = event.target || event.srcElement;
if (event.keyCode == 13 && !(element && (element.tagName.toLowerCase() == "textarea") ) ) 
    {
        var targetIndex = -1;
        for (i = 0; i < targetArray.length; i++)
        {
            for (j = 0; j < sourceMultiArray[i].length; j++)
            {
              if ( sourceMultiArray[i][j] == element.id) 
              {
                targetIndex = i ; break;
              }
            }
            if (targetIndex != -1) { break;}
         }
        if (targetIndex <0)
        {
           return true;
        }
        var target = targetArray[targetIndex];
        var defaultButton=null;
        if (__nonMSDOMBrowser) 
        {
            defaultButton = document.getElementById(target);           
            var evObj = document.createEvent('MouseEvents');
            evObj.initEvent( 'click', true, true );
            defaultButton.dispatchEvent(evObj);
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return false;
                
        }
        else 
        {
            defaultButton = document.all[target];
            if (defaultButton && typeof(defaultButton.click) != "undefined") 
            {
                defaultButton.click();
                event.cancelBubble = true;
                if (event.stopPropagation) event.stopPropagation();
                return false;
                }
        }

    }
return true;
}

function PromptRSSUrl(pURL) {
    prompt('Enter the URL below into your RSS feed reader to view headlines',pURL) 
}


function toggleRegionalContacts()
{
	var newdisplay = "", newinnerHTML = "";
	
	if (document.getElementById('RegionalContacts').style.display != 'none') {
		newdisplay = "none";
		if (document.getElementById('showRegionalContacts').innerHTML.indexOf('-ch') >= 0) {
    		newinnerHTML = "<img class=\"image-button-showregcontacts-ch\" src=\"/imagesnew/spacer.gif\" />";
    	} else  {
    		newinnerHTML = "<img class=\"image-button-showregcontacts\" src=\"/imagesnew/spacer.gif\" />";
    	}
	} else {
		newdisplay = "";
		if (document.getElementById('showRegionalContacts').innerHTML.indexOf('-ch') >= 0) {
    		newinnerHTML = "<img class=\"image-button-hideregcontacts-ch\" src=\"/imagesnew/spacer.gif\" />";			
    	} else {
    		newinnerHTML = "<img class=\"image-button-hideregcontacts\" src=\"/imagesnew/spacer.gif\" />";			
    	}
	}
	document.getElementById('showRegionalContacts').innerHTML = newinnerHTML;
	document.getElementById('RegionalContacts').style.display= newdisplay;			
}



