window.history.forward(1);

//
// ifSubmitFormNoFrame - a no frame version of the ifSubmitForm flag
//
var ifSubmitFormNoFrame = false;


//Reset the Flag that control double click prevention and ensure http request sent one after one
if(parent != null && parent.ifSubmitForm != null) 
{ 
	parent.ifSubmitForm = "no";
} 

//Turn the control flag on to prevent double click and multiple http request at a time
function setHttpReqCrtlFlg()
{
	if(parent != null && parent.ifSubmitForm != null)
	{
		parent.ifSubmitForm = "yes";
	}
}

//When hyperlink is clicked, set control flag and replace location
function chgLocation(link)
{
	setHttpReqCrtlFlg();
	location.replace(link);
	return;
}

//When a form, inputForm, is about to be sent, set control flag if the reqType is "Y"
//and submit form
function formSubmit3(reqType)
{
	if(document != null && document.inputForm != null)
	{
		if(reqType == "Y")
		{
			setHttpReqCrtlFlg();
		}
      	document.inputForm.submit();
	}
      return;
}

//When a form, inputForm, is about to be sent, set control flag and submit form
function formSubmit()
{
	if(document != null && document.inputForm != null)
	{
		setHttpReqCrtlFlg();
      	document.inputForm.submit();
	}
      return;
}

//When a form, inputForm1, is about to be sent, set control flag and submit form
function form1Submit() 
{
	if(document != null && document.inputForm1 != null)
	{
		setHttpReqCrtlFlg();
		document.inputForm1.submit();
	}
      return;
}

//When a form, inputForm, is about to be sent, set control flag and submit form
function formSubmit2(id)
{
  parent.nav.location="/servlet/com.hsbc.ebank.app.hib.base.MenuServlet?id=" + id + "";
  setHttpReqCrtlFlg(); 
  document.inputForm.submit();
  return;
}

//Check the control flag status
function checkIfSubmittedForm()
{
  if(parent != null && parent.ifSubmitForm != null && parent.ifSubmitForm=="yes")
  {
    return true;
  }
  else
  {
    return false;
  }
}


//
// checkIfSubmittedFormNoFrame - check the ifSubmittedForm flag for pages with no frames
//   return - true if the form is submitted, false otherwise
//
function checkIfSubmittedFormNoFrame()
{
    return ifSubmitFormNoFrame;
}


//
// setIfSubmittedFormNoFrame - set the ifSubmittedForm flag value for no frame pages
//   flag - true if the form is submitted, false otherwise
//
function setIfSubmittedFormNoFrame(flag)
{
    ifSubmitFormNoFrame = flag;
}


//
// inputFormSubmitNoFrame - no frame version of formSubmit. It checks if the form is submited
//                          if not, set the flag and trigger the inputForm submission. 
//
function inputFormSubmitNoFrame()
{
    if (!checkIfSubmittedFormNoFrame())
    {
        setIfSubmittedFormNoFrame(true);
        document.inputForm.submit();
    }

    return;       // this to avoid any redirection of the hyperlink
}


//
// formSubmitNoFrame - form submit with an argument. This one should be used in forms that are
//                     not named inputForm and no frame situation
//   form - the form to carry out the submission
//
function formSubmitNoFrame(form)
{
    if (!checkIfSubmittedFormNoFrame())
    {
        setIfSubmittedFormNoFrame(true);       
        form.submit();
    }
}


//
// chgLocationNoFrame - this is for hyperlinks on no frame pages. It checks the form submit
//                      flag before doing the redirection.
//   link - the link to be redirected to
//
function chgLocationNoFrame(link)
{
    if (!checkIfSubmittedFormNoFrame())
    {
        setIfSubmittedFormNoFrame(true);
        location.replace(link);
    }

    return;       // this to avoid any redirection of the hyperlink
}

//
// showPopupNoFrame - check the form submit flag and carry out a function
//                    in a frameless page
//   popup - the name of the popup function
//   args - the rest of the arguments will be used to call that popup function
//   return - true if the form is not previously submitted, false otherwise
//
function showPopupNoFrame(popup)
{
    if (!checkIfSubmittedFormNoFrame())
    {
        var args = showPopupNoFrame.arguments;
        var popupArgs = new Array(args.length);

        // trim the first argument from the argument list
        for (i = 0; i < args.length - 1; i++)
        {
            popupArgs[i] = args[i + 1];
        }

        // apply the popup function if with the argument list
        popup.apply(this, popupArgs);
     
        return true;
    }
    return false;
}



function click1(e)
{
	if (document.all)
	{
		if (event.button == 2)
		{ 
			alert(message); 
			return false; 
		} 
	} 
	if (document.layers) 
	{ 
		if (e.which == 3) 
		{ 
			alert(message); submitForm = "no"; 
 			return false; 
		} 
	} 
}

function click2(e) 
{ 
	if (e.which == 3) 
	{ 
		alert(message); 
		return false; 
	} 
} 

var s = navigator.appVersion; 
var len = s.length; 
var t = s.substring (0, 3); 
var ver = parseFloat(t); 

if ( (navigator.appName == "Netscape") && (ver >=5)) 
	document.onmouseup=click2; 
else 
	document.onmousedown=click1;

// code for disabling Enter Key
if (navigator.appName == "Netscape")
{
    window.onfocus = function()
    {
        if (document.inputForm)
        {
            for (var i = 0; i < document.inputForm.length; i++)
            {
                document.inputForm[i].onkeypress = function(e)
                {
                    var c = document.layers ? e.which : document.all ? event.keyCode : e.keyCode;
                    if (c == 13 || c == 3) return false;
                };
            }
        }
        window.onfocus = null;
    };
}
else
{
    document.onkeypress = function(e)
    {
        var c = document.layers ? e.which : document.all ? event.keyCode : e.keyCode;
        if ((document.activeElement.type == "text" || document.activeElement.type == "password") && (c == 13 || c == 3)) return false;
    };
}

