// IE script to display and drag balloon help window (id has "DRAG" in name)
// Developed by HiTech Consulting 2002 - www.hitechcon.com
//
//Following section add an empty help window on the document
var undef;
if ("undefined" == typeof balloonStyle) var balloonStyle = 1;
if ("undefined" == typeof balloonTail) var balloonTail = "";
if ("undefined" == typeof balloonInfo) var balloonInfo = true;
if ("undefined" == typeof balloonHelp) var balloonHelp = false;
if ("undefined" == typeof balloonTitleBar) var balloonTitleBar = false;

document.writeln("<div id=\"BalloonDRAG\" style=\"position:absolute; color:black; top:0; left:0; z-index:99; display:none;filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=1, OffY=1, Color='#ff666666', Positive='true')progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='#bb999999', Positive='true')progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='#AABBBBBB', Positive='true')\">");
if (balloonStyle == 1 || balloonStyle == 2) {
	topBar = (balloonTitleBar)?'mid_yellowbar_top2.gif':'mid_yellow_top2.gif';
	document.writeln("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" id=\"GRIPBAR1\" style=\"font-weight : bold; font-family: Verdana, Arial, Geneva, Arial, Helvetica, sans-serif; font-size: 9pt; color:black; cursor:move; margin: 0px 0px 0px 0px;\">");

	document.writeln("<tr><td ><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/topemptyfill.gif\" alt=\"\" width=\"5\" height=\"17\" border=\"0\"></td><td height=\"17\"><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/topbarfill.gif\" alt=\"\" width=\"6\" height=\"17\" border=\"0\"></td><td><img style=\"display: block;\" id=\"bh_tail_lup\" src=\""+hostPages+"/images/balloonhelp/tail_left_up.gif\" alt=\"\" width=\"17\" height=\"17\" border=\"0\"></td><td width=\"100%\" height=\"17\" background=\""+hostPages+"/images/balloonhelp/topbarfill.gif\"><td><img style=\"display: block;\" id=\"bh_tail_rup\" src=\""+hostPages+"/images/balloonhelp/tail_right_up.gif\" alt=\"\" width=\"17\" height=\"17\" border=\"0\"></td><td height=\"17\"><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/topbarfill.gif\" alt=\"\" width=\"6\" height=\"17\" border=\"0\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/topemptyfill.gif\" alt=\"\" width=\"5\" height=\"17\" border=\"0\"></td></tr></table>");

	document.writeln("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" id=\"GRIPBAR2\" style=\"font-weight : bold; font-family: Verdana, Arial, Geneva, Arial, Helvetica, sans-serif; font-size: 9pt; color:black; cursor:move; margin: 0px 0px 0px 0px;\">");

	document.writeln("<tr><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/left_Yellow_top2.gif\" alt=\"\" width=\"6\" height=\"21\" border=\"0\"></td>");
	if (balloonInfo) document.writeln("<td valign=\"middle\" height=\"21\" background=\""+hostPages+"/images/balloonhelp/"+topBar+"\"><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/Info_16.gif\" alt=\"Close\" width=\"16\" height=\"16\" border=\"0\" hspace=\"2\"></td>");
	if (balloonHelp) document.writeln("<td valign=\"middle\" height=\"21\" background=\""+hostPages+"/images/balloonhelp/"+topBar+"\"><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/Question_16.gif\" alt=\"Close\" width=\"16\" height=\"16\" border=\"0\"  hspace=\"2\"></td>");
	if (balloonTitleBar || balloonHelp || balloonInfo) document.writeln("<td valign=\"middle\" height=\"21\" background=\""+hostPages+"/images/balloonhelp/"+topBar+"\">&nbsp;</td>");

	document.writeln("<td align=\"left\" width=\"100%\" id=helpTitle background=\""+hostPages+"/images/balloonhelp/"+topBar+"\">&nbsp;</td><td style=\"cursor: pointer;\" onClick=\"closeBalloon();\" background=\""+hostPages+"/images/balloonhelp/"+topBar+"\"><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/CloseBox.gif\" alt=\"Close\" width=\"15\" height=\"15\"  border=\"0\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/right_yellow_top2.gif\" alt=\"\" width=\"6\" height=\"21\" border=\"0\"></td></tr></table>");
	
	/*document.writeln("<div id=\"helpInner\" style=\"z-index:1; border-color: gray; background-color: FFFFE1; border: black; border-style: none solid none solid; border-width: 1px 1px 0px 1px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; scrollbar-base-color: D6D6BF;\"><div id=\"helpContent\" style=\"margin: 5px 5px 5px 5px;\">&nbsp;</div></div>");*/
	document.writeln("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"  id=\"helpInner\" style=\"z-index:1; border-color: gray; background-color: #FFFFE1; border: black; border-style: none solid none solid; border-width: 1px 1px 0px 1px; margin: 0px 0px 0px 0px;\">");
	document.writeln("<td><div id=\"helpContent\" style=\"margin: 5px 5px 5px 5px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; scrollbar-base-color: D6D6BF;background-color: #FFFFE1;filter:none;font-weight:normal;\">&nbsp;</div></td>");
	document.writeln("</td></tr></table>");


	if (balloonTail == "left") {
		document.writeln("<table id=\"baseHelp\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" class=\"header\" style=\" margin: 0px 0px 0px 0px;\"><tr><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/left_yellow_bottomTail.gif\" alt=\"\" width=\"6\" height=\"24\" border=\"0\"></td><td width=\"5%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/tail_left.gif\" alt=\"\" width=\"17\" height=\"24\" border=\"0\"></td><td width=\"100%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td width=\"95%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/right_yellow_bottomTail.gif\" alt=\"\" width=\"6\" height=\"24\" border=\"0\"></td></tr></table></div>");
	} else if (balloonTail == "right") {
		document.writeln("<table id=\"baseHelp\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"1\" class=\"header\" style=\" margin: 0px 0px 0px 0px;\"><tr><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/left_yellow_bottomTail.gif\" alt=\"\" width=\"6\" height=\"24\" border=\"0\"></td><td width=\"100%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/tail_right.gif\" alt=\"\" width=\"17\" height=\"24\" border=\"0\"></td><td width=\"95%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td width=\"5%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/right_yellow_bottomTail.gif\" alt=\"\" width=\"6\" height=\"24\" border=\"0\"></td></tr></table></div>");
	} else {
		document.writeln("<table border=0 id=\"baseHelp\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" class=\"header\" style=\"margin: 0px 0px 0px 0px;\"><tr><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/left_yellow_bottomTail.gif\" alt=\"\" width=\"6\" height=\"24\" border=\"0\"></td><td height=\"24\"><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\" alt=\"\" width=\"6\" height=\"24\" border=\"0\"></td><td><img style=\"display: block;\"  id=\"bh_tail_l\" src=\""+hostPages+"/images/balloonhelp/tail_left.gif\" alt=\"\" width=\"17\" height=\"24\" border=\"0\"></td><td width=\"100%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td width=\"95%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td width=\"100%\" height=\"24\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\"></td><td><img style=\"display: block;\" id=\"bh_tail_r\" src=\""+hostPages+"/images/balloonhelp/tail_right.gif\" alt=\"\" width=\"17\" height=\"24\" border=\"0\"></td><td height=\"24\"><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif\" alt=\"\" width=\"6\" height=\"24\" border=\"0\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/right_yellow_bottomTail.gif\" alt=\"\" width=\"6\" height=\"24\" border=\"0\"></td></tr></table></div>");
	}
} else {	// balloonStyle = 3
	document.writeln("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" id=\"GRIPBAR\" style=\"font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; color:#666666; cursor:move; margin: 0px 0px 0px 0px;\"><tr><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/left_gray_top.gif\" alt=\"\" width=\"4\" height=\"20\" border=\"0\"></td><td width=\"100%\" height=\"20\" background=\""+hostPages+"/images/balloonhelp/mid_gray_top.gif\">&nbsp;&nbsp;<b><span id=helpTitle>&nbsp;</span></b></td><td style=\"cursor: pointer;\" onClick=\"closeBalloon();\" background=\""+hostPages+"/images/balloonhelp/mid_gray_top.gif\"><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/box_X.gif\" alt=\"\" width=\"12\" height=\"13\" hspace=\"4\" border=\"0\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/right_gray_top.gif\" alt=\"\" width=\"4\" height=\"20\" border=\"0\"></td></tr></table>");
	
	document.writeln("<div id=\"helpInner\"  style=\"padding: 5px 5px 5px 5px;\" z-index:1; border-color: gray; background-color: ffffcc; border: Gray; border-style: solid solid none solid; border-width: 1px 1px 0px 1px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; scrollbar-base-color: D6D6BF;\"><div id=\"helpContent\">&nbsp;</div></div>");
	
	document.writeln("<table id=\"baseHelp\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" class=\"header\" style=\" margin: 0px 0px 0px 0px;\"><tr><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/left_yellow_bottom.gif\" alt=\"\" width=\"4\" height=\"4\" border=\"0\"></td><td width=\"100%\" height=\"4\" background=\""+hostPages+"/images/balloonhelp/mid_yellow_bottom.gif\"></td><td><img style=\"display: block;\" src=\""+hostPages+"/images/balloonhelp/right_yellow_bottom.gif\" alt=\"\" width=\"4\" height=\"4\" border=\"0\"></td></tr></table></div>");
}


var baseFilter = "progid:DXImageTransform.Microsoft.dropshadow(OffX=1, OffY=1, Color='#ff666666', Positive='true')progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='#bb999999', Positive='true')progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='#AABBBBBB', Positive='true')";
var balloonHelpSelectList = null;
var balloonHelpTopAdj = 20; // tail zone
var balloonHelpBottomAdj = 35; // tail zone
var bh_lastTitle = "";
var bh_isIE56 = document.all && ((navigator.userAgent.search(/MSIE 5/i) != -1)
	|| (navigator.userAgent.search(/MSIE 6/i) != -1));
function displayBalloon(x, y, title, innerContent, sizeX, sizeY, bdirection )
{
	var undef;
	if (bdirection == undef) bdirection = "";
	helpObj = document.getElementById('BalloonDRAG');
	if (helpObj.style.display=='')
	{
		// just close if it is the same balloon
		if (bh_lastTitle == title) 
		{
			closeBalloon();
			return;
		}
		helpObj.style.filter = baseFilter;
		helpObj.style.display='none';
	}
	bh_lastTitle = title;
	// initialize list of selects (windowed elements)
	// for ie only....
	if (bh_isIE56 && balloonHelpSelectList==null) {
		balloonHelpSelectList = new Array();
		// find all of the selects and hide
		for (i=0; i<document.forms.length; i++) {
			// loop all the forms
			for (j=0; j<document.forms[i].elements.length; j++) {
				// loop the form elements looking for type "select-one"
				if (document.forms[i].elements[j].type == "select-one") {
					balloonHelpSelectList[balloonHelpSelectList.length] = document.forms[i].elements[j];
				}
			}
		}
	}

	bHasTail = (balloonTail == "left") || (balloonTail == "right");
	
	iCurveSize = (balloonStyle==3)?4:6;
	y = (y == undef)? 0 : y+4;
	x = (x == undef)? 0 : x-6;
	sx = (sizeX == undef)? 150: sizeX;
	sy = (sizeY == undef)? 0: sizeY;
	
	if ((bdirection == "" && balloonTail == "left") || bdirection == "NE") {
		document.getElementById("bh_tail_l").src = hostPages+"/images/balloonhelp/tail_left.gif";
		document.getElementById("bh_tail_r").src = hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif";
		document.getElementById("bh_tail_lup").src = hostPages+"/images/balloonhelp/topbarfill.gif";
		document.getElementById("bh_tail_rup").src = hostPages+"/images/balloonhelp/topbarfill.gif";
		y = (sizeY == undef) ? y : (y - sizeY);
		if (sy!=0) { 
			y = y - 32;
		} else {
			y = y - 5;
		}
		x = x+9;
	} else if ((bdirection == "" && balloonTail == "right") || bdirection == "NW") {
		document.getElementById("bh_tail_l").src = hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif";
		document.getElementById("bh_tail_r").src = hostPages+"/images/balloonhelp/tail_right.gif";
		document.getElementById("bh_tail_lup").src = hostPages+"/images/balloonhelp/topbarfill.gif";
		document.getElementById("bh_tail_rup").src = hostPages+"/images/balloonhelp/topbarfill.gif";
		x = x-sx+18;
		y = (sizeY != 0) ? y - sizeY -32 : (y - sizeY);
		if (sy!=0) { 
			y = y - 5;
		} else {
			y = y - 5;
		}
	} else if ( bdirection == "SE") {
		y = y+14;
		x = x+10;
		document.getElementById("bh_tail_lup").src = hostPages+"/images/balloonhelp/tail_left_up.gif";
		document.getElementById("bh_tail_rup").src = hostPages+"/images/balloonhelp/topbarfill.gif";
		document.getElementById("bh_tail_l").src = hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif";
		document.getElementById("bh_tail_r").src = hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif";
	} else if ( bdirection == "SW") {
		y = y+14;
		document.getElementById("bh_tail_lup").src = hostPages+"/images/balloonhelp/topbarfill.gif";
		document.getElementById("bh_tail_rup").src = hostPages+"/images/balloonhelp/tail_right_up.gif";
		document.getElementById("bh_tail_l").src = hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif";
		document.getElementById("bh_tail_r").src = hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif";
		x = x-sx+20;
	} else {
		y = (sizeY == undef) ? y : (y - sizeY);
		document.getElementById("bh_tail_lup").src = hostPages+"/images/balloonhelp/topbarfill.gif";
		document.getElementById("bh_tail_rup").src = hostPages+"/images/balloonhelp/topbarfill.gif";
		document.getElementById("bh_tail_l").src = hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif";
		document.getElementById("bh_tail_r").src = hostPages+"/images/balloonhelp/mid_yellow_bottomTail.gif";
	}
	
	helpObj.style.top = y + "px";
	helpObj.style.left = x + "px";

	document.getElementById("helpContent").innerHTML = innerContent;
	document.getElementById("helpTitle").innerHTML = title;
	
	helpObj.style.filter = baseFilter+"alpha(opacity=0)";
	helpObj.style.display='';
	
	document.getElementById("BalloonDRAG").style.width = sx + "px";
	document.getElementById("helpInner").style.width = sx + "px";
	if (sy == 0)
	{
		document.getElementById("helpInner").style.overflow = "";
		document.getElementById("helpInner").style.height = "";
		ptop = y - document.getElementById("baseHelp").offsetTop - 24;//(bHasTail?24:iCurveSize);
		if ( bdirection == "SE" || bdirection == "SW") {
			ptop = y
		} else {
			ptop = y - document.getElementById("baseHelp").offsetTop - 24;//(bHasTail?24:iCurveSize);
			ptop = (ptop>2)?ptop:2;
		}
		document.getElementById("BalloonDRAG").style.top = ptop + "px";
		//document.recalc(true);
	} else {
		document.getElementById("helpInner").style.overflow = "auto";
		helpObj.style.height = sy + "px";
		document.getElementById("helpInner").style.height = (sy-(16+2*iCurveSize)) + "px";
		if (bHasTail) {
			document.getElementById("helpInner").style.height = (sy-((16+2*iCurveSize)+16)) + "px";
		}
	}
	// for ie only....
	if (bh_isIE56) hideUnderSelects();

	fadeInOutObject(25, 25, 20, 'BalloonDRAG');
}

function hideUnderSelects()
{
	helpObj = document.getElementById('BalloonDRAG');
	
	helpMinX = getPositionX(helpObj);
	helpMaxX = helpMinX + helpObj.offsetWidth;
	helpMinY = getPositionY(helpObj) + balloonHelpTopAdj;
	helpMaxY = getPositionY(helpObj) + helpObj.offsetHeight - balloonHelpBottomAdj;
	
	// hide selects under a help bubble
	for (i=0; i<balloonHelpSelectList.length; i++) {
		selMinX = getPositionX(balloonHelpSelectList[i]);
		selMaxX = selMinX + balloonHelpSelectList[i].offsetWidth;
		selMinY = getPositionY(balloonHelpSelectList[i]);
		selMaxY = selMinY + balloonHelpSelectList[i].offsetHeight;
		//if (i==1)status = helpMinX+", "+helpMaxX+", "+helpMinY+", "+helpMaxY+" -- "		+selMinX+", "+selMaxX+", "+selMinY+", "+selMaxY
		if ( !(helpMaxX <= selMinX || selMaxX <= helpMinX 
			|| helpMaxY <= selMinY || selMaxY <= helpMinY)) {
			balloonHelpSelectList[i].style.visibility = "hidden";
		}
	}
	
}

function fadeInOutObject(fade, change, time, divename)
{
	newfade = fade + change;
	fadeObj = document.getElementById(divename);
	if (newfade >= 100) {
		fadeObj.style.display = '';
		fadeObj.style.filter = baseFilter;
	} else if (newfade <= 0) {
		fadeObj.style.display='none';
		fadeObj.style.filter = '';
	} else {
		fadeObj.style.filter = baseFilter+"alpha(opacity=" + newfade + ")";
		setTimeout("fadeInOutObject("+newfade+", "+change+", "+time+", '"+divename+"')",time);
		//alert("fade="+newfade);
	}
}

function closeBalloon()
{
	fadeInOutObject(100, -25, 20, 'BalloonDRAG');
	// restore selects
	if (bh_isIE56) {
		// IE only
		if ("undefined" != typeof balloonHelpSelectList && balloonHelpSelectList!=null) {
			for (i=0; i<balloonHelpSelectList.length; i++) {
				balloonHelpSelectList[i].style.visibility = "";
			}
		}
	}
	bh_lastTitle = "";
}



