/* ======================================
	Toggle Disply
======================================---*/
function ToggleDisplay(oButton, oItems)
{

	if ((oItems.style.display == "") || (oItems.style.display == "none"))	{
		oItems.style.display = "block";
		oButton.src = "/Images/Minus.gif";
	}	else {
		oItems.style.display = "none";
		oButton.src = "/Images/Plus.gif";
	}
}


/* ======================================
	scoreboard
======================================---*/

var scorewin = null
function SCOREBOARD_onclick() {
if (!scorewin || scorewin.closed) {
	scorewin = window.open('Scoreboard.asp',"subwindow","width=540, height=260,status=yes,scrollbars=yes")
	} else {
		scorewin.close()
		scorewin = window.open('Scoreboard.asp',"subwindow","width=540, height=260,status=yes,scrollbars=yes")
	}
}


/* ======================================
	PUD
======================================---*/

function PUD() {
   var diarywin = null  
   if (!diarywin || diarywin.closed)
    {
	}
	else 
	{
	diarywin.close()
	}
	diarywin = window.open("/RMIS/mydiaries.asp","subwindow","width=200 height=150,status=yes,scrollbars=yes,toolbar=yes,resizable=yes,alwaysRaised") 
}


/* ======================================
	OpenWindow
======================================---*/

function OpenWindow(URL,name,height,width,status,toolbar,menubar,location,dependent,top,left,scrollbars,resizable){
var gwin = null
//alert("height=" +height +",width=" +width +",status=" +status +",toolbar=" +toolbar +",menubar=" +menubar +",location=" +location +",dependent=" +dependent +", top=" +top +", left=" +left +", scrollbars=" +scrollbars +", resizable=" +resizable)
	if (!gwin || gwin.closed) {
			gwin = window.open(URL,name,"height=" +height +",width=" +width +",status=" +status +",toolbar=" +toolbar +",menubar=" +menubar +",location=" +location +",dependent=" +dependent +", top=" +top +", left=" +left +", scrollbars=" +scrollbars +", resizable=" +resizable)
		} else {
			gwin.close()
			gwin = window.open(URL,name,"height=" +height +",width=" +width +",status=" +status +",toolbar=" +toolbar +",menubar=" +menubar +",location=" +location +",dependent=" +dependent +", top=" +top +", left=" +left +", scrollbars=" +scrollbars +", resizable=" +resizable)
		}
}


/* ======================================
	ChangeDescAndCode
======================================---*/

function ChangeDescAndCode(DescAndCodeValue,CodeName,DescName,FormName) {
  /*
  this functions populates the hidden inputs for codes and descriptions from dropdown boxes
  the value sent to DescAndCodeValue must be in "Description|Code" format
  there can only be one form on the page.
  */
  
  if (DescAndCodeValue.length >= 1) {
  	var LocationArray = DescAndCodeValue.split("|");
  	
 	eval('document.' +FormName +'.' +DescName +'.value = LocationArray[0];')
  	eval('document.' +FormName +'.' +CodeName +'.value = LocationArray[1];')
  }
}


//function handleMouseover() {
//	eSrc = window.event.srcElement;
//	eSrcTag=eSrc.tagName.toUpperCase();
//	if (eSrcTag=="DIV" && eSrc.className.toUpperCase()=="CLSTOCHEAD")	eSrc.style.textDecoration = "underline";
//	if (eSrcTag=="LABEL") eSrc.style.color="#FF0000";
//}

//function handleMouseout() {
//	eSrc = window.event.srcElement;
//	eSrcTag=eSrc.tagName.toUpperCase();
//	if (eSrcTag=="DIV" && eSrc.className.toUpperCase()=="CLSTOCHEAD")	eSrc.style.textDecoration = "";
//	if (eSrcTag=="LABEL") eSrc.style.color="";
//}

//document.onmouseover=handleMouseover;
//document.onmouseout=handleMouseout;

// *********************************************
//
// For session handling
//
// function writeHdnFlds()
// 		Sets hidden fields for use with globalUpdate.asp
//		for setting sessions.  writeHdnFlds needs to be 
//		in the body onLoad event and you need to
//		document.write (sessionsFlds) somewhere between
//		your opening and closing forms tags for EVERY form
//		on your page.

var sessionsFlds;

/* ======================================
	writeHdnFlds
======================================---*/

function writeHdnFlds() {

	
	if (top.refType == 'CLM') {
		sess =  '<input type="hidden" name="ReferenceNum" value="' + top.vTOPRefNo + '">';
		sess += '<input type="hidden" name="Coverage" value="' + top.vTOPCov + '">';
		sess += '<input type="hidden" name="ClaimNum" value="' + top.vTOPClaimNo + '">';
		sess += '<input type="hidden" name="refType" value="' + top.refType + '">';
		sess += '<input type="hidden" name="lossDate" value="' + top.vTOPLossDate + '">';
		sess += '<input type="hidden" name="boardNum" value="' + top.vTOPBOSNum + '">';
		sess += '<input type="hidden" name="status" value="' + top.vTOPStatus + '">';
		sess += '<input type="hidden" name="fileType" value="' + top.vTOPFileTp + '">';
		sess += '<input type="hidden" name="claimant" value="' + top.vTOPClaimant + '">';
		
	} else {
		sess =  '<input type="hidden" name="IncidRefNo" value="' + top.vTOPRefNo + '">';
		sess += '<input type="hidden" name="FormType" value="' + top.vTOPFormType + '">';
		sess += '<input type="hidden" name="IncidentNum" value="' + top.vTOPIncidentNum + '">';
		sess += '<input type="hidden" name="refType" value="' + top.refType + '">';
		sess += '<input type="hidden" name="lossDate" value="' + top.vTOPLossDate + '">';
		sess += '<input type="hidden" name="cov" value="' + top.vTOPCov + '">';
	}
	
	return sess;
}


/* ======================================
	showBalloon
======================================---*/

function showBalloon(balloonText){
	var moBox = eval('document.all.showText');
	var x = (window.event.clientX);
	var y = (window.event.clientY);
	moBox.style.top = y + 12;
	moBox.style.left = x + 12;
	moBox.innerHTML = balloonText;
	moBox.style.visibility = 'visible';
}

/* ======================================
	hideBalloon
======================================---*/

function hideBalloon(){
	var moBox = eval('document.all.showText');
	moBox.style.top = 0
	moBox.style.left = 0
	moBox.innerHTML = ''
	moBox.style.visibility = 'hidden';
}


/* ======================================
	moveCursor
======================================---*/

function moveCursor(from,to,len) {
	/*
	This function is used on Phone # and SSN fields.  this automatically
	tabs the cursor to the next textbox when the proper number of characters
	have been typed in.
	variable "from" is the name of the textbox.  example: document.contact.PHONE_NUM1
	variable "to" is the name of the textbox to tab to.  example: document.contact.PHONE_NUM2
	variable "len" is the number of characters the textbox should accept.
	*/
	if(from.value.length>=len) {
		to.focus();
	}
	return true;
}


/* ======================================
	CombineNumbers
======================================---*/

function CombineNumbers(MainInputName,form) {
	/*
	this function requires the form to have a main input, and the other input names
		should have the same name with a suffix.
	example: Home_Phone_Num, Home_Phone_Num1, Home_Phone_Num2, Home_Phone_Num3
	where Home_Phone_Num stores the phone num. Home_Phone_Num1,2,3 hold parts of
	the Home_Phone_Num
	
	tip: the hidden field for the entire number may need an ID and NAME
	example: <input type=hidden id=HOME_PHONE_NUM name=col1HOME_PHONE_NUM>
	
	the "MainInputName" variable should be the name of the hidden input.
	the "form" variable should be the name of the form.
	example: CombineNumbers('HOME_PHONE_NUM','contact')
	*/
	
	var sub_number1 = MainInputName +'1'
	var sub_number2 = MainInputName +'2'
	var sub_number3 = MainInputName +'3'
	
	eval('document.' +form +'.' +MainInputName +'.value = document.' +form +'.' +sub_number1 +'.value + document.' +form +'.' +sub_number2 +'.value + document.' +form +'.' +sub_number3 +'.value;') 
	
}



/* ======================================
	genAge
======================================---*/

function genAge(loDate, hiDate, setFld) {

	/* **********************************************

		This function is build using a gregorian stan-
		dard of 365.2524 days in a calendar year which
		is accurate for approx 10000 years.

	********************************************** */

	var frm1 = eval('document.' + loDate);
	var frm2 = eval('document.' + hiDate);
	var stFld = eval('document.' + setFld);
	var one_year = 86400000 * 365;

	if (isValidDate(frm1.value,frm1.id,frm2.id,stFld.id) && isValidDate(frm2.value,frm1.id,frm2.id,stFld.id)) {

		var objDt1 = new Date(frm1.value);
		var objDt2 = new Date(frm2.value);

		var Tm1 = objDt1.getTime();
		var Tm2 = objDt2.getTime();

		if (!(Tm2 >= Tm1)) {
			frm1.focus();
			frm1.style.backgroundColor = 'yellow';
			alert('YOU MAY NOT ENTER A DATE THAT EXCEEDS THE ACCIDENT/INCIDENT DATE.');

		} else {
			var tm3 = (Tm2 - Tm1);
			tm3 = (tm3 / 86400000) / 365.2425;
			stFld.value = parseInt(tm3);
		}

	} else {
		//alert(message);
	}
}


/* ======================================
	isValidDate
======================================---*/

function isValidDate(datefield,datename1,datename2,agename) {
	message = ""
	dateStr = datefield;
	if(datefield == '') {
		datefield = '[no date]'
	}
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
	message = datefield + " : "

	// Checks for the following valid date formats:
	// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
	// Also separates date into month, day, and year variables
	// To require a 4 digit year entry, use this line instead:
	// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		message += datename1 + " and " + datename2 + " are required to calculate " + agename + ".\nA date is missing or date format needs to be valid (MM/DD/YYYY).";
		return false;
	}

	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) { // check month range
		message += "Month must be between 1 and 12.";
		return false;
	}
	if (day < 1 || day > 31) {
		message += "Day must be between 1 and 31.";
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		message += "Month "+month+" doesn't have 31 days!";
		return false
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			message += "February " + year + " doesn't have " + day + " days!";
			return false;
	   }
	}
	return true;  // date is valid
}


/* ======================================
	parseDate
======================================---*/

function parseDate(returnWhat,strBegDate){
var strMonth,strDay, strYear, slash
		//Find the location of the first slash in the date field
		slash = strBegDate.indexOf("/");

		//get the value of the Month field
		strMonth = strBegDate.substr(0,slash);

		//set remaining part of the date to a variable
		strBegDate = strBegDate.substr((slash + 1),strBegDate.length);

		//Find the location of the second slash in the remaining part of the date
		slash = strBegDate.indexOf("/");

		//get the value of the Day field
		strDay = strBegDate.substr(0,slash);

		//set remaining part of the date to a variable for the year
		strYear = strBegDate.substr((slash+1),strBegDate.length)

		if (returnWhat == "month"){
			//return the month only for this function
			return (strMonth-1);
		}else if (returnWhat == "day"){
			//return the day only for this function
			return strDay;
		}else if (returnWhat == "year"){
		//return the year only for this function
			return strYear;
		}
	}



/* ======================================
	chkFutDate
======================================---*/

//This function makes sure that an entered Date is no greater than current date
//call the function on the onBlur event of the date to be entered
//pass the form field name as a paramter

function chkFutDate(dtFld){
	var dateField
	var incMonth,incDay,incYear,incDate;
	var todayDate = new Date();

	dateField = eval('document.forms[0].' + dtFld);

	//Get the Date as a date
	incMonth = parseDate("month",dateField.value);
	incDay = parseDate("day",dateField.value);
	incYear = parseDate("year",dateField.value);
	incDate = new Date(incYear,incMonth,incDay);

	// check to make sure from date not before entered date
	if (incDate > todayDate){
		alert("YOU MAY NOT ENTER A DATE THAT EXCEEDS THE CURRENT DATE.")
		dateField.focus();
		dateField.style.backgroundColor = 'yellow';
	// on the input field, add the onblur event calling this function
	}
}




/* ======================================
	currencyFormat
======================================---*/

function currencyFormat(field_object, comma, decimal, e) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = WholeNumberInReverseOrder = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;

	if (whichCode == 13) return true;  // Enter is pressed

	key = String.fromCharCode(whichCode);  // Get key value from key code

	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key

	len = field_object.value.length;

	//find the first number > 0 in the value
	for(i = 0; i < len; i++) 
		if ((field_object.value.charAt(i) != '0') && (field_object.value.charAt(i) != '$') && (field_object.value.charAt(i) != decimal)) break;
		
	aux = '';

	for(; i < len; i++) 
		if (strCheck.indexOf(field_object.value.charAt(i))!=-1) aux += field_object.value.charAt(i);
		
	aux += key;
	
	//remove the dollar sign
	aux.replace(/$/g, "")
	
	len = aux.length;
	if (len == 0) field_object.value = '';
	if (len == 1) field_object.value = '$0'+ decimal + '0' + aux;
	if (len == 2) field_object.value = '$0'+ decimal + aux;
	
	if (len > 2) {
		WholeNumberInReverseOrder = '';
		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				WholeNumberInReverseOrder += comma;
				j = 0;
			}
			WholeNumberInReverseOrder += aux.charAt(i);
			j++;
		}
		field_object.value = '';
		len2 = WholeNumberInReverseOrder.length;
		
		field_object.value = "$"
		for (i = len2 - 1; i >= 0; i--) {
			field_object.value += WholeNumberInReverseOrder.charAt(i);
		}
		
		field_object.value += decimal + aux.substr(len - 2, len);
	}
	return false;
}
//<input type=text name=test maxlength=15 onKeyPress="return(currencyFormat(this,',','.',event))">



/* ======================================
	dateFormat 
======================================---*/

function dateFormat(field_object, slash, e) {
	var TodayDate = new Date()
	var ThisYear = TodayDate.getYear()
	var Century = ThisYear.toString()
	Century = Century.substring(0,2)
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;

	if (whichCode == 13) return true;  // Enter is pressed

	key = String.fromCharCode(whichCode);  // Get key value from key code

	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key

	len = field_object.value.length;

	for(i = 0; i < len; i++) 
		if ( (field_object.value.charAt(i) != slash)) break;
		
	aux = '';
	for(; i < len; i++) 
		if (strCheck.indexOf(field_object.value.charAt(i)) != -1){
			aux += field_object.value.charAt(i);
		}
	
	aux += key;
	len = aux.length;
	if (len == 0) field_object.value = '';
	if (len == 1) field_object.value = aux ;
	if (len == 2) field_object.value = aux + slash ;
	
	if (len >= 3) {
			month = aux.substring(0,2)
			day = aux.substring(2,4)
			year = aux.substring(4,8)
			if (len==3) {
				field_object.value = month + slash + day ;
			} else {
				field_object.value = month + slash + day + slash + year;
			}
			//alert(month + slash + day + slash + year)
	}
	if (len == 4) {
				month = aux.substring(0,2)
				day = aux.substring(2,4)
				year = aux.substring(4,8)
				field_object.value = month + slash + day + slash + Century;
				//alert(month + slash + day + slash + year)
	}
	if (len == 8) {
		Validate_Date(field_object)
	}
	
	
	return false;
}
//usage: <input type=text name=test onKeyPress="return(dateFormat(this, '/', event))">




/* =====================================
	Validate_date
======================================---*/
function Validate_Date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(0,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(2,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   
   if (err != 0) {
      alert("Invalid date!");
	  DateField.select();
	  DateField.focus();
   }
   
}




/* ======================================
	Social Security Format 
======================================---*/

function ssnFormat(field_object_with_dashes, field_object_no_dashes, e) {
	len = field_object_with_dashes.value.length;
	RemoveAllDashes = /-/g
	WhichKeyWasPressed = (window.Event) ? e.which : e.keyCode;
	NumbersOnly = field_object_with_dashes.value
	NumbersOnly = NumbersOnly.replace(RemoveAllDashes, "")
	field_object_no_dashes.value = NumbersOnly
	
	//if not backspace or delete
	if (WhichKeyWasPressed != 46 && WhichKeyWasPressed != 8) {
		switch (len) {
			case 3:
				field_object_with_dashes.value = field_object_with_dashes.value + "-"
				break;
			case 6:
				field_object_with_dashes.value = field_object_with_dashes.value + "-"
				break;
		}
	}
	
}
//<input type="text" name=ssn maxlength=11 value="" onKeyUp="ssnFormat(this, document.TestForm.col1ssn, event)">
//<input type="text" name=col1ssn value="" readonly style="background-color:silver">



/* ======================================
	Phone Number Format 
======================================---*/

function PhoneNumberFormat(field_object_with_dashes, field_object_no_dashes, e) {
	len = field_object_with_dashes.value.length;
	RemoveAllDashes = /-/g
	WhichKeyWasPressed = (window.Event) ? e.which : e.keyCode;
	NumbersOnly = field_object_with_dashes.value
	NumbersOnly = NumbersOnly.replace(RemoveAllDashes, "")
	field_object_no_dashes.value = NumbersOnly
	
	//if not backspace or delete
	if (WhichKeyWasPressed != 46 && WhichKeyWasPressed != 8) {
		switch (len) {
			case 3:
				field_object_with_dashes.value = field_object_with_dashes.value + "-"
				break;
			case 7:
				field_object_with_dashes.value = field_object_with_dashes.value + "-"
				break;
		}
	}
	
}



/* ======================================
	Alerts the maxlength of a DB field
======================================---*/

function textAreaMaxLength(length,dblength,fieldID,fieldName){
	if(length > dblength){
		alert('The maximum characters allowed for  ' + fieldID + '  has exceeded ' + dblength + '.\nYou have entered ' + length + ' characters, including spaces and/or puncuation.\nPlease revise this data.');
		textArea = eval('document.all.' + fieldName);
		textArea.style.backgroundColor = 'yellow';
		textArea.focus();
	}
}

/* =================================
	Flashing Text
====================================---*/
 window.onerror = null;
 var bName = navigator.appName;
 var bVer = parseInt(navigator.appVersion);
 var NS4 = (bName == "Netscape" && bVer >= 4);
 var IE4 = (bName == "Microsoft Internet Explorer" 
 && bVer >= 4);
 var NS3 = (bName == "Netscape" && bVer < 4);
 var IE3 = (bName == "Microsoft Internet Explorer" 
 && bVer < 4);
 var blink_speed=500;
 var i=0;
 
if (NS4 || IE4) {
 if (navigator.appName == "Netscape") {
 	layerStyleRef="layer.";
 	layerRef="document.layers";
 	styleSwitch="";
 } else	{
 	layerStyleRef="layer.style.";
 	layerRef="document.all";
 	styleSwitch=".style";
 }
}

//BLINKING
function Blink(layerName){
 if (NS4 || IE4) { 
 	if(i%2==0) {
 		eval(layerRef+'["'+layerName+'"]'+
 		styleSwitch+'.visibility="visible"');
 	} else {
 		eval(layerRef+'["'+layerName+'"]'+
 		styleSwitch+'.visibility="hidden"');
 	}
 }
 
 if (i<1) {
 	i++;
 } else {
 	i--
 }
 
 setTimeout("Blink('"+layerName+"')",blink_speed);
}

/* =================================
	Floating HTML
====================================---*/
function Floating_HTML(x_coordinate, y_coordinate) {

	//x&y coordinages set here
	var startX = x_coordinate,
	startY = y_coordinate;

	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;

	function ml(id) {
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.right=x;this.style.top=y;};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		el.y -= startY;
		}
		return el;
	}

	window.stayTopRight=function() {
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : document.body.scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopRight()", 10);
	}

	ftlObj = ml("divStayTopRight");
	stayTopRight();
}


/* =================================
	TheWindowWasClosed - returns true or false
====================================---*/


function TheWindowWasClosed() {
	var top=self.screenTop;
	if (top>9000) {
		//alert('window  closed');
		//window.open('delete_incident.htm', 'windowincident', 'dependent=yes, resizable=yes')
		return true;
	} else {
		//alert('window got refreshed or navigated to another page.');
		return false;
    }
}



/* ==============================================
	chkTxtareaLength - alerts textarea maxlength
====================================================---*/

function chkTxtareaLength(formName,textAreaName,maxCharNum) {

	var maxChar = maxCharNum;
	textArea = eval('document.' + formName + '.' + textAreaName);

	if (textArea.value.length > maxChar) {
		diff = textArea.value.length - maxChar;
		if (diff > 1)
			diff = diff + " characters";
		else
			diff = diff + " character";
		alert("Text is limited to " + maxChar + " characters.\n" + "Please reduce the text by " + diff + ".\nAny additional information can be added as a Note.");
		textArea.focus();
		textArea.style.backgroundColor = 'yellow';
		return (false);
	}
}



/* ==============================================
	These 3 functions control popup windows.
	experts-exchange.com Keeping track of all popup windos opened across a webapplication
	http://members.cox.net/mkosbie/index.html
====================================================---*/
function newWin(targetDoc, name, winStats){
 top.Head.newWin(targetDoc, name, winStats);
}

function closeWin(name){
 top.Head.closeWin(name);
}

function closeAll(){
 top.Head.closeAll();
}



/* =====================================
	This  resets the 15 minute timer for the auto logout feature
	in work order 5
======================================= */

function resetTimer(IncYN) {

	if (IncYN == "Inc") {
		NumberOfSeconds=0;
		NumberOfMinutes=15;
	} else {

		var strMainWindow = parent.window.top.location.toString()
		//alert(parent.window.opener.parent.opener.parent.top.location.toString())

		if (strMainWindow.indexOf("launch.asp") > 1) {
			parent.window.top.NumberOfSeconds=0;
			parent.window.top.NumberOfMinutes=15;
		} else {
			strMainWindow = parent.window.top.opener.top.location.toString();

			if (strMainWindow.indexOf("launch.asp") > 1) {
				parent.window.top.opener.top.NumberOfSeconds=0;
				parent.window.top.opener.top.NumberOfMinutes=15;
			} else {

				strMainWindow = parent.window.opener.parent.top.location.toString();

				if (strMainWindow.indexOf("launch.asp") > 1) {
					parent.window.opener.parent.NumberOfSeconds=0;
					parent.window.opener.parent.top.NumberOfMinutes=15;
				} else {

					strMainWindow = parent.window.opener.parent.opener.parent.top.location.toString();

					if (strMainWindow.indexOf("launch.asp") > 1) {
						parent.window.opener.parent.opener.parent.top.NumberOfSeconds=0;
						parent.window.opener.parent.opener.parent.top.NumberOfMinutes=15;
					}
				}
			}
		}
	}
}

function resetIncidentTimer() {
	NumberOfSeconds=0;
	NumberOfMinutes=15;
}


/* ==================================================================
	This formats form fields with a dollar sign and comma separator
================================================================---*/
function populateHiddenDollars(parShowField, parHiddenField, form) {

	var newValue = parShowField.value
	newValue = newValue.replace("$", "")
	newValue = newValue.replace(",", "")

	hiddenField = eval("document." + form + "." + parHiddenField)
	hiddenField.value = newValue
}


/* ==================================================================
	Format Currency Function
================================================================---*/
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}



/* ==============================================
	textCounter - counts textarea maxlength
====================================================---*/

function textCounter(field,cntfield,maxlimit) {

	if (field.value.length > maxlimit)
		// if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else
		cntfield.value = maxlimit - field.value.length;
	}