/******************************************************************
tocstart.js - requires scripts/cookie.js

Copyright © Global Knowledge Software LLC 2007.  All Rights Reserved.

This program is protected by U.S. and International Copyright and
Patent Laws.  Unauthorized duplication and/or distribution of this
program is strictly prohibited. Distribution and duplication of this
program are limited by license. If you do not currently have a valid
license from Global Knowledge for this program, any copying or
distribution of the program is unauthorized.  If you do have a current
license from Global Knowledge to utilize this program, your use is
strictly limited by the terms of that license.

Patent Pending.
******************************************************************/

var toc_window_name = "Od85Toc";
var toc_force_new_window = false;

function _OpenTocWindow(URL,win,left,top,width,height)
{
	if (isIE7)
	{
		this.location.href=URL;
		return;
	}

	if (toc_force_new_window)
	{
		OldWindow = window.open("",win);
		if (OldWindow) OldWindow.close();
	}
	NewWindow = window.open(URL,win,"channelmode=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,toolbar=no,top=" + top + ",left=" + left + ",width=" + width + ",height=" + height);
	if(NewWindow) NewWindow.focus()
}

function TocStart()
{
	var systemCookie = new Cookie(document,"OnDemandToc",365);
	systemCookie.Load();

	var HeightPercent = .80;
	var WidthPercent = .81;
	var MaxHeight = 750;
	var MaxWidth = 880;
	var MinWidth = 770;

	var WindowTop;
	var WindowLeft;
	var WindowWidth;
	var WindowHeight;

	if (systemCookie.TocWidth)
	{
		WindowWidth = Number(systemCookie.TocWidth);
		WindowHeight =  Number(systemCookie.TocHeight);
		WindowTop = Number(systemCookie.TocTop);
		WindowLeft = Number(systemCookie.TocLeft);
	}
	else
	{
		WindowWidth = screen.availWidth * WidthPercent;
		WindowHeight = screen.availHeight * HeightPercent;
		WindowWidth = WindowWidth > MaxWidth?MaxWidth:WindowWidth;
		WindowHeight = WindowHeight > MaxHeight?MaxHeight:WindowHeight;
		WindowWidth = WindowWidth < MinWidth?MinWidth:WindowWidth;

		WindowTop = Math.floor((screen.height-WindowHeight)/2);
		WindowLeft = Math.floor((screen.width-WindowWidth)/2);
	}
	
	if (WindowLeft<0)
		WindowLeft=0;
	if (WindowTop<0)
		WindowTop=0;
	if (WindowLeft+WindowWidth>screen.availWidth-12)
	{
		if (WindowWidth>screen.availWidth-12)
		{
			WindowLeft=0;
			WindowWidth=screen.availWidth-12;
		}
		else
		{
			WindowLeft=screen.availWidth-12-WindowWidth;
		}
	}
	if (WindowTop+WindowHeight>screen.availHeight-36)
	{
		if (WindowHeight>screen.availHeight-36)
		{
			WindowTop=0;
			WindowHeight=screen.availHeight-36;
		}
		else
		{
			WindowTop=screen.availHeight-36-WindowHeight;
		}
	}

	_OpenTocWindow(tocstart_baseurl+"toc.html"+tocstart_querystr,toc_window_name,WindowLeft,WindowTop,WindowWidth,WindowHeight)
}
