<!--
//javascript:window.history.forward(1);

var IDLE_TIME = 900000; // 15 minutes
var timerID = -1;

function resetTimer() 
{
   if (timerID != -1) 
   {
     clearTimeout(timerID);
     startTimer();
   }
}

function startTimer() 
{
   timerID = window.setTimeout("timeOut()",IDLE_TIME);
}

function timeOut() 
{
   if (timerID != -1) 
   {
     // redirect to the logout action servlet
     location.href = 'logout.do';
   }
}


// A utility function that returns true if a string contains only
// whitespace characters.
function isblank(s)
{
  for (var i=0; i < s.length; i++)
  {
     var c = s.charAt(i);
     if((c != ' ') && (c != '') && (c != '\n') && (c != '\t'))
       return false;
  }
  return true;
}

function isnotblank(s)
{
  for (var i=0; i < s.length; i++)
  {
     var c = s.charAt(i);
     if((c != ' ') && (c != '') && (c != '\n') && (c != '\t'))
       return true;
  }
  return false;
}

function contains(s, target)
{
  for (var i=0; i < s.length; i++)
  {
     var c = s.charAt(i);
     if(c == target)
       return true;
  }
  return false;
}


function setFocus(field)
{
  var focusControl = document.getElementById(field);

  if (focusControl.type != "hidden") 
  {
     focusControl.focus();
  }
}


var topHelpWin = null;
function helpwin() 
{

  var winURL    = "help/index.html";
  var winName   = "";
  var winWidth  = 800;
  var winHeight = 500;
  var winResize = "yes";
  var winScroll = "yes";
  var winLeft   = 0;
  var winTop    = 0;
  
  var winParams = "width=" + winWidth + ",height=" + winHeight +
                  ",resizable=" + winResize + ",scrollbars=" + winScroll +
				  ",left=" + winLeft + ",top=" + winTop;
  
  // check if it is not null and already open
  if(topHelpWin != null && !topHelpWin.closed)
  {
    topHelpWin.close(); // close the current help window
  }//end if

  topHelpWin = window.open(winURL, winName, winParams);
  topHelpWin.focus();
}

var popWindow = null;
function showPopupWindow(winURL, winWidth, winHeight, winResize, winScroll) 
{
  //var winURL    = url;
  var winName   = "";
  // var winWidth  = width;
  // var winHeight = height;
  // var winResize = "yes";
  // var winScroll = "yes";
  //var winLeft   = 0;
  //var winTop    = 0;
  
  var winParams = "width=" + winWidth + ",height=" + winHeight +
                  ",resizable=" + winResize + ",scrollbars=" + winScroll;
  //popWindow = window.open(url,'name','height=380,width=400');
  // check if it is not null and already open
  if(popWindow != null && !popWindow.closed)
  {
     popWindow.close(); // close the current help window
  }//end if
   
  popWindow = window.open(winURL, winName, winParams);
  popWindow.focus();
  
}



function keyToUpperCase(field, evt) 
{
  if (document.all) 
  {
    var c = event.keyCode;
    var C = String.fromCharCode(c).toUpperCase().charCodeAt(); 
    event.keyCode = C;
    return true;
  }
  else 
    return true;
}


function validateLoginForm(form) 
{

   if (isblank(form.username.value)) 
   { 
        form.action.value = "Login"; // change the button label
	//This checks to make sure the field is not empty
	alert("Please enter the User Name!"); //Informs user of empty field
	form.username.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }

   if (isblank(form.password.value)) 
   { 
        form.action.value = "Login"; // change the button label
	//This checks to make sure the field is not empty
	alert("Please enter the Password!"); //Informs user of empty field
	form.password.focus(); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }

   // make sure the user selects a db region
   var myindex = form.region.selectedIndex;

   if (myindex==0) 
   {
      form.action.value = "Login"; // change the button label
      alert("\nPlease select a database region!");
      form.region.focus();
      return false; //This prevents the form from being submitted
   }
      
      
   return (true);
}

var defaultComments = "Enter your message here. Maximum 500 characters.";

function clearComments(obj)
{
   if (obj.value == defaultComments)
   {
   	obj.value = "";
   }

}

function validateRecordPropertiesForm(form)
{
   if (isblank(form.recordName.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("No record to edit!"); //Informs user of empty field
	return false; //This prevents the form from being submitted
   }
}

function validateRecordSearchForm(form) 
{
   if (isblank(form.recordName.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Please enter Record Name!"); //Informs user of empty field
	form.recordName.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
      
   return (true);
}

function validateFieldSearchForm(form) 
{
   if (isblank(form.fieldName.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Please enter Field Name!"); //Informs user of empty field
	form.fieldName.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
      
   return (true);
}



function validateFieldCopyForm(form) 
{
   if (isblank(form.fieldNameFrom.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Field cannot be left blank!"); //Informs user of empty field
	form.fieldNameFrom.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
   else if (isblank(form.fieldNameTo.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Field cannot be left blank!"); //Informs user of empty field
	form.fieldNameTo.focus(); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
      
   return (true);
}

// Used to validate the Field Create Form
function validateFieldCreateForm(form)
{
   var fieldname = form.fieldName.value;

   if (isblank(fieldname)) 
   { 
	//This checks to make sure the field is not empty
	alert("Field Name is a required field."); //Informs user of empty field
	form.fieldName.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   } 
   else if (fieldname == "FILLER") 
   { 	
	alert("Field name invalid."); 
	form.fieldName.focus( ); 
	return false; //This prevents the form from being submitted
   }

   if (contains(fieldname,'\'')) 
   { 	
	alert("The field name can not contain single quotes."); 
	form.fieldName.focus( ); 
	return false; //This prevents the form from being submitted
   }     
   
   
   // validate storageType
   myOption = -1;
   var storagetype;
   for (i=form.storageType.length-1; i > -1; i--) 
   {
      if (form.storageType[i].checked) 
      {
        myOption = i;
        storagetype = form.storageType[i].value;
        break;
      }
   }
   
   if (myOption == -1) 
   {
      alert("You didn\'t choose any of the Storage Type!");
      return false;
   }   
   // If this is not an 88-level, then an input format should be entered
   else if ((storagetype != "8") && isblank(form.inputFormat.value))
   {
      alert("Input format must be entered for any Storage Type other than 88-Level.");
      return false;      
   }   
   // If this is not an 88-level, then an input format should be entered
   else if ((storagetype != "8") && isblank(form.outputFormat.value))
   {
      alert("Output format must be entered for any Storage Type other than 88-Level.");
      return false;      
   }
   // If this is an 88-level, then an input format should not be entered
   else if ((storagetype == "8") && !isblank(form.inputFormat.value))
   {
      alert("Input format not allowed for 88-Level fields.");
      return false;      
   }   
   // If this is an 88-level, then an input format should not be entered
   else if ((storagetype == "8") && !isblank(form.outputFormat.value))
   {
      alert("Output format not allowed for 88-Level fields.");
      return false;      
   }    
   else if (isblank(form.databasePicture.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Database Picture is a required field."); //Informs user of empty field
	form.databasePicture.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
   
   else if ((storagetype != "8") && isblank(form.inputFormat.value) && (form.inputFormat.value.charAt(0) != 'X')) 
   { 
   	alert("Input format must be represented by an X picture clause, for example X(10)."); 
   	form.inputFormat.focus( ); 
   	return false; 
   }   


   return (true);
}


function validateRecordCopyForm(form) 
{
   if (isblank(form.recordNameFrom.value)) 
   { 
	//This checks to make sure the record is not empty
	alert("Record cannot be left blank!"); //Informs user of empty record
	form.recordNameFrom.focus( ); //This focuses the cursor on the empty record
	return false; //This prevents the form from being submitted
   }
   else if (isblank(form.recordNameTo.value)) 
   { 
	//This checks to make sure the record is not empty
	alert("Record cannot be left blank!"); //Informs user of empty record
	form.recordNameTo.focus(); //This focuses the cursor on the empty record
	return false; //This prevents the form from being submitted
   }
      
   return (true);
}

// Used to validate the Field Create Form
function validateFieldCreateForm(form)
{
   var fieldname = form.fieldName.value;

   if (isblank(fieldname)) 
   { 
	//This checks to make sure the field is not empty
	alert("Field Name is a required field."); //Informs user of empty field
	form.fieldName.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   } 
   else if (fieldname == "FILLER") 
   { 	
	alert("Field name invalid."); 
	form.fieldName.focus( ); 
	return false; //This prevents the form from being submitted
   }

   if (contains(fieldname,'\'')) 
   { 	
	alert("The field name can not contain single quotes."); 
	form.fieldName.focus( ); 
	return false; //This prevents the form from being submitted
   }     
   
   
   // validate storageType
   myOption = -1;
   var storagetype;
   for (i=form.storageType.length-1; i > -1; i--) 
   {
      if (form.storageType[i].checked) 
      {
        myOption = i;
        storagetype = form.storageType[i].value;
        break;
      }
   }
   
   if (myOption == -1) 
   {
      alert("You didn\'t choose any of the Storage Type!");
      return false;
   }   
   // If this is not an 88-level, then an input format should be entered
   else if ((storagetype != "8") && isblank(form.inputFormat.value))
   {
      alert("Input format must be entered for any Storage Type other than 88-Level.");
      return false;      
   }   
   // If this is not an 88-level, then an input format should be entered
   else if ((storagetype != "8") && isblank(form.outputFormat.value))
   {
      alert("Output format must be entered for any Storage Type other than 88-Level.");
      return false;      
   }
   // If this is an 88-level, then an input format should not be entered
   else if ((storagetype == "8") && !isblank(form.inputFormat.value))
   {
      alert("Input format not allowed for 88-Level fields.");
      return false;      
   }   
   // If this is an 88-level, then an input format should not be entered
   else if ((storagetype == "8") && !isblank(form.outputFormat.value))
   {
      alert("Output format not allowed for 88-Level fields.");
      return false;      
   }    
   else if (isblank(form.databasePicture.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Database Picture is a required field."); //Informs user of empty field
	form.databasePicture.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
   
   else if ((storagetype != "8") && isblank(form.inputFormat.value) && (form.inputFormat.value.charAt(0) != 'X')) 
   { 
   	alert("Input format must be represented by an X picture clause, for example X(10)."); 
   	form.inputFormat.focus(); 
   	return false; 
   }   


   return (true);
}


function validateTableCopyForm(form) 
{
   if (isblank(form.tableNameFrom.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Copy From table name cannot be left blank!"); //Informs user of empty field
	form.fieldNameFrom.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
   else if (isblank(form.tableNameTo.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Copy To table name cannot be left blank!"); //Informs user of empty field
	form.fieldNameTo.focus(); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
      
   return (true);
}


function validateTableSearchForm(form) 
{
   if (isblank(form.tableName.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Please enter Table Name!"); //Informs user of empty field
	form.tableName.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
      
   return (true);
}


function validateReportSearchForm(form)
{
   if (isblank(form.reportName.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Please enter Report Name!"); //Informs user of empty field
	form.reportName.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
      
   return (true);
}


function validateScreenSearchForm(form) 
{
   if (isblank(form.screenName.value)) 
   { 
	//This checks to make sure the field is not empty
	alert("Please enter Screen Name!"); //Informs user of empty field
	form.screenName.focus( ); //This focuses the cursor on the empty field
	return false; //This prevents the form from being submitted
   }
      
   return (true);
}


function dropDownMenu(form)  
{
   var myindex=document.forms[0].highLevelRecordName.selectedIndex;
   if (myindex==0) 
   {
      alert("\nYou must select a high level record name from the drop-down menu.");
      document.forms[0].highLevelRecordName.focus();
   }
   else 
   {
     menu_selection=document.forms[0].menu.options[myindex].value;
     return true;
   }
}

function disableFormatFields()
{
   document.fieldBean.inputFormat.disabled=true;
   document.fieldBean.inputFormat.value = "";
   document.fieldBean.outputFormat.disabled=true;
   document.fieldBean.outputFormat.value = "";
}

function enableFormatFields()
{
   document.fieldBean.inputFormat.disabled=false;
   document.fieldBean.outputFormat.disabled=false;
} 


// Used to validate the Record Edit Form
function validateRecordEditForm(form)
{

   var recordname = form.recordName.value;

   
}


// Used to validate the Record Create Form
function validateRecordCreateForm(form)
{

   var recordname = form.recordName.value;

   if (isblank(recordname)) 
   { 
	//This checks to make sure the record is not empty
	alert("Record Name is a required record."); //Informs user of empty record
	form.recordName.focus( ); //This focuses the cursor on the empty record
	return false; //This prevents the form from being submitted
   } 
   else if (recordname == "FILLER") 
   { 	
	alert("Record name invalid."); 
	form.recordName.focus( ); 
	return false; //This prevents the form from being submitted
   }

   if (contains(recordname,'\'')) 
   { 	
	alert("The record name can not contain single quotes."); 
	form.recordName.focus( ); 
	return false; //This prevents the form from being submitted
   } 
   
}



function newWindow(mypage, myname, w, h, scroll) 
{
	var winl = screen.width - w-20;
	var wint = 15;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// this script will generate values for the calendar page

function y2k(number)    { return (number < 1000) ? number + 1900 : number; }
function padout(number) { return (number < 10) ? '0' + number : number; }

var today = new Date();
var day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear()), whichOne = 0;

function restart() 
{
    document.voipForm.elements[document.voipForm.selectedField.value].value = '' + padout(month - 0 + 1) + '/' + padout(day) + '/' + year;
    mywindow.close();
}

function calendarWindow(selectedtype) 
{
	document.voipForm.selectedField.value = selectedtype ; 
	var winl = screen.width - 500;
	var wint = 100;
	winprops = 'height='+270+',width='+350+',top='+wint+',left='+winl+',resizable=no'
	
    day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear());
    mywindow=open('calendar.html','myname',winprops);
    mywindow.location.href = 'calendar.html';
    if (mywindow.opener == null) mywindow.opener = self;
}

function redirect(url)
{
   window.location = url;
   return;
}


function highlightRow (element, color) 
{
  
  while (element.tagName.toUpperCase() != 'TR' && element != null)
    element = document.all ? element.parentElement : element.parentNode;
  if (element)
    element.bgColor = color;
   
  document.all.selectIndex.value = element.value; 
  alert("document.all.selectIndex.value="+document.all.selectIndex.value);
    
}

function resetHighlightRow (element, color) 
{
  while (element.tagName.toUpperCase() != 'TR' && element != null)
    element = document.all ? element.parentElement : element.parentNode;
  if (element)
    element.bgColor = color;
}

function formCheck(url) 
{
  if (document.all.selectIndex.value != null) 
  {
     location.href = url;
     return true;
  }
  else
  {
     alert("Please select a record.");
     return false;
  }
  return false;
}


function radio_input(url)
{
   // Re-direct the browser to the url value
   window.location.href =  url 
}


//  check for valid numeric strings	
function isNumeric(strString)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
   }
   return blnResult;
}

function currencyFormat(fld, milSep, decSep, e) {
  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
  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  len = fld.value.length;
  for(i = 0; i < len; i++)
  if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
  aux = '';
  for(; i < len; i++)
  if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
  aux += key;
  len = aux.length;
  if (len == 0) fld.value = '';
  if (len == 1) fld.value = '0'+ decSep + '0' + aux;
  if (len == 2) fld.value = '0'+ decSep + aux;
  if (len > 2) {
    aux2 = '';
    for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
    }
    fld.value = '';
    len2 = aux2.length;
    for (i = len2 - 1; i >= 0; i--)
    fld.value += aux2.charAt(i);
    fld.value += decSep + aux.substr(len - 2, len);
  }
  return false;
}


function formatNumber(obj, decimal) 
{

  if (obj.value.length == 0)
  {
    return;
  }

  anynum = obj.value;
  anynum = replace(anynum,",", "");
  divider =10;
  switch(decimal)
  {
	case 0:
		divider =1;
		break;
	case 1:
		divider =10;
		break;
	case 2:
		divider =100;
		break;
	default:
		divider =1000;
   }

   workNum=Math.abs((Math.round(anynum*divider)/divider));

   workStr=""+workNum;

   if (workStr.indexOf(".")==-1){workStr+="."}

   dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0
   pStr=workStr.substr(workStr.indexOf("."))

   while (pStr.length-1< decimal)
   {
	  pStr+="0"
   }

   if(pStr =='.') 
   	pStr ='';

   if (dNum>=1000) 
   {
	  dLen=dStr.length
	  dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
   }

   if (dNum>=1000000) 
   {
	  dLen=dStr.length
	  dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
   }
   retval = dStr + pStr

   if (anynum < 0) 
   {
   	retval="";
   }
   obj.value = retval;

}

function replace(string,text,by) 
{
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;
	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;
	var newstr = string.substring(0,i) + by;
	if (i+txtLength < strLength)
	newstr += replace(string.substring(i+txtLength,strLength),text,by);
	return newstr;
}
 
//-->