var winHelp;
var sysname='Learning Place';
function openHelp (page,winName,opts) {
                winHelp=window.open(page,winName,opts);
                winHelp.focus();
                return false;}

function closeHelp () {
                if (winHelp && !winHelp.closed) {
                        winHelp.close();
                        return true;}
                return false;}
function detect_js()
{
    if (document.forms)
    for (i=0;i<document.forms.length;++i)
        for (j=0;j<document.forms[i].length;++j)
        {
            thing = document.forms[i][j];
            if (thing.name == 'jscp')
                thing.value = '1';
        }
}
    var errors;    function validatePass(thing){
            if (thing.value.indexOf(' ') != -1)
            errors += 'Passwords cannot contain spaces\n';
    }
function validateLogin(frm)
{
    errors = '';
    var banner='Can\'t Log in to ';
    var legal ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@.-_';
    var illegalch = '';
    for (j=0;j<document.forms[frm].length;++j)
    {
        thing = document.forms[frm][j];
         if (thing.name == 'username')
        {
            if (thing.value.length == 0)
            errors += 'You must enter your username\n';
            if (thing.value.length < 2)
            errors += 'Usernames must be at least 2 characters\n';
            for (i=0;i<thing.value.length;++i)
            {
                if (legal.indexOf(thing.value.charAt(i))==-1)
                    illegalch += thing.value.charAt(i);  
            }
            if (illegalch.length) 
            {
                errors += 'Username contains illegal character(s)\n';
                errors += '\'' + illegalch +'\'\n';
            }
        }
        if (thing.type == 'password')
        {
            if (thing.value.length == 0)
            errors += 'You must enter your password\n';
            if (thing.value.length < 3)
            errors += 'Passwords must be at least 3 characters\n';
            if (thing.value.length > 16)
            errors += 'Passwords must be no more than 16 characters\n';
            validatePass(thing);
        }
    }
    if (errors.length)
    {
        alert(banner + sysname +':\n' + errors);
//		  return(false);
    }
    else
	 document.forms[frm].submit();
	 // return(true);
}
function entersubmit(e) {
  var whichcode = 0;
  var MSIE = 0;
  if (window.event){
    MSIE=1;whichcode=window.event.keyCode;
  }
  else
  {whichcode=e.which;}

   if (whichcode == 13)
   {
     if(!MSIE)
       validateLogin(e.target.form.name);
     else
       validateLogin(e.srcElement.form.name);
     return false;
    }
    else
      return true;
}
function partners(){window.open('/learner/view_partners_page.php?sess_key=SYS_GUEST','partners','width=268,height=400,menubar=no,location=no,resizeable=no,titlebar=no,scrollbars=yes');}

function popup(earl,title,sx,sy){window.open(earl,title,'width='+sx+',height='+sy+',menubar=0,location=0,resizable=1,titlebar=0,scrollbars=1');
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

