/*
// Needed to associate Control with Selected
*/
var m_SelectedGroup = new Array();
var m_SelectedItem = new Array();

var g_OutlookBars = new Array();

function OLB_SetSize(Control, Height, Width)
{
	var c = OLB_GetElementById(Control);
	var h = parseInt(c.style.height,10);
	var dh = Height - h;
	var w = Width - parseInt(c.style.left,10);
	var dw = w - parseInt(c.style.width , 10);
	var g;
	
	
	for(g = 0; g < g_OutlookBars[Control].GroupsCount; g++)
	{
		var id = Control + "_g" + String(g) + "b";
		var group = OLB_GetElementById(id);
		
		group.style.top = String(parseInt(group.style.top,10) + dh) + "px";
		group.style.width =	String(parseInt(group.style.width,10) + dw) + "px";	
				
		id = Control + "_g" + String(g) + "t";
		group = OLB_GetElementById(id);
		group.style.width =	String(parseInt(group.style.width,10) + dw) + "px";		
		
		var i = 0;
		var item;
		
		while(true)
		{
			id = Control + "_g" + String(g) + "i" + String(i) + "_t";
			item = OLB_GetElementById(id);
			if( item == null )
				break;
			item.style.width =	String(parseInt(item.style.width,10) + dw) + "px";		
			i++;
		}
	}
	c.style.height = String(h + dh) + "px";
	c.style.width = String(parseInt(c.style.width,10) + dw) + "px";
}
/*
// OutlookBar Class
*/
new OutlookBar("", "");
/*
// Constructor
*/
function OutlookBar(Control, SelectedGroup, GroupsCount)
{
	if( Control == "" )
		return;
	g_OutlookBars[Control] = this;
	
	this.GroupsCount = GroupsCount;
	this.Control = Control;
	this.SelectedGroup = SelectedGroup;
	this.SelectedImage = null;
	this.SelectedText = null;
}
/*
// OnItemMouseOver
*/
function OLB_OnItemMouseOver(Control, Image, Div)
{
	g_OutlookBars[Control].OnItemMouseOver(Image, Div);
}
OutlookBar.prototype.OnItemMouseOver = function(Image, Div)
{
	if( this.SelectedText == OLB_GetElementById(Div) )
		return;
	OLB_SetItemClasses(this.Control, Image, Div, "_IIMO", "_IDMO");
}
function OLB_SetItemClasses(Control, Image, Div, i, d)
{
	OLB_SetItemClass(Control, Image, i);
	OLB_SetItemClass(Control, Div, d);
}
function OLB_SetItemClass(control, thing, name)
{
	var item = OLB_GetElementById(thing);
	
	if( item != null )
		item.className = control + name;
}
/*
// OnItemMouseOut
*/
function OLB_OnItemMouseOut(Control, Image, Div)
{
	g_OutlookBars[Control].OnItemMouseOut(Image, Div);
}
OutlookBar.prototype.OnItemMouseOut = function(Image, Div)
{
	if( this.SelectedText == OLB_GetElementById(Div) )
		OLB_SetItemClasses(this.Control, Image, Div, "_IIS",  "_IDS");
	else
		OLB_SetItemClasses(this.Control, Image, Div, "_IIN",  "_IDN");
	
}
/*
// OnItemMouseOut
*/
function OLB_OnItemMouseDown(Control, Image, Div)
{
	g_OutlookBars[Control].OnItemMouseDown(Control, Image, Div);
}
OutlookBar.prototype.OnItemMouseDown = function(Control, Image, Div)
{
	OLB_SetItemClasses(this.Control, Image, Div, "_IIMD",  "_IDMD");
}
/*
// OnItemMouseClick
*/
function OLB_OnItemClick(Control, Image, Div, TargetFrame, TargetUrl)
{
	g_OutlookBars[Control].OnItemClick(Control, Image, Div, TargetFrame, TargetUrl);
}
OutlookBar.prototype.OnItemClick = function(Control, Image, Div, TargetFrame, TargetUrl)
{
	var item = OLB_GetElementById(Div);

	if( this.SelectedText != item )
	{
		if( this.SelectedText != null )		
			this.SelectedText.className = this.Control + "_IDN";
		if( this.SelectedImage != null )		
			this.SelectedImage.className = this.Control + "_IIN";
		this.SelectedText = item;
		this.SelectedImage = OLB_GetElementById(Image);
	}	
	OLB_SetItemClasses(this.Control, Image, Div, "_IIS",  "_IDS");


	if(TargetUrl == null && TargetFrame == null )
		return;
	
	if(TargetFrame != null && TargetUrl != null && OLB_GetElementById(TargetFrame)!=null)
	{
		OLB_GetElementById(TargetFrame).src = TargetUrl;	
	}
	else if(TargetFrame != null && TargetUrl != null && TargetFrame != "" && TargetUrl != "")
	{
		eval("parent.frames['"+TargetFrame+"'].location='"+TargetUrl+"';");
	}
	else if(TargetUrl != null && TargetUrl.search("http") == -1)
	{
		// *** CLG *** for resume .doc
		if ( TargetUrl.search("ChrisGallucciResume.doc") >= 0 )
			eval("parent.top.location='"+TargetUrl+"';");
		else
			eval(TargetUrl);
	}
	else if(TargetUrl != null )
		window.open(TargetUrl);
}


function LoadFrame(thing, source)
{
	var doc = eval(thing + ".document");
	
	doc.open();
	doc.write(eval(source));
	doc.close();
}

function OLB_Init(Control, SelectedGroup, GroupsCount)
{
	var olb;
	
	try
	{
		olb = new OutlookBar(Control, SelectedGroup, GroupsCount);

		if( g_OutlookBars[Control] != null )
		{
			m_SelectedGroup[Control] = SelectedGroup;
			m_SelectedItem[Control] = "";
			var temp = OLB_GetElementById(OLB_TopGroupName(Control, SelectedGroup)+ "_Btn");
			
			if( temp != null )
				temp.className = temp.getAttribute("selectedClass");
		}
	} catch(e) {
		return;
	}
}
/*
 Group methods
*/
function OLB_GroupClicked(Sender, Control, Group, Count)
{
	if( Group == m_SelectedGroup[Control] )
		return;

	var prevGroup = m_SelectedGroup[Control];	

	var temp  = OLB_GetElementById(OLB_BotGroupName(Control, m_SelectedGroup[Control]));
	temp.className = temp.getAttribute("normalClass");
	
	temp  = OLB_GetElementById(OLB_TopGroupName(Control, prevGroup));
	temp.className = temp.getAttribute("normalClass");

	m_SelectedGroup[Control] = Group;


	var temp  = OLB_GetElementById(OLB_TopGroupName(Control, m_SelectedGroup[Control]));
	temp.className = temp.getAttribute("selectedClass");
	temp  = OLB_GetElementById(OLB_BotGroupName(Control, m_SelectedGroup[Control]));
	temp.className = temp.getAttribute("selectedClass");
		
	var g;
		
	for(g = 0; g < Count; g++)
	{
		var topName = OLB_TopGroupName(Control, g);
		var botName = OLB_BotGroupName(Control, g);

		if(g <= Group)
		{
			OLB_GetElementById(topName).style.display="";
			OLB_GetElementById(botName).style.display="none";
		}else{
			OLB_GetElementById(topName).style.display="none";
			OLB_GetElementById(botName).style.display="";
		}
	}
	temp = OLB_GetElementById(Control + "_G" + String(Group) + "_I");
	temp.style.display = "";

	temp = OLB_GetElementById(Control + "_G" + String(prevGroup) + "_I");
	temp.style.display = "none";
}
function OLB_TopGroupName(Control, N)
{
	return Control + "_g" + new String(N + "t");
}
function OLB_BotGroupName(Control, N)
{
	return Control + "_g" + new String(N + "b");
}
function OLB_GroupMouseOut(Sender, Control, Group)
{
	if( Group == m_SelectedGroup[Control] )
		Sender.className = Sender.getAttribute("selectedClass");
	else
		Sender.className = Sender.getAttribute("normalClass");
}
function OLB_GroupMouseOver(Sender, Control, Group)
{
	if( Group == m_SelectedGroup[Control] )
		Sender.className = Sender.getAttribute("selectedClass");
	else
		Sender.className = Sender.getAttribute("hoverClass");
}
function OLB_GroupMouseDown(Sender, Control, Group)
{
	if( Group == m_SelectedGroup[Control] )
		return;
	Sender.className = Sender.getAttribute("mouseDownClass");
}

function OLB_GetElementById(ID)
{
	if(document.getElementById)
		return document.getElementById(ID);
	else
		return document.all[ID];
}
