﻿// Show an alert type tooltip with obj centered, text, and the following optionional parameteres width, height, and timeToDisapear
function showAlertToolTip(obj, text, tooltipWidth, tooltipHeight, timeToDisapear) {
	var textTip = '';
	var maxWidth = '';
	var maxHeight = '';
	
	if(tooltipWidth == 'undefined' || tooltipWidth == null || tooltipWidth == 0) {
		maxWidth = 300;
	}
	if(tooltipHeight == 'undefined' || tooltipHeight == null || tooltipHeight == 0) {
		maxHeight = 35;
	}
	
	textTip = text;
	textTip = '<TABLE CLASS="appContent" ALIGN="center" BORDER="0" WIDTH="' + maxWidth + '" HEIGHT="'+ maxHeight + '">';
	textTip += '<TR><TD ALIGN="left" CLASS="messageArea"><IMG SRC="../intranet/images/Misc_Information.gif" WIDTH="30" HEIGHT="30" BORDER="0" ALIGN="absmiddle">&nbsp;';
	textTip += text;
	textTip += '</TD></TR>';
	textTip += '</TABLE>';
	Tip(textTip, ABOVE, false, FIX, [obj, ((obj.offsetWidth / 2) - (maxWidth / 2)), 0 - maxHeight], CLICKCLOSE, true, CLOSEBTN, false, CENTERMOUSE, true, STICKY, true, SHADOW, true, SHADOWWIDTH, 2, PADDING, 0, OPACITY, 100, TEXTALIGN, 'center', SHADOWCOLOR, '#e1e2e3');

	if(timeToDisapear != 'undefined' || timeToDisapear != null || timeToDisapear != 0) {
		window.setTimeout("UntipToolTip()", timeToDisapear);
	}
}
// function to KILL the toolTip window
function UntipToolTip() {
	tt_HideInit();
}
// Custom function to show the GTT toolTip balloon
function displayCustomToolTip(formHtml, obj, pointer, objX, objY, opacity, clickClose, tableWidth, tableVAlign, headerTitle, toolWidth, hPointerPadding, vPointerPadding) {
	var currTableVAlign = 'bottom';
	var currTableWidth = 100;
	var currObjX = -58;
	var currObjY = 5;
	var currOpacity = 97;
	var html = '';
	var currPointer = 'Down';
	var currClickClose = false;
	var currHeaderTitle = '';
	var currToolWidth = 300;
	var currHPointerPadding = 30;
	var currVPointerPadding = 100;

	if(tableVAlign != 'undefined' && tableVAlign != null) currTableVAlign = tableVAlign;
	if(tableWidth != 'undefined' && tableWidth != null) currTableWidth = tableWidth;
	if(objX != 'undefined' && objX != null) currObjX = objX;
	if(objY != 'undefined' && objY != null) currObjY = objY;
	if(opacity != 'undefined' && opacity != null) currOpacity = opacity;
	if(pointer != 'undefined' && pointer != null) currPointer = pointer;
	if(clickClose != 'undefined' && clickClose != null) currClickClose = clickClose;
	if(headerTitle != 'undefined' && headerTitle != '' && headerTitle != null) currHeaderTitle = headerTitle;
	if(toolWidth != 'undefined' && toolWidth != '' && headerTitle != null && headerTitle != 0) currToolWidth = toolWidth;
	if(hPointerPadding != 'undefined' && hPointerPadding != null) currHPointerPadding = hPointerPadding;
	if(vPointerPadding != 'undefined' && vPointerPadding != null) currVPointerPadding = vPointerPadding;

	html += '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="' + currToolWidth + 'px" HEIGHT="475px" BORDER="0" CLASS="appContent">';
	html += '<TR><TD VALIGN="' + currTableVAlign + '">';
		html += '<TABLE CLASS="appContent" CELLPADDING="0" CELLSPACING="0" WIDTH="' + currTableWidth + '%" BORDER="0">';
		// Show the pointer UP 
		if(currPointer == 'Up') {
			// Pointer Row 
			html += '<TR><TD COLSPAN="3" STYLE="padding: 0px ' + currHPointerPadding + 'px 0px 0px;">';
				html += '<IMG SRC="../intranet/images/tooltip_t.gif" STYLE="position: relative; float: right; width: 23px; height: 12px;">';
			html += '</TD></TR>';
			// Content Header 
			html += '<TR style="background-color: #5C5C5C;"><TD COLSPAN="3">';
			html += '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0" CLASS="appContent">';
			html += '<TR><TD STYLE="color: white; font-weight: bold;">';
			if(currHeaderTitle != '') { html += currHeaderTitle; } else { html += '&nbsp;'; }
			html += '</TD><TD>&nbsp;</TD><TD VALIGN="top" ALIGN="right" HEIGHT="12px" STYLE="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">';
			html += '<DIV style="margin: 2px 2px 2px 1px; padding: 0px 0px 0px 0px; background-color: #950000; font-size: 12px; text-align: center; font-weight: bold; color: white; width: 20px; height: 14px; cursor: pointer;" ONMOUSEOVER="this.style.backgroundColor = \'#D20000\';" ONMOUSEOUT="this.style.backgroundColor = \'#950000\';" ONCLICK="tt_HideInit();">';
			html += 'X';
			html += '</DIV>';
			html += '</TD></TR>';
			html += '</TABLE>';
			html += '</TD></TR>';
			// Set row to enable table with the content of the form 
			html += '<TR style="background-color: #BBBBBB;"><TD></TD><TD>';
			// table with form 
			html += formHtml;	
			html += '</TD><TD></TD></TR>';
			// Corners Row 
			html += '<TR><TD STYLE="padding: 0px 0px 0px 0px;" ALIGN="right" VALIGN="top">';
				html += '<IMG SRC="../intranet/images/toolTipLeftCorner.png">';
			html += '</TD><TD WIDTH="96%" HEIGHT="5px" style="background-color: #BBBBBB;"></TD><TD STYLE="padding: 0px 0px 0px 0px;" ALIGN="left" VALIGN="top">';
				html += '<IMG SRC="../intranet/images/toolTipRightCorner.png">';
			html += '</TD></TR>';
		// Show the pointer DOWN 
		}else if(currPointer == 'Down') {
			// Content Header 
			html += '<TR style="background-color: #5C5C5C;"><TD COLSPAN="3">';
			html += '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0" CLASS="appContent">';
			html += '<TR><TD STYLE="color: white; font-weight: bold;">';
			if(currHeaderTitle != '') { html += currHeaderTitle; } else { html += '&nbsp;'; }
			html += '</TD><TD>&nbsp;</TD><TD VALIGN="top" ALIGN="right" HEIGHT="12px" STYLE="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">';
			html += '<DIV style="margin: 2px 2px 2px 1px; padding: 0px 0px 0px 0px; background-color: #950000; font-size: 12px; text-align: center; font-weight: bold; color: white; width: 20px; height: 14px; cursor: pointer;" ONMOUSEOVER="this.style.backgroundColor = \'#D20000\';" ONMOUSEOUT="this.style.backgroundColor = \'#950000\';" ONCLICK="tt_HideInit();">';
			html += 'X';
			html += '</DIV>';
			html += '</TD></TR>';
			html += '</TABLE>';
			html += '</TD></TR>';
			// Set row to enable table with the content of the form 
			html += '<TR style="background-color: #BBBBBB;"><TD></TD><TD>';
			// table with form 
			html += formHtml;	
			html += '</TD><TD></TD></TR>';
			// Corners Row 
			html += '<TR><TD STYLE="padding: 0px 0px 0px 0px;" ALIGN="right" VALIGN="top">';
				html += '<IMG SRC="../intranet/images/toolTipLeftCorner.png">';
			html += '</TD><TD WIDTH="96%" HEIGHT="5px" style="background-color: #BBBBBB;"></TD><TD STYLE="padding: 0px 0px 0px 0px;" ALIGN="left" VALIGN="top">';
				html += '<IMG SRC="../intranet/images/toolTipRightCorner.png">';
			html += '</TD></TR>';
			// Pointer Row 
			html += '<TR><TD COLSPAN="3" STYLE="padding: 0px ' + currHPointerPadding + 'px 0px 0px;">';
				html += '<IMG SRC="../intranet/images/tooltip_b.gif" STYLE="position: relative; float: right; width: 23px; height: 12px;">';
			html += '</TD></TR>';
		// Show the pointer LEFT 
		}else if(currPointer == 'Left') {
			// Content Header 
			html += '<TR><TD></TD><TD COLSPAN="3" style="background-color: #5C5C5C;">';
			html += '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0" CLASS="appContent">';
			html += '<TR><TD STYLE="color: white; font-weight: bold;">';
			if(currHeaderTitle != '') { html += currHeaderTitle; } else { html += '&nbsp;'; }
			html += '</TD><TD>&nbsp;</TD><TD VALIGN="top" ALIGN="right" HEIGHT="12px" STYLE="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">';
			html += '<DIV style="margin: 2px 2px 2px 1px; padding: 0px 0px 0px 0px; background-color: #950000; font-size: 12px; text-align: center; font-weight: bold; color: white; width: 20px; height: 14px; cursor: pointer;" ONMOUSEOVER="this.style.backgroundColor = \'#D20000\';" ONMOUSEOUT="this.style.backgroundColor = \'#950000\';" ONCLICK="tt_HideInit();">';
			html += 'X';
			html += '</DIV>';
			html += '</TD></TR>';
			html += '</TABLE>';
			html += '</TD></TR>';
			// Set row to enable table with the content of the form 
			html += '<TR><TD STYLE="padding: ' + currVPointerPadding + 'px 0px 0px 0px;">';
				html += '<IMG SRC="../intranet/images/tooltip_l.gif" HSPACE="0" STYLE="position: relative; float: right; width: 12px; height: 23px;">';
			html += '</TD><TD style="background-color: #BBBBBB;"></TD><TD style="background-color: #BBBBBB;">';
			// table with form 
			html += formHtml;	
			html += '</TD><TD style="background-color: #BBBBBB;"></TD></TR>';
			// Corners Row 
			html += '<TR><TD></TD><TD STYLE="padding: 0px 0px 0px 0px;" ALIGN="right" VALIGN="top">';
				html += '<IMG SRC="../intranet/images/toolTipLeftCorner.png">';
			html += '</TD><TD WIDTH="96%" HEIGHT="5px" style="background-color: #BBBBBB;"></TD><TD STYLE="padding: 0px 0px 0px 0px;" ALIGN="left" VALIGN="top">';
				html += '<IMG SRC="../intranet/images/toolTipRightCorner.png">';
			html += '</TD></TR>';
		// Show the pointer RIGHT 
		}else if(currPointer == 'Right') {
			// Content Header 
			html += '<TR><TD COLSPAN="3" style="background-color: #5C5C5C;">';
			html += '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0" CLASS="appContent">';
			html += '<TR><TD STYLE="color: white; font-weight: bold;">';
			if(currHeaderTitle != '') { html += currHeaderTitle; } else { html += '&nbsp;'; }
			html += '</TD><TD>&nbsp;</TD><TD VALIGN="top" ALIGN="right" HEIGHT="12px" STYLE="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">';
			html += '<DIV style="margin: 2px 2px 2px 1px; padding: 0px 0px 0px 0px; background-color: #950000; font-size: 12px; text-align: center; font-weight: bold; color: white; width: 20px; height: 14px; cursor: pointer;" ONMOUSEOVER="this.style.backgroundColor = \'#D20000\';" ONMOUSEOUT="this.style.backgroundColor = \'#950000\';" ONCLICK="tt_HideInit();">';
			html += 'X';
			html += '</DIV>';
			html += '</TD></TR>';
			html += '</TABLE>';
			html += '</TD><TD></TD></TR>';
			// Set row to enable table with the content of the form 
			html += '<TR><TD style="background-color: #BBBBBB;"></TD><TD style="background-color: #BBBBBB;">';
			// table with form 
			html += formHtml;
			html += '</TD><TD style="background-color: #BBBBBB;"></TD><TD STYLE="padding: ' + currVPointerPadding + 'px 0px 0px 0px;">';
				html += '<IMG SRC="../intranet/images/tooltip_r.gif" HSPACE="0" STYLE="position: relative; float: right; width: 12px; height: 23px;">';
			html += '</TD></TR>';
			// Corners Row 
			html += '<TR><TD STYLE="padding: 0px 0px 0px 0px;" ALIGN="right" VALIGN="top">';
				html += '<IMG SRC="../intranet/images/toolTipLeftCorner.png">';
			html += '</TD><TD WIDTH="96%" HEIGHT="5px" style="background-color: #BBBBBB;"></TD><TD STYLE="padding: 0px 0px 0px 0px;" ALIGN="left" VALIGN="top">';
				html += '<IMG SRC="../intranet/images/toolTipRightCorner.png">';
			html += '</TD><TD></TD></TR>';
		}
		html += '</TABLE>';
		html += '</TD></TR>';
		html += '</TABLE>';
	// Put all html code into var that will link to the API of the toolTips
	textTip = html;

	// Now this is the call of the function of the API of toolTips to show the toolTip
	Tip(textTip, FIX, [obj, currObjX, currObjY], ABOVE, true, OFFSETY, -15, CLOSEBTN , false, CLICKCLOSE, currClickClose, CENTERMOUSE, true, STICKY, true, SHADOW, false, OPACITY, currOpacity, BORDERWIDTH, 0, BGCOLOR, '', BORDERCOLOR, '#777d86', SHADOWCOLOR, '');
}
// Custom tool tip to the currencies convertes
function displayCurrenciesTip(obj, value) {
	if(http_request.readyState == 4 && http_request.status == 200) {
		var xmldoc = http_request.responseXML;

		if (xmldoc.getElementsByTagName("root")[0]) {
			var currencies = xmldoc.getElementsByTagName('currencies')[0].getElementsByTagName('currency');
			var currLen = currencies.length;

			var html = '';
	
			html += '<TABLE CLASS="appContent" CELLPADDING="0" CELLSPACING="0" BORDER="0">';
			if(currLen == 0) {
				html += '<TR CLASS="regTextSml"><TD VALIGN="top" WIDTH="250" ALIGN="center">';
					html += 'No currencies available in the system.';
				html += '</TD></TR>';
			} else {
				html += '<TR CLASS="regTextSml"><TD WIDTH="250" ALIGN="left">';
					if (navigator.appName == "Microsoft Internet Explorer") {
						html += value + ' ' + xmldoc.getElementsByTagName('currencies')[0].getElementsByTagName('defaultCurrency')[0].text + ' equals';
					} else {
						html += value + ' ' + xmldoc.getElementsByTagName('currencies')[0].getElementsByTagName('defaultCurrency')[0].childNodes[0].nodeValue + ' equals';
					}
				html += '</TD></TR><TR><TD WIDTH="250" ALIGN="center">';
					html += '<TABLE CLASS="appContent" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0">';
						for(i = 0; i < currLen; i++) {
							html += '<TR CLASS="regTextSml"' + ((i % 2 != 0)? 'STYLE="background-color: #ECECEC;"': '') + '><TD WIDTH="10%">&nbsp;</TD><TD ALIGN="right">';
								html += '<IMG SRC="../intranet/images/flags/' + currencies[i].getAttribute("flag") + '.png" TITLE="' + currencies[i].getAttribute("abr") + '" ALT="' + currencies[i].getAttribute("abr") + '" WIDTH="16" HEIGHT="11" BORDER="0" ALIGN="absmiddle" STYLE="cursor: default;">&nbsp;&nbsp;';
							html += '</TD><TD NOWRAP>';
								html += currencies[i].getAttribute("abr");
							html += '</TD><TD ALIGN="right">';
								if (navigator.appName == "Microsoft Internet Explorer") {
									html += currencies[i].text;
								} else {
									html += currencies[i].childNodes[0].nodeValue;
								}
							html += '</TD><TD WIDTH="10%">&nbsp;</TD></TR>';
						}
				html += '</TABLE>';
			}
			html += '</TABLE>';

			displayCustomToolTip(html, obj, 'Up', -190, 487, 95, true, 75, 'top', 'Currencies:', 250);
		} else {
			alert("There was a problem with the request.");
		}
	}
}