// Navigation

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Switch Frames

function showHomeNav() {
top.main.cols="*,1024";
top.appFrameset.rows="27,*";
}
function showFileNav() {
top.main.cols="*,1024";
top.appFrameset.rows="54,*";
}
function showInbox() {
top.main.cols="1024,*";
}
function hideInbox() {
top.main.cols="*,1024";
}
function showQueue() {
top.appFrameset.rows="27,*";
}
function hideAllNav() {
top.main.cols="*,1024"
top.appFrameset.rows="0,100%"
}
// New Mail

function newMail() {
top.appNav.inboxTD.className="inboxHot";
top.inboxNav.inboxTD.className="inboxHot";
top.appNav.form1.inbox.className="inboxHotButton";
top.inboxNav.form1.inbox.className="inboxHotButton";
}

// Automatically figure out the first textfield that has to be filled in
function focusForm() {

  // If there is a form in the doc...
  if (document.forms) {

    theElems = document.forms[0].elements;
    // loop over the elements until finding a non-hidden one
    for (i = 0; i < theElems.length; i++) {
      theElem = theElems[i];
      if
	  (theElem.readonly=="readonly") {
        continue;
      }
      // focus on the first non-hidden element
      theElem.focus();
      break;
    }
  }
}

//END

// Automatically tab to the next field when filling SSN and Phone Numbers

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

//END

// Open and Close section 

function toggleFirstSection(divObj1,divObj2) {

state = document.getElementById(divObj2).style.display;

if(state != null && state == "none")
 {
 document.getElementById(divObj1).className = "firstSectionOpen";
 document.getElementById(divObj2).style.display = "block";

  } 
  else 
  {
 	document.getElementById(divObj1).className = "firstSectionClose";
	document.getElementById(divObj2).style.display = "none";

  }
}

function toggleSecondSection(divObj1,divObj2) {

state = document.getElementById(divObj2).style.display;
 
 if(state != null && state == "none") 
 {
  document.getElementById(divObj1).className = "secondSectionOpen";
  document.getElementById(divObj2).style.display = "block";
  window.scrollBy(0,(event.y-10)); 
  } 
  else 
  {
   document.getElementById(divObj1).className = "secondSectionClose";
   document.getElementById(divObj2).style.display = "none";
   window.scrollBy(0,(event.y-10)); 
  }
}

function toggleThirdSection(divObj1,divObj2) {

state = document.getElementById(divObj2).style.display;
 
 if(state != null && state == "none") 
 {
  document.getElementById(divObj1).className = "thirdSectionOpen";
  document.getElementById(divObj2).style.display = "block";
  window.scrollBy(0,(event.y-10)); 
  } 
  else 
  {
   document.getElementById(divObj1).className = "thirdSectionClose";
   document.getElementById(divObj2).style.display = "none";
   window.scrollBy(0,(event.y-10)); 
  }
}
//END

// Check for MAXLENGTH in TEXTAREA

function CheckLength(length) {
if (window.event.srcElement.value.length >= length) {
	alert('You have reached the maximum length of 1000 characters permitted here.');
		return false;
		}
}

// END

// Enable Texboxes for specific conditions by checking checkboxes or radio buttons

function enableTextBox(radioButton,textbox) {
radioState = document.getElementById(radioButton).checked;
if (radioState == checked)
	{
	document.getElementById(textbox).readonly != "readonly";
	}
	else
	{
	document.getElementById(textbox).readonly == "readonly";
	}
}

// END

// Highlight textboxes that are inFocus

function f(tb) {
tb.style.backgroundColor= "#FFFF99";
}

function b(tb) {
tb.style.backgroundColor= "#FFFFFF";
}
// END

function blank(tb) {
tb.value = "";
}


function check(cb,f) {
if (cb.checked == true)
	checkAll(f);
	else
	uncheckAll(f);
}	

// Check/Uncheck All Check boxes

function uncheckParent(thisCB,pCB) {
	pCB.checked = false;
	}
	

function checkAll(f)
{
    if ((f.length == null) || (f.length == "undefined")) {
        f.checked = true;
    }
    else {
        for (i = 0; i < f.length; i++) {
            f[i].checked = true ;
            }
        }
}

function uncheckAll(f)
{
    if ((f.length == null) || (f.length == "undefined")) {
        f.checked = false;
    }
    else {
        for (i = 0; i < f.length; i++) {
            f[i].checked = false ;
            }
    }
}

// END
function enableDisableAll(cb,f) {
if (cb.checked == true)
	enableAll(f);
	else
	disableAll(f);
}	

// Check/Uncheck All Check boxes

function disableAll(f)
{
for (i = 0; i < f.length; i++)
	f[i].disabled = false ;
}

function enableAll(f)
{
for (i = 0; i < f.length; i++)
	f[i].disabled = true ;
}

function openBrWindow(theURL) { 
var winName = "Popup";
var features = "scrollbars=yes,width=400,height=300";

  window.open(theURL,winName,features);
}

	// JavaScript Document
	function submitform()
	{
	
			document.loginEntry.action = "../html/Client_Home.htm";
			 
		
		document.loginEntry.submit();
	}
	
	
function ltrim(str){
        return str.replace(/^\s+/, '');
    }

function rtrim(str) {
        return str.replace(/\s+$/, '');
    }

function alltrim(str) {
        return str.replace(/^\s+|\s+$/g, '');
    }