status = 'Entertainment Industry 401(k) Plan';

function autotab(cur_field, char_max, next_field){  
   if (cur_field.value.length == char_max){
     next_field.focus();
   }
}

function changebgNew(cell) {
	cell.style.backgroundColor="blue";
}

function changebgOld(cell) {
	cell.style.backgroundColor="#000099";
}

function changeCase(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	tmpStr = frmObj.value.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			} else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	frmObj.value = tmpStr;
}

function displayText() {
  if (document.getElementById) {
	text = document.getElementById('txt').style;
  } else if (document.all) {
	text = document.all.txt.style;
  } else if (document.layers) {
	text = document.txt;
  }
  text.visibility = 'visible';
}

function goHome() {
     var addr;
     addr = "http://www.entind-401kplan.com";
	 parent.location.href = addr; 
}


//Original: Sandeep V. Tamhankar (stamhankar@hotmail.com)
//This script and many more are available free online at
//The JavaScript Source!! http://javascript.internet.com
//modified by William S. Markley (markleyws@earthlink.net) for different date patterns, 
//special variables and different alerts.
function isValidDate(dateStr,format) {
	// Checks for the following valid date formats: 
	// format 1 = MM/DD/YY or MM-DD-YY (this is also the default if no 'format' parameter is sent)
	// format 2 = MM/DD/YY
	// format 3 = MM/DD/YYYY or MM-DD-YYYY
	// format 4 = MM/DD/YYYY
	
	// Also separates date into month, day, and year variables
	
	if (format=="1") {
	  var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;  // MM/DD/YY or MM-DD-YY 
	} else if (format=="2") { 
      var datePat = /^(\d{2})(\/)(\d{2})\2(\d{2})$/;  // MM/DD/YY only
	} else if (format=="3") {
	  var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // MM/DD/YYYY or MM-DD-YYYY
	} else if (format=="4") {
      var datePat = /^(\d{2})(\/)(\d{2})\2(\d{4})$/;  // MM/DD/YYYY only
	} else {
	  var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;  // MM/DD/YY or MM-DD-YY by default
	}
		
	var matchArray = dateStr.match(datePat); // is the format ok? 
//	alert(matchArray);
	if (matchArray == null) { 
		alert("Date is not in a valid format."); 
		return false; 
	}
	month = matchArray[1]; // parse date into variables 
	day = matchArray[3]; 
	year = matchArray[4];
	dobStr = month + day + year;	
	if (month < 1 || month > 12) { // check month range 
		alert("Month must be between 01 and 12."); 
		return false; 
	} 
	if ((month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)&& (day < 1 || day > 31)) {
		alert("Day must be between 01 and 31."); 
		return false; 
	}	
	if ((month==4 || month==6 || month==9 || month==11) && (day <1 || day>30)) {
		alert("Day must be between 01 and 30."); 
		return false;
	} 
	if (month == 2) { // check for february 
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if(isleap && (day < 1 ||day > 29)) {
		    alert("February day must be between 01 and 29.");
			return false;	
		} else if (!isleap && (day <1 || day > 28)) { 
			alert("February day must be between 01 and 28."); 
			return false; 
		} 
	} 
//    alert("dobStr= " +dobStr+ " year= " +year+ " month= " +month+ " day= " +day);
	return true; // date is valid  
}

function logOut() {
//  alert("logOut()");
	var addr;
	addr = "https://www.data-server.info/401kPlan/conBPI_logout.asp?login=" + ssnpin3;
	showProgress2();
//	alert(addr);
	parent.location.href = addr; 
}

function LTrim(str) {
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1) {
         j++;
      }
      s = s.substring(j, i);
   }
   return s;
}

function OpenCertDetails(){
    thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=USWILL66-1', 'anew', config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}

function printPage() {
	var menuLine;
	var thawte;
	thawte = "empty";
	if (window.print) {
		if (document.getElementById) {
			menuLine = document.getElementById("menuLine");
			if (document.getElementById('thawte')) {
				thawte = document.getElementById('thawte');
			}
		} else if (document.all) {
			menuLine = document.all.menuLine;
			if (document.all.thawte) {
				thawte = document.all.thawte;
			}
		} else if (document.layers) {
			menuLine = document.menuLine;
			if (document.thawte) {
				thawte = document.thawte;
			}
		}
		menuLine.style.visibility = "hidden";
		if(thawte != "empty") {
			thawte.style.visibility = "hidden"
		}
		
		window.print();
		
		menuLine.style.visibility = "visible";
		if(thawte != "empty") {
			thawte.style.visibility = "visible";
		}
	} else {
		alert("This command will not work with your current browser.  Please use \"File/Print\" or use the print button on your brower menu line.");
	}
}

function progress_update() {
	progressAt++;
	if (progressAt > progressEnd) 
	  progress_clear();
	else document.getElementById('progress'+progressAt).style.backgroundColor = progressColor;
	progressTimer = setTimeout('progress_update()',progressInterval);
}

function progress_update2() {
//	alert("progress_update2 function");
	var progressClr;
	progressClr = progressAt-1;
	if (progressAt > progressEnd) {
		progressAt = 1;
	}
	document.getElementById('progress'+progressAt).style.visibility='visible';
//	alert(progressAt +"  "+ progressClr);
//	alert('progress'+progressAt);
	if (progressClr < 1) {
		document.getElementById('progress'+progressEnd).style.visibility='hidden';
	} else {
		document.getElementById('progress'+progressClr).style.visibility='hidden'; 
	}
	progressAt++;
	progressTimer = setTimeout('progress_update2()',progressInterval);
}

function progress_clear() {
	for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).style.backgroundColor = 'transparent';
	progressAt = 0;
}

function progress_stop() {
	clearTimeout(progressTimer);
	progress_clear();
}

function progress_stop2() {
	clearTimeout(progressTimer);
}

function roundNum(xnum,xdec) {
	xnum = "" + xnum //convert value to string
	xdec = parseInt(xdec);
	var pos = xnum.indexOf(".");
	var whole = "" + Math.round(xnum * Math.pow(10,xdec));
//	alert("xnum="+xnum+"   xdec="+xdec+"   whole="+whole+"   Math.power="+Math.pow(10,xdec)+"   " +Math.pow(10,-xdec)+"   pos="+pos);		
	if (xdec < 0) {
	   rtnStr = whole.substring(0,pos) * Math.pow(10,-xdec) ;
	   return rtnStr;
	}
	if (pos != 0){
	   rtnStr = whole.substring(0,pos);
	   rtnStr += ".";
	   rtnStr += whole.substring(pos,whole.length);
	} else {
	   rtnStr = whole;
	}
	if (xdec == 0){
	  rtnStr = rtnStr.substring(0,pos);
	}
	return rtnStr;
}

function RTrim(str)  {
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
         i--;
      }
      s = s.substring(0, i+1);
   }
   return s;
}

function rtnAcctAccess()  {
	var addr;
	addr = "https://www.entind-401kplan.com/ai-query-main.php?login=" + ssnpin3;
//	alert(addr);
	parent.location.href = addr; 
}

function showProgress() {
   displayText();
   progress_update();
}

function showProgress2() {
//	alert("showProgress2");
	placeIt();
	showIt();
	progress_update2(); 
}

function Trim(str) {
    return RTrim(LTrim(str));
}

function writeLogo(pageName) {   //writes the 401(k)Plan logo & page name (if any) and a horizontal line
  document.write("<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0><TR>");
  document.write("<TD ROWSPAN=3 WIDTH=400><IMG SRC=images/401k_title.gif WIDTH=400 HEIGHT=116></TD>");
  document.write("<TD VALIGN=BOTTOM><DIV ALIGN=RIGHT><FONT COLOR=#990033 SIZE=5><B>");
	if (pageName=="" || pageName==" " || pageName=="undefined" || pageName==undefined) {
		document.write ("&nbsp;");
	} else {
  	document.write(pageName);
	}
  document.write("</B></FONT></DIV></TD></TR>");
  document.write("<TR><TD><HR SIZE=6 WIDTH=100% COLOR=#990033></TD></TR>");
  document.write("<TR><TD></TD></TR></TABLE>");
}

function writeMenuLine(menuItems) {  //writes out the navigational buttons on the menu line
	document.write("<DIV ID='menuLine' CLASS='margin' ALIGN='RIGHT'>");
	if (menuItems.indexOf("print") != -1) {
		document.write("<A HREF='javascript: printPage()' CLASS='navbutton'>&nbsp;&nbsp;Print This Page&nbsp;&nbsp;</A>&nbsp;");
	}
	if (menuItems.indexOf("access") != -1) {
		document.write("<A HREF='javascript: rtnAcctAccess()' CLASS='navbutton'>&nbsp;&nbsp;Return to On-line Account Access&nbsp;&nbsp;</A>&nbsp;");
	}
	if (menuItems.indexOf("home") != -1) {
		document.write("<A HREF='javascript: goHome()' CLASS='navbutton'> &nbsp;&nbsp;Home&nbsp;&nbsp;</A>&nbsp;");
	}
	document.write("<A HREF='javascript: logOut()' CLASS='navbutton'>&nbsp;&nbsp;LogOut&nbsp;&nbsp;</A></DIV>");
}

function writeThawteSeal() {
  var sealCode;
//  sealCode = "<DIV ID='thawte'><A HREF='javascript:OpenCertDetails()'><IMG SRC='images/200x35_static.gif' BORDER=0 ALT='Click here for more details'></A></DIV>";
	sealCode="<script language='javascript' src='https://siteseal.thawte.com/cgi/server/thawte_seal_generator.exe'></script>";
  document.write(sealCode);
}

function writeTopRow(title1,title2) {     //writes the logo in the corner & the arrows and sections name
  document.write("<TR ALIGN='left'>");
	document.write("<TD ID='menu' WIDTH='225' ALIGN='center'><IMG SRC='images/401k_logo_white.gif' WIDTH='216' HEIGHT='76'></TD>");
  document.write("<TD VALIGN='top'><BR><IMG ALIGN='top' SRC='images/spacer.gif' WIDTH='10'><IMG ALIGN='top' SRC='images/right-aro.gif' WIDTH='20' HEIGHT='21'>");
	document.write("<FONT FACE='helvetica, arial' COLOR='#990000' SIZE='4'><B>");
	document.write(title1);
	if (title2 == "" || title2 == " " || title2 == "undefined" || title2 == undefined) {
	} else {
	  document.write("<BR><IMG ALIGN='top' SRC='images/spacer.gif' WIDTH='20'><IMG ALIGN='top' SRC='images/right-aro.gif' WIDTH='20' HEIGHT='21'>");
	  document.write(title2);
	  document.write("<BR>");
	}
	document.write("</B></FONT></TD></TR>");
}
function showProgress2() {
//	alert("showProgress2");
	placeIt();
	showIt();
	progress_update2(); 
}
function progress_update2() {
//	alert("progress_update2 function");
	var progressClr;
	progressClr = progressAt-1;
	if (progressAt > progressEnd) {
		progressAt = 1;
	}
	document.getElementById('progress'+progressAt).style.visibility='visible';
//	alert(progressAt +"  "+ progressClr);
//	alert('progress'+progressAt);
	if (progressClr < 1) {
		document.getElementById('progress'+progressEnd).style.visibility='hidden';
	} else {
		document.getElementById('progress'+progressClr).style.visibility='hidden'; 
	}
	progressAt++;
	progressTimer = setTimeout('progress_update3()',progressInterval);
}
