function setStatus(msg)	{
	status=msg;
	return true;
}

var appWindow = null

function CreateMainWindow(form) {
	if (!IsJavaEnabled()) {
		var download = window.confirm("Your browser currently does not support Java Applets.  Click 'OK' and then 'Open' to download and install this component or 'Cancel' to exit.");		
		if ((download) && (form.jvmlocation)) {
			window.location = form.jvmlocation.value;
			return false;
		}
		else if (download) {
			window.location = "http://www.download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/MSJavWU_8073687b82d41db93f4c2a04af2b34d.exe";
			return false;
		}
	}

	form.action = "https://marjack.reactornet.com/cgi-bin/secure.cgi/admin/mainmenu";
	document.Login.loginname.value = form.name.value;
	document.Login.loginpassword.value = form.password.value;
	
	var ok = VerifyForm(form)
	
	if (ok && (!appWindow || appWindow.closed)) {
		form.name.value = "";
		form.password.value = "";
		
		var avail_width = screen.availWidth - 10;
		var avail_height = screen.availHeight - 93;
				
//		appWindow = window.open("","MainApp", "location,menubar,toolbar,scrollbars,resizable,status,width="+avail_width + ",height=" + avail_height + ",top=0,left=0");

//		document.Login.target = "MainApp";
		document.Login.submit();

//		appWindow.opener = null;		
	}
	else if (ok) {
		form.name.value = "";
		form.password.value = "";
		document.Login.target = "MainApp";
		document.Login.submit();
		appWindow.focus();		
	}
}

function VerifyForm(form) {
  if (document.Login.loginname.value == "")
  {
    alert("Please enter a value for the Username field.");
    form.name.focus();
    return (false);
  }

  if (document.Login.loginname.value.length < 5)
  {
    alert("Please enter at least 5 characters in the Username field.");
    form.name.focus();
    return (false);
  }

  if (document.Login.loginname.value.length > 20)
  {
    alert("Please enter at most 20 characters in the Username field.");
    form.name.focus();
    return (false);
  }

  var checkOK = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ. ";
  var checkStr = document.Login.loginname.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
	alert("The following character in your Username is invalid: " + ch);
    	form.name.focus();
    	return (false);
    }
  }

  if (document.Login.loginpassword.value == "")
  {
    alert("Please enter a value for the Password field.");
    form.password.focus();
    return (false);
  }

  if (document.Login.loginpassword.value.length < 4)
  {
    alert("Please enter at least 4 characters in the Password field.");
    form.password.focus();
    return (false);
  }

  if (document.Login.loginpassword.value.length > 8)
  {
    alert("Please enter at most 8 characters in the Password field.");
    form.password.focus();
    return (false);
  }

  return (true);
}


function IsJavaEnabled() {
	if (navigator.javaEnabled()) {
		return true;
	}
	return false;
}
