/*function exp()
			{
				if(window.name != "pblip")
				{
					var targeturl="playerform.aspx"
					newwin=window.open("","","scrollbars")
					if (document.all){
						newwin.moveTo(0,0)
						newwin.resizeTo(845, 680)
						newwin.name = "pblip";
					}
					newwin.location=targeturl
					window.opener = top;
					window.close();					
				}				
			}*/
		
function arrangeTabs()
{
	bringToFront(document.forms[0].openedTab.value);
	layoutAdjust();
}

var topZIndex = 0;			
function bringToFront(id) {
	if(id != "") {
		document.getElementById(id).style.zIndex = ++topZIndex;
	}
}

function doBodyLoaded() 
{							
	arrangeTabs();
	layoutAdjust();
}

function doBodyResized()
{
	layoutAdjust();
}

function doTabClick(id){
	bringToFront(id);
	document.forms[0].openedTab.value = id;				
}

var maximisedContent = false;
function toggleMaximisedContent(){
	if(maximisedContent) {
		maximisedContent = false;					
	} else {
		maximisedContent = true;				
	}
	
	layoutAdjust();			
}


function layoutAdjust()
{
	var tabBtnYOffset = 10;
	var itmCollTabOffsetY = 85;
	var topVertSplitPadding = 5;
	var topPadding = 27;
	var middlePadding = 40;
	var bottomPadding = 36;
	
	var upperPanelHeight = mapWindowHeight;	
	var innerHeight = document.body.clientHeight;
	var innerWidth = 880;//document.body.clientWidth;
		
	var lowerPanelsY = topPadding + upperPanelHeight + middlePadding;
	
	var minimumLowerPanelHeight = tabBtnYOffset + itmCollTabOffsetY + 84;
	var minimumBottomBarTop = lowerPanelsY + minimumLowerPanelHeight;
	
	var lowerPanelHeight = innerHeight - topPadding - 
		upperPanelHeight - middlePadding - bottomPadding - 2;		
	if(lowerPanelHeight < minimumLowerPanelHeight) lowerPanelHeight = minimumLowerPanelHeight;
	
	scenInfoBar = document.getElementById("scenInfo");
	
	var bottomBarTop = innerHeight - bottomPadding;
	if(bottomBarTop < minimumBottomBarTop) bottomBarTop = minimumBottomBarTop;
	
	if (browser.isIE) {
		scenInfoBar.style.top = bottomBarTop;
	} else {
		scenInfoBar.style.top = bottomBarTop - 8;
	}
	scenInfoImgBar = document.getElementById("scenInfoImg");
	if (browser.isIE) {
		scenInfoImgBar.style.top = bottomBarTop;
	} else {
		scenInfoImgBar.style.top = bottomBarTop + 3;
	}
	maximiseButton = document.getElementById("maximiseBtn");
	if (browser.isIE) {
		maximiseButton.style.top = bottomBarTop;
	} else {
		maximiseButton.style.top = bottomBarTop + 3;
	}	
	
	actionViewer = document.getElementById("actnViewer");
	actionViewer.style.top = lowerPanelsY;
	actionViewer.style.width = tabPanelWidth;
	actionViewer.style.height = lowerPanelHeight;
	
	actionTabBtn.style.left = tabPanelWidth;
	actionTabBtn.style.top = lowerPanelsY + tabBtnYOffset;
			
	mapNavigator.style.height = upperPanelHeight;
	mapNavigator.style.width = mapWindowWidth;	
	
	envNavigator.style.height = upperPanelHeight;
	envNavigator.style.left = mapWindowWidth + topVertSplitPadding;
	envNavigator.style.width = 880 - topVertSplitPadding - mapWindowWidth;
	
	collectorBox = document.getElementById("EnvironmentNavigator1_collectorBox");
	if(collectorBox) {
	    collectorBox.style.top = upperPanelHeight - 74;
	    collectorBox.style.left = 880 - topVertSplitPadding - mapWindowWidth - 64 - 10;
	}
	
	endMsg.style.top = upperPanelHeight + topPadding;
	viewDispBar.style.top = upperPanelHeight + topPadding;
	
	//itemCollector = document.getElementById("itmCollector");
	itemCollector.style.top = lowerPanelsY;
	itemCollector.style.width = tabPanelWidth;
	itemCollector.style.height = lowerPanelHeight;
	
	itmCollTabBtn.style.left = tabPanelWidth;
	itmCollTabBtn.style.top = parseInt(actionTabBtn.style.top) + itmCollTabOffsetY;
	
	//actionsPanel = document.getElementById("ActionViewer21_actionsPnl");	
	tabInsetHeight = lowerPanelHeight - 60;
	if(tabInsetHeight < 0) tabInsetHeight = 0;
	actionsPanel.style.height = tabInsetHeight +"px";
	
	//itemsPanel = document.getElementById("ItemCollector1_itmsPanel");
	itemsPanel.style.height = tabInsetHeight +"px";
	
	//contentFrame = document.getElementById("ContentViewer1_content");
	if(maximisedContent) {				
		contentFrame.style.top = 26;
		contentFrame.style.left = 0;
		contentFrame.style.width = 878;
		contentFrame.style.height = parseInt(scenInfoImgBar.style.top) - 28;
		
		maximiseButton.src = "Application/Media/Images/editorcontracticn.gif";
		//maximiseButton.style.backgroundImage = "url(Application/Media/Images/down.gif)";
	} else {
		contentFrame.style.height = lowerPanelHeight;
		contentFrame.style.width = innerWidth - parseInt(actionViewer.style.width) - 8 - 25;
		contentFrame.style.top = lowerPanelsY;
		contentFrame.style.left = parseInt(actionViewer.style.width) + 25;		
		
		maximiseButton.src = "Application/Media/Images/editorexpandicn.gif";
		//maximiseButton.style.backgroundImage = "url(Application/Media/Images/up.gif)";
	}				
}
				    
var TogglePnls = new Object();
TogglePnls.Panels = new Array(3);
TogglePnls.PnlCount = 0;
		
function toggle(div)
{
	if(TogglePnls.PnlCount < 3) {
	
		TogglePnls.Panels[TogglePnls.PnlCount] = div;
		TogglePnls.PnlCount++;
	}
	
	divElement = document.getElementById(div);
							
	if(divElement.style.visibility == 'visible') {
		divElement.style.visibility = 'hidden';
	} else {			       
		divElement.style.visibility = 'visible';
		for(i = 0; i < TogglePnls.PnlCount; i++)		
			if(TogglePnls.Panels[i] != div)
				document.getElementById(TogglePnls.Panels[i]).style.
					visibility = 'hidden';
	}
}
		
function popupNotes()
{
	newwindow = window.open('Application/Gui/Pages/NotepadPage.aspx',
	'notes','height=300, width=400, resizable');
	if (window.focus) {newwindow.focus()}
	return false;
}

