// JavaScript Document

// Assign frameset document URL and default content frame document
var framesetURL = "/support/help/fos/default.htm";
var contentURL = "/support/help/fos/home.aspx";

function printPage() {
	window.parent.content.focus();
	window.parent.content.print();
}

function openWebLink(url) {
	window.open(url, 'web', 'status=1,toolbar=1,location=1,menubar=1,resizable=1,scrollbars=1');
}

// Creates the frameset HTML
function createFrameset() {
	if (location.search.length > 0) {
		var qs = (location.search.charAt(0) == '?') ? location.search.substring(1) : location.search;
		var pair = qs.split("&");
		for (var i = 0; i < pair.length; i++) {
			var itemval = pair[i].split("=");
			if (itemval.length > 1 && itemval[0] == "url") {
				if (itemval[1].indexOf(".aspx") != -1) contentURL = unescape(itemval[1]);
			}
		}
	}
	document.write('<frameset cols="215, *" border="0" id="screen">' +
				   '<frame src="nav.htm" name="nav" frameborder="0" noresize="noresize" scrolling="no" />' +
				   '<frame src="' + contentURL + '" name="content" frameborder="0" scrolling="auto" />' +
				   '</frameset>');
}

// Resizes a window to a given width and height
function resizeWindow(w, h) {
	var maxX = Math.min(w, screen.availWidth - 50);
	var maxY = Math.min(h, screen.availHeight - 50);
	var moveX = 0;
	var moveY = 0;
	if (window.screenLeft) {
		if (window.screenLeft + maxX > screen.availWidth) moveX = screen.availWidth - (window.screenLeft + maxX);
		if (window.screenTop + maxY > screen.availHeight) moveY = screen.availHeight - (window.screenTop + maxY);
		if (moveX != 0 || moveY != 0) window.moveBy(moveX, moveY);
	} else if (window.screenX) {
		if (window.screenX + maxX > screen.availWidth) moveX = screen.availWidth - (window.screenX + maxX);
		if (window.screenY + maxY > screen.availHeight) moveY = screen.availHeight - (window.screenY + maxY);
		if (moveX != 0 || moveY != 0) window.moveBy(moveX, moveY);
	} else {
		window.moveTo(0, 0);
	}
	if (window.innerWidth) {
		iWidth = window.innerWidth;
		iHeight = window.innerHeight;
	} else if (document.documentElement.clientWidth) {
		iWidth = document.documentElement.clientWidth;
		iHeight = document.documentElement.clientHeight;
	} else {
		iWidth = document.body.clientWidth;
		iHeight = document.body.clientHeight;
	}
	if (iWidth < w || iHeight < h) {
		iWidth = (iWidth < w) ? maxX - iWidth : 0;
		iHeight = (iHeight < h) ? maxY - iHeight : 0;
		window.resizeBy(iWidth, iHeight);
	}
}

// Determines if the document needs to be loaded in the frameset
function forceFrames() {
	var currentTopURL = top.location.pathname + top.location.search;
	qs = (currentTopURL.indexOf(".aspx") != -1) ? "?url=" + escape(currentTopURL) : "";
	if (currentTopURL.indexOf(framesetURL) == -1) top.location.href = framesetURL + qs;
}

function doOnLoad() {
	if (self.frames.length==0) forceFrames();
	else if (self.frames.length > 0) resizeWindow(800, 600);
}


if (window.addEventListener) window.addEventListener("load", doOnLoad, false);
else if (window.attachEvent) window.attachEvent("onload", doOnLoad);