
///////////////////////////////////////////////////
// Code for Section Tabs and Page Frame Behaviors
///////////////////////////////////////////////////

var activeTabId = null;

function ColorSectionTab(tabId,color)
{
	document.getElementById(tabId + "left").style.backgroundImage = "url('./_onefiles/style/" + color + "Tab_LeftCorner.gif')";
	document.getElementById(tabId + "mid").style.backgroundImage = "url('./_onefiles/style/" + color + "Tab_Middle.gif')";
	document.getElementById(tabId + "right").style.backgroundImage = "url('./_onefiles/style/" + color + "Tab_RightCorner.gif')";
}

function setTabBottomBorder(tabId,color)
{
	document.getElementById(tabId).style.borderBottom = "1 " + color + " solid";
}

function onClickSectionTab(tabId,hexColor,strColorName)
{
	// add underline on other section tab
	if (activeTabId != null)
	{
		setTabBottomBorder(activeTabId,"#4674B9");
	}
	
	// set the border color for new section tab
	setTabBottomBorder(tabId,hexColor);
	
	
	// set the content background color
	document.getElementById("content").style.backgroundColor = hexColor;
	document.getElementById("content").style.backgroundImage = "url('./_onefiles/style/" + strColorName + "_SectionBG.png')";
	
	// set the new active tab
	activeTabId = tabId;
}

function moveSectionTabsLeft()
{
	// get current location
	var strleftpos = document.getElementById("tabs").style.left;
	var intleftpos = parseInt(strleftpos.replace(/px/,""));
	
	// check if left pos reached a bound
	// (currently don't have a bound)
	if (true)
	{	
		// set left position to current - 20 pixels to left
		intleftpos -= 200;
		document.getElementById("tabs").style.left = intleftpos.toString() + "px";		
	}
	
}

function moveSectionTabsRight()
{
	// get current location
	var strleftpos = document.getElementById("tabs").style.left;
	var intleftpos = parseInt(strleftpos.replace(/px/,""));
	
	// check if left pos reached a bound
	// (currently don't have a bound)
	if (intleftpos < 0)
	{	
		// set left position to current - 20 pixels to right
		intleftpos += 200;
		
		// make sure we don't push it in further than necessary
		// Note: this is a crappy hack to accomodate the 5px padding for page tabs...
		if (intleftpos > 5)
		{
			intleftpos = 5;
		}

		document.getElementById("tabs").style.left = intleftpos.toString() + "px";		
	}

}

function setBackground(elementId,bgUrl)
{
	document.getElementById(elementId).style.backgroundImage = "url('" + bgUrl + "')";
}

/////////////////////////////////////////////
// Code for Page Tab Behavior
/////////////////////////////////////////////


var currentPage = "";
var currentPageColor = "";

function ColorPageTab(pageId,color)
{
	document.getElementById(pageId + "body").style.backgroundImage = "url('../style/" + color + "Page_Body.gif')";
	document.getElementById(pageId + "corner").src = "../style/" + color + "Page_RightCorner.gif";
}

function onMouseOverPageTab(pageId,color)
{
	ColorPageTab(pageId,color);
}

function onMouseExitPageTab(pageId,color)
{
	if (currentPage != pageId)
	{
		ColorPageTab(pageId,color);
	}
}

function onClickPageTab(pageId,tabColor,editPage)
{
	// deactive previous page tab
	if (currentPage != "" & currentPageColor != "")
	{
		ColorPageTab(currentPage,currentPageColor);
	}
	
	// active new page Tab
	ColorPageTab(pageId,"Rollover");

	// update edit page URL
	setEditUrl(editPage);
	
	currentPage = pageId;
	currentPageColor = tabColor;	
}

function setEditUrl(editUrl)
{
    ((window.parent).parent).document.getElementById("editbuttonlink").href = editUrl;
}


