//  form validation stuff, taken from apple

// email

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

// non-empty textbox

function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = strng+"\n"
  }
return error;	  
}

function getRandNum(high)
{
	return Math.floor(Math.random() * high);
}

var infowin = null;

function newPopWin(url,w,h)
{
  infowin = window.open("","","scrollbars=yes,top=20,left=20,width=" + w + ",height=" + h);
  if (infowin != null)
  {
    infowin.location.href = url;
// is the window.focus method supported by this verison of javascript
// if so, then do it.
    if (window.focus)
    {
       infowin.focus();
    }
  }
// return true;
}

function closePopWin()
{
  if (infowin != null && infowin.open) infowin.close();
// return true;
}                                           

var NewWindow;
function ProfilePop(username) {
	NewWindow = window.open("https://gremlin.bc.edu/faculty/profile.page/FACPROF_ITEMID="+username,"popupwin","width=680,height=450,left=0,top=50,resizable=yes,scrollbars=1,toolbar=1,location=0,favorites=0, status=1, bookmarks=1");
}
// this function tests to see if the new window is open and if it is it brings it to the front

function test_for_newwindow() {
	if (!NewWindow || NewWindow.closed) return;
	else 
		NewWindow.focus();
}
