
//function check()             mm 9-21
// {                            mm 9-21
//  if (alreadyclick == true) {return false;}   mm 9-21
//  with(document.forms[0]) {    mm 9-21
        
//  }                            mm 9-21
//  alreadyclick = true;         mm 9-21
//  return true                  mm 9-21  
// }                             mm 9-21


function openNewWin(strPath, strAppName)
 {
  window.open(strPath+strAppName+'.htm',strAppName,
'toolbar=0,directories=0,location=0,scrollbars=1,resizable=1')
}

function Go(str)
{
//alert("HI in go, str=" + str);
//alert("pf_key=" + top.app.document.forms[0].MY_PFKEY.value);
 if  (top.app.document.forms[0].MY_PFKEY.value != '32')
   {top.app.document.forms[0].MY_PFKEY.value=str
// mm added app below 11/13
  top.app.PWCSubmit();}
  
}



function ReadCook() {
	var Induser = document.cookie.indexOf("@pwc@");
	var IndEnduser = document.cookie.indexOf(" ");
	var Indpasswd = document.cookie.indexOf("@pwc@", Induser+5);

	MyUser = document.cookie.substring(Induser+5, Indpasswd);
	if (IndEnduser != -1)
		if (IndEnduser < Indpasswd)
			MyUser = document.cookie.substring(Induser+5, IndEnduser);


	MyPasswd= document.cookie.substring(Indpasswd+5);

	if (MyUser == "") MyUser = "." ;
	if (MyPasswd == "") MyPasswd = "." ;

}


function UpdatePosCursor (aObjectText) {
  top.app.document.forms[0].MYCURSOR.value = aObjectText.name;
}

function SetPosCursor () {
  var thetype = eval( "top.app.document.forms[0]."+ top.app.document.forms[0].MYCURSOR.value +".type;");
 //mm 731 if (thetype && thetype!="hidden")
 //mm 731   eval( "top.app.document.forms[0]."+ top.app.document.forms[0].MYCURSOR.value +".focus();");
}

function DisplayError () {
  if (top.app.document.forms[0].MYERRORS.value != "")
        alert(top.app.document.forms[0].MYERRORS.value);
}

function PWCLoad()
{
//alert("hi in pwcload");
  var today = new Date();
  top.app.document.onsubmit=PWCSubmit;

  if (navigator.appName != "Netscape")
        top.app.document.onkeypress = PWCKeyPressed;

  else
  {
	top.app.document.captureEvents(Event.KEYPRESS);
	top.app.document.onKeyPress = PWCKeyPressed;
 } 
   
// mm  top.app.document.forms[0].action='/cgi/perl.exe?cgicgi.pl%20' + today.getTime() + // mm '%20PROBATEWEB%20.%20.%20localhost';
top.app.document.forms[0].action='../../../cgi/cgicgi.pl?TimeStamp=' + today.getTime() + "&Monitor=" + top.myMonitor  + "&Server_Name=localhost";	 
	
// mm  top.app.document.forms[0].action='/cgi/cgicgi.pl';

  top.SetPosCursor();
  top.DisplayError();
// added app below 11/13
  top.app.PWCLoadA();
  top.app.PWCSCRLoadA();
}

function PWCUnload()
{
//alert("in pwcunload");
  top.app.PWCSCRUnloadB();
// mm added app below 11/13
  top.app.PWCUnloadB();
}

function PWCChange(objet)
{

//alert("in pwcchange" + objet);
  top.app.PWCSCRChangeB(objet); 
  //top.PWCChangeB(objet); mm 7-12

  //top.PWCChangeA(objet); mm 7-12
  top.app.PWCSCRChangeA(objet);
} 

function PWCKeyPressed(e)
{

  top.app.PWCSCRKeyPressedB(e);
//mm added app below 11/13
  top.app.PWCKeyPressedB(e);

  var wKeyCode;
  top.app.PWCSCRKeyPressedB(top.app.event);
  if (navigator.appName == "Netscape")
    wKeyCode = e.which;
  else
    wKeyCode = top.app.event.keyCode;
//mm 9-20-06 changed en to 32 below

   if (wKeyCode == 13) 
{
 
   top.Go('32');
}
}

function PWCSubmit()
{
//alert("HI in pwcsubmit");
   top.app.PWCSCRSubmitB();

 // top.PWCSubmitB(); mm7-12
//top.app.PWCSubmitB();


//  if (top.app.check() == true)   mm 9-21
//   {

    top.app.document.forms[0].submit();
 
//  }
}

var gTrace="";
function TraceInit()
{
top.gTrace = "";
}

function Trace(sTrace)
{
	var wToday = new Date();
	if ((top.gTrace.length + sTrace.length) > 20000)
		top.gTrace = top.gTrace.substr(top.gTrace.length-10000);
	top.gTrace += wToday.getMinutes() + ":" + wToday.getSeconds() + ">" + sTrace + "<BR>";
}

function TraceView()
{
msgWindow=window.open("","displayWindow",'menubar=1, resizable=1,scrollbars=1');
msgWindow.document.write
      ("<HTML><HEAD><TITLE>Trace</TITLE></HEAD><BODY bgcolor=white>Trace<BR>");
msgWindow.document.write("<code>" + top.gTrace + "</code>");
msgWindow.document.write
      ("</BODY></HTML>");
}

function setChoice(xchoice)
{
top.app.document.forms[0].XAACHO_990101.value = xchoice;
// alert (top.app.document.forms[0].XAACHO_990101.value);
}

function setChoice0(xchoice)
{
top.app.document.forms[0].XAACHO_000101.value = xchoice;
//alert (top.app.document.forms[0].XAACHO_000101.value);
}


function chgsTonext(scrollmsg)
{
var enextValue;

   {
   breakout:
   switch (scrollmsg)
    {
    case "F9=MORE":
    case "F9-SCROLL":
    case "F9&nbsp;MORE":
    case "F9&nbsp;=&nbsp;MORE": 
       enextValue = "Next >";
       break breakout;
    case "undefined":
    case "":
       enextValue = " ";
       break breakout;
     }
    }
return enextValue;
}

// jssi
function copyData (choice, docket, charge, indictment, ticket, aragency, escrow, rni, attorney)
{
//alert("in copydata");

	// This function copies data passed to it to the 7 input fields on the form in the right frame.
	// The form in the RF has these 7 fields as "hidden", so they are not available to the user
	// Values that are not passed to this function are initialized to empty.
	// alert ("in senddata");


	if (typeof choice == "undefined")
		choice = '';
	if (typeof docket == "undefined")
		docket = '';
	if (typeof charge == "undefined")
		charge = '';
	if (typeof indictment == "undefined")
		indictment = '';
	if (typeof ticket == "undefined")
		ticket = '';
        if (typeof aragency == "undefined")		 
                aragency = ''; 
	if (typeof escrow == "undefined")
		escrow = '';
	if (typeof rni == "undefined")
		rni = '';
        if (typeof attorney == "undefined") 
                attorney = '';
	//if (top.mainDisplayed == true)		// DC	mm 7-14
	//	frm = top.document.appForm
	//else
	//{
	//	alert ("in copyData, this should not happen");	//since we should always copy to RF form
	//	frm = top.app.document.appForm;
	//}

          frm = top.app.document.appForm;
//mm

	for (var i = 0; i < frm.length; i++)
	{
		//alert (frm [i].name + "->" + frm [i].value);
		with (frm [i])
		{
		  if ((name != "PACBASEID") && (name != "MY_PFKEY") && (name != "MYCURSOR") && (name != "OK"))
      		    {

			if (name.search ("XAACHO_") >= 0)
				value = choice;
			else if (name.search ("XBKMNOC") >= 0)
				frm [i].value = docket;	
			else if (name.search ("XCTMCGC") >= 0)
				frm [i].value = charge;
			else if (name.search ("XCRMINC") >= 0)
				frm [i].value = indictment;
			else if (name.search ("XTTMTNC") >= 0)
				frm [i].value = ticket;
            else if (name.search ("XCICAAC") >= 0) 
                frm [i].value = aragency;
			else if (name.search ("XGEMESC") >= 0)
				frm [i].value = escrow;
			else if (name.search ("XRIMNO1") >= 0)
				frm [i].value = rni;
            else if (name.search ("XAAMATC") >= 0)
				frm [i].value = attorney;

			else
			{
				//alert (name + ":" + value);
				frm [i].value = "";
			}
		   }
		}
	}

}

function parseSession (sessionValue)
{
	//alert ("in parsesession:" + sessionValue + "a");
	var sessionTm = "";
	if (typeof(sessionValue) != "undefined")
	{
		switch (sessionValue)
		{
			case "1":
				sessionTm = "9:00 a.m.";
				break;
			case "2":
				sessionTm = "1:30 p.m.";
				break;
			case "3":
				sessionTm = "10:30 a.m.";
				break;
			case "undefined":
			case "":
			case " ":
				//alert ("in parsesession:" + sessionValue + "b");
				sessionTm = " ";	
				break;
			default:
				//alert ("in parsesession:" + sessionValue + "c");
				sessionTm = sessionValue;
		}
	}
	//alert (sessionTm);
	return sessionTm;
}

function parseOffenseClass (classValue)
{
	//alert ("in parseOffenseClass:" + classValue);
	var offense;
	switch (classValue)
	{
		case "M":
			offense = "MISDEMEANOR";
			break;
		case "F":
			offense = "FELONY";
			break;
		case "C":
			offense = "CITY ORDINANCE";
			break;
		case "O":
			offense = "COUNTY ORDINANCE";
			break;
		case "A":
			offense = "ARLINGTON CITY ORDINANCE";
			break;
		case "L":
			offense = "LAKELAND ORDINANCE";
			break;
		case "I":
			offense = "CIVIL";
			break;
		case "V":
			offense = "DOMESTIC VIOLENCE";
			break;
		case "undefined":
		case "":
			offense = "";	
			break;
		default :
			offense = classValue;
	}
	return offense;
}


function parseStatus(classValue)
{
	var status;
	switch (classValue)
	{
		case "O":
			status = "ACTIVE - OPEN FOR WORK";
			break;
		case "R":
			status = "ACTIVE - RESEARCH REQUIRED";
			break;	
		case "D":
			status = "ACTIVE - DEAD END";
			break;
		case "J":
			status = "ACTIVE - OFFENDER IN JAIL BUT WARRANT NOT PROCESSED";
			break;
		case "A":
			status = "INACTIVE - OFFENDER ARRESTED";
			break;
		case "C":
			status = "INACTIVE - COURT RECALLED";
			break;
		case "X":
			status = "INACTIVE - CANCELED,DELETED,EXPIRED";
			break;			
		case "undefined":
		case "":
			status = "";	
			break;
		default :
			status = classValue;
	}
	return status;
}


function parseResetReason(resetcode)
{
	var resetreason;
	switch (resetcode)
	{
		case "A2":
			resetreason = "ARRAIGNMENT2";
			break;
		case "AR":
			resetreason = "ARRAIGNMENT";
			break;	
		case "AT":
			resetreason = "ATTORNEY";
			break;
		case "AY":
			resetreason = "ATTORNEY FIRST APPEARANCE";
			break;
		case "BS":
			resetreason = "BOND SURRENDER";
			break;
		case "BW":
			resetreason = "BENCH WARRANT";
			break;
		case "CH":
			resetreason = "CONTEMPT HEARING";
			break;
                case "CB":
			resetreason = "SET ASIDE CF RECALL BW";
			break;
                case "CD":
			resetreason = "SET ASIDE CF";
			break;	
                case "CM":
			resetreason = "COMPLIANCE";
			break;	
                case "D1":
			resetreason= "APPLICATION FOR DIVERSION";
			break;
                case "D2":
			resetreason = "END OF DIVERSION";
			break;		
                case "DD":
			resetreason = "DEFENSIVE DRIVING SCHOOL";
			break;
                case "DP":
			resetreason = "DISPOSITION";
			break;		
		case "DT":
			resetreason = "DRUG TREATMENT PROGRAM";
			break;	
                case "FA":
			resetreason = "FINAL SETTING FOR ATTORNEY";
			break;	
                case "FC":
			resetreason = "FINAL COMPLIANCE";
			break;	
                case "FD":
			resetreason = "FINAL SETTING FOR DISPOSITION";
			break;	
                case "FF":
			resetreason = "FINAL FORFEITURE";
			break;	
                case "FP":
			resetreason = "FAIL TO PAY FINE";
			break;	
                case "FR":
			resetreason = "FINAL SETTING FOR REPORT";
			break;	
                case "ME":
			resetreason = "MENTAL EVALUATION";
			break;	
                case "MO":
			resetreason = "MOTION";
			break;
                case "MT":
			resetreason = "MISTRIAL";
			break;	
                case "PE":
			resetreason = "PETITION TO REVOKE";
			break;	
                case "PH":
			resetreason = "PRELIMINARY HEARING";
			break;	
                case "PL":
			resetreason = "GUILTY PLEA";
			break;	
                case "PS":
			resetreason = "PET TO SUSP REM SENTENCE";
			break;	
                case "RP":
			resetreason = "REPORT TO COURT";
			break;
                case "SA":
			resetreason = "SET ASIDE";
			break;	
                case "SN":
			resetreason = "SENTENCING";
			break;	
                case "TR":
			resetreason = "TRIAL";
			break;	
                case "VB":
			resetreason = "VIOLATION OF BAIL CONDITIONS HEARING";
			break;	
                case "VO":
			resetreason = "VIOLATION OF PROTECTION ORDER HEARING";
			break;
                case "VP":
			resetreason = "VOP HEARING";
			break;	
                case "VR":
			resetreason = "VIDEO ARRAIGNMENT";
			break;		 	 	   		
		case "undefined":
		case "":
			resetreason = "";	
			break;
		default :
			resetreason = resetcode;
	}
	return resetreason;
}
// Handle the error message
function handleError (errorMessage, javaError)
{
	//alert (errorMessage);
	return errorMessage;
  
}

function openHelp(screen, fld){
	// This function opens a help window and displays the help associated with a screen
	// Parameters: 
	//	screen: name of the screen whose help is to be invoked
	//	fld: is an optional parameter, and if specified, the screen help will be 
	// 	positioned on that field.

	var hrefValue;

	//alert ("help fld:" + fld + ", helpLoaded:" + parent.helpLoaded);
	if (typeof screen == "undefined")
		screen = "JSMENU";

	helpDir = "/help/";
	helpHTM = "JSI_help_" + screen;

	if (parent.helpLoaded == false)
	{
		//help window has not been opened yet
		//alert ("help was not loaded");
		helpWin = openHelpWin(helpDir, helpHTM);
	}
	else
	{
		// Check if the window is truly open, before displaying the correct help page
		if (eval(helpWin))
		{
			if (helpWin.closed)
			{
				//alert ("help win not open");
				helpWin = openHelpWin(helpDir, helpHTM);
			}
			else
			{
				//alert ("help win open, loading correct page");
				hrefValue = helpDir + helpHTM + ".htm";
			}
		}
	}
	if (typeof fld != "undefined")
	{
		//Field help is being invoked. So, jump to the field anchor on the help page
		//alert ("jumping to field help");
		//helpWin.location.href = helpDir + helpHTM + ".htm" + "#" + fld;
		hrefValue = helpDir + helpHTM + ".htm" + "#" + fld;
	}

	if (typeof hrefValue != "undefined")
		helpWin.location.href = hrefValue;
	top.helpLoaded = true;
	helpWin.focus ();
}
function openHelpWin (strPath, strPageName) 
{
	//alert ("in openHelpWin:" + strPageName);
	return window.open (strPath + strPageName + '.htm', "Help", 'resizable,status,width=' + (screen.availWidth - 250) + ',height=' + (screen.availHeight - 150) + ',screenX=10,screenY=50,menubar,resizable,scrollbars');
}

// Open the calendar tool. Open the window at the position, if specified.

// Open the calendar tool. Open the window at the position, if specified.
function openCalendar (xpos, ypos)
{
	// xpos and ypos are optional
	// caldrFld must be defined by the calling page. This is the field where the selected date will go
	var targetFld = top.app.caldrFld;		//caldrFld must be populated by the calling page
	if (targetFld != "")
	{
		cmd = "targetField = top.app.document.appForm." + targetFld;
		if (eval (cmd))
		{
			if (navigator.appName == "Netscape")
			{				
				calWin = window.open ("/app/calendar.htm", "calendar", "dependent=yes,width=200,height=210,toolbar=no,titlebar=no,resizable=no");
			}
			else if (navigator.appName == "Microsoft Internet Explorer")
			{
				calWin = window.open ("/app/calendar.htm", "calendar", "width=200,height=200,toolbar=no,titlebar=no,resizable=no");
				//Note IE does not have the dependent attribute with window.open function
			}
			if ((xpos != "undefined") && (ypos !="undefined"))
				calWin.moveTo(xpos,ypos);
			calWin.focus();		
		}
	}
}

function doHourglass()
{
  document.body.style.cursor = 'wait';
}

function handleError (errorMessage, javaError)
{
	//alert (errorMessage);
	return errorMessage;
  
}

function blankZero(field)
{


  if (field == 0) 
     {return ''}
     
      else 
     {return field}
  
}

