//RESIZE CONTAINER


// VARIABLE DECLARATIONS
var emptyOK = true;
var emptyNotOK = false;


// whitespace characters
var whitespace = " \t\n\r";

// Valid U.S. Postal Codes for states, territories, armed forces, etc.
// See http://www.usps.gov/ncsc/lookups/abbr_state.txt.

var USStateCodeDelimiter = "|";
var USStateCodes = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP"

// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";

// non-digit characters which are allowed in first and last name
var nameDelimiters = "-' ";

// non-digit characters which are allowed in an account number
var accountNumberDelimiters = "-";

// non-digit characters which are allowed in the addresss and city fields
var addressDelimiters = "-.;# ";

// U.S. phone numbers have 10 digits.
// They are formatted as 123 456 7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;

// U.S. ZIP codes have 5 or 9 digits.
// They are formatted as 12345 or 12345-6789.
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9


var defaultEmptyOK = false;

// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}


submission_counter = 0;
function submission_monitor()
{
     submission_counter++;
     if  (submission_counter % 2 == 0 )
     {
        return false;
     }
     return true;
}



// Returns true if string s is empty or
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}



function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}



// Returns true if character c is a digit
// (0 .. 9).

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isAlphabetic (s)

{   var i;

    if (isEmpty(s))
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    // All characters are letters.
    return true;
}


function isAlphanumeric (s)

{
 var i;

    if (isEmpty(s))
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number or letter.
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    // All characters are numbers or letters.
    return true;
}

function isStateCode(s)
{   if (isEmpty(s))
       if (isStateCode.arguments.length == 1) return defaultEmptyOK;
       else return (isStateCode.arguments[1] == true);
    return ( (USStateCodes.indexOf(s) != -1) &&
             (s.indexOf(USStateCodeDelimiter) == -1) )
}





function isAddress (s)
{
 if (isEmpty(s))
  if (isAddress.arguments.length == 1) return defaultEmptyOK;
  else return (isAddress.arguments[1] == true);

    else
    {
        // Check that first character is letter OR a digit.
        var c = s.charAt(0);

        if ((!isLetter(c)) && (!isDigit(c)))
   return false;

  var normalizedAddress = stripCharsInBag(s, addressDelimiters)
        if (!isAlphanumeric(normalizedAddress, false))
         return false;
  else
   return true;
 }
}


function isEmail (s)
{
 if (isEmpty(s))
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);

 // Check that first character is letter.
    var c = s.charAt(0);

 if ((!isLetter(c)) && (!isDigit(c)))
        return false;

    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != "."))
  return false;
    else
  return true;
}


function isInteger (s)

{   var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}


function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a positive, not negative, number

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}
function isPositiveIntegerWithZero (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveIntegerWithZero.arguments.length > 1)
        secondArg = isPositiveIntegerWithZero.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is NOT negative, number

    return (isSignedInteger(s, secondArg)
         && ( (parseInt (s) >= 0) ) );
}
function isSignedInteger (s)

{   if (isEmpty(s))
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}


function isPhone (s)
{

 if (isEmpty(s))
       if (isPhone.arguments.length == 1) return defaultEmptyOK;
       else return (isPhone.arguments[1] == true);

    else
    {
  var normalizedPhone = stripCharsInBag(s, phoneNumberDelimiters)
  return isUSPhoneNumber(normalizedPhone, isPhone.arguments[1] );
 }
}


function isInteger (s)
{
 var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}


// isUSPhoneNumber (STRING s [, BOOLEAN emptyOK])
//
// isUSPhoneNumber returns true if string s is a valid U.S. Phone
// Number.  Must be 10 digits.
//
// NOTE: Strip out any delimiters (spaces, hyphens, parentheses, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isUSPhoneNumber (s)
{   if (isEmpty(s))
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}


// isZIPCode (STRING s [, BOOLEAN emptyOK])
//
// isZIPCode returns true if string s is a valid
// U.S. ZIP code.  Must be 5 or 9 digits only.
//
// NOTE: Strip out any delimiters (spaces, hyphens, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isZIPCode (s)
{  if (isEmpty(s))
       if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) &&
            ((s.length == digitsInZIPCode1) ||
             (s.length == digitsInZIPCode2)))
}


function checkDecimals(fieldName, fieldValue)
{

	decimals = 2;  // how many decimals are allowed?

	if (isNaN(fieldValue))
	{
		alert("That does not appear to be a valid number.\nPlease try again.");
		fieldName.select();
		fieldName.focus();
        return false;
	}
//	else
//	{
//		timeshundred = parseFloat(fieldValue * Math.pow(10, decimals));
//		integervalue = parseInt(parseFloat(fieldValue) * Math.pow(10, decimals));
//
//		if (timeshundred != integervalue)
//		{
//			alert ("Please enter a number with up to " + decimals + " decimal places.\nPlease try again.");
//			fieldName.select();
//			fieldName.focus();
//           return false;
//    	}
//   	}
    return true;
}


top.HelpWindowOpen = false;

function ShowDocument(filename, title)
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;

    top.HelpWindow = window.open( filename, "", "status=yes,toolbar=yes,location=no,left=0,top=0,screenX=0,screenY=0,menu=yes,resizeable,scrollbars,width="+screen.width+",height="+screen.height);
}


function ShowInfoWindow(disppage, title, mywidth, myheight )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;

    pos_x = (screen.width - mywidth) / 2;
    pos_y = (screen.height - myheight) / 2;



    top.HelpWindow = window.open( "System_Help_Viewer.jsp?title=" + escape(title) + "&disppage=" +escape(disppage), "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable=yes,scrollbars=yes,width="+mywidth+",height="+myheight);
}

function ProcessForm( value )
{

    document.THEFORM.FORM_ACTION.value=value;
    if ( submission_monitor() )
    {
//alert( document.getElementById('inputs').innerHTML);
      document.THEFORM.submit();

    }

}

function EditForm( value )
{
    document.THEFORM.FORM_ACTION.value='EDIT';
    document.THEFORM.INDEX.value=value;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}
function EditComment( value, column )
{
	setScrollPosition();
    document.THEFORM.FORM_ACTION.value='EDIT_COMMENT';
    document.THEFORM.INDEX.value=value;
    document.THEFORM.COLUMN.value=column;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }

}

function DeleteRecord( )
{
     var agree=confirm("Confirm the Deletion.\nAre you sure you want to delete?");
     if (agree)
     {
        document.THEFORM.FORM_ACTION.value='DELETE';
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
     }
}


function Handle_Save()
{
    if ( Form_Validator() )
    {
        document.THEFORM.FORM_ACTION.value='SUBMIT';
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
    }
}


function ProcessForm_wPos( value )
{
    setScrollPosition();
    document.THEFORM.FORM_ACTION.value=value;

    if ( submission_monitor() )

    {

       document.THEFORM.submit();
    }
}

function EditForm_wPos( value )
{
    setScrollPosition();
    document.THEFORM.FORM_ACTION.value='EDIT';
    document.THEFORM.INDEX.value=value;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}


function DeleteRecord_wPos( )
{
     var agree=confirm("Confirm the Deletion.\nAre you sure you want to delete?");
     if (agree)
     {
	setScrollPosition();
        document.THEFORM.FORM_ACTION.value='DELETE';
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
     }
}


function Handle_Save_wPos()
{
    if ( Form_Validator() )
    {
	setScrollPosition();
        document.THEFORM.FORM_ACTION.value='SUBMIT';
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
    }
}





function navigate_back( )
{
    document.THEFORM.APP.value="NAVIGATE_BACK";
    document.THEFORM.action="System_Department_Post.jsp";
    document.THEFORM.encoding="application/x-www-form-urlencoded";
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}

function Handle_Help_Window( title, disppage )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;
    pos_x = 0;
    pos_y = 0;

    myheight = screen.height-135;

    top.HelpWindow = window.open( "System_Help_Viewer.jsp?title=" + escape(title) + "&disppage=" +escape(disppage), "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable,scrollbars,width="+(screen.width - 20)+",height="+myheight);
}

function View_Document( type, ID )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;
    pos_x = 0;
    pos_y = 0;

    myheight = screen.height-105;

    top.HelpWindow = window.open( "System_File_Viewer.jsp?Type="+type+"&ID="+ID, "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable,scrollbars,width="+screen.width+",height="+myheight);
}

function View_Document1( ID )
{
    document.THEFORM.FORM_ACTION.value='VIEW_DOCUMENT_FROM_LIST';
    document.THEFORM.INDEX.value=ID;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}


function View_Document2( )
{
    document.THEFORM.FORM_ACTION.value='VIEW_DOCUMENT';
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}



function Handle_Wizard_Help_Window( title, disppage )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;
    pos_x = 0;
    pos_y = 0;

    pos_x = screen.width/2;
    mywidth  = screen.width/2;
    myheight = screen.height-105;

    top.HelpWindow = window.open( "System_Help_Viewer.jsp?title=" + escape(title) + "&disppage=" +escape(disppage), "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable=yes,scrollbars=yes,width="+mywidth+",height="+myheight);
}



function Handle_Template_Info(  )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;
    pos_x = 0;
    pos_y = 0;

    pos_x = (screen.width - 650) /2;
    pos_y = (screen.height - 400) /2;
    mywidth  = 650;
    myheight = 400;

    top.HelpWindow = window.open( "RB_Template_Lang_Viewer.jsp", "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable=yes,scrollbars=yes,width="+mywidth+",height="+myheight);
}



var NS4= (document.layers) ? 1 : 0;
var IE4= (document.all) ? 1 : 0;



function show(id)
{
    if (NS4) document.layers[id].visibility = "show"
    else if (IE4) document.all[id].style.visibility = "visible"
}

function hide(id)
{
    if (NS4) document.layers[id].visibility = "hide"
    else if (IE4) document.all[id].style.visibility = "hidden"
}

function getSelectedRadio(buttonGroup)
{
    // returns the array number of the selected radio button or -1 if no button is selected
    if (buttonGroup[0])
    { // if the button group is an array (one button is not an array)
         for (var i=0; i<buttonGroup.length; i++)
	   {
            if (buttonGroup[i].checked)
		{
			return i
		}
	   }
    }
    else
    {
	   if (buttonGroup.checked)
         {
 		return 0;
         } // if the one button is checked, return zero
    }
    // if we get to this point, no radio button is selected
    return -1;
} // Ends the "getSelectedRadio" function

function getSelectedCheckbox(buttonGroup)
{
// Go through all the check boxes. return an array of all the ones
// that are selected (their position numbers). if no boxes were checked,
// returned array will be empty (length will be zero)
    var retArr = new Array();
    var lastElement = 0;

    box = eval(buttonGroup);
    if(box != null)
    {

       if (buttonGroup[0])
       { // if the button group is an array (one check box is not an array)
		   for (var i=0; i<buttonGroup.length; i++)
	   {
		if (buttonGroup[i].checked)
		{
			retArr.length = lastElement;
			retArr[lastElement] = i;
			lastElement++;
		}
	   }
      }
      else
      {
 	   // There is only one check box (it's not an array)
	  if (buttonGroup.checked)
	  {
		// if the one check box is checked
		retArr.length = lastElement;
		retArr[lastElement] = 0; // return zero as the only array value
	  }
      }
    }
    return retArr;
} // Ends the "getSelectedCheckbox" function


var selectionToggle = 1;
<!-- hide from old browsers
    function checkboxAll()
    {
    // evaluate for one row first
    box = eval("document.THEFORM.ID");
    if(box != null)
    {
        box.checked = selectionToggle;
        // evaluate for multiple rows (if necessary)
        for (var e=0; e < document.THEFORM.length; e++)
        {
            box = eval("document.THEFORM.ID[e]");
            if (box != null)
            box.checked = selectionToggle;
        }
    }
    selectionToggle = !selectionToggle;
}
//stop hiding -->








//***************   START POP UP BOX CODE ******************************


isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

var layerIdName = "";

function setPopupId( value ){
  layerIdName = value;
}

function ddInit(e){

  topDog=isIE ? "BODY" : "HTML";
  whichDog = document.getElementById(layerIdName);
  hotDog=isIE ? event.srcElement : e.target;
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
	//ddEnabled=false;
  } else {
	ddEnabled=false;
  }
}

function trueddEnabled(e) {
  ddEnabled=true;
}

function falseddEnabled(e) {
  ddEnabled=false;
}

function dd(e){
  //checkmousemove();
  //document.onmouseup=falseddEnabled;
  //document.onmousedown=trueddEnabled;
  if (!ddEnabled) return;
  mouseloc = "";
  mouseloc =isIE ? event.srcElement : e.target;
  if ( mouseloc.id=="titleBar" ) {
    if (isIE) {
       newX = nowX+event.clientX-offsetx;
	   newY = nowY+event.clientY-offsety;
    } else {
	   newX = nowX+e.clientX-offsetx;
	   newY = nowY+e.clientY-offsety;
    }
	/*
    diffrange= 60;
    diffX = newX - nowX;
    if ( diffX > diffrange )
	   newX = nowX + diffrange;
    if ( diffX < -diffrange )
	   newX = nowX - diffrange;

    diffY = newY - nowY;
    if ( diffY > diffrange )
	   newY = nowY + diffrange;
    if ( diffY < -diffrange )
	   newY = nowY - diffrange;
	*/
    if (newX != nowX || newY != nowY ) {

	/*
	  if ( newX < 0 ) {
		newX = 0;
	  }

	  if ( newY < 0 ) {
		newY = 0;
	  }
	*/
	     whichDog.style.left=newX;
         whichDog.style.top=newY;
     }
   } else {
	   ddEnabled = false;
   }
  //whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
  //whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  obj = eval("document."+layerIdName);
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) obj.visibility="hide";
}

function openPopup1( xpos, ypos){
    obj = eval("document."+layerIdName);
    whichDog = document.getElementById(layerIdName);


    if (isIE||isNN){
	whichDog.style.visibility="visible";
	whichDog.style.left = xpos;
	whichDog.style.top = ypos;
    }
    else if (isN4){
	obj.visibility="show";
    }

}


function openPopup(){
    obj = eval("document."+layerIdName);
    whichDog = document.getElementById(layerIdName);


    if (isIE||isNN){
	whichDog.style.visibility="visible";
    }
    else if (isN4){
	obj.visibility="show";
    }

}



//document.onmousemove=setCursorPosition;
//document.onmousedown=ddInit;
//document.onmouseup=Function("ddEnabled=false");


function setCursorPosition(e)
{
 	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)//Netscape
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)//IE
	{
		posx = e.clientX;
		posy = e.clientY;
	}
	document.THEFORM.LAST_X.value = posx;
	document.THEFORM.LAST_Y.value = posy;
}


//**************  END POP UP BOX CODE  ******************



function setScrollPosition(){
    var myPageX;
    var myPageY;
    if (document.all){
        myPageX = document.body.scrollLeft;
        myPageY = document.body.scrollTop;
    }
    else{
        myPageX = window.pageXOffset;
        myPageY = window.pageYOffset;
    }
    document.THEFORM.SCROLL_X.value = myPageX;
    document.THEFORM.SCROLL_Y.value = myPageY;
}


function SaveWordProcessor()
{
    getContent();

    setScrollPosition();

    document.THEFORM.FORM_ACTION.value='SAVE_HTML_EDITOR_CONTENT';
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }

}

function ViewProfile(url, user_id)
{

	document.THEFORM.action = url
	document.THEFORM.SYSTEM_USER_ID.value=user_id;
	document.THEFORM.target='_parent';
    if ( submission_monitor() )
    {
           document.THEFORM.submit();
    }
}

// VARIABLE DECLARATIONS
var emptyOK = true;
var emptyNotOK = false;


// whitespace characters
var whitespace = " \t\n\r";

// Valid U.S. Postal Codes for states, territories, armed forces, etc.
// See http://www.usps.gov/ncsc/lookups/abbr_state.txt.

var USStateCodeDelimiter = "|";
var USStateCodes = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP"

// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";

// non-digit characters which are allowed in first and last name
var nameDelimiters = "-' ";

// non-digit characters which are allowed in an account number
var accountNumberDelimiters = "-";

// non-digit characters which are allowed in the addresss and city fields
var addressDelimiters = "-.;# ";

// U.S. phone numbers have 10 digits.
// They are formatted as 123 456 7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;

// U.S. ZIP codes have 5 or 9 digits.
// They are formatted as 12345 or 12345-6789.
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9


var defaultEmptyOK = true;

// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}


submission_counter = 0;
function submission_monitor()
{
     submission_counter++;
     if  (submission_counter % 2 == 0 )
     {
        return false;
     }
     return true;
}



// Returns true if string s is empty or
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}

function isFloat(s)
{
var n =Trim(s);
return n.length>0 && !(/[^0-9.]/).test(n) && (/\.\d/).test(n);
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}



// Returns true if character c is a digit
// (0 .. 9).

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isAlphabetic (s)

{   var i;

    if (isEmpty(s))
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    // All characters are letters.
    return true;
}


function isAlphanumeric (s)

{
 var i;

    if (isEmpty(s))
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number or letter.
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    // All characters are numbers or letters.
    return true;
}

function isStateCode(s)
{   if (isEmpty(s))
       if (isStateCode.arguments.length == 1) return defaultEmptyOK;
       else return (isStateCode.arguments[1] == true);
    return ( (USStateCodes.indexOf(s) != -1) &&
             (s.indexOf(USStateCodeDelimiter) == -1) )
}





function isAddress (s)
{
 if (isEmpty(s))
  if (isAddress.arguments.length == 1) return defaultEmptyOK;
  else return (isAddress.arguments[1] == true);

    else
    {
        // Check that first character is letter OR a digit.
        var c = s.charAt(0);

        if ((!isLetter(c)) && (!isDigit(c)))
   return false;

  var normalizedAddress = stripCharsInBag(s, addressDelimiters)
        if (!isAlphanumeric(normalizedAddress, false))
         return false;
  else
   return true;
 }
}


function isEmail (s)
{
 if (isEmpty(s))
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);

 // Check that first character is letter.
    var c = s.charAt(0);

 if ((!isLetter(c)) && (!isDigit(c)))
        return false;

    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != "."))
  return false;
    else
  return true;
}


function isInteger (s)

{   var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}


function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a positive, not negative, number

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}
function isPositiveIntegerWithZero (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveIntegerWithZero.arguments.length > 1)
        secondArg = isPositiveIntegerWithZero.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is NOT negative, number

    return (isSignedInteger(s, secondArg)
         && ( (parseInt (s) >= 0) ) );
}
function isSignedInteger (s)

{   if (isEmpty(s))
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}


function isPhone (s)
{

 if (isEmpty(s))
       if (isPhone.arguments.length == 1) return defaultEmptyOK;
       else return (isPhone.arguments[1] == true);

    else
    {
  var normalizedPhone = stripCharsInBag(s, phoneNumberDelimiters)
  return isUSPhoneNumber(normalizedPhone, isPhone.arguments[1] );
 }
}


function isInteger (s)
{
 var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}


// isUSPhoneNumber (STRING s [, BOOLEAN emptyOK])
//
// isUSPhoneNumber returns true if string s is a valid U.S. Phone
// Number.  Must be 10 digits.
//
// NOTE: Strip out any delimiters (spaces, hyphens, parentheses, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isUSPhoneNumber (s)
{   if (isEmpty(s))
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}


// isZIPCode (STRING s [, BOOLEAN emptyOK])
//
// isZIPCode returns true if string s is a valid
// U.S. ZIP code.  Must be 5 or 9 digits only.
//
// NOTE: Strip out any delimiters (spaces, hyphens, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isZIPCode (s)
{  if (isEmpty(s))
       if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) &&
            ((s.length == digitsInZIPCode1) ||
             (s.length == digitsInZIPCode2)))
}


function checkDecimals(fieldName, fieldValue)
{

	decimals = 2;  // how many decimals are allowed?

	if (isNaN(fieldValue))
	{
		alert("That does not appear to be a valid number.\nPlease try again.");
		fieldName.select();
		fieldName.focus();
        return false;
	}
//	else
//	{
//		timeshundred = parseFloat(fieldValue * Math.pow(10, decimals));
//		integervalue = parseInt(parseFloat(fieldValue) * Math.pow(10, decimals));
//
//		if (timeshundred != integervalue)
//		{
//			alert ("Please enter a number with up to " + decimals + " decimal places.\nPlease try again.");
//			fieldName.select();
//			fieldName.focus();
//           return false;
//    	}
//   	}
    return true;
}


top.HelpWindowOpen = false;

function ShowDocument(filename, title)
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;

    top.HelpWindow = window.open( filename, "", "status=yes,toolbar=yes,location=no,left=0,top=0,screenX=0,screenY=0,menu=yes,resizeable,scrollbars,width="+screen.width+",height="+screen.height);
}


function ShowInfoWindow(disppage, title, mywidth, myheight )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;

    pos_x = (screen.width - mywidth) / 2;
    pos_y = (screen.height - myheight) / 2;



    top.HelpWindow = window.open( "System_Help_Viewer.jsp?title=" + escape(title) + "&disppage=" +escape(disppage), "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable=yes,scrollbars=yes,width="+mywidth+",height="+myheight);
}

function ProcessForm( value )
{
    document.THEFORM.FORM_ACTION.value=value;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}

function EditForm( value )
{
    document.THEFORM.FORM_ACTION.value='EDIT';
    document.THEFORM.INDEX.value=value;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}

function EditFormRecord( value, ID )
{
    setScrollPosition();
    document.THEFORM.FORM_ACTION.value=value;
    document.THEFORM.INDEX.value=ID;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}

function DeleteFormRecord( value )
{
     setScrollPosition();
     var agree=confirm("Confirm the Deletion.\nAre you sure you want to delete?");
     if (agree)
     {
        document.THEFORM.FORM_ACTION.value=value;
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
     }
}



function EditComment( value, column )
{
	setScrollPosition();
    document.THEFORM.FORM_ACTION.value='EDIT_COMMENT';
    document.THEFORM.INDEX.value=value;
    document.THEFORM.COLUMN.value=column;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }

}

function DeleteRecord( )
{
     var agree=confirm("Confirm the Deletion.\nAre you sure you want to delete?");
     if (agree)
     {
        document.THEFORM.FORM_ACTION.value='DELETE';
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
     }
}


function Handle_Save()
{
    if ( Form_Validator() )
    {
        document.THEFORM.FORM_ACTION.value='SUBMIT';
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
    }
}


function ProcessForm_wPos( value )
{
    setScrollPosition();
    document.THEFORM.FORM_ACTION.value=value;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}

function EditForm_wPos( value )
{
    setScrollPosition();
    document.THEFORM.FORM_ACTION.value='EDIT';
    document.THEFORM.INDEX.value=value;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}


function DeleteRecord_wPos( )
{
     var agree=confirm("Confirm the Deletion.\nAre you sure you want to delete?");
     if (agree)
     {
	setScrollPosition();
        document.THEFORM.FORM_ACTION.value='DELETE';
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
     }
}


function Handle_Save_wPos()
{
    if ( Form_Validator() )
    {
	setScrollPosition();
        document.THEFORM.FORM_ACTION.value='SUBMIT';
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
    }
}


function Handle_SaveForm_wPos( value )
{
    if ( Form_Validator() )
    {
	setScrollPosition();
        document.THEFORM.FORM_ACTION.value=value;
        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
    }
}



function navigate_back( )
{
    document.THEFORM.APP.value="NAVIGATE_BACK";
    document.THEFORM.action="System_Department_Post.jsp";
    document.THEFORM.encoding="application/x-www-form-urlencoded";
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}

function Handle_Help_Window( title, disppage )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;
    pos_x = 0;
    pos_y = 0;

    myheight = screen.height-135;

    top.HelpWindow = window.open( "System_Help_Viewer.jsp?title=" + escape(title) + "&disppage=" +escape(disppage), "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable,scrollbars,width="+(screen.width - 20)+",height="+myheight);
}

function View_Document( type, ID )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;
    pos_x = 0;
    pos_y = 0;

    myheight = screen.height-105;

    top.HelpWindow = window.open( "System_File_Viewer.jsp?Type="+type+"&ID="+ID, "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable,scrollbars,width="+screen.width+",height="+myheight);
}

function View_Document1( ID )
{
    document.THEFORM.FORM_ACTION.value='VIEW_DOCUMENT_FROM_LIST';
    document.THEFORM.INDEX.value=ID;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}


function View_Document2( )
{
    document.THEFORM.FORM_ACTION.value='VIEW_DOCUMENT';
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}



function Handle_Wizard_Help_Window( title, disppage )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;
    pos_x = 0;
    pos_y = 0;

    pos_x = screen.width/2;
    mywidth  = screen.width/2;
    myheight = screen.height-105;

    top.HelpWindow = window.open( "System_Help_Viewer.jsp?title=" + escape(title) + "&disppage=" +escape(disppage), "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable=yes,scrollbars=yes,width="+mywidth+",height="+myheight);
}



function Handle_Template_Info(  )
{
    if (top.HelpWindowOpen)
        top.HelpWindow.close();
    top.HelpWindowOpen = true;
    pos_x = 0;
    pos_y = 0;

    pos_x = (screen.width - 650) /2;
    pos_y = (screen.height - 400) /2;
    mywidth  = 650;
    myheight = 400;

    top.HelpWindow = window.open( "RB_Template_Lang_Viewer.jsp", "", "status=yes,toolbar=yes,location=no,left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",menu=yes,resizable=yes,scrollbars=yes,width="+mywidth+",height="+myheight);
}



var NS4= (document.layers) ? 1 : 0;
var IE4= (document.all) ? 1 : 0;



function show(id)
{
    if (NS4) document.layers[id].visibility = "show"
    else if (IE4) document.all[id].style.visibility = "visible"
}

function hide(id)
{
    if (NS4) document.layers[id].visibility = "hide"
    else if (IE4) document.all[id].style.visibility = "hidden"
}

function getSelectedRadio(buttonGroup)
{
    // returns the array number of the selected radio button or -1 if no button is selected
    if (buttonGroup[0])
    { // if the button group is an array (one button is not an array)
         for (var i=0; i<buttonGroup.length; i++)
	   {
            if (buttonGroup[i].checked)
		{
			return i
		}
	   }
    }
    else
    {
	   if (buttonGroup.checked)
         {
 		return 0;
         } // if the one button is checked, return zero
    }
    // if we get to this point, no radio button is selected
    return -1;
} // Ends the "getSelectedRadio" function

function getSelectedCheckbox(buttonGroup)
{
// Go through all the check boxes. return an array of all the ones
// that are selected (their position numbers). if no boxes were checked,
// returned array will be empty (length will be zero)
    var retArr = new Array();
    var lastElement = 0;

    box = eval(buttonGroup);
    if(box != null)
    {

       if (buttonGroup[0])
       { // if the button group is an array (one check box is not an array)
		   for (var i=0; i<buttonGroup.length; i++)
	   {
		if (buttonGroup[i].checked)
		{
			retArr.length = lastElement;
			retArr[lastElement] = i;
			lastElement++;
		}
	   }
      }
      else
      {
 	   // There is only one check box (it's not an array)
	  if (buttonGroup.checked)
	  {
		// if the one check box is checked
		retArr.length = lastElement;
		retArr[lastElement] = 0; // return zero as the only array value
	  }
      }
    }
    return retArr;
} // Ends the "getSelectedCheckbox" function


var selectionToggle = 1;
<!-- hide from old browsers
    function checkboxAll()
    {
    // evaluate for one row first
    box = eval("document.THEFORM.ID");
    if(box != null)
    {
        box.checked = selectionToggle;
        // evaluate for multiple rows (if necessary)
        for (var e=0; e < document.THEFORM.length; e++)
        {
            box = eval("document.THEFORM.ID[e]");
            if (box != null)
            box.checked = selectionToggle;
        }
    }
    selectionToggle = !selectionToggle;
}

var selectionToggle2 = 1;
<!-- hide from old browsers
    function checkboxAll2(id)
    {
    // evaluate for one row first
    box = eval("document.THEFORM."+id);
    if(box != null)
    {
        box.checked = selectionToggle;
        // evaluate for multiple rows (if necessary)
        for (var e=0; e < document.THEFORM.length; e++)
        {
            box = eval("document.THEFORM."+id+"[e]");
            if (box != null)
            box.checked = selectionToggle;
        }
    }
    selectionToggle = !selectionToggle;
}
//stop hiding -->



function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}



//***************   START POP UP BOX CODE ******************************


isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

var layerIdName = "";

function setPopupId( value ){
  layerIdName = value;
}

function ddInit(e){

  topDog=isIE ? "BODY" : "HTML";
  whichDog = document.getElementById(layerIdName);
  hotDog=isIE ? event.srcElement : e.target;
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
	//ddEnabled=false;
  } else {
	ddEnabled=false;
  }


}

function trueddEnabled(e) {
  ddEnabled=true;
}

function falseddEnabled(e) {
  ddEnabled=false;
}

function dd(e){

  //checkmousemove();
  //document.onmouseup=falseddEnabled;
  //document.onmousedown=trueddEnabled;
  if (!ddEnabled) return;
  mouseloc = "";
  mouseloc =isIE ? event.srcElement : e.target;
  if ( mouseloc.id=="titleBar" ) {
    if (isIE) {
       newX = nowX+event.clientX-offsetx;
	   newY = nowY+event.clientY-offsety;
    } else {
	   newX = nowX+e.clientX-offsetx;
	   newY = nowY+e.clientY-offsety;
    }
	/*
    diffrange= 60;
    diffX = newX - nowX;
    if ( diffX > diffrange )
	   newX = nowX + diffrange;
    if ( diffX < -diffrange )
	   newX = nowX - diffrange;

    diffY = newY - nowY;
    if ( diffY > diffrange )
	   newY = nowY + diffrange;
    if ( diffY < -diffrange )
	   newY = nowY - diffrange;
	*/
    if (newX != nowX || newY != nowY ) {

	/*
	  if ( newX < 0 ) {
		newX = 0;
	  }

	  if ( newY < 0 ) {
		newY = 0;
	  }
	*/
	     whichDog.style.left=newX;
         whichDog.style.top=newY;
     }
   } else {
	   ddEnabled = false;
   }
  //whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
  //whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;

  loadEditorIFrame();
  return false;
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}



function hideMe(){
  obj = eval("document."+layerIdName);
  if (isIE||isNN)
    whichDog.style.visibility="hidden";
  else if (isN4)
    obj.visibility="hide";
  hideIFrame();
}

function hideNavigator(){
  obj = eval("document."+layerIdName);
  if (isIE||isNN)
    whichDog.style.visibility="hidden";
  else if (isN4)
    obj.visibility="hide";
  document.THEFORM.NAVIGATOR_STATE.value = 0;
  hideIFrame();
}


function openPopup1( xpos, ypos){
    obj = eval("document."+layerIdName);
    whichDog = document.getElementById(layerIdName);


    if (isIE||isNN){
	whichDog.style.visibility="visible";
	whichDog.style.left = xpos;
	whichDog.style.top = ypos;

    }
    else if (isN4){
	obj.visibility="show";
    }
  	if(isIE)
    {
        loadEditorIFrame();
    }


}


function openPopup(){
    obj = eval("document."+layerIdName);
    whichDog = document.getElementById(layerIdName);


    if (isIE||isNN){
	whichDog.style.visibility="visible";

    }
    else if (isN4){
	obj.visibility="show";
    }
	if(isIE)
    {
        loadEditorIFrame();
    }
}



//document.onmousemove=setCursorPosition;
//document.onmousedown=ddInit;
//document.onmouseup=Function("ddEnabled=false");


function setCursorPosition(e)
{
 	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)//Netscape
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)//IE
	{
		posx = e.clientX;
		posy = e.clientY;
	}
	document.THEFORM.LAST_X.value = posx;
	document.THEFORM.LAST_Y.value = posy;
}


//**************  END POP UP BOX CODE  ******************



function setScrollPosition(){
    var myPageX;
    var myPageY;
    if (document.all){
        myPageX = document.body.scrollLeft;
        myPageY = document.body.scrollTop;
    }
    else{
        myPageX = window.pageXOffset;
        myPageY = window.pageYOffset;
    }
    document.THEFORM.SCROLL_X.value = myPageX;
    document.THEFORM.SCROLL_Y.value = myPageY;
}

function setDivMainScrollPosition(){
    var objDiv = document.getElementById("main");
    if ( objDiv != null )
    {
       document.THEFORM.SCROLL_X.value = objDiv.scrollLeft;
       document.THEFORM.SCROLL_Y.value = objDiv.scrollTop;
    }
}




function SaveWordProcessor()
{
    getContent();

    setDivMainScrollPosition();

    document.THEFORM.FORM_ACTION.value='SAVE_HTML_EDITOR_CONTENT';
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }

}

function ViewProfile(url, user_id)
{

	document.THEFORM.action = url
	document.THEFORM.SYSTEM_USER_ID.value=user_id;
	document.THEFORM.target='_parent';
    if ( submission_monitor() )
    {
           document.THEFORM.submit();
    }
}



/*
	This function checks if a string 'searchString' begins with the specified
	'prefix'.  If so, it returns true, false otherwise
*/
function startsWith( searchString, prefix )
{
    if( prefix != null && searchString != null )
    {
        prefixLength = prefix.length;
        if( prefixLength > searchString.length )
            return false;

        for( var k=0; k < prefixLength; k++ )
        {
            if( prefix.charAt(k) != searchString.charAt(k) )
                return false;
        }
    }
    else
        return false;

    return true;
}

/*
	This function checks if a string 'searchString' ends with the specified
	'postfix'.  If so, it returns true, false otherwise
*/
function endsWith(searchString, postfix)
{
    if( postfix != null && searchString != null )
    {
        postfixLength = postfix.length;
        searchStringLength = searchString.length;
        if( postfixLength > searchStringLength )
            return false;
        searchIndex = searchStringLength - postfixLength;
        for( postfixIndex=0; searchIndex < searchStringLength; searchIndex++, postfixIndex++)
        {
            if( postfix.charAt(postfixIndex) != searchString.charAt(searchIndex) )
                return false;
        }
    }
    else
        return false;

    return true;
}

function Trim(s)
{
// Remove leading spaces and carriage returns
while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
{ s = s.substring(1,s.length); }

// Remove trailing spaces and carriage returns
while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
{ s = s.substring(0,s.length-1); }

return s;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

    function LightenColor(rgbtext, delta) {
      var r, g, b, txt;
      r= parseInt(rgbtext.substr(1, 2), 16),
      g= parseInt(rgbtext.substr(3, 2), 16),
      b= parseInt(rgbtext.substr(5, 2), 16),

      r+= delta;  if (r> 255) r= 255;  if (r< 0) r= 0;
      g+= delta;  if (g> 255) g= 255;  if (g< 0) g= 0;
      b+= delta;  if (b> 255) b= 255;  if (b< 0) b= 0;
      txt= b.toString(16);       if (txt.length< 2) txt= "0"+ txt;
      txt= g.toString(16)+ txt;  if (txt.length< 4) txt= "0"+ txt;
      txt= r.toString(16)+ txt;  if (txt.length< 6) txt= "0"+ txt;

      return "#"+ txt;
    }
    function DarkenColor(rgbtext, delta) {
      return LightenColor(rgbtext, delta* -1);
    }


function highLight( ele)
{
    if(ele.checked)
    {
        if(ele.darkened == 'no')
        {
        	ele.parentNode.parentNode.style.backgroundColor=DarkenColor(ele.parentNode.parentNode.style.backgroundColor, 40);
			ele.darkened='yes';
        }
    }
    else
    {
        if(ele.darkened == 'yes')
        {
        	ele.parentNode.parentNode.style.backgroundColor=LightenColor(ele.parentNode.parentNode.style.backgroundColor, 40);;
			ele.darkened='no';
        }
    }
}

function highLightAll(id)
{

    var eles = document.getElementsByName(id);
    for(var i = 0; i < eles.length; i++)
    {
        highLight( eles[i] );
    }

}




IE1 = (document.all) ? 1 : 0;
var WAIT_IN_MSECS=1000; /* 1 seconds */
var timer=null;
var evt = null;
var x =0;
var y =0;

function showPopupInfo1(status_info, divId, on_off, xOff, yOff, evt1)
{
   evt = evt1;
    if( IE1 )
    {
   		x = evt.x;
   		y = evt.y;
    }
    else
    {
    	x = evt.clientX;
   		y = evt.clientY;
    }
  if(on_off == 'visible')
  {
   var funct  ="showPopupInfo2('"+status_info+"','"+divId+"', '"+on_off+"', "+xOff+", "+yOff+")";
    timer=setTimeout(funct,WAIT_IN_MSECS);
  }
  else
  {
  	showPopupInfo2(status_info, divId, on_off, xOff, yOff);
    if(timer)
	{
	  clearTimeout(timer);
	  timer=null;
	}

  }
}






function showPopupInfo2( status_info, divId, on_off, xOff, yOff)
{
	window.status = status_info ;
    var element = null;
    if( IE1 )
    {

        element = document.all[divId];
        element.style.visibility = on_off;
        element.style.left = x - findWidth(element) + xOff;
        element.style.top = y + document.body.scrollTop + yOff;
    }
    else
    {

        element = document.getElementById(divId);
        element.style.visibility = on_off;
        element.style.left = x - findWidth(element) + xOff;
        element.style.top = y + window.pageYOffset + yOff;

    }

	//Cover
	if(IE1 && on_off == 'visible')
    {
    	var shim = getShim(element);
    	if (shim==null) shim = createMenuShim(element,getShimId(element));
		element.style.zIndex = 100;
    	shim.style.width = findWidth(element);
    	shim.style.height = findHeight(element);
    	shim.style.top 		= element.style.top;
    	shim.style.left 	= element.style.left;
    	shim.style.zIndex = element.style.zIndex - 1;
    	shim.style.position = "absolute";
    	shim.style.display = "block";
    }
    else if (IE1)
    {
        closeShim(element);
    }
	locked = false;
}

//The following creates a dynamic iframe to cover "DIV" over <select>
function closeShim(ele)
{
    if (ele==null) return;
    var shim = getShim(ele);
    if (shim!=null) shim.parentNode.removeChild(shim);
}

function createMenuShim(ele)
{
    if (ele==null) return null;

    var shim = document.createElement("<iframe scrolling='no' src='text.html' frameborder='0'"+
                                      "style='position:absolute; top:0px;"+
                                      "left:0px; display:none'></iframe>");
    shim.name = getShimId(ele);
    shim.id = getShimId(ele);
    //Unremark this line if you need your element to be transparent for some reason
    shim.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";

    if (ele.offsetParent==null || ele.offsetParent.id=="")
    {
        window.document.body.appendChild(shim);
    }
    else
    {
        ele.offsetParent.appendChild(shim);
    }

    return shim;
}

//Creates an id for the shim based on the element id
function getShimId(ele)
{
    if (ele.id==null) return "__shim";
    return "__shim"+ele.id;
}

//Returns the shim for a specific menu
function getShim(ele)
{
    return document.getElementById(getShimId(ele));
}

//End Iframe code





function findWidth(element){
     this.h=0;
     if (element==document){
          this.w=element.body.clientWidth;
     }else if (element!=null){
          var e=element;
          var left=e.offsetLeft;
          while ((e=e.offsetParent)!=null) {
               left+=e.offsetLeft;
          }
          var e=element;
          var top=e.offsetTop;
          while((e=e.offsetParent)!=null) {
               top+=e.offsetTop;
          }
          this.w=element.offsetWidth;
     }
     return this.w;
}

function findHeight(element){
     this.h=0;
     if (element==document){
          this.h=element.body.clientHeight;
     }else if (element!=null){
          var e=element;
          var left=e.offsetLeft;

          while ((e=e.offsetParent)!=null) {
               left+=e.offsetLeft;
          }
          var e=element;
          var top=e.offsetTop;
          while((e=e.offsetParent)!=null) {
               top+=e.offsetTop;
          }
          this.h=element.offsetHeight;
     }
     return this.h;
}

function findViewableHeight(){
	var my_height = 0;
	if ( typeof( window.innerHeight ) == 'number' )
	{
		my_height = window.innerHeight;
	}else if ( document.documentElement &&
	( document.documentElement.clientWidth ||
	document.documentElement.clientHeight ) )
	{
		my_height = document.documentElement.clientHeight ;
	}
	else if ( document.body &&
	( document.body.clientWidth || document.body.clientHeight ) )
	{
		my_height = document.body.clientHeight;
	}
	return my_height;
}
function findViewableWidth(){
	var my_width = 0;
	if ( typeof( window.innerHeight ) == 'number' )
	{
		my_width = window.clientWidth;
	}else if ( document.documentElement &&
	( document.documentElement.clientWidth ||
	document.documentElement.clientWidth ) )
	{
		my_width = document.documentElement.clientWidth ;
	}
	else if ( document.body &&
	( document.body.clientWidth || document.body.clientWidth ) )
	{
		my_width = document.body.clientWidth;
	}
	return my_width;
}

function getElementsByClassName(clsName)
{
	var arr = new Array();
	var elems = document.getElementsByTagName("*");
	for ( var cls, i = 0; ( elem = elems[i] ); i++ )
	{
		if ( elem.className == clsName )
		{
			arr[arr.length] = elem;
		}
	}
	return arr;
}



function wait(millis)
{
	date = new Date();
	var curDate = null;

	do { var curDate = new Date(); }
	while(curDate-date < millis);
}

//this is used in conjunction with Study_Submission.DisplaySubmissionPacketDV
function CompareVersions(checkBoxName)
{
	// alert('checkBoxName: ' + checkBoxName);
   var checkedBoxes = document.getElementsByName(checkBoxName);
   var num = 0;
   for (i = 0; i < checkedBoxes.length; i++) {
   if (checkedBoxes[i].checked) {
    	  num++;
	   }
   }

   // alert('num: ' + num);

   if(num == 2)
   {
	   if(checkBoxName.indexOf('ID_APP') == 0)
	   {
		   document.THEFORM.FORM_ACTION.value='COMPARE_APPLICATION';
	   }
	   if(checkBoxName.indexOf('ID_FORM') == 0)
	   {
		   document.THEFORM.FORM_ACTION.value='COMPARE_FORM';
	   }
	   if(checkBoxName.indexOf('ID_CON_F') == 0)
	   {
		   document.THEFORM.FORM_ACTION.value='COMPARE_CONSENT_FORM';
	   }
	   if(checkBoxName.indexOf('ID_DOC') == 0)
	   {
		   document.THEFORM.FORM_ACTION.value='COMPARE_DOCUMENT';
	   }

        if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
    }
	else
	{
		alert("Please check exactly two items in the same folder.");
	}

}

function Show_Hide ( ele, value )
{

	var items = getElementsByClassName(value);
	var imgs = getChildrenByTagName(ele, "IMG");
	var img = imgs[0];


	for(var i = 0; i < items.length; i++)
	{
		var item = items[i];

		if(item.style.display == 'none')
		{
			//item.style.display = '';
			item.style.display = "";
			//alert(item.style.visibility);
			//img.src="images/icon_colapse.gif";
			img.setAttribute('src','images/icon_colapse.gif')

		}
		else
		{
			item.style.display = 'none';
			//item.style.display.visibility='collapse';
			img.setAttribute('src','images/icon_expand.gif')
			//img.src="images/icon_expand.gif";
		}
	}
}
function getChildrenByTagName(oParent, sTagName)
{
	//alert('1');
    var i=0,   aResults=[], oTemp;
	//alert('2');
    for(i = 0; i < oParent.childNodes.length; i++)
	{
		oTemp=oParent.childNodes[i];
		if(oTemp.nodeName==sTagName)
		{
			//alert('4');
			aResults.push(oTemp);
		}
	}
    return aResults;
}


function hideformdiv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showformdiv(id)
{
	//safe function to show an element with a specified id

	if (document.getElementById)
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else
	{
		if (document.layers)
		{ // Netscape 4
			document.id.display = 'block';
		}
		else
		{ // IE 4
			document.all.id.style.display = 'block';
		}
	}

}

function doDateCheck(from, to)
{
         if (Date.parse(from.value) <= Date.parse(to.value))
         {
            return 0;
         }
         else
         {
           if (from.value == "" || to.value == "")
             return 0;
           else
             return 1;
         }
}
function getMouseX(e) {
  if (isIE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY

  return tempX
}
function getMouseY(e) {
  if (isIE) { // grab the x-y pos.s if browser is IE
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempY = e.pageY
  }
  // catch possible negative values in NS4
  if (tempY < 0){tempY = 0}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY

  return tempY
}




/*
The following js's support validating grants.gov form.
They should not be altered unless it's related to grants.gov
*/
function tEmpty(name)
{
	var eles = document.getElementsByName(name); //there should be only one element unless it's radio type
	if(eles != null && eles.length == 1)
	{
		var ele = eles[0];
		if(isEmpty(ele.value))
		{
			ele.style.background='#FF9999';
			ele.select();
			if(confirm("The value must NOT be empty. \nClick cancel to ignore  "+name))
			{
				ele.style.background='#FF9999';
				ele.select();
				return true;
			}
			else
			{
			  //ele.blur();
			  ele.style.background='#FFFFFF ';
			}
			return false;
		}
		else
		{
			return false;
		}
	}
}
/*
function tMinLength(name, length, allowEmpty)
{
	var eles = document.getElementsByName(name); //there should be only one element unless it's radio type


	if(eles != null && eles.length == 1)
	{
		var ele = eles[0];
		if(!allowEmpty && isEmpty(ele.value))
		{
			ele.style.background='#FF9999';
			ele.select();
			if(confirm("The value must NOT be empty. \nClick cancel to ignore  "+name))
			{
				ele.style.background='#FF9999';
				ele.select();
				return true;
			}
			else
			{
			  //ele.blur();
			  ele.style.background='#FFFFFF ';
			  return false;
			}

		}
		else
		{
			if( ele.value != null && ele.value.length < length )
			{
				if(confirm("The value must have at least "+length+" characters. \nClick cancel to ignore  "+name))
				{
					ele.style.background='#FF9999';
					ele.select();
					return true;
				}
				else
				{
				//ele.blur();
					ele.style.background='#FFFFFF ';
					return false;
				}

			}
		}

		return false;

	}
}


function tMaxLength(name, length, allowEmpty)
{
	var eles = document.getElementsByName(name); //there should be only one element unless it's radio type

	if(eles != null && eles.length == 1)
	{
		var ele = eles[0];

		if(!allowEmpty && isEmpty(ele.value))
		{
			ele.style.background='#FF9999';
			ele.select();
			if(confirm("The value must NOT be empty. \nClick cancel to ignore  "+name))
			{
				ele.style.background='#FF9999';
				ele.select();
				return true;
			}
			else
			{
			  //ele.blur();
			  ele.style.background='#FFFFFF ';
			  return false;
			}

		}
		else

		if( ele.value != null && ele.value.length > length )
		{
			if(confirm("The value must have at most "+length+" characters. \nClick cancel to ignore  "+name))
			{
				ele.style.background='#FF9999';
				ele.select();
				return true;
			}
			return false;
		}
	}
	return false;
}
*/
function tString(name, min, max, allowEmpty)
{
	var eles = document.getElementsByName(name); //there should be only one element unless it's radio type
	var title = name.substring(name.lastIndexOf('$') + 1, name.length );
	if(eles != null && eles.length == 1)
	{
		var ele = eles[0];
		title = ele.title;
		var value = ele.value;
		if(!allowEmpty)
		{
			if(isEmpty(value))
			{
				ele.style.background='#FF9999';
				//ele.select();
				resetScroll(ele);

				if(confirm("The value must NOT be empty. \nClick cancel to ignore.\n( "+ title+" )"))
				{
					ele.style.background='#FF9999';
					ele.select();
					return true;
				}
				else
				{

					ele.style.background='#FFFFA0 ';
					return false;
				}
			}
		}
		else
		{
			if(value.length == 0)
			{
				return false;
			}

		}

		if(value.length < min)
		{
			ele.style.background='#FF9999';
			resetScroll(ele);
			if(confirm("The value may have at least "+min+" characters. \nClick cancel to ignore.\n( "+ (title)+" )"))
			{
				ele.style.background='#FF9999';

				ele.select();
				return true;
			}
			else
			{
				ele.style.background='#FFFFFF ';
				return false;
			}
		}

		if(value.length > max)
		{
			ele.style.background='#FF9999';
			resetScroll(ele);
			if(confirm("The value may have at most "+max+" characters. \nClick cancel to ignore.\n( "+ (title)+" )"))
			{
				ele.style.background='#FF9999';
				ele.select();
				return true;
			}
			else
			{
				ele.style.background='#FFFFFF ';
				return false;
			}
		}
	}
	else
	{
		error('Could not find the element.\nPlease note the name and report to administrator.\n Name: ' + name);
	}
	return false;
}



function tDouble(name, min, max, allowEmpty)
{
	var eles = document.getElementsByName(name); //there should be only one element unless it's radio type
	var title = name.substring(name.lastIndexOf('$') + 1, name.length );
	if(eles != null && eles.length == 1)
	{
		var ele = eles[0];
		title = ele.title;
		var value = ele.value;
		if(!allowEmpty)
		{
			if(isEmpty(value))
			{
				ele.style.background='#FF9999';
				//ele.select();
				resetScroll(ele);

				if(confirm("The value must NOT be empty. \nClick cancel to ignore.\n( "+ title+" )"))
				{
					ele.style.background='#FF9999';
					ele.select();
					return true;
				}
				else
				{

					ele.style.background='#FFFFA0 ';
					return false;
				}
			}
		}
		else
		{
			if(value.length == 0)
			{
				return false;
			}

		}
		if(!isFloat(value))
		{
			ele.style.background='#FF9999';
			resetScroll(ele);
			if(confirm("The value must be a floating point number. \nClick cancel to ignore.\n( "+ (title)+" )"))
			{
				ele.style.background='#FF9999';

				ele.select();
				return true;
			}
			else
			{
				ele.style.background='#FFFFFF ';
				return false;
			}
		}


		if(parseFloat(value) < parseFloat(min))
		{
			ele.style.background='#FF9999';
			resetScroll(ele);
			if(confirm("The value must be least "+min+". \nClick cancel to ignore.\n( "+ (title)+" )"))
			{
				ele.style.background='#FF9999';

				ele.select();
				return true;
			}
			else
			{
				ele.style.background='#FFFFFF ';
				return false;
			}
		}

		if(parseFloat(value) > parseFloat(max))
		{
			ele.style.background='#FF9999';
			resetScroll(ele);
			if(confirm("The value must be at most "+max+". \nClick cancel to ignore.\n( "+ (title)+" )"))
			{
				ele.style.background='#FF9999';
				ele.select();
				return true;
			}
			else
			{
				ele.style.background='#FFFFFF ';
				return false;
			}
		}
	}
	else
	{
		error('Could not find the element.\nPlease note the name and report to administrator.\n Name: ' + name);
	}
	return false;
}



function tInteger(name, min, max, allowEmpty)
{
	var eles = document.getElementsByName(name); //there should be only one element unless it's radio type
	var title = name.substring(name.lastIndexOf('$') + 1, name.length );
	if(eles != null && eles.length == 1)
	{
		var ele = eles[0];
		title = ele.title;
		var value = ele.value;
		if(!allowEmpty)
		{
			if(isEmpty(value))
			{
				ele.style.background='#FF9999';
				//ele.select();
				resetScroll(ele);

				if(confirm("The value must NOT be empty. \nClick cancel to ignore.\n( "+ title+" )"))
				{
					ele.style.background='#FF9999';
					ele.select();
					return true;
				}
				else
				{

					ele.style.background='#FFFFA0 ';
					return false;
				}
			}
		}
		else
		{
			if(value.length == 0)
			{
				return false;
			}

		}
		if(!isInteger(value))
		{
			ele.style.background='#FF9999';
			resetScroll(ele);
			if(confirm("The value must be an integer. \nClick cancel to ignore.\n( "+ (title)+" )"))
			{
				ele.style.background='#FF9999';

				ele.select();
				return true;
			}
			else
			{
				ele.style.background='#FFFFFF ';
				return false;
			}
		}


		if(parseInt(value) < parseInt(min))
		{
			ele.style.background='#FF9999';
			resetScroll(ele);
			if(confirm("The value must be least "+min+". \nClick cancel to ignore.\n( "+ (title)+" )"))
			{
				ele.style.background='#FF9999';

				ele.select();
				return true;
			}
			else
			{
				ele.style.background='#FFFFFF ';
				return false;
			}
		}

		if(parseInt(value) > parseInt(max))
		{
			ele.style.background='#FF9999';
			resetScroll(ele);
			if(confirm("The value must be at most "+max+". \nClick cancel to ignore.\n( "+ (title)+" )"))
			{
				ele.style.background='#FF9999';
				ele.select();
				return true;
			}
			else
			{
				ele.style.background='#FFFFFF ';
				return false;
			}
		}
	}
	else
	{
		error('Could not find the element.\nPlease note the name and report to administrator.\n Name: ' + name);
	}
	return false;
}







function resetScroll(ele)
{
	var h = findViewableHeight();
	var w = findViewableWidth();
    var myPageX = findPosX(ele)- w/2;
    var myPageY = findPosY(ele) - h/2;
    if (document.all){
        document.body.scrollLeft = myPageX;
        document.body.scrollTop = myPageY;
    }
    else if (document.documentElement ){
        document.documentElement.scrollLeft  = myPageX;
        document.documentElement.scrollTop = myPageY;
    }
}

function camelcase( s )
{

	if( /\S[A-Z]{2,2}/.test( s ) ) return s;
	s = Trim( s );
	return ( /\S[A-Z]/.test( s ) ) ?
			s.replace( /(.)([A-Z])/g, function(t,a,b) { return a + ' ' + b.toLowerCase(); } ) :
			s.replace( /( )([a-z])/g, function(t,a,b) { return b.toUpperCase(); } );
}
	String.prototype.camelCase =
function()
{
	var s = Trim( this );
	return ( /\S[A-Z]/.test( s ) ) ?
	s.replace( /(.)([A-Z])/g, function(t,a,b) { return a + ' ' + b.toLowerCase(); } ) :
	s.replace( /( )([a-z])/g, function(t,a,b) { return b.toUpperCase(); } );
};



/*
End grants.gov js's
*/

<!--

// function switchDiv()
//  this function takes the id of a div
//  and calls the other functions required
//  to show that div
//

function setDivStyle(div_id, show_type)
{
  var style_sheet = getStyleObject(div_id);
  if (style_sheet != null)
  {
	    style_sheet.visibility = show_type;
        if ( show_type == 'visible' )
   	       style_sheet.display='block';
        else
   	       style_sheet.display='none';
  }
}

function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {
	return document.all(objectId).style;
   }
   else if (document.layers && document.layers[objectId]) {
	return document.layers[objectId];
   } else {
	return false;
   }
}

// -->

function ProcessDivForm( value )
{
    document.THEFORM.FORM_ACTION.value=value;
    setDivMainScrollPosition();
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}


function ProcessDivFormRecord( value, ID )
{
    setDivMainScrollPosition();
    document.THEFORM.FORM_ACTION.value=value;
    document.THEFORM.INDEX.value=ID;
    if ( submission_monitor() )
    {
       document.THEFORM.submit();
    }
}


function ProcessDivDeleteRecord( value )
{
     var agree=confirm("Confirm the Deletion.\nAre you sure you want to delete?");
     if (agree)
     {
        document.THEFORM.FORM_ACTION.value=value;
        setDivMainScrollPosition();
         if ( submission_monitor() )
        {
           document.THEFORM.submit();
        }
     }
}


function ProcessDivSaveRecord( value )
{
    if ( Form_Validator() )
    {
	 document.THEFORM.FORM_ACTION.value=value;
	 setDivMainScrollPosition();
	 if ( submission_monitor() )
	 {
         document.THEFORM.submit();
	 }
    }
}


/* The following  render gradient image in header */

function draw( a, ele )
{
	if(ele == null) return false;
 	var lastLeft = findPosX(ele);
 	var top = findPosY(ele);
 	var height = findHeight(ele);
 	var grid = null;
 	for(i = a.length - 1; i >=0; i--)
 	{
    	grid = document.createElement( 'div' );
    	grid.style.position = 'absolute';
    	grid.style.width = 1;
    	grid.style.height = height;
    	grid.style.backgroundColor = a[i] ;
    	grid.style.left = lastLeft ;
    	grid.style.top = top;
    	lastLeft++;
    	ele.parentNode.appendChild(grid);
 	}
}


function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N)
{
 	if (N==null) return "00";
 	N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 	N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 	return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}

function colourgradient( v1, v2, n )
{
 	v1 = val2hex( v1 );
 	v2 = val2hex( v2 );
 	var a = [];
 	if( ( v1+v2 ).length==12 )
	{
  		var vn = n, 	i = vn + 1,
   		r1 = hex2dec( v1.substring(0,2) ),
   		g1 = hex2dec( v1.substring(2,4) ),
   		b1 = hex2dec( v1.substring(4) ),
   		rs = ( hex2dec( v2.substring(0,2) ) - r1 ) / vn,
   		gs = ( hex2dec( v2.substring(2,4) ) - g1 ) / vn,
   		bs = ( hex2dec( v2.substring(4) ) - b1 ) / vn;
  		while(i--)
    	{
   			a[i] = '#' + dec2hex( r1 ) + dec2hex( g1 ) + dec2hex( b1 );
   			r1 += rs;
   			g1 += gs;
   			b1 += bs;
  		}
 	} else {}
    return a;
}


function dec2hex( s ) { return ( s<15.5 ? '0' : '' ) + Math.round( s ).toString( 16 ); }
function hex2dec( s ) { return parseInt( s, 16 ); }
function val2hex( s ) { return s.toLowerCase().replace( /[^\da-f]/g, '' ).replace( /^(\w)(\w)(\w)$/, '$1$1$2$2$3$3' ); }

function renderGradient()
{
	var header = getElementsByClassName('screen_header')[0];
	if(header == null) return false;
	var bg = '';
	if (header.currentStyle)
	{
     	bg = header.currentStyle['backgroundColor'];
	}
	else if (window.getComputedStyle)
	{
		bg = document.defaultView.getComputedStyle(header,null).getPropertyValue('background-color');
		bg = bg.replace('rgb(','');
		bg = bg.replace(')','');
		token = bg.split(',');
		bg = '#'+RGBtoHex(token[0],token[1],token[2] );
	}
	var imgs = header.getElementsByTagName('img');
	var ele = null;
	for(i = 0; i < imgs.length; i++ )
	{
    	if(imgs[i].src.indexOf('iRIS_Transition.gif') >= 0)
    	{
        	ele = imgs[i];
        	break;
    	}
	}
	if(ele != null)
	{
		var width = findWidth(ele);
		var a = colourgradient( 'FFFFFF', bg, width );
		draw( a, ele );
	}
}


/* End render header gradient */



