﻿function OnSubmitForm(HTTPSPort)
{
  if (document.pressed == 'LOGIN BUTTON')
  {
		var url = window.location.href;
		var hostIndex = url.indexOf(':') + 3;
		var host = url.substring(hostIndex, url.indexOf('/', hostIndex));
		
		var portIndex = host.indexOf(':') // remove any port number from the host name
		if (portIndex > -1)
		{
			host = host.substring(0, portIndex);
		}
		
		if (HTTPSPort != '')
		{
			host += ':' + HTTPSPort;
		}
		var newURL = 'https://' + host + url.substring(url.indexOf('/', hostIndex));
		document.aspnetForm.action = newURL;
  }
  return true;
}