/// <reference path="TPFormStrings.js" />
//
// (c) Travel Power Limited 2006-11
//
var newWindow;
var newWindowName="TPPOPUP";
var InQuickLink=false;

var gSuffixNum="";
var gFirstSuffixNum="";
var gSuffixRowNum=0;

var com;
if (!com) com={};
else if (typeof com != "object")
	throw new Error("com already exists and is not an object");

if (!com.travelpower) com.travelpower = {}
else if (typeof com.travelpower != "object")
	throw new Error("com.travelpower already exists and is not an object");

com.travelpower.EnvironmentCode = "";

com.travelpower.QuicklinkWarning = "";
com.travelpower.NavigationWarning = "";
com.travelpower.SSLPostBackTo = "";
com.travelpower.Control = {};

com.travelpower.ImageURLs = new Array();

com.travelpower.ImageNotFound = function(thisElement)
{
    if (thisElement)
    {
    }
    else if (window.event)
    {
		if (window.event.srcElement.src != 'images/noimage.gif')
		{
			window.event.srcElement.src = 'images/noimage.gif';
		}
    }
}

com.travelpower.HotelImageNotFound = function(thisElement)
{
    if (thisElement)
    {
    	if (thisElement.src != 'images/no_hotel_image.gif')
    	{
    		thisElement.src = 'images/no_hotel_image.gif';
    	}
    }
    else if (window.event)
    {
		if (window.event.srcElement.src != 'images/no_hotel_image.gif')
		{
			window.event.srcElement.src = 'images/no_hotel_image.gif';
		}
    }
}

com.travelpower.PreloadImage = function(thisURL)
{
    if (document.images)
    {
        com.travelpower.ImageURLs[com.travelpower.ImageURLs.length] = new Image();
        com.travelpower.ImageURLs[com.travelpower.ImageURLs.length-1].src = thisURL;
    }
}

com.travelpower.ConfirmThis = function(thisTitle, thisText)
{
	if (com.travelpower.NavigationWarning == "")
		return(true);
//
// Use DialogueBox if it exists
//		
	if (com.travelpower.DialogueBox)
	{
	}
	else
	{
		return(confirm(thisText+"\n\nClick OK to continue or Cancel to stay on this page"));
	}
}

com.travelpower.ConfirmNavigation = function()
{
	return(com.travelpower.ConfirmThis("",com.travelpower.NavigationWarning));
}

function gfManualValidateRows(thisForm, thisStartNode, thisSuffixFunction)
{
	if (typeof thisForm == "string") thisForm = document.getElementById(thisForm);

	//alert("gfManualValidateRows");
	
	gSuffixRowNum = 0;
	for (feControl=0; feControl<thisForm.elements.length; feControl++)
	{
		var thisElement=thisForm.elements[feControl];
		if (thisElement.type=="hidden")
		{
			//alert(thisElement.getAttribute("name"));
			if (gfFORMSTRINGS_StartsWith(thisElement.getAttribute("name"),"STARTNODE"))
			{
				if (thisElement.value==thisStartNode)
				{
					gfSetSuffix(thisElement.getAttribute("name"));
					gSuffixRowNum += 1;
					if (thisSuffixFunction()==false)
						return(false);
				}
			}
		}
	}
	
	return(true);
}

function gfSetSuffix(thisName)
{
	//alert("gfSetSuffix:"+thisName);
	gSuffixNum=thisName.substring(thisName.length-3,thisName.length);
}

function gfSetFirstSuffix(thisForm, thisStartNode)
{
	if (typeof thisForm == "string") thisForm = document.getElementById(thisForm);

	gSuffixRowNum = 0;
	for (feControl=0; feControl<thisForm.elements.length; feControl++)
	{
		var thisElement=thisForm.elements[feControl];
		if (thisElement.type=="hidden")
		{
			//alert(thisElement.getAttribute("name"));
			if (gfFORMSTRINGS_StartsWith(thisElement.getAttribute("name"),"STARTNODE"))
			{
				if (thisElement.value==thisStartNode)
				{
					gfSetSuffix(thisElement.getAttribute("name"));
					gSuffixRowNum += 1;
					gFirstSuffixNum=gSuffixNum;
					return;
				}
			}
		}
	}
}

function gfSetLastSuffix(thisForm, thisStartNode)
{
	if (typeof thisForm == "string") thisForm = document.getElementById(thisForm);

	gSuffixRowNum = 0;
	for (feControl=0; feControl<thisForm.elements.length; feControl++)
	{
		var thisElement=thisForm.elements[feControl];
		if (thisElement.type=="hidden")
		{
			//alert(thisElement.getAttribute("name"));
			if (gfFORMSTRINGS_StartsWith(thisElement.getAttribute("name"),"STARTNODE"))
			{
				if (thisElement.value==thisStartNode)
				{
					gfSetSuffix(thisElement.getAttribute("name"));
					gSuffixRowNum += 1;
				}
			}
		}
	}
}


function gfCopyControlValueToClipboard(thisControl)
{
	if (typeof thisControl == "string") thisControl = document.getElementById(thisControl);

	if (window.clipboardData && clipboardData.setData)
	{
		clipboardData.clearData();
		clipboardData.setData("Text", thisControl.value);
	}
	else
	{
		alert("Internet Explorer required");
	}
}

function gfCopyControlHTMLToClipboard(thisControl)
{
	if (typeof thisControl == "string") thisControl = document.getElementById(thisControl);

	if (window.clipboardData && clipboardData.setData)
	{
		clipboardData.clearData();
		clipboardData.setData("Text", thisControl.innerHTML);
	}
	else
	{
		alert("Internet Explorer required");
	}
}

function gfCopyToClipboard(thisText)
{
	if (window.clipboardData && clipboardData.setData)
	{
		clipboardData.clearData();
		clipboardData.setData("Text", thisText);
	}
	else
	{
		alert("Internet Explorer required");
	}
}

function gfCopyToClipboardAlert(thisText)
{
	if (window.clipboardData && clipboardData.setData)
	{
		clipboardData.clearData();
		clipboardData.setData("Text", thisText);
		alert("'"+thisText+"' copied to clipboard");
	}
	else
	{
		alert("Internet Explorer required");
	}
}

function gfShowHide(thisId)
{
	if (document.getElementById(thisId).style.display=="inline")
		document.getElementById(thisId).style.display="none";
	else
		document.getElementById(thisId).style.display="inline";
}
function gfTogglePlus(thisRoot, setStyle)
{
	var lNewStyle = "";
	var lUnHide = "";		//inline
	var lSpan=document.getElementById(thisRoot+"span");
	
	if (!lSpan)
		return;
	
	if (setStyle)
		lNewStyle=setStyle;
	else
	{
		if (lSpan.style.display==lUnHide)
			lNewStyle="none";
		else
			lNewStyle=lUnHide;
	}	
		
	if (lNewStyle=="none")
	{
		lSpan.style.display="none";
		document.getElementById(thisRoot+"image").src="images/plus.gif";
	}
	else
	{
		lSpan.style.display=lUnHide;
		document.getElementById(thisRoot+"image").src="images/minus.gif";
	}
}
//
// This does not work on IE6. Great heh?
//
function gfAutoHelpText()
{
	var lHelpElements = document.getElementsByTagName("HelpText");
	for (lElement=0; lElement<lHelpElements.length; lElement++)
	{
		lHelpElements[lElement].setAttribute("id",lHelpElements[lElement].getAttribute("TPHelpId")+"Help");
	}
}

function gfAutoHelp(thisForm)
{
	var lTPType="";
		
	for (fElementNum=0; fElementNum < thisForm.elements.length; fElementNum++)
	{
		var lElement = thisForm.elements[fElementNum];
		gfAutoHelpElement(lElement);
	}
	
	//gfAutoHelpText();
	
	return(true);
}

function gfAutoHelpAttachEvent(thisElement, thisEvent, thisFunction)
{
	if (thisEvent == "blur")
	{
		if (thisElement.blur)
		{
			var oldHandler = thisElement.blur;
			thisElement.blur = function() {oldHandler(); thisFunction();}
			return(true);
		}
	}
	
	try
	{
		if (document.addEventListener)
		{
			thisElement.addEventListener(thisEvent, thisFunction, false);
		}
		else if (document.attachEvent)
		{
			thisElement.attachEvent("on"+thisEvent, thisFunction);
		}
	}
	catch (er) {}
}

function gfAutoHelpElement(thisElement)
{
	if (thisElement.type == "text" 
		|| thisElement.type == "button" 
		|| thisElement.type == "checkbox" 
		|| thisElement.type == "password" 
		|| thisElement.type == "textarea" 
		|| thisElement.type == "select-one" 
		|| thisElement.type == "select-multiple")
	{
		try
		{
			if (!thisElement.getAttribute("id"))
			{
				thisElement.setAttribute("id",thisElement.getAttribute("name"));
			}
		}
		catch(er) {alert(er);}
			
		gfAutoHelpAttachEvent(thisElement,"focus",gfSetIdHelpHTML);
		
		lTPType=thisElement.getAttribute("TPType");
		if (lTPType == null)
			gfAutoHelpAttachEvent(thisElement,"blur",gfClearStatus);
		else
		{
			if (lTPType == "Date" || lTPType=="MDate")
			{
				gfAutoHelpAttachEvent(thisElement, "blur", gfFormatShortDateOnBlur);					
			}
		}
	}
}
function gfAutoValidateElement(thisElement)
{
	var lTPType=thisElement.getAttribute("TPType");
	if (lTPType=="" || lTPType==null)
		return(true);

	var lTPName=thisElement.getAttribute("TPName");
	if (!lTPName)
		lTPName=thisElement.getAttribute("name");

	var lMandatory=false;
	if (lTPType.charAt(0)=="M")
	{
		lMandatory=true;
		lTPType=lTPType.substring(1);
	}		
			
	if (thisElement.type == "text")
	{
		if (lTPType == "Text")
		{
			if (gbFORMSTRINGS_StringOnSubmit(thisElement, lMandatory, lTPName, 0)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "Period")
		{
			if (gbFORMSTRINGS_PeriodOnSubmit(thisElement, lMandatory, lTPName, 2)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "AltPeriod")
		{
			if (gbFORMSTRINGS_AltPeriodOnSubmit(thisElement, lMandatory, lTPName, 3)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "Age")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 0, 1, 99)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "Int99")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 0, 1, 99)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "Int0999")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 0, 0, 999)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "Int999")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 0, 1, 999)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "Cost")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 0, 0, 9999)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "Cost2")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 2, 0, 99999)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "CostRef2")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 2, -99999, 99999)==false)
				return(false);
			else
				return(true);
		}		
		if (lTPType == "Price")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 2, 0, 99999)==false)
				return(false);
			else
				return(true);
		}
		if (lTPType == "Million")
		{
			if (gbFORMNUMBERSNumberOnSubmit(thisElement, lMandatory, lTPName, 2, 0, 999999) == false)
				return (false);
			else
				return (true);
		}
		if (lTPType == "Date")
		{
			if (gbValidShortDateOnSubmit(thisElement, lMandatory, lTPName)==false)
				return(false);
			else
				return(true);
		}		
	}
	return(true);
}

function gfAutoValidateForm(thisForm)
{
	if (typeof thisForm == "string") thisForm = document.getElementById(thisForm);

	for (fElementNum=0; fElementNum < thisForm.elements.length; fElementNum++)
	{
		var lElement = thisForm.elements[fElementNum];
		
		if (gfAutoValidateElement(lElement)==false)
		{
			return(false);
		}
	}
	
	return(true);
}

function gfStdMaintOnBack()
{
	try
	{
		if (document.getElementById("idBackButton").value!="")
		{
			try	{document.getElementById("idDivBackButton").style.display="inline";}
			catch(er) {}
			try	{document.getElementById("idSpanBackButton").style.display="inline";}
			catch(er) {}
		}
		else
		{
			try	{document.getElementById("idDivBackButton").style.display="none";}
			catch(er) {}
			try	{document.getElementById("idSpanBackButton").style.display="none";}
			catch(er) {}
		}
	}
	catch(er) {}
}
function gfStdMaintOnSubmit()
{
	com.travelpower.Control = document.getElementById("idQuickListWarningTable")
	if (com.travelpower.Control != null)
		com.travelpower.Control.style.display="none";
}

function gfOnEnter(thisEvent, thisFunction)
{
	if (arguments.length == 1)
	{
		if (window.event)
		{
			if (window.event && window.event.keyCode == 13)
			{
				arguments[0]();
			}
		}
	}
	else
	{
		var lEvent = thisEvent || window.event;
		var lKeyCode = lEvent.charCode || lEvent.keyCode;
		if (lKeyCode == 13)
		{
			thisFunction();
		}
	}
	return(true);
}
// thisEvent = event object (needed for FireFox)
// thisForm = the form to submit
//function gfSubmitOnEnter(thisEvent, thisForm)
//{
//	//if (window.event && window.event.keyCode == 13)
//	var lEvent = thisEvent || window.event;
//	var lKeyCode = lEvent.charCode || lEvent.keyCode;
//	if (lKeyCode == 13)
//	{
//		if (thisForm)
//			thisForm.submit();
//		else
//			mformToSubmit.submit();
//		return(false);
//	}
//	else
//		return(true);
//}
function gfEventTabOnEnter(thisEvent, autoSubmit)
{
	gfTabOnEnter(thisEvent, autoSubmit, true)
}
function gfTabOnEnter(optionalEvent, autoSubmit, hasThisEvent)
{
	var lEvent;
	var lAutoSubmit;
	var lKeyPressed;

	if (hasThisEvent)
	{
		lEvent = optionalEvent || window.event;
		lKeyPressed = lEvent.charCode || lEvent.keyCode || lEvent.which;
		lAutoSubmit = autoSubmit;
	}
	else
	{
		if (window.event)
		{
			lEvent = window.event;
			lKeyPressed = lEvent.keyCode;
			lAutoSubmit = optionalEvent;
		}
		else
		{
			lEvent = optionalEvent;
			lKeyPressed = lEvent.charCode || lEvent.keyCode;
			lAutoSubmit = autoSubmit;
		}
	}
	
	if (lEvent && lKeyPressed == 13)
	{
		var thisControl=lEvent.srcElement || lEvent.target;
		//
		// Check for Auto-submit
		//
		if (lAutoSubmit)
		{
			if (thisControl.value != "")
			{
				try { lAutoSubmit(); }
				catch(er) { alert(er); }
				return(true);
			}
		}
		
		var thisForm=thisControl.form;
		var thisFormLength = thisForm.elements.length;
		
        for(elementnum = 0; elementnum < thisFormLength; elementnum++)
            {    
                if (thisControl.name == thisForm.elements[elementnum].name)
                {
                    nextElement = thisForm.elements[elementnum+1];
                }
            }
        //alert(nextElement.name);
        if (nextElement.name=="SERVICE")
	 	{
	 		document.getElementById("idSearch").focus();
			//location.hash="#Search";
			//mformToSubmit.submit();
			return(false);
		}
		else
	        nextElement.focus();
			return(true);
	  	}
	else
		return(true);
}
function gfTabOnEnter2()
{
	if (window.event && window.event.keyCode == 13)
	{
		var thisControl=window.event.srcElement;
		var thisForm=thisControl.form;
		var thisFormLength = thisForm.elements.length;
		
        var nextElement = thisForm.elements[thisFormLength-1]; //Gets the last element in the form
        var nextTabIndex=thisForm.elements[thisFormLength-1].getAttribute("tabindex");
		alert(nextElement.name + ":" + thisFormLength + " @" + nextTabIndex);
        
        //if current field is the last set focus on the first in the form
        if (thisControl.name == nextElement.name)
        {
            thisForm.elements[0].focus();
            return;
        }

        //find a field that has a tabindex higher than current field and lower than the last (or any found previously)
        //by looping through entire form
        
        var thisTabIndex= thisControl.tabindex; // Gets the tabindex of current field
        var tryTabIndex=0;
        alert("thisTabIndex=" + tryTabIndex + " nextTabIndex=" + nextTabIndex);
        
        for(elementnum = 0; elementnum < thisFormLength; elementnum++)
            {    
            	tryTabIndex=thisForm.elements[elementnum].getAttribute('tabindex');
            	alert(elementnum + ". " + thisForm.elements[elementnum].name + "=" + tryTabIndex);
                if ((tryTabIndex > thisTabIndex) &&
                    (tryTabIndex < nextTabIndex))
                {
                    //replace with better match than the one we had
                    nextElement = thisForm.elements[elementnum];
                    nextTabIndex=tryTabIndex;
                }
            }
        alert(nextElement.getAttribute('tabindex'));
        nextElement.focus();
        return;
  	}
	else
		return(true);
}

function gfPopupXLS(serviceCode, thisAction)
{
	newWindow=window.open('', 'EXCEL', 'screenX=50,screenY=50,left=50,top=50,height=350,width=600,status=yes,scrollbars=yes,toolbar=no,resizable=yes,menubar=yes');
	document.frmPopup.target='EXCEL';
	document.frmPopup.SERVICE.value=serviceCode;

	if (thisAction!= null)
		document.frmPopup.action=thisAction;
	
	document.frmPopup.submit();
	newWindow.focus();
}

var gfPopupAction='';
var gfPopupDefAction='TPGateway';

var gfPopupOptions='';
var gfPopupDefOptions='screenX=50,screenY=50,left=50,top=50,height=500,width=600,scrollbars=yes,toolbar=no';
var gfPopupOptionsWide='screenX=50,screenY=50,left=50,top=50,height=500,width=800,scrollbars=yes,resize=yes';
var gfPopupOptionsA='width=700,height=500,toolbar=0,scrollbars=1,resizable=1';
var gfPopupOptionsP='width=400,height=400,top=300,left=400,toolbar=0,scrollbars=1,resizable=0';
function gfPopup(serviceCode, innerTemplatePath, showPrintYN, thisURN)
{
	/* If not set, set Pop-up Options */
	if (gfPopupAction=="")
		gfPopupAction=gfPopupDefAction+gActionSuffix;
		
	if (!gfPopupAction)
		gfPopupAction=gfPopupDefAction+gActionSuffix;
		
	/* If not set, set Pop-up Options */
	if (!gfPopupOptions)
		gfPopupOptions=gfPopupDefOptions;
		
	if (gfPopupOptions=="")
		gfPopupOptions=gfPopupDefOptions;
		
	try
	{
		newWindow.close();
	}
	catch(er) {}
	
	newWindow=window.open('Loading.htm', newWindowName, gfPopupOptions, true);
	
	document.frmPopup.action=gfPopupAction;
	document.frmPopup.target=newWindowName;
	document.frmPopup.SERVICE.value=serviceCode;

	if (innerTemplatePath != null)
		document.frmPopup.InnerTemplatePath.value=innerTemplatePath;
	if (showPrintYN != null)
		document.frmPopup.ShowPrintYN.value=showPrintYN;
	if (thisURN != null)
		document.frmPopup.URN.value=thisURN;
	
	document.frmPopup.submit();
	try { newWindow.focus(); }
	catch (er) {}
	//document.frmPopup.reset();
	
	/* Reset Pop-up Options anyway */
	gfPopupOptions=gfPopupDefOptions;
	gfPopupAction="";

}
function gfPopupURL(thisURL, theseOptions)
{
	if (theseOptions)
		newWindow=window.open(thisURL, newWindowName, theseOptions);
	else
		newWindow=window.open(thisURL, newWindowName, gfPopupOptions);
}

function gfGoTo(thisIDName, thisURN, serviceCode, thisAction, thisConfirm)
{
    /// <summary>Go to a Service</summary>
    /// <param name="thisIDName" type="string">The String to check</param>
    /// <param name="thisURN" type="string">Starts with this</param>
    /// <param name="thisAction" type="string">Starts with this</param>
    /// <param name="thisConfirm" type="string">Starts with this</param>
    /// <returns>Submits Form 'GoToForm'</returns>

    if (thisConfirm != null && thisConfirm != "")
		if (confirm(thisConfirm) == false)
			return(false);

	document.getElementById("idGoToID").name=thisIDName;
	document.getElementById("idGoToID").value=thisURN;
	document.getElementById("idGoToSERVICE").value=serviceCode;
		
	if (thisAction!=null)
		document.getElementById("GoToForm").action=thisAction;

	if (com.travelpower.SSLPostBackTo != "")
		document.getElementById("GoToForm").action = com.travelpower.SSLPostBackTo;
	
	document.getElementById("GoToForm").submit();
}
function gfNavigateSetURN(thisURN, thisIDName) 
{
    /// <summary>Navigate To</summary>
    /// <param name="thisURN" type="string">The URN</param>
    /// <param name="thisIDName" type="string">The Id</param>
    /// <returns>NULL</returns>

	if (thisIDName)
		document.getElementById("idNavigationFormURN").name=thisIDName;
		
	document.getElementById("idNavigationFormURN").value=thisURN;
	
}
function gfNavigateTo(serviceCode, thisAction)
{
	if (com.travelpower.ConfirmNavigation()==false)
		return(false);
	
	var lDefaultAction = document.getElementById("NavigationForm").action;
	
	document.getElementById("idNavigationFormSERVICE").value=serviceCode;
		
	if (thisAction!=null)
		document.getElementById("NavigationForm").action=thisAction;

	if (com.travelpower.SSLPostBackTo != "")
		document.getElementById("NavigationForm").action = com.travelpower.SSLPostBackTo;
	
	document.getElementById("NavigationForm").submit();
	document.getElementById("NavigationForm").action=lDefaultAction;
}
function gfQuickLinkTo(serviceCode, thisAction)
{
	try
	{
		if (document.getElementById("idInQuickLink").value=="Y")
		{
			document.getElementById("idInQuickLink").value="N";
			return(true);
		}
		document.getElementById("idInQuickLink").value="Y";
	}
	catch(er) {}
	
	document.NavigationForm.SERVICE.value=serviceCode;

	if (thisAction!=null)
		document.NavigationForm.action=thisAction;

	if (com.travelpower.SSLPostBackTo != "")
		document.NavigationForm.action = com.travelpower.SSLPostBackTo;
	
	document.NavigationForm.submit();
}
function gfSetVisibleTab(thisTab)
{
	//alert("gfSetVisibleTab:"+thisTab);
	if (document.getElementById("idVisibleTab").value=="")
		document.getElementById("idVisibleTab").value=thisTab;
	else
	{
		var l_VisibleTab=document.getElementById("idVisibleTab").value;
		document.getElementById("idVisibleTab").value=thisTab;
		gfShowTab(l_VisibleTab);
	}
}
function gfShowTab(thisTab)
{
	//alert("gfShowTab:"+thisTab);
	if (document.getElementById("idVisibleTab").value!="")
	{
		var OldTab=document.getElementById("idVisibleTab").value;
		document.getElementById(OldTab).style.display="none";
		document.getElementById(OldTab+"Left").className="TabsTableItemLeft";
		document.getElementById(OldTab+"Right").className="TabsTableItemRight";
	}
	document.getElementById("idVisibleTab").value=thisTab;
	document.getElementById(thisTab).style.display="inline";
	document.getElementById(thisTab+"Left").className="TabsTableItemLeftOn";
	document.getElementById(thisTab+"Right").className="TabsTableItemRightOn";
}

function gfSetIdHelpHTML()
{
	//alert(window.event.srcElement.id);
	if (window.event)
	{
		try { gfSetHelpHTML(window.event.srcElement.id); }
		catch (er)
		{
			try { document.getElementById("idSpanHelpText").innerHTML = ""; }
			catch (er1) { }
		}
	}
}
function gfSetHelpHTML(thisField)
{
	var StatusText="";
	com.travelpower.Control = document.getElementById(thisField + "Help");
	if (com.travelpower.Control != null)
		StatusText = com.travelpower.Control.innerHTML;

	if (StatusText == "")
	{
		com.travelpower.Control = document.getElementById(thisField.substring(0,thisField.length-3) + "Help");
		if (com.travelpower.Control != null)
			StatusText = com.travelpower.Control.innerHTML;
	}
	
	//alert(thisField.substring(0,thisField.length-3)+"Help");

	com.travelpower.Control = document.getElementById("idSpanHelpText");
	if (com.travelpower.Control != null)
		com.travelpower.Control.innerHTML=StatusText;
	
	StatusText="";

	com.travelpower.Control = document.getElementById(thisField + "Status");
	if (com.travelpower.Control != null)
		StatusText = com.travelpower.Control.innerHTML;
	
	window.status=StatusText;
	
	return(true);
}
function gfSetStatus(thisText)
{
	window.status=thisText;
	if (document.getElementById("idSpanHelpText"))
	{
		try {document.getElementById("idSpanHelpText").innerHTML="&bull;&nbsp;"+thisText;}
		catch(er) {}
	}
	return(true);
}
function gfClearStatus()
{
	window.status="";
	if (document.getElementById("idSpanHelpText") && document.getElementById("idDefaultHelp"))
	{
		try {document.getElementById("idSpanHelpText").innerHTML=document.getElementById("idDefaultHelp").innerHTML;}
		catch(er)
		{
			try {document.getElementById("idSpanHelpText").innerHTML="";}
			catch(er) {}
		}
	}
	return(true);
}

var AgentCommVisible="none";
function mfToggleAgentComm()
{
	if (AgentCommVisible == "none")
	{
		AgentCommVisible = "inline"
	}
	else
	{
		AgentCommVisible = "none"
	}

	document.getElementById("idRowAgentComm").style.display=AgentCommVisible;

	try {document.getElementById("idRowAgentVATOnComm").style.display=AgentCommVisible}
	catch (er) {}
	
	try {document.getElementById("idRowBalanceAmount").style.display=AgentCommVisible}
	catch (er) {}
	
}

//alert("OuterMaintenance.js");

