// -------------------------------------
// BUSINESS ACTIVATION HOTSPOT MOUSEOVER
// -------------------------------------
// Copyright (c) 2003 The Salamander Organization Ltd.  All Rights Reserved.
//
// THIS WORK IS SUBJECT TO U.K. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
//
// DISCLAIMER:
//
// The Salamander Organization Ltd. (hereto referred as "Salamander") makes no representations or warranties
// with respect to the contents or use of this code, and specifically disclaims any express or implied
// warranties of merchantability or fitness for any particular purpose.  Further, Salamander reserves the right
// to revise this publication and to make changes to its content, at any time, without obligation to notify any
// person or entity of such revisions or changes.
//
// Further, Salamander makes no representations or warranties with respect to any software, and specifically
// disclaims any express or implied warranties of merchantability or fitness for any particular purpose.  Salamander
// reserves the right to make changes to any and all parts of the software, at any time, without obligation to notify
// any person or entity of such changes.
//
// Inclusion of the above notice does not necessarily imply publication.



// =================================================
// --- USER VARIABLES ---

var globalTimeout = "500";  // milliseconds value of time-to-close on PopUp
var popupWidth = 300;  // pixel width of the information popup
var popupHeight = 100;  // pixel height of the information popup

// Uncomment only one of these lines at a time to choose what happens when there's no memo field text
//BA_Show = BA_Show_No_Info_Give_Warning;  // if there's no memo field, show a friendly warning
BA_Show = BA_Show_No_Info_No_Boxes;  // if there's no memo field, don't show anything

// DO NOT MODIFY ANYTHING BELOW THIS LINE
// =================================================

// --- SYSTEM VARIABLES ---
var timer;

// --- CORE METHODS ---

// --- Model Process onMouseOver ---
function isFocused(childGUID)
{
	if (DisplayIsSafe(childGUID)) 
	{
		LockDisplay();
		BA_Show(childGUID);
	}
}


// --- Model Process onMouseOut ---
function isBlurred(childGUID)
{
	if (DisplayIsSafe(childGUID)) 
	{
		UnlockDisplay();
	}
}


// check you can actually create the required objects
// and a popup box exists on the page.
function DisplayIsSafe(childGUID)
{
	return ((eval("document.all.process"+childGUID)) && (winList['PopUp']));
}



// show information for this process
function BA_Show_No_Info_Give_Warning(myGUID)
{
	var popup = winList['PopUp'];
	setPopupPosition(popup);

	MemoText = eval("memotext"+myGUID+".innerHTML");
	TitleText = eval("process"+myGUID+".innerHTML");

	if (!MemoText) MemoText = "No information is available for this element.";

	popup.clientArea.innerHTML = "<p>" + MemoText + "</p>";	
	popup.titleBarText.innerHTML = TitleText;
	popup.open();
}

// show information for this process, unless there is no information
function BA_Show_No_Info_No_Boxes(myGUID)
{
	var popup = winList['PopUp'];
	MemoText = eval("memotext"+myGUID+".innerHTML");

	if (MemoText)
	{
		setPopupPosition(popup);
		
		TitleText = eval("process"+myGUID+".innerHTML");
		
		popup.clientArea.innerHTML = "<p>" + MemoText + "</p>";	
		popup.titleBarText.innerHTML = TitleText;
		popup.open();
	}
	else
	{
		popup.close();
	}
}


// --- PopUp onMouseOver ---
function LockDisplay()
{
	if(timer) clearTimeout(timer);
}


// --- PopUp onMouseOut ---
function UnlockDisplay()
{
	timer = setTimeout("winList['PopUp'].close();", globalTimeout);
}

// --- DYNAMIC POPUP DISPLAY METHODS ---

function setPopupPosition(popup)
{	
	var offsetSize = 10;
	
	var eventPosX = window.event.clientX;
	var eventPosY = window.event.clientY;

	var boxWidth = Math.min(popupWidth, (Model_0.width/2));
	var boxHeight = Math.min(popupHeight, (Model_0.height/2));

	var isLeft = ((eventPosX - LeftOffset(Model_0, 0)) > (Model_0.width/2));
	var isTop = ((eventPosY - TopOffset(Model_0, 0)) > (Model_0.height/2));

	var boxLeft = eventPosX + offsetSize - (isLeft * (boxWidth + offsetSize*2));
	var boxTop = eventPosY + offsetSize - (isTop * (boxHeight + offsetSize*2));

	// Set up box dimensions
	SetOpacity();
	popup.frame.style.left = boxLeft + "px";
	popup.frame.style.top = boxTop + "px";		
	popup.frame.style.width = boxWidth + "px"
	popup.clientArea.style.height = boxHeight + "px";	
}

// if IE5.5 and over, set 90% opacity for the .window style
function SetOpacity()
{
	strVers = navigator.appVersion;
	strName = navigator.appName;
	strPlat = navigator.platform;
	intIndex1 = strVers.indexOf("MSIE");
	intIndex1 = intIndex1+5;
	intIndex2 = strVers.lastIndexOf(";");
	intVer = strVers.substring(intIndex1, intIndex2);
	intVer = parseInt(intVer);

	if ((strName == "Microsoft Internet Explorer") && (strPlat == "Win32") && (intVer >= "5.5"))
	{
		winList['PopUp'].frame.style.filter = "alpha(opacity=90)";
	}
}

// --- Get model left
function LeftOffset(pageElement, knownOffset)
{
	if (pageElement.parentElement == null) return knownOffset;
	else return LeftOffset(pageElement.parentElement, knownOffset+pageElement.offsetLeft);
}

function TopOffset(pageElement, knownOffset)
{
	if (pageElement.parentElement == null) return knownOffset;
	else return TopOffset(pageElement.parentElement, knownOffset+pageElement.offsetTop);
}