﻿var tabs = null;
var panels = null;

_spBodyOnLoadFunctionNames.push("moreInfoInit");

function moreInfoInit()
{	
	tabClick(1);
	
	// set the height of the main display table cell equal to the max height of either of the panels
	var main_content = document.getElementById("moreInfoContent");
	main_content.style.height = Math.max(panels[0].offsetHeight, panels[1].offsetHeight) + 5 + "px";
	
	// find the total offset of the main web part and place the absolutely-positioned panel divs in the middle of it
	var div = document.getElementById("MoreInfo");
	var top = 0;
	var left = 0;
	
	do {
		if (div.className != "webpartTable")
		{
			top += div.offsetTop;
			left += div.offsetLeft;
		}
	} while( div = div.offsetParent );
		
	panels[0].style.top = top + 30 + "px";
	panels[1].style.top = top + 30 + "px";
	panels[0].style.left = left + 10 + "px";
	panels[1].style.left = left + 10 + "px";
}

function FindElements()
{
	tabs = new Array(2);
	panels = new Array(2);
	
	// get refernces to our tab headers and divs
    tabs[0] = document.getElementById("moreInfoTab1");
	tabs[1] = document.getElementById("moreInfoTab2");    
    
    panels[0] = document.getElementById("moreInfoPanel1");
    panels[1] = document.getElementById("moreInfoPanel2");
}

function tabClick(tabNumber)
{
	if( tabs == null ) FindElements();
		
	var newTab = document.getElementById("moreInfoTab" + tabNumber);
	
	// set tab displays
	if( newTab.id == tabs[0].id )
	{
		tabs[0].className = "moreInfoTabOn";
		tabs[1].className = "moreInfoTabOff";
		
		panels[0].style.visibility = "visible";
		panels[1].style.visibility = "hidden";

	}
	else
	{
		tabs[0].className = "moreInfoTabOff";
		tabs[1].className = "moreInfoTabOn";
		
		panels[0].style.visibility = "hidden";
		panels[1].style.visibility = "visible";


	}
}