function submission(what)
{
    document.PINForm.dowhat.value=what

 	// if(what=='clearform')
    	// Help('pincache.html')
    document.PINForm.submit()
    return false
}

function printPage()
{
	document.PINForm.dowhat.value='display'	
	document.PINForm.state.value='105'
	document.PINForm.submit()
}

function getPage(szType)
{
	if(szType == 1 || szType == null)
	{
		szType = '';
	}
	document.PINForm.dowhat.value='exit' + szType	
	document.PINForm.submit()
}


function pinSubmit(dothis)
{

    document.PINForm.doThis.value=dothis

 	if(dothis=='clearform')
    	Help('pincache.html')


    document.PINForm.submit()
    return false
}

var clHandleHelp = null  // handle for the help window
// open a help file
function Help(szHelp) {
	var szFile
	var szWinFeatures = "status=yes,resizable=yes,scrollbars=yes,width=400,height=375"
	var szErrMsg  = "\nYour web browser have failed to open a separate window "
		szErrMsg += "\nto display the help document.  Please close all unused "
		szErrMsg += "\nbrowser windows, and try again."

	if (szHelp)
		szFile = "/help/" + szHelp   // open with a given file
	else
		szFile = "/help/pintoc00.htm"  // by default, open the help content file

	// Netscape Navigator allows to open only 100 windows at the maximum
	// recycle the existing one to avoid exceeding the limit (R.L.)
	if (clHandleHelp) {
		if (!clHandleHelp.closed)    // if help window not closed
			clHandleHelp.location.href = szFile
		else
			clHandleHelp = window.open(szFile, 'help', szWinFeatures)
	} else
		clHandleHelp = window.open(szFile, 'help', szWinFeatures)

	// check if new window failed to open
	if (clHandleHelp)
		clHandleHelp.focus()
	else
		alert(szErrMsg) // this is an extremely rare case, if it ever happens.
}
function PIN(szHelp) {
	var szFile
	var szWinFeatures = "status=yes,resizable=yes,scrollbars=yes,width=600,height=500"
	var szErrMsg  = "\nYour web browser have failed to open a separate window "
		szErrMsg += "\nto display the help document.  Please close all unused "
		szErrMsg += "\nbrowser windows, and try again."

		szFile = szHelp   // open with a given file

	// Netscape Navigator allows to open only 100 windows at the maximum
	// recycle the existing one to avoid exceeding the limit (R.L.)
	if (clHandleHelp) {
		if (!clHandleHelp.closed)    // if help window not closed
			clHandleHelp.location.href = szFile
		else
			clHandleHelp = window.open(szFile, 'help', szWinFeatures)
	} else
		clHandleHelp = window.open(szFile, 'help', szWinFeatures)

	// check if new window failed to open
	if (clHandleHelp)
		clHandleHelp.focus()
	else
		alert(szErrMsg) // this is an extremely rare case, if it ever happens.
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
  	x.src=x.oSrc;
}

function MM_preloadImages()
{ //v3.0
  var d=document;
  if(d.images)
  {
  	if(!d.MM_p)
  		d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
    for(i=0; i<a.length; i++)
    	if (a[i].indexOf("#")!=0)
    	{
    		d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
    	}
   }
}

function MM_findObj(n, d)
{ //v3.0
  var p,i,x;
  if(!d)
  	d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all)
  	x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++)
  	x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
  	x=MM_findObj(n,d.layers[i].document);

  return x;
}

function MM_swapImage()
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr=new Array;
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null)
   {
   		document.MM_sr[j++]=x;
   		if(!x.oSrc)
   			x.oSrc=x.src;
   		x.src=a[i+2];
   }

 }
function SetFocus(szField)
{
	if (szField) {
		if (szField.type.indexOf("select") < 0)
			szField.select();
		szField.focus();
	} else {
		with (document.PINForm) {
			for (var i=0; i<length; i++) {
				if (elements[i].type == "text"		|| 
					elements[i].type == "textarea" 	||
					elements[i].type == "password" 	|| 
					elements[i].type == "file") {
					elements[i].focus();
					elements[i].select();
					break;
				} else if (elements[i].type.indexOf("select") >= 0) {
					elements[i].focus();
					break;
				}
			}
		} 
	}
}

function InitForm(clVar, szErrMsg, bAlert)
{

	if(!bAlert)
	{
		alert("The browser is using less than a 128-bit encryption level. While this level of encryption is acceptable, we recommend that you use the 128-bit encryption level to increase the security of the application information.");
	}
	if (szErrMsg != null && szErrMsg != '')
	{
		alert(szErrMsg);
		if (clVar != null)
		{
			SetFocus(clVar);
		}
	}
	else
	{
		SetFocus();
	}

}

// Redirect 02-03 eSAR e-mail links to Student Access
function ePINRedirect()
{
	var servlet = "PINWebApp/PINServlet"
	var pinkey = window.location.search
	if (pinkey.length < 2)
	{
		document.PIN.szFILE.value = servlet + "?state=710"
	}
	else
	{
		document.PIN.szFILE.value = servlet + "?state=710&" + pinkey.substring(1); 
	}
		
	document.PIN.submit()
}

function Print() {
	// CM 3183
	// R.L. 12/27/00
	// The 0102 cycle uses hyperlink that can not invoke the print function on Mac.
	// So display message instead.
	if (navigator.userAgent.toLowerCase().indexOf("mac") >= 0) {
		alert("Please select File/Print... from your browser's menu, or press shortcuts Ctrl+P.")
		return;
	}


	if (window.print) {
		// NN 4.x and IE 5.x browsers use the built-in print function
		window.print();
	} else 	{
		if (document.all) {
			// IE 4.x browsers use the bultin-in WebBrowser control
			document.body.insertAdjacentHTML("beforeEnd", "<object id=\"printWB\" width=0 height=0 classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\"></object>");

			execScript("on error resume next: printWB.ExecWB 6, 1", "VBScript");
			printWB.outerHTML = "";
		} else {
			// NN 3.x or other unsupported browser
			alert("Please select File/Print... from your browser's menu, or press shortcuts Ctrl+P.")
		}
	}
}
