var FAQWindow;
var FormsListWindow;
var HelpWindow;	
var OfxWindow;
var PrintWindow;
var ReportWindow;
var SiteMapWindow;
var SummaryWindow;
var SupportWindow;
var TaxAdviceWindow;
var LogoutWindow;
var HelpCenterWindow;
var MyAccountWindow;
var PrintCenterWindow;
var EFCenterWindow;
var EFStatusWindow;
var EmailPrefWindow;
var	UpdateAccountWindow;

var ie = document.all ? 1 : 0
var ns = document.layers ? 1 : 0
var ns6 = document.getElementById&&!document.all ? 1 : 0
var bInSubmit = false;
var cLastTaxYear = 2004;
var cTaxYear = 2005;
var cNextTaxYear = 2006;
var cPreviewVersion = "PREVIEW"
var cFINALVersion = "FINAL"
var cVersion = "FINAL"				//	BUGBUG - Update for PREVIEW/FINAL
var	cImagesDir = "images/final/"	//	BUGBUG - Update for PREVIEW/FINAL

//------ IE openurl ----------------------------------

function IsPreview() {
	if (cVersion == cPreviewVersion)
		return true;
	else
		return false;
}
function FinalOnly(sFeature) {
	window.alert (sFeature + ' is only available in the Final Filing Version of TaxACT Online, which will be available in January, ' + cNextTaxYear + '.');
}

function ClearInSubmit () {
	bInSubmit = false;
}

function ResetLogoutTimer(){
	if (this.parent.mainbody_frame)
		this.parent.mainbody_frame.ResetLogoutTimer();
	else if (window.opener) {
		if (window.opener.parent.mainbody_frame)
			window.opener.parent.mainbody_frame.ResetLogoutTimer();
	}
}

function OnClickHandler(){
	if (IsMicrosoft()){
		var el=null;
		var flag=true;
		el = event.srcElement;
		while (flag && el){
			if (el.tagName == "A"){
				flag=false;
				if (el.protocol == "javascript:"){
					execScript(el.href, "javascript");
					window.event.returnValue = false;
				}
				if (el.protocol == "vbscript:"){ 
					execScript(el.pathname, "vbscript");
					window.event.returnValue = false;
				}
			}else{
				el = el.parentElement;
			}
		}
	}
}

//------ functions for form fields ----------------------------------

function IsMac(){
	return (navigator.platform.indexOf("Mac") >= 0);
}

function IsNetscape(){
	return (navigator.appName == "Netscape");
}

function IsMicrosoft(){
	return ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform == "Win32"));
}

function calcSetModified(){
	document.TAForm.FLD_MODIFIED.value = "1";
}

function calcSetFieldModified(fld){
	fld.value = "1";
	calcSetModified();
}

//	These 2 functions are used by Details functions from pop-up window
function calcSetModified_2(){
	window.opener.document.TAForm.FLD_MODIFIED.value = "1";
}

function calcSetFieldModified_2(fld){
	fld.value = "1";
	window.opener.calcSetModified();
}

function calcFieldButtonClick(btn){
	if (btn.name.indexOf("FBTN_IDC_DELETE_STATE_",0) != -1){
		if (!window.confirm("Are you sure you want to delete this state?"))
			return;
	}
	calcSetModified();
	document.TAForm.hidden_Button.value = btn.name;
	//	NIB 12/13/2003 - Changed the following line to fix problem in NS 6.01
	//	if (document.TAForm.onsubmit()){
	if (OnSubmitForm(document.TAForm) == true) {
		document.TAForm.submit();
	}
}

function calcImageButtonClick(btnname){
	if (btnname != "Step1" && !document.TAForm.hidStep1Comp){
		window.alert("You must start with Step 1. Basic Information.");
		return;
	}
	document.TAForm.hidden_Button.value = btnname;
	//	NIB 12/13/2003 - Changed the following line to fix problem in NS 6.01
	//	if (document.TAForm.onsubmit()){
	if (OnSubmitForm(document.TAForm) == true) {
		document.TAForm.submit();
	}
}

function calcButtonClick(btn){
	if ((btn.name == "FBTN_NEWFORM") && document.TAForm.FCPY_LIST){
		var lst;
		lst = document.TAForm.FCPY_LIST;
		if (lst.options[lst.length - 1].value != "0"){
			return;
		}
	}else if ((btn.name == "FBTN_REVIEWFORM") && document.TAForm.FCPY_LIST){
		var lst;
		lst = document.TAForm.FCPY_LIST;
		if ((lst.selectedIndex < 0) || (lst.options[lst.selectedIndex].value == "0")){
			return;
		}
	}else if ((btn.name == "FBTN_DELETEFORM") && document.TAForm.FCPY_LIST){
		var lst;
		var opt;
		var msg;
		lst = document.TAForm.FCPY_LIST;
		if ((lst.selectedIndex < 0) || (lst.options[lst.selectedIndex].value == "0")){
			return;
		}
		opt = document.TAForm.FCPY_LIST.options[lst.selectedIndex];
		msg = "Do you wish to delete ";
		msg += opt.text;
		msg += "?  Click OK to proceed.";
		if (!window.confirm(msg)){
			return;
		}
		//document.TAForm.action = "javascript:location.replace('http://localhost/onlineta/taxmanager.dll/OnSubmit')";
		//document.TAForm.hidden_Button.value = btn.name;
		//location.reload(true);
		//location.replace("http://localhost/onlineta/taxmanager.dll/OnSubmit");
		//return;
	}else if (btn.name == "FBTN_IDC_HOMEPAGE"){
		var BrowseWindow;
		var cx = 640;//this.screen.width-25;
		var cy = 480;//this.screen.height-50;
		BrowseWindow = window.open("http://www.taxact.com","TaxACTHelpWindow","toolbar,resizable,scrollbars,left=0,top=0,height="+cy+",width="+cx);
		BrowseWindow.opener = self;
		return;
	}
	document.TAForm.hidden_Button.value = btn.name;
	//	NIB 12/13/2003 - Changed the following line to fix problem in NS 6.01
	//	if (document.TAForm.onsubmit()){
	if (OnSubmitForm(document.TAForm) == true) {
		document.TAForm.submit();
	}
}

function calcCopyListChange(lst){
	if (lst.form.FBTN_NEWFORM){
		if (lst.options[lst.length - 1].value != "0"){
			lst.form.FBTN_NEWFORM.disabled = true;
		}else{
			lst.form.FBTN_NEWFORM.disabled = false;
		}
	}
	if (lst.form.FBTN_REVIEWFORM && lst.form.FBTN_DELETEFORM){
		if ((lst.selectedIndex < 0) || (lst.options[lst.selectedIndex].value == "0")){
			lst.form.FBTN_REVIEWFORM.disabled = true;
			lst.form.FBTN_DELETEFORM.disabled = true;
		}else{
			lst.form.FBTN_REVIEWFORM.disabled = false;
			lst.form.FBTN_DELETEFORM.disabled = false;
		}
	}
}

function calcCopyListDblClick(lst){
	if (lst.selectedIndex >= 0){
		if (lst.options[lst.selectedIndex].value == "0"){
			document.TAForm.hidden_Button.value = "FBTN_NEWFORM";
		}else{
			document.TAForm.hidden_Button.value = "FBTN_REVIEWFORM";
		}
	}
	if (lst.form.onsubmit()){
		lst.form.submit();
	}
}

function calcDefaultFilter(txt,evt){
	var code;
	if (IsNetscape()){
		code = evt.which;
	}else{
		code = evt.keyCode;
	}
	if (code == 13){
		return false;
	}
}

function calcCurrencyFilter(txt,evt){
	//var hasdp;
	//var hassign;
	var code;
	var c;
	//hassign = (txt.value.indexOf("-") >= 0);
	//hasdp = (txt.value.indexOf(".") >= 0);
	if (IsNetscape()){
		code = evt.which;
	}else{
		code = evt.keyCode;
	}
	if (code == 13){
		return false;
	}
	if ((code >= 32) && (code <= 127)){
		c = String.fromCharCode(code);
		//if (((c < "0") || (c > "9")) && ((c != ".") || hasdp) && ((c != "-") || hassign))
		if (((c < '0') || (c > '9')) && (c != '.') && (c != '-')){
			return false;
		}
	}
}

function calcCurrencyToString(currval){
	var i;
	var j;
	var dollarval;
	var centval;
	var newval;

	i = currval;
	if (i < 0){
		i *= -1;
	}
	j = ((i - (i % 100)) / 100);
	dollarval = j.toString();
	j = (i % 100);
	if (j < 10){
		centval = "0";
		centval += j.toString();
	}else{
		centval = j.toString();
	}
	if (currval < 0){
		newval = "-";
	}else{
		newval = "";
	}
	newval += dollarval + "." + centval;
	return newval;
}

function calcCurrencyValidate(txt,minval,maxval,insubmit){
	var i;
	var c;
	var currval;
	var newval;
	var isdollar;
	var signval;
	var dollarval;
	var centval;
	var intval;
	var testval;
	var msg;

	currval = txt.value;
	signval = "";
	dollarval = "";
	centval = "";
	isdollar = true;
	for (i = 0; i < currval.length; i++){
		c = currval.charAt(i);
		if ((c == "-") && (i == 0)){
			signval = c;
		}else if ((c >= '0') && (c <= '9')){
			if (isdollar){
				dollarval += c;
			}else{
				centval += c;
			}
		}else if (c == '.'){
			isdollar = false;
		}
	}
	newval = dollarval;
	if (centval.length == 0){
		centval = "00";
	}else if (centval.length == 1){
		centval += "0";
	}
	newval += centval.substr(0,2);
	intval = parseInt(newval,10);
	if ((centval.length > 2) && (centval.charAt(2) >= '5')){
		intval += 1;
	}
	if (intval == 0){
		if (currval.length > 0){
			txt.value = "0.00";
		}else{
			txt.value = "";
		}
		return true;
	}
	testval = intval;
	if (signval == "-"){
		testval *= -1;
	}
	if ((testval < minval) || (testval > maxval)){
		if (insubmit || IsMicrosoft()){
			msg = "Please enter a value between ";
			msg += calcCurrencyToString(minval);
			msg += " and ";
			msg += calcCurrencyToString(maxval);
			msg += ".";
			window.alert(msg);
			txt.focus();
			txt.select();
		}
		return false;
	}
	newval = signval;
	newval += calcCurrencyToString(intval);
	txt.value = newval;
	return true;
}

function calcFloatFilter(txt,evt){
	//var hasdp;
	//var hassign;
	var code;
	var c;

	//hassign = (txt.value.indexOf("-") >= 0);
	//hasdp = (txt.value.indexOf(".") >= 0);
	if (IsNetscape()){
		code = evt.which;
	}else{
		code = evt.keyCode;
	}
	if (code == 13){
		return false;
	}
	if ((code >= 32) && (code <= 127)){
		c = String.fromCharCode(code);
		//if (((c < "0") || (c > "9")) && ((c != ".") || hasdp) && ((c != "-") || hassign))
		if (((c < '0') || (c > '9')) && (c != '.') && (c != '-')){
			return false;
		}
	}
}

function calcFloatValidate(txt,minval,maxval,precis,insubmit){
	var hasdp;
	var addprecis;
	var i;
	var c;
	var preciscnt;
	var precisval;
	var currval;
	var newval;
	var fltval;

	currval = txt.value;
	newval = "";
	hasdp = false;
	if ((precis == 0) || (precis > 6)){
		precis = 6;
	}
	addprecis = false;
	preciscnt = 0
	precisval = 1.0;
	for (i = 0; i < currval.length; i++){
		c = currval.charAt(i);
		if ((c == '-') && (i == 0)){
			newval += c;
		}else if ((c >= '0') && (c <= '9')){
			newval += c;
			if (hasdp){
				if (preciscnt == precis){
					if (c >= '5'){
						addprecis = true;
					}
					break;
				}
				precisval /= 10.0;
				preciscnt++;
			}
		}else if ((c == '.') && !hasdp){
			newval += c;
			hasdp = true;
		}
	}
	if (newval == "-"){
		newval = "";
	}
	if (newval.length > 0){
		fltval = parseFloat(newval);
		if (addprecis){
			if (fltval < 0.0){
				fltval -= precisval;
			}else{
				fltval += precisval;
			}
		}
		if ((fltval < minval) || (fltval > maxval)){
			if (insubmit || IsMicrosoft()){
				msg = "Please enter a value between ";
				msg += minval.toString();
				msg += " and ";
				msg += maxval.toString();
				msg += ".";
				window.alert(msg);
				txt.focus();
				txt.select();
			}
			return false;
		}
	}
	txt.value = newval;
	return true;
}

function calcNumberFilter(txt,evt){
	//var hassign;
	var code;
	var c;

	//hassign = (txt.value.indexOf("-") >= 0);
	if (IsNetscape()){
		code = evt.which;
	}else{
		code = evt.keyCode;
	}
	if (code == 13){
		return false;
	}
	if ((code >= 32) && (code <= 127)){
		c = String.fromCharCode(code);
		//if (((c < "0") || (c > "9")) && ((c != "-") || hassign))
		if (((c < '0') || (c > '9')) && (c != '-')){
			return false;
		}
	}
}

function calcNumberValidate(txt,minval,maxval,insubmit){
	var i;
	var c;
	var currval;
	var newval;
	var intval;

	currval = txt.value;
	newval = "";
	for (i = 0; i < currval.length; i++){
		c = currval.charAt(i);
		if (((c >= '0') && (c <= '9')) || ((c == '-') && (i == 0))){
			newval += c;
		}
	}
	if (newval == "-"){
		newval = "";
	}
	if (newval.length > 0){
		intval = parseInt(newval,10);
		if ((intval < minval) || (intval > maxval)){
			if (insubmit || IsMicrosoft()){
				msg = "Please enter a value between ";
				msg += minval.toString();
				msg += " and ";
				msg += maxval.toString();
				msg += ".";
				window.alert(msg);
				txt.focus();
				txt.select();
			}
			return false;
		}
	}
	txt.value = newval;
	return true;
}

function calcSSNFilter(txt,evt){
	var code;
	var c;
	var c1st;

	if (IsNetscape()){
		code = evt.which;
	}else{
		code = evt.keyCode;
	}
	if (code == 13){
		return false;
	}
	if (txt.value.length > 0){
		if ((code >= 32) && (code <= 127)){
			c = String.fromCharCode(code);
			c1st = txt.value.charAt(0);
			if ((c1st >= '0') && (c1st <= '9')){
				if (((c < '0') || (c > '9')) && (c != '-')){
					return false;
				}
			}
		}
	}
}

function calcSSNValidate(txt,insubmit){
	var i;
	var c;
	var currval;
	var newval;

	if (txt.value.length == 0){
		return true;
	}
	currval = txt.value.toUpperCase();
	newval = "";
	if (currval == "DIED"){
		newval = "DIED";	//	NIB 12/10/2004
	}else{
		for (i = 0; i < currval.length; i++){
			c = currval.charAt(i);
			if ((c >= '0') && (c <= '9')){
				newval += c;
			}
			if ((newval.length == 3) || (newval.length == 6)){
				newval += "-";
			}
		}
		if (newval.length != 11){
			if (insubmit || IsMicrosoft()){
				window.alert("Please enter a SSN as ###-##-####.");
				txt.focus();
				txt.select();
			}
			return false;
		}
	}
	txt.value = newval;
	return true;
}

function calcEINFilter(txt,evt){
	//var hasdash;
	var code;
	var c;

	if (IsNetscape()){
		code = evt.which;
	}else{
		code = evt.keyCode;
	}
	if (code == 13){
		return false;
	}
	if ((code >= 32) && (code <= 127)){
		//hasdash = (txt.value.indexOf("-") >= 0);
		c = String.fromCharCode(code);
		//if (((c < "0") || (c > "9")) && ((c != "-") || hasdash))
		if (((c < '0') || (c > '9')) && (c != '-')){
			return false;
		}
	}
}

function calcEINValidate(txt,insubmit){
	var i;
	var c;
	var currval;
	var newval;

	if (txt.value.length == 0){
		return true;
	}
	currval = txt.value;
	newval = "";
	for (i = 0; i < currval.length; i++){
		c = currval.charAt(i);
		if ((c >= '0') && (c <= '9')){
			newval += c;
		}
		if (newval.length == 2){
			newval += "-";
		}
	}
	if (newval.length != 10){
		if (insubmit || IsMicrosoft()){
			window.alert("Please enter a EIN as ##-#######.");
			txt.focus();
			txt.select();
		}
		return false;
	}
	txt.value = newval;
	return true;
}

function calcPhoneFilter(txt,evt){
	var code;
	var c;

	if (IsNetscape()){
		code = evt.which;
	}else{
		code = evt.keyCode;
	}
	if (code == 13){
		return false;
	}
	if ((code >= 32) && (code <= 127)){
		c = String.fromCharCode(code);
		if (((c < '0') || (c > '9')) && (c != '-') && (c != '(') && (c != ')') && (c != '.')){
			return false;
		}
	}
}

function calcPhoneValidate(txt,insubmit){
	var i;
	var c;
	var currval;
	var newval;

	if (txt.value.length == 0){
		return true;
	}
	currval = txt.value.toUpperCase();
	newval = "";
	for (i = 0; i < currval.length; i++){
		c = currval.charAt(i);
		if (newval.length == 0){
			newval += "(";
		}
		if ((c >= '0') && (c <= '9')){
			newval += c;
		}
		if (newval.length == 4){
			newval += ")";
		}
		if (newval.length == 8){
			newval += "-";
		}
	}
	if (newval.length != 13){
		if (insubmit || IsMicrosoft()){
			window.alert("Please enter a phone number as (###)###-####.");
			txt.focus();
			txt.select();
		}
		return false;
	}
	txt.value = newval;
	return true;
}

function calcDateFilter(txt,evt){
	var code;
	var c;
	var c1st;

	if (IsNetscape()){
		code = evt.which;
	}else{
		code = evt.keyCode;
	}
	if (code == 13){
		return false;
	}
	if (txt.value.length > 0){
		if ((code >= 32) && (code <= 127)){
			c = String.fromCharCode(code);
			c1st = txt.value.charAt(0);
			if ((c1st >= '0') && (c1st <= '9')){
				if (((c < '0') || (c > '9')) && (c != '-') && (c != '/') && (c != '.')){
					return false;
				}
			}
		}
	}
}

function calcGetMonthDays(monthval,yearval){
	var days; 
	var monthdays = [31,28,31,30,31,30,31,31,30,31,30,31];
	
	days = monthdays[monthval - 1];
	if ((monthval == 2) && (((yearval % 4) == 0) && (((yearval % 100) != 0) || ((yearval % 400) == 0)))){
		days++;
	} 
  return days; 
} 
 
function calcDateValidate(txt,insubmit){
	var i;
	var c;
	var currval;
	var newval;
	var isday;
	var ismonth;
	var issep;
	var isinvalid;
	var dayval;
	var monthval;
	var yearval;
	var dayint;
	var monthint;
	var yearint;
	var msg;
	var currdate = new Date();

	if (txt.value.length == 0){
		return true;
	}
	currval = txt.value.toUpperCase();
	if ((currval == "TODAY") || (currval == "CURRENT")){
		monthint = currdate.getMonth();
		dayint = currdate.getDate();
		yearint = currdate.getFullYear();
	}else if (currval.substr(0,3) == "VAR"){
		txt.value = "Various";
		return true;
	}else if (currval.substr(0,3) == "INH"){
		txt.value = "Inherited";
		return true;
	}else if (currval.substr(0,4) == "BANK"){
		txt.value = "Bankrupt";
		return true;
	}else{
		ismonth = true;
		isday = false;
		issep = false;
		isinvalid = false;
		monthval = "";
		dayval = "";
		yearval = "";
		for (i = 0; i < currval.length; i++){
			c = currval.charAt(i);
			if ((c >= '0') && (c <= '9')){
				if (issep){
					if (ismonth){
						ismonth = false;
						isday = true;
					}else if (isday){
						ismonth = false;
						isday = false;
					}else{
						isinvalid = true;
						break;
					}
					issep = false;
				}
				if (ismonth){
					monthval += c;
				}else if (isday){
					dayval += c;
				}else{
					yearval += c;
				}
			}else{
				issep = true;
			}
		}
		if ((monthval.length == 0) || (dayval.length == 0)){
			isinvalid = true;
		}
		if (isinvalid){
			if (insubmit || IsMicrosoft()){
				window.alert("Please enter a date as ##/##/####.");
				txt.focus();
				txt.select();
			}
			return false;
		}
		monthint = parseInt(monthval,10);
		dayint = parseInt(dayval,10);
		if (yearval.length == 0){
			yearint = cTaxYear; // current year
		}else{
			yearint = parseInt(yearval,10);
			// BUGBUG - increment this every year
			if (yearint < 8){ // current year + 3
				yearint += 2000;
			}else if (yearint < 100){
				yearint += 1900;
			}
		}
	}
	if ((yearint < 1900) || (yearint > 2020)){
		msg = "Please enter a valid year.";
		isinvalid = true;
	}else if ((monthint < 1) || (monthint > 12)){
		msg = "Please enter a valid month.";
		isinvalid = true;
	}else if ((dayint < 1) || (dayint > calcGetMonthDays(monthint,yearint))){
		msg = "Please enter a valid day.";
		isinvalid = true;
	}
	if (isinvalid){
		if (insubmit || IsMicrosoft()){
			window.alert(msg);
			txt.focus();
			txt.select();
		}
		return false;
	}
	newval = "";
	if (monthint < 10){
		newval += "0";
	}
	newval += monthint.toString();
	newval += "/";
	if (dayint < 10){
		newval += "0";
	}
	newval += dayint.toString();
	newval += "/";
	newval += yearint.toString();
	txt.value = newval;
	return true;
}

//------------------------------------------------------------------
//------ General Purpose functions ---------------------------------
//------------------------------------------------------------------
function imgOnBack(){
	history.go(-1);
}

//------------------------------------------------------------------
//------ signin.html support functions -----------------------
//------------------------------------------------------------------
function ValSignInfo(inForm){
	//	NIB 1/13/2004 - Add check if user presses button more than once
	if (bInSubmit)
		return;
		
	if (inForm.hidIsImport)
		var bValidUserID = ValidImportUserID(inForm.username);
	else
		var bValidUserID = ValidSigninUserID(inForm.username)


	if (!bValidUserID){
		//inWindow.location = "err_signin.asp";
	}else if (!ValidSigninPassword(inForm.password)){
		//inWindow.location = "err_signin.asp";
	}else{
		var	sFormAction = inForm.action;
		if (sFormAction.indexOf("ValSignInfo") != -1)		//	BUGBUG - Clean this up for next year
			inForm.action = inForm.form_action_url.value;	//	ValSignInfo is called from multiple places
		bInSubmit = true;									//	Automatically submit page on Enter
		inForm.submit();
	}
}

function StoreScreenAttributes(){
	var nCX = this.screen.width;
	var nCY = this.screen.height;
	document.cookie = "cx=1024;" + "path=/;" + "expires=Mon, 31 Dec 2009 23:59:59 UTC;";
	document.cookie = "cy=700;" + "path=/;" + "expires=Mon, 31 Dec 2009 23:59:59 UTC;";
}

//------------------------------------------------------------------
//------ Registration.html support functions -----------------------
//------------------------------------------------------------------

function ValRegInfo(inForm){
//	NOTE:  Called from Registration.asp

	//	NIB 1/13/2004 - Add check if user presses button more than once
	if (bInSubmit)
		return;

	var sURL = inForm.form_action_url.value;
	
	if (!ValidUserID(inForm.username)){
		//return(false);
	}else if (!ValidPassword(inForm.password,inForm.username)){
		//return(false);
	}else if (!CheckPassword(inForm.password, inForm.check_password)){
		//return(false);
	}else if (!ValidSecretQuestion(inForm.secret_question)){
		//return(false);
	}else if (!ValidSecretAnswer(inForm.secret_answer)){
		//return(false);
//	}else if (!ValidHint(inForm.hint, inForm.password)){
//		//return(false);
	}else if (!ValidSSN(inForm.ssn)){
		//return(false);
	}else if (!ValidEmail(inForm.email)){
		//return(false);
//	//}else if (!ValidEmail(inForm.confirm_email)){
//		//return(false);
//	}else if (!CheckEmail(inForm.email)){
//		//return(false);
	}else if (!AcceptedLicense(inForm.registration_url, inForm.license)) {
		//return(false);
	}else if (!SelectedBundleState(inForm.bundle, inForm.bundle_state)) {
		//return(false);
	}
	else {
		//	Submit Registration to TaxManager.DLL
		//document.regbutton.src=regbutton2.src;
		//document.getElementById('regbutton').disabled=true;
		sURL = inForm.form_action_url.value;
		
		//	Submit Registration
		var sSSN = inForm.ssn.value;
		sSSN = sSSN.replace ("-", "");
		sSSN = sSSN.replace ("-", "");
		inForm.ssn.value = sSSN;

		bInSubmit = true;
		inForm.action = sURL;
		inForm.submit();
	}
}

function ValRegInfo2(inForm){
//	NOTE:  Called from Registration_2.asp

	//	NIB 1/13/2004 - Add check if user presses button more than once
	if (bInSubmit)
		return;

	var sURL = inForm.registration_2_url.value;
	var	sAction = inForm.cmdAction.value;

	if (sAction == "ReviewBirthDate_Yes") {
		inForm.cmdAction.value = 'ReviewParent';
		inForm.submit();
	}
	else if (sAction == "ReviewParent_Yes" || sAction == 'ReviewBirthDate2_No') {
		inForm.cmdAction.value = 'EnterBirthDate';
		inForm.submit();
	}
	else if (sAction == "ReviewParent_No" || sAction == "ReviewBirthDate2_Yes") {
		inForm.cmdAction.value = "UnableToCompleteReg";
		inForm.submit();
	}
	else if (sAction == "ReviewBirthDate_No" || sAction == "Back") {
		inForm.action = inForm.registration_url.value;
		inForm.submit();
	}
	else {
		//	Submit Registration to TaxManager.dll
		//document.regbutton.src=regbutton2.src;
		//document.regbutton.disabled=true;
		sURL = inForm.form_action_url.value;

		//	Submit Registration
		bInSubmit = true;
		inForm.action = sURL;
		inForm.submit();
	}
}

function ValEmailPrefs(inForm){
	//	NIB 1/13/2004 - Add check if user presses button more than once
	if (bInSubmit)
		return;

	var sURL = inForm.form_action_url.value;
	
	if (!ValidEmail(inForm.email)){
		//return(false);
	}
	else {
		//	Submit Registration
		bInSubmit = true;
		inForm.action = sURL;
		inForm.submit();
	}

}

function SSNRecommended () {
	window.alert ('Enter your SSN if you used TaxACT ' + cLastTaxYear + ' Online and would like to use the SAME User Name as last year.');
}

//------------------------------------------------------------------
function trimLeading (s) {   
//------------------------------------------------------------------
    var sTrim = '';
    var bNonSpaceFound = false;

    for (var i = 0; i < s.length; i++) {   
        var c = s.charAt(i);
        if (c != ' ' || bNonSpaceFound) {
			sTrim += c;
			bNonSpaceFound = true;
		}
    }

    return sTrim;
}

//------------------------------------------------------------------
function ValidUserID(inField){
//------------------------------------------------------------------
	bValid = true;
	var szError = "";
		
	if (inField.value == "") {
		bValid = false;
		szError = "Your User Name is blank.\r\n\r\nPlease enter a User Name between 6 and 100 characters.";
	}
	else if (inField.value.length < 6) {
		bValid = false;
		szError = "The User Name entered is less than 6 characters.\r\n\r\nPlease enter a User Name between 6 and 100 characters.";
	}
	else {
		var regex = /^[a-zA-Z0-9_`~!@#$%^&*()_+-={}|\[\]\\:;<>?.]{6,100}$/;
		bValid = regex.test(inField.value);
		if (bValid == false) {
			szError = "The User Name entered is invalid.\r\n\r\nPlease enter a User Name containing only letters (a-z, A-Z), numbers (0-9) or symbols (_ ` ~ ! @ # $ % ^ & * ( ) _ + - = { } | [ ] \ :  ;  < > ? , . /), with no blank spaces.";
		}
	}
	
	if (bValid == false){
		inField.focus();
		inField.select();
		alert(szError);
		return (false);
	}else{	
		return(true);
	}
}

//------------------------------------------------------------------
function ValidSigninUserID(inField){
//------------------------------------------------------------------
	bValid = true;
	var szError = "";
		
	if (inField.value == "" || inField.value.length < 6) {
		bValid = false;
		szError = "The User Name entered is less than 6 characters.\r\n\r\nPlease enter a User Name between 6 and 100 characters.";
	}
	else {
		var regex = /^[a-zA-Z0-9_`~!@#$%^&*()_+-={}|\[\]\\:;<>?.]{6,100}$/;
		bValid = regex.test(inField.value);
		if (bValid == false) {
			szError = "The User Name entered is invalid.\r\n\r\nPlease enter a User Name containing only letters (a-z, A-Z), numbers (0-9) or symbols (_ ` ~ ! @ # $ % ^ & * ( ) _ + - = { } | [ ] \ :  ;  < > ? , . /), with no blank spaces.";
		}
	}
	
	if (bValid == false){
		inField.focus();
		inField.select();
		alert(szError);
		return (false);
	}else{	
		return(true);
	}
}
//------------------------------------------------------------------
function ValidImportUserID(inField){
//------------------------------------------------------------------
	bValid = true;
	var szError = "";
		
	if (inField.value == "" || inField.value.length < 5 || inField.value.length > 25) {
		bValid = false;
		szError = "User name must contain at least 5 characters.";
	}
	
	if (bValid == false){
		inField.focus();
		inField.select();
		alert(szError);
		return (false);
	}else{	
		return(true);
	}
}
function ValidSigninPassword(inField){
	bValid = true;
	var szError = "";
		
	if (inField.value == "" || inField.value.length < 5){
		bValid = false;
		szError = "The Password entered is less than 5 characters.\r\n\r\nPlease enter a Password between 5 and 16 characters.";
	}
	else {
		var regex = /^[a-zA-Z0-9_`~!@#$%^&*()_+-={}|\[\]\\:;<>?.]{5,16}$/;
		bValid = regex.test(inField.value);
		if (bValid == false)
			szError = "The Password entered is invalid.\r\n\r\nPlease enter a Password containing only letters (a-z, A-Z), numbers (0-9) or symbols (_ ` ~ ! @ # $ % ^ & * ( ) _ + - = { } | [ ] \ :  ;  < > ? , . /).";
	}
	
	if (bValid == false){
		inField.focus();
		inField.select();
		alert(szError);
		return (false);
	}else{
		return(true);
	}
}


function ValidPassword(inField,inUserID){
	bValid = true;
	var szError = "";
	
		
	if (inField.value == ""){
		bValid = false;
		szError = "Your Password is blank.\r\n\r\nPlease enter a Password between 6 and 16 characters.";
	}
	else if (inField.value.length < 5 || inField.value.length > 16){
		bValid = false;
		szError = "The Password entered is less than 5 characters.\r\n\r\nPlease enter a Password between 5 and 16 characters.";
	}
	else {
		var regex = /^[a-zA-Z0-9_`~!@#$%^&*()_+-={}|\[\]\\:;<>?.]{5,16}$/;
		bValid = regex.test(inField.value);
		if (bValid == false)
			szError = "The Password entered is invalid.\r\n\r\nPlease enter a Password containing only letters (a-z, A-Z), numbers (0-9) or symbols (_ ` ~ ! @ # $ % ^ & * ( ) _ + - = { } | [ ] \ :  ;  < > ? , . /).";
	}

	if (bValid == true) {
		var szUserID = inUserID.value.toUpperCase();
		var szPassword = inField.value.toUpperCase();
		var nPos;
		nPos = szUserID.indexOf(szPassword);
	
		if (nPos != -1) {
			bValid = false;
			szError = "The User Name and Password entered are too similar.\r\n\r\nPlease enter a more unique User Name and Password.";
		}

		if (szPassword.indexOf("PASSWORD") != -1 || szPassword.indexOf("TAX") != -1){
			bValid = false;
			szError = "The Password entered is too common.\r\n\r\nPlease enter a more unique password.";
		}
	}
		
	if (bValid == false){
		inField.focus();
		inField.select();
		alert(szError);
		return (false);
	}else{
		return(true);
	}
}

function CheckPassword(inUserPassword, inCheckPassword){
	bValid = true;
	var szError = "";
	
	if (inUserPassword.value != inCheckPassword.value){
		bValid = false;
	}

	if (bValid == false){
		inUserPassword.focus();
		inUserPassword.select();
		alert("The Passwords entered do not match.\r\n\r\nPlease enter the same Password in both password fields.");
		return (false);
	}else{
		return(true);
	}
}

function ValidEmail(inField){
	var bValid = true;
	var invalidChars = "/;,: ";
	var szError = "The E-mail Address entered is invalid.\r\n\r\nE-mail address must contain an \"at\" sign (@) and a period (.) somewhere to the right of the @, with no spaces or commas. (Ex: yourname@mailserver.com)";

	var email = inField.value;
	
	if (email == ""){
		bValid = false;
		szError = "Your E-Mail Address is blank.";
	}
	else if (email.toLowerCase().indexOf("abuse@") > -1 || email.toLowerCase().indexOf("uce@ftc.gov") > -1) {
		bValid = false;
		szError = "The E-mail Address entered is invalid.\r\n\r\nE-mail address must contain an \"at\" sign (@) and a period (.) somewhere to the right of the @, with no spaces or commas. (Ex: yourname@mailserver.com)";
	}
	else{
		for (i=0;i<invalidChars.length;i++){
			badChar = invalidChars.charAt(i);
			if (email.indexOf(badChar,0) > -1){
				bValid = false;
				szError = "The E-mail Address entered is invalid.\r\n\r\nE-mail address must contain an \"at\" sign (@) and a period (.) somewhere to the right of the @, with no spaces or commas. (Ex: yourname@mailserver.com)";
				break;
			}
		}
		atPos = email.indexOf("@",1);
		if (atPos == -1 && bValid){
			bValid = false;
			szError = "The  E-mail Address entered is missing the \"at\" sign(@).  (Ex: yourname@mailserver.com)";
		}
	
		periodPos = email.indexOf(".",atPos);
		if (periodPos == -1 && bValid){
			bValid = false;
		}
	
		if (periodPos+3 > email.length && bValid){
			bValid = false;
		}
	}
	
	if (!bValid){
		inField.focus();
		inField.select();
		alert(szError);
		return false;
	}else{
		return(true);
	}
}

function CheckEmail(inField){
	bValid = true;
	var szError = "";
	
	if (inField.value != inField.form.email.value){
		bValid = false;
	}
		
	if (bValid == false){
		inField.focus();
		inField.select();
		alert("The E-mail Addresses do not match.\r\n\r\nPlease enter the same e-mail address in both e-mail fields.");
		return (false);
	}else{
		return(true);
	}
}

function ValidHint(inField, inPassword){
	if (inField.value == ""){
		inField.focus();
		inField.select();
		alert("Missing password hint.");
		return (false);
	}
	else {
		if (inField.value.indexOf (inPassword.value) >= 0) {
			inField.focus();
			inField.select();
			alert("Hint cannot contain your password.");
			return (false);
		}
	}	
	return true;
}

function ValidBirthDate(inField){
	bValid = true;
	var szError = "";

	var sBirthDate = trimLeading (inField.value);
	if (sBirthDate == ""){
		inField.value = '';
		bValid = false;
		szError = "Missing Birth Date.";
		window.alert (szError);
	}	
	else {
		if (calcDateValidate (inField, true) == false) {
			bValid = false;
			//	NOTE:  calcDateValidation will display error
		}		
	}
	if (bValid == false) {
		inField.focus();
		inField.select();
	}

	return (bValid);
}

function ValidSecretQuestion(inField){
	if (inField.selectedIndex == 0){
		inField.focus();
		alert("Please select a Secret Question.");
		return (false);
	}
	return true;
}

function ValidSecretAnswer(inField){
	if (inField.value == ""){
		inField.focus();
		inField.select();
		alert("Your Secret Answer is blank.\r\n\r\nPlease select a Secret Answer to the Secret Question you selected.");
		return (false);
	}
	return true;
}

function ValidSSN(inField){
	var i;
	var c;
	var currval;
	var newval;

	if (inField.value.length == 0){
		return true;
	}
	currval = inField.value.toUpperCase();
	newval = "";
	for (i = 0; i < currval.length; i++){
		c = currval.charAt(i);
		if ((c >= '0') && (c <= '9')){
			newval += c;
		}
		if ((newval.length == 3) || (newval.length == 6)){
			newval += "-";
		}
	}
	if (newval.length != 11){
		window.alert("The SSN entered is invalid.\r\n\r\nPlease enter a SSN as ###-##-####.");
		inField.focus();
		inField.select();
		return false;
	}

	inField.value = newval;
	return true;
}

function AcceptedLicense (fldRegistrationURL, fldLicense)
{
	var bAccepted = true;
	
	if (fldRegistrationURL.value.toLowerCase() == 'registrationd.asp' || fldRegistrationURL.value.toLowerCase() == 'registration.asp') {
		if (!fldLicense.checked) {
			window.alert("Please view and accept the TaxACT Online License Agreement & Limited Warranty before continuing.");
			fldLicense.focus();
			fldLicense.select();
			bAccepted = false;
		}
	}

	return (bAccepted);
}

function SelectedBundleState (fldBundle, fldBundleState)
{
	var bSelected = true;
//	if (fldBundle.value != "") {
//		if (fldBundleState.selectedIndex == 0) {
//			window.alert("Please select the State you plan to file.");
//			fldBundleState.focus();
//			bSelected = false;
//		}
//	}
	return (bSelected);
}

//------------------------------------------------------------------
//------------------ OnUpdateNavigator(p) ---------------------------
//------------------------------------------------------------------
function OnUpdateNavigator(imgSrc,szValue){}

function OnUpdateMenu(p){
	if ((p) && (p.navframe) && (p.navframe.TANAVFORM)){
		if (p.mainbody_frame.document.TAForm.step1comp.value == "1"){
			p.navframe.TANAVFORM.step1.src = "../" + cImagesDir + "nav_active_1_green.gif";
		}else{
			p.navframe.TANAVFORM.step1.src = "../" + cImagesDir + "nav_active_1.gif";
		}
		if (p.mainbody_frame.document.TAForm.step1comp.value == "1"){
			p.navframe.TANAVFORM.step1.src = "../" + cImagesDir + "nav_rollover_1_green.gif";
		}else{
			p.navframe.TANAVFORM.step1.src = "../" + cImagesDir + "nav_rollover_1.gif";
		}
		if (p.mainbody_frame.document.TAForm.step2comp.value == "1"){
			p.navframe.TANAVFORM.step2.src = "../" + cImagesDir + "nav_active_2_green.gif";
		}else{
			p.navframe.TANAVFORM.step2.src = "../" + cImagesDir + "nav_active_2.gif";
		}
		if (p.mainbody_frame.document.TAForm.step2comp.value == "1"){
			p.navframe.TANAVFORM.step2.src = "../" + cImagesDir + "nav_rollover_2_green.gif";
		}else{
			p.navframe.TANAVFORM.step2.src = "../" + cImagesDir + "nav_rollover_2.gif";
		}
		if (p.mainbody_frame.document.TAForm.step3comp.value == "1"){
			p.navframe.TANAVFORM.step3.src = "../" + cImagesDir + "nav_active_3_green.gif";
		}else{
			p.navframe.TANAVFORM.step3.src = "../" + cImagesDir + "nav_active_3.gif";
		}
		if (p.mainbody_frame.document.TAForm.step3comp.value == "1"){
			p.navframe.TANAVFORM.step3.src = "../" + cImagesDir + "nav_rollover_3_green.gif";
		}else{
			p.navframe.TANAVFORM.step3.src = "../" + cImagesDir + "nav_rollover_3.gif";
		}
		if (p.mainbody_frame.document.TAForm.step4comp.value == "1"){
			p.navframe.TANAVFORM.step4.src = "../" + cImagesDir + "nav_active_4_green.gif";
		}else{
			p.navframe.TANAVFORM.step4.src = "../" + cImagesDir + "nav_active_4.gif";
		}
		if (p.mainbody_frame.document.TAForm.step4comp.value == "1"){
			p.navframe.TANAVFORM.step4.src = "../" + cImagesDir + "nav_rollover_4_green.gif";
		}else{
			p.navframe.TANAVFORM.step4.src = "../" + cImagesDir + "nav_rollover_4.gif";
		}
		if (p.mainbody_frame.document.TAForm.step5comp.value == "1"){
			p.navframe.TANAVFORM.step5.src = "../" + cImagesDir + "nav_active_5_green.gif";
		}else{
			p.navframe.TANAVFORM.step5.src = "../" + cImagesDir + "nav_active_5.gif";
		}
		if (p.mainbody_frame.document.TAForm.step5comp.value == "1"){
			p.navframe.TANAVFORM.step5.src = "../" + cImagesDir + "nav_rollover_5_green.gif";
		}else{
			p.navframe.TANAVFORM.step5.src = "../" + cImagesDir + "nav_rollover_5.gif";
		}
		if (p.mainbody_frame.document.TAForm.step6comp.value == "1"){
			p.navframe.TANAVFORM.step6.src = "../" + cImagesDir + "nav_active_6_green.gif";
		}else{
			p.navframe.TANAVFORM.step6.src = "../" + cImagesDir + "nav_active_6.gif";
		}
		if (p.mainbody_frame.document.TAForm.step6comp.value == "1"){
			p.navframe.TANAVFORM.step6.src = "../" + cImagesDir + "nav_rollover_6_green.gif";
		}else{
			p.navframe.TANAVFORM.step6.src = "../" + cImagesDir + "nav_rollover_6.gif";
		}
		if (p.mainbody_frame.document.TAForm.step7comp.value == "1"){
			p.navframe.TANAVFORM.step7.src = "../" + cImagesDir + "nav_active_7_green.gif";
		}else{
			p.navframe.TANAVFORM.step7.src = "../" + cImagesDir + "nav_active_7.gif";
		}
		if (p.mainbody_frame.document.TAForm.step7comp.value == "1"){
			p.navframe.TANAVFORM.step7.src = "../" + cImagesDir + "nav_rollover_7_green.gif";
		}else{
			p.navframe.TANAVFORM.step7.src = "../" + cImagesDir + "nav_rollover_7.gif";
		}

		p.navframe.TANAVFORM.imgtax.src = p.mainbody_frame.document.TAForm.hidrefimg.value;
		//p.navframe.TANAVFORM.reftax.innerText = p.mainbody_frame.document.TAForm.hidrefamt.value;
		p.navframe.TANAVFORM.hidstatus.value = "IDLE";
	}
}

//------------------------------------------------------------------
//--------------------- Script Functions ---------------------------
//------------------------------------------------------------------
function OnSubmitIS(inURL){
	doDate = new Date();
	strDate = doDate.getTime();
	inURL += "time="+strDate;
	document.location.href = inURL;
}

function OnLogout(){ 
	doDate = new Date();
	strDate = doDate.getTime();
	var sURL = "../taxmanager.dll/logoff?time=" + strDate;
	if (this.parent.mainbody_frame)
		this.parent.mainbody_frame.document.location = sURL;
	else if (opener.parent.mainbody_frame)
		opener.parent.mainbody_frame.document.location = sURL;
}

function CheckSessionTimeout () {
	var bTimedOut = false;
	
	if (window.opener.opener) {
		// if (!(window.opener.opener && window.opener.opener.open && !window.opener.opener.closed) || (window.opener.opener.top.frames.length == 0))
		if (!(window.opener.opener && window.opener.opener.open && !window.opener.opener.closed))
			bTimedOut = true
	}
	else if (window.opener) {
		if (!(window.opener && window.opener.open && !window.opener.closed) || (window.opener.top.frames.length == 0))
			bTimedOut = true
	}
	
	//	Check if Session has Timed Out
	if (bTimedOut) {
		var newWindow = window.open ("../introduction/signin.asp?status=timeout", "TaxACTOnline","location,toolbar,menubar,resizable,scrollbars,height=600,width=800");
		newWindow.opener = self;
		newWindow.focus();

		if (window.opener) {
			if (window.SiteMapWindow && !window.SiteMapWindow.closed())
				window.SiteMapWindow.close();
		}
	
		bTimedOut = true;
		window.close();
	}
	
	return (bTimedOut);
}

function OnHelp(inURL,HelpTopic){
	if (CheckSessionTimeout () != false)
		return;
		
	ResetLogoutTimer();		

	var EncodedTopic;
	var TopicURL;
	EncodedTopic = escape(HelpTopic);
	EncodedTopic = EncodedTopic.replace ('+', '***AND***')

	TopicURL = inURL + EncodedTopic;

	doDate = new Date();
	strDate = doDate.getTime();
	TopicURL += "&time="+strDate;
	
	if (HelpWindow && !HelpWindow.closed){
  		HelpWindow.close();
	}
	HelpWindow = window.open(TopicURL,"TaxACTHelpWindow","toolbar,resizable,scrollbars,height=400,width=600");
	HelpWindow.opener = self;
	HelpWindow.focus();
}

function OnSiteMap(inURL){
	var newURL = inURL;
	doDate = new Date();
	strDate = doDate.getTime();
	newURL = newURL  + "?time=" + strDate;
	if (!SiteMapWindow || SiteMapWindow.closed){
		SiteMapWindow = window.open(newURL,"SiteMap","status,resizable,scrollbars,height=550,width=600");
		SiteMapWindow.opener = self;
	 }
	 else{
		SiteMapWindow.document.location = newURL;
	}
	SiteMapWindow.focus();
}

function OnSummary(inURL,szModule){
	if (CheckSessionTimeout () != false)
		return;

	ResetLogoutTimer();

	var newURL = inURL+"summary_module="+szModule;
	doDate = new Date();
	strDate = doDate.getTime();
	newURL = newURL  + "&time=" + strDate;
	if (!SummaryWindow || SummaryWindow.closed){
		SummaryWindow = window.open(newURL,"TaxSummary","status,resizable,height=460,width=525");
		SummaryWindow.opener = self;
	 }
	 else{
		SummaryWindow.document.location = newURL;
	}
	SummaryWindow.focus();
}

function OnHelpCenter(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL;
	if (newURL.indexOf("?") > 0)
		newURL += "&t=" + strDate;
	else
		newURL += "?t=" + strDate;
	if (!HelpCenterWindow || HelpCenterWindow.closed){
		HelpCenterWindow = window.open(newURL,"Help","height=600,width=800,toolbar=1,location=1,directories=1,status=1,menuBar=1,scrollBars=1,resizable=1");
		HelpCenterWindow.opener = self;
	 }
	 else{
		HelpCenterWindow.document.location = newURL;
	}
	HelpCenterWindow.focus();
}
function OnMyAccount(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!MyAccountWindow || MyAccountWindow.closed){
		MyAccountWindow = window.open(newURL,"MyAccount","status,resizable,scrollbars,height=550, width=600");
		MyAccountWindow.opener = self;
	 }
	 else{
		MyAccountWindow.document.location = newURL;
	}
	MyAccountWindow.focus();
}
function OnEFCenter(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!EFCenterWindow || EFCenterWindow.closed){
		EFCenterWindow = window.open(newURL,"EFCenter","status,resizable,scrollbars,height=600, width=800");
		EFCenterWindow.opener = self;
	 }
	 else{
		EFCenterWindow.document.location = newURL;
	}
	EFCenterWindow.focus();
}
function OnEFStatus(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!EFStatusWindow || EFStatusWindow.closed){
		EFStatusWindow = window.open(newURL,"EFStatus","toolbar=1,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1,height=600, width=800");
		EFStatusWindow.opener = self;
	}
	else{
		EFStatusWindow.document.location = newURL;
	}
	EFStatusWindow.focus();
}
function OnUpdateEmailPrefs(inURL){
	var newURL = inURL;
	if (!EmailPrefWindow || EmailPrefWindow.closed){
		EmailPrefWindow = window.open(newURL,"EmailPrefWindow","toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1,height=500, width=800");
		EmailPrefWindow.opener = self;
	}
	else{
		EmailPrefWindow.document.location = newURL;
	}
	EmailPrefWindow.focus();
}
function OnUpdateAccount(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!UpdateAccountWindow || UpdateAccountWindow.closed){
		UpdateAccountWindow = window.open(newURL,"UpdateAccount","toolbar=1,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1,height=600, width=800");
		UpdateAccountWindow.opener = self;
	 }
	 else{
		UpdateAccountWindow.document.location = newURL;
	}
	UpdateAccountWindow.focus();
}
function OnPrintCenter(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!PrintCenterWindow || PrintCenterWindow.closed){
		PrintCenterWindow = window.open(newURL,"PrintCenter","status,resizable,scrollbars,height=600, width=800");
		PrintCenterWindow.opener = self;
	 }
	 else{
		PrintCenterWindow.document.location = newURL;
	}
	PrintCenterWindow.focus();
}
function DoReport(inURL,ReportType){
	ResetLogoutTimer();

	if (ReportWindow && !ReportWindow.closed){
		ReportWindow.close();
	}

	var newURL = inURL + ReportType;
	doDate = new Date();
	strDate = doDate.getTime();
	newURL = newURL  + "&time=" + strDate;
	if (ReportType.indexOf("Depr") >= 0){
		ReportWindow = window.open(newURL,"TaxACTReportWindow","toolbar,resizable,scrollbars,height=400,width=800");
	}else{
		ReportWindow = window.open(newURL,"TaxACTReportWindow","toolbar,resizable,scrollbars,height=600,width=800");
	}
	ReportWindow.opener = self;
	ReportWindow.focus();
}

function DoPrint(inURL,PrintType){
	if (CheckSessionTimeout () != false)
		return;

	if (PrintWindow && !PrintWindow.closed){
		PrintWindow.close();
	}

	var newURL = inURL + PrintType;
	doDate = new Date();
	strDate = doDate.getTime();
	newURL = newURL  + "&time=" + strDate;
	PrintWindow = window.open(newURL,"TaxACTPrintWindow","toolbar,resizable,scrollbars,height=480,width=600");
	PrintWindow.opener = self;
	PrintWindow.focus();
}

function OpenOfx(inURL){
	if (CheckSessionTimeout () != false)
		return;

	ResetLogoutTimer();

	if (OfxWindow && !OfxWindow.closed){
		OfxWindow.close();
	}
	
	var newURL = inURL;
	doDate = new Date();
	strDate = doDate.getTime();
	newURL = newURL  + "&time=" + strDate;
	OfxWindow = window.open(newURL,"TaxACTOfxWindow","toolbar,resizable,scrollbars,height=480,width=640");
	OfxWindow.opener = self;
	OfxWindow.focus();
}

function OfxLogin(){
	ResetLogoutTimer();

	if (document.OfxForm.LoginID.value.length == 0){
		window.alert("Please enter your LoginID.");
		document.OfxForm.LoginID.focus();
		return;
	}else if (document.OfxForm.Password.value.length == 0){
		window.alert("Please enter your password.");
		document.OfxForm.Password.focus();
		return;
	}
	document.OfxForm.submit();
	return;
}

function OfxSelectAll(bSelect){
	var check;
	var index;
	
	ResetLogoutTimer();

	for (index = 0; true; index++){
		if (!(check = eval("document.OfxForm.OFX_TRANS_" + index.toString()))){
			break;
		}
		check.checked = bSelect;
	}
}

function show(document,divObject){
	var doc;
	var vis;

	if (document.layers){
		doc = 'document.';
		vis = '.visibility';
	}else{
		doc = 'document.all.';
		vis = '.style.visibility';
	}

    eval(doc + divObject + vis + ' = "visible"');
}

function hide(document,divObject){
	var doc;
	var vis;

	if (document.layers){
		doc = 'document.';
		vis = '.visibility';
	}else{
		doc = 'document.all.';
		vis = '.style.visibility';
	}

    eval(doc + divObject + vis + ' = "hidden"');
}

function hideAll(document){
    hide(document,'PROCESSING');
    hide(document,'QUESTION');
}

//------------------------------------------------------------------
//--------------------- Menu Functions -----------------------------
//------------------------------------------------------------------

function openFormWin( inURL, windowName){ 
	if (CheckSessionTimeout () != false)
		return;

	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	inURL = inURL  + "time=" + strDate;

	if (window.opener.opener) {
		if (window.opener.opener.parent.mainbody_frame.document.TAForm){
			var szModule = window.opener.opener.parent.mainbody_frame.document.TAForm.hidmod.value;
			inURL = inURL + "&hidmod=" + szModule;

			if (FormsListWindow && !FormsListWindow.closed){
				FormsListWindow.close();
			}
			FormsListWindow = window.open( inURL, windowName, 'width=800,height=400,toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1'); 
			FormsListWindow.opener = self;
			FormsListWindow.focus();
		}
	}
	else if (window.opener) {
		if (window.opener.parent.mainbody_frame.document.TAForm){
			var szModule = window.opener.parent.mainbody_frame.document.TAForm.hidmod.value;
			inURL = inURL + "&hidmod=" + szModule;

			if (FormsListWindow && !FormsListWindow.closed){
				FormsListWindow.close();
			}
			FormsListWindow = window.open( inURL, windowName, 'width=800,height=400,toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1'); 
			FormsListWindow.opener = self;
			FormsListWindow.focus();
		}
	}
} 

function openSupportWin( inURL, windowName){ 
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	inURL = inURL  + "&time=" + strDate;

	if (SupportWindow && !SupportWindow.closed){
		SupportWindow.close();
	}
	SupportWindow = window.open( inURL, windowName, 'width=760,height=480,toolbar=1,location=1,directories=1,status=1,menuBar=1,scrollBars=1,resizable=1'); 
	SupportWindow.opener = self;
	SupportWindow.focus();
}

function openFAQWin( inURL, windowName){ 
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	inURL = inURL  + "time=" + strDate;

	if (FAQWindow && !FAQWindow.closed){
		FAQWindow.close();
	}
	FAQWindow = window.open( inURL, windowName, 'width=760,height=480,toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1'); 
	FAQWindow.opener = self;
	FAQWindow.focus();
} 

function openTaxAdviceWin( inURL, windowName){ 
	ResetLogoutTimer();

	if (TaxAdviceWindow && !TaxAdviceWindow.closed){
		TaxAdviceWindow.close();
	}
	TaxAdviceWindow = window.open( inURL, windowName, 'width=760,height=480,toolbar,location,directories=0,status=1,menuBar,scrollBars=1,resizable=1'); 
	TaxAdviceWindow.opener = self;
	TaxAdviceWindow.focus();
} 

function OnFirstQuestion(szURL){
	ResetLogoutTimer();

	if (CheckSessionTimeout () != false)
		return;

	doDate = new Date();
	strDate = doDate.getTime();
	inURL = szURL + "time="+strDate;
	document.location.href = inURL;
}

function OnNavClick(inURL){
	//	NIB 1/13/2004 - Add check if user presses button more than once
	if (bInSubmit)
		return;

	if (CheckSessionTimeout () != false)
		return;

	doDate = new Date();
	strDate = doDate.getTime();
	inURL = inURL  + "&time=" + strDate;

	if (window.opener.opener) {
		if (window.opener.opener.parent) {
			if (window.opener.opener.parent.mainbody_frame.document.TAForm.hidStep1Comp) {
				if (window.opener.opener.parent.mainbody_frame.document.TAForm.hidStep1Comp.value == "0")
					window.alert("You must start with Step 1. Basic Information.");
				else {
					bInSubmit = true;
					window.opener.opener.parent.mainbody_frame.location = inURL;
				}
			}
		}
	}
	else if (window.opener) {
		if (window.opener.parent) {
			if (window.opener.parent.mainbody_frame.document.TAForm) {
				if (window.opener.parent.mainbody_frame.document.TAForm.hidStep1Comp) {
					if (window.opener.parent.mainbody_frame.document.TAForm.hidStep1Comp.value == "0")
						window.alert("You must start with Step 1. Basic Information.");
					else {
						bInSubmit = true;
						window.opener.parent.mainbody_frame.location = inURL;
					}
				}
				else if (inURL.indexOf("Home_Page") != -1 || inURL.indexOf("IV_USStep1_Q1") != -1) {
					bInSubmit = true;
					window.opener.parent.mainbody_frame.location = inURL;
				}
				else
					window.alert("You must start with Step 1. Basic Information.");
				window.opener.focus();
			}
		}
	}
}

//------------------------------------------------------------------
//The following functions are used by the SiteMap window
//------------------------------------------------------------------
function HeaderInstructions(inURL){
	if (CheckSessionTimeout () != false)
		return;

	ResetLogoutTimer();

	if (window.opener.opener) {
		if (window.opener.opener.parent.mainbody_frame.document.forms[0] != null && window.opener.opener.parent.mainbody_frame.document.forms[0].name == "TAForm"){
			DoReport(inURL,"PrintInstructions");
		}else{
			alert("You must be logged in to an existing return before you can view the instructions.");
		}
	}
	else if (window.opener) {
		if (window.opener.parent.mainbody_frame.document.forms[0] != null && window.opener.parent.mainbody_frame.document.forms[0].name == "TAForm"){
			DoReport(inURL,"PrintInstructions");
		}else{
			alert("You must be logged in to an existing return before you can view the instructions.");
		}
	}
}

function HeaderSummary(inURL){
	if (CheckSessionTimeout () != false)
		return;

	ResetLogoutTimer();

	if (opener.parent.mainbody_frame.document.forms[0] != null && opener.parent.mainbody_frame.document.forms[0].name == "TAForm"){
		OnSummary(inURL,opener.parent.mainbody_frame.document.TAForm.hidmod.value);
	}else{
		alert("You must be logged in to an existing return before you can check your Tax Summary.");
	}
}

function HeaderEFileChecklists(inURL){
	if (CheckSessionTimeout () != false)
		return;

	ResetLogoutTimer();

	if (opener.parent.mainbody_frame.document.forms[0] != null && opener.parent.mainbody_frame.document.forms[0].name == "TAForm"){
		DoReport(inURL,"EFileChecklists");
	}else{
		alert("You must be logged in to an existing return before you can view the e-file checklists.");
	}
}


//------------------------------------------------------------------
//The following functions are used by all pop-up windows
//------------------------------------------------------------------
function closeWin () {
	window.close();
}

function printWin () {
	window.print();
}

//------------------------------------------------------------------
//-- Functions to Set/Reset the background color of current field --
//------------------------------------------------------------------
	function setFieldBGColor (Field) 
	{
		if (ie)
			Field.style.backgroundColor='#FFFFC6';
		else if (ns)
			Field.backgroundColor='#FFFFC6';
		else if (ns6)
			Field.style.backgroundColor='#FFFFC6';
	}

	function resetFieldBGColor (Field) 
	{
		if (ie)
			Field.style.backgroundColor='#FFFFFF';
		else if (ns)
			Field.backgroundColor='#FFFFFF';
		else if (ns6)
			Field.style.backgroundColor='#FFFFFF';
	}

//------------------------------------------------------------------
//-- Functions to Set/Reset the background color of current field for Details Window
//------------------------------------------------------------------
	function onFocusDetails (Field) 
	{
		if (ie)
			Field.style.backgroundColor='#FFFFC6';
		else if (ns)
			Field.backgroundColor='#FFFFC6';
		else if (ns6)
			Field.style.backgroundColor='#FFFFC6';
			
		var sErrorField = document.frmDetails.hidErrorFieldName.value;
		if (sErrorField != '') {
			eval ("document.frmDetails." + sErrorField + ".focus()");
			document.frmDetails.hidErrorFieldName.value	= '';
		}
	}

	function onBlurDetails (Field) 
	{
		if (ie)
			Field.style.backgroundColor='#FFFFFF';
		else if (ns)
			Field.backgroundColor='#FFFFFF';
		else if (ns6)
			Field.style.backgroundColor='#FFFFFF';
	}

//------------------------------------------------------------------
//-- Functions for Details Window functionality
//------------------------------------------------------------------
	function setDetailsStatus (nFieldIndex, sStatus) {
		//	Detail status is an array of characters, one for each field in the question
		//		0 - Details NOT enabled for this field
		//		1 -	NO, details have not been entered
		//		2 - YES, details have been entered
		var sDetailsStatus = window.opener.document.TAForm.hidDetailsStatus.value;
		var sNewDetailsStatus = '';

		for (var n=0; n < sDetailsStatus.length; n++) {
			if (n == nFieldIndex-1)
				sNewDetailsStatus += sStatus;
			else
				sNewDetailsStatus += sDetailsStatus.charAt(n);
		}
		return (sNewDetailsStatus);
	}

	function validDetails () {
		var bValidDetails = true;
		
		var nRows = document.frmDetails.nRows.value;
		for(var n=1; n <= nRows; n++) {
			var fldDate = eval ("document.frmDetails.txtDate_" + n);
			var fldAmount = eval ("document.frmDetails.txtAmount_" + n);
	
			if (calcDateValidate (fldDate, false) != true) {
				bValidDetails = false;
				fldDate.focus();
				fldDate.select();
				document.frmDetails.hidErrorFieldName.value	= fldDate.name;			
				break;
			}		
			if (calcCurrencyValidate (fldAmount, -999999999.99, 999999999.99, true) != true) {
				bValidDetails = false;
				fldAmount.focus();
				fldAmount.select();
				document.frmDetails.hidErrorFieldName.value	= fldAmount.name;
				break;
			}
		}

		return (bValidDetails);
	}

	function submitDetails (sAction) {
		if (CheckSessionTimeout () != false)
			return;

		ResetLogoutTimer();

		var bCloseAndSaveChanges = false;
		var bCloseWindow = false;

		document.frmDetails.cmdAction.value = sAction;
		var sFieldName = document.frmDetails.hidCurFieldName.value;
		var nFieldIndex = document.frmDetails.hidCurFieldIndex.value * 1;
		var nFieldType = document.frmDetails.hidCurFieldType.value;

		if (sAction == 'Close') {
			if (document.frmDetails.bDataChanged.value == 'true')
			{
				if (confirm ('Detailed Information has been modified.  Would you like to save the change?\r\n\r\nPress [OK] to save changes;  otherwise, press [Cancel].'))
					bCloseAndSaveChanges = true;
			}
			bCloseWindow = true;
		}

		if (sAction == 'Save' || bCloseAndSaveChanges == true) {
			if (validDetails() == true) {
				calcDetailsTotal ();
				var nValue = document.frmDetails.txtTotal.value;

				//	Check if any Details data exists
				var	bDetailsDataExists = false;
				var nRows = document.frmDetails.nRows.value;
				for(var n=1; n <= nRows; n++) {
					var	strDate = eval ("document.frmDetails.txtDate_" + n + ".value");
					var	strDescr = eval ("document.frmDetails.txtDescr_" + n + ".value");
					var	strAmount = eval ("document.frmDetails.txtAmount_" + n + ".value");
					if (strDate != '' || strDescr != '' || strAmount != '') {
						bDetailsDataExists = true;
						break;
					}
				}
				var	strNote = eval ("document.frmDetails.txtNote.value");
				if (strNote != '')
					bDetailsDataExists = true;
			
				if (bDetailsDataExists == true)
					sHidDetailsStatus = setDetailsStatus (nFieldIndex, '2');
				else
					sHidDetailsStatus = setDetailsStatus (nFieldIndex, '1');

				if (eval ('window.opener.document.TAForm.' + sFieldName)) {
					//	if FLDTYPE_CURRENCY update value in parent field of Details Window
					if (nFieldType == 1) {
						eval ('window.opener.document.TAForm.' + sFieldName + '.value="' + nValue + '"');
					}

					//	Update Details Status
					window.opener.document.TAForm.hidDetailsStatus.value = sHidDetailsStatus;
					
					//	Update Field Modified
					var sModFieldName = 'FFMOD' + sFieldName.substring (sFieldName.indexOf("_"), sFieldName.length);
					calcSetFieldModified_2 (eval ('window.opener.document.TAForm.' + sModFieldName));
				}

				document.frmDetails.cmdAction.value = 'Save';
				document.frmDetails.submit();
			}
		}
		
		else if (sAction == 'Clear') {
			var nRows = document.frmDetails.nRows.value;
			for(var n=1; n <= nRows; n++) {
				eval ('document.frmDetails.txtDate_' + n + '.value = ""');
				eval ('document.frmDetails.txtDescr_' + n + '.value = ""');
				eval ('document.frmDetails.txtAmount_' + n + '.value = ""');
			}
			document.frmDetails.txtTotal.value = '0.00';
			document.frmDetails.txtNote.value = '';
		}

		else if (sAction == 'Cancel') {
			bCloseWindow = true;
		}
		
		if (bCloseWindow) {
			if (eval ('window.opener.document.TAForm.' + sFieldName + '.value'))
				eval ('window.opener.document.TAForm.' + sFieldName + '.focus()');
			window.close();
		}
	}

	function printDetails () {
		print();
	}
	function helpDetails () {
		window.alert ('Help???');
	}
	function calcDetailsTotal () {
		var nValue, strValue, bIsNeg;
		var nRows = document.frmDetails.nRows.value;
		var nTotal = parseFloat('0');

		for(var n=1; n <= nRows; n++) {
			strValue = eval ("document.frmDetails.txtAmount_" + n + ".value");
			bIsNeg = strValue.indexOf("-") != -1;
			strValue = strValue.replace (" ", "");
			strValue = strValue.replace (",", "");
			strValue = strValue.replace ("-", "");
			
			if (strValue != "") {
				nValue = parseFloat (strValue);
				if (bIsNeg)
					nTotal = nTotal - nValue;
				else
					nTotal = nTotal + nValue;
			}
		}
		document.frmDetails.txtTotal.value = nTotal;
		calcCurrencyValidate (document.frmDetails.txtTotal);
	}

	function isDetailsClosed() {
		if (window.document.frmDetails.cmdAction.value == 'CloseNoSave' || window.opener.document.TAForm.hidDetailsStatus.value == 'XXX')
			var bResult = true;
		else
			var bResult = false;
		
		return (bResult);
	}
	
	function onUnloadDetailsWin () {
		return;
	}
	
	function onDetailsDataChanged () {
		document.frmDetails.bDataChanged.value = true;
	}

	function calcTextAreaValidate (txt, nMaxLength, insubmit) {
		var bIsValid = true;
		var sValue = txt.value;
		
		if (sValue.length > nMaxLength) 
			bIsValid = false;

		if (bIsValid == false) {
			if (insubmit || IsMicrosoft()) {
				window.alert ('Please enter a value with no more than ' + nMaxLength + ' characters.');
			}
		}
		
		return (bIsValid);
	}
	
	function CompareDetailItems (sFieldType, sVal1, sVal2) {
	//	Returns true if sVal1 < sVal2;  otherwise, returns false
		var bResult;

		//	Date
		if (sFieldType == 'Date') {
			var nMonth1, nDay1, nYear1;
			var nMonth2, nDay2, nYear2;
			var sDate1, sDate2, arrDate1, arrDate2
			
			nMonth1=0;nDay1=0;nYear1=0;
			nMonth2=0;nDay2=0;nYear2=0;
			
			sDate1 = sVal1 + '//';
			sDate2 = sVal2 + '//';
			arrDate1 = sDate1.split("/");
			arrDate2 = sDate2.split("/");
			
			nMonth1 = parseInt ('0' + arrDate1[0], 10);
			nDay1 = parseInt ('0' + arrDate1[1], 10);
			nYear1 = parseInt ('0' + arrDate1[2], 10);
			
			nMonth2 = parseInt ('0' + arrDate2[0], 10);
			nDay2 = parseInt ('0' + arrDate2[1], 10);
			nYear2 = parseInt ('0' + arrDate2[2], 10);

			if ( (nYear1 < nYear2) || 
				 ( (nMonth1 < nMonth2) && (nYear1 <= nYear2) ) || 
				 ( (nDay1 < nDay2) && (nMonth1 <= nMonth2) && (nYear1 <= nYear2) ) )
				bResult = true;
			else
				bResult = false;
		}
		
		
		//	Amount
		else if (sFieldType == 'Amount') {
			if (parseFloat ('0' + sVal1) < parseFloat ('0' + sVal2))
				bResult = true;
			else
				bResult = false;
		}
		
		//	Text
		else {
			if (sVal1 < sVal2)
				bResult = true;
			else
				bResult = false;
		}
			
		return (bResult);
	}

	function SwapDetailItems (i, j) {
		var sDate_I, sDescr_I, sAmount_I;
		var sDate_J, sDescr_J, sAmount_J;
		
		sDate_I = eval ('document.frmDetails.txtDate_' + i + '.value');
		sDescr_I = eval ('document.frmDetails.txtDescr_' + i + '.value');
		sAmount_I = eval ('document.frmDetails.txtAmount_' + i + '.value');

		sDate_J = eval ('document.frmDetails.txtDate_' + j + '.value');
		sDescr_J = eval ('document.frmDetails.txtDescr_' + j + '.value');
		sAmount_J = eval ('document.frmDetails.txtAmount_' + j + '.value');
		
		eval ('document.frmDetails.txtDate_' + i + '.value = "' + sDate_J  + '"');
		eval ('document.frmDetails.txtDescr_' + i + '.value = "' + sDescr_J + '"');
		eval ('document.frmDetails.txtAmount_' + i + '.value = "' + sAmount_J + '"');

		eval ('document.frmDetails.txtDate_' + j + '.value = "' + sDate_I + '"');
		eval ('document.frmDetails.txtDescr_' + j + '.value = "' + sDescr_I + '"');
		eval ('document.frmDetails.txtAmount_' + j + '.value = "' + sAmount_I + '"');
	}

	function sortDetails (sSort) {
		var sCurSort = document.frmDetails.hidCurSort.value;
		var sCurSortOrder = document.frmDetails.hidCurSortOrder.value;
		var sSortOrder = 'ASC';
		var nRows = document.frmDetails.nRows.value;
		var nRowsToSort = 0;
		var sDate, sDescr, sAmount;

		if (sSort == sCurSort) {
			if (sCurSortOrder == 'ASC')
				sSortOrder = 'DESC';
		}
		document.frmDetails.hidCurSort.value = sSort;
		document.frmDetails.hidCurSortOrder.value = sSortOrder;
		
		for(var n=1; n <= nRows; n++) {
			sDate = eval ('document.frmDetails.txtDate_' + n + '.value');
			sDescr = eval ('document.frmDetails.txtDescr_' + n + '.value');
			sAmount = eval ('document.frmDetails.txtAmount_' + n + '.value');
			
			if (sDate.length > 0 || sDescr.length > 0 || sAmount.length > 0) {
				nRowsToSort = n;
			}
		}
		
		var	sVal1, sVal2;
		for(var i=1; i <= nRowsToSort; i++) {
			//	DESC order
			if (sSortOrder == 'DESC') {
				for(var j=nRowsToSort; j >= (1+i); j--) {
					sVal1 = eval ('document.frmDetails.txt' + sSort + '_' + parseInt(j-1, 10) + '.value');
					sVal2 = eval ('document.frmDetails.txt' + sSort + '_' + j   + '.value');
					
					if (CompareDetailItems (sSort, sVal1, sVal2))
						SwapDetailItems (j-1, j);
				}
			}
			
			//	ASC order
			else {
				for(var j=1; j <= nRowsToSort-i; j++) {
					sVal1 = eval ('document.frmDetails.txt' + sSort + '_' + j   + '.value');
					sVal2 = eval ('document.frmDetails.txt' + sSort + '_' + parseInt(j+1, 10) + '.value');

					if (CompareDetailItems (sSort, sVal2, sVal1))
						SwapDetailItems (j, j+1);
				}
			}
		}

		eval ('document.frmDetails.txt' + sSort + '_1.focus()');
		eval ('document.frmDetails.txt' + sSort + '_1.select()');
	}

    function OnStep6AmendReturn () {
		if (window.opener.document.TAForm.hidedition.value != '2')
			window.opener.parent.mainbody_frame.location.href = '../taxmanager.dll/jumpto?nav_script=iv_usdlxadds_dlxforms';
		else {
			if (window.opener.document.TAForm.hidFedPaid.value == '0')
				window.alert ('You will need to complete \"Step 6 - Filing\" before filing an Amended Return.');
			else
				window.opener.parent.mainbody_frame.location.href = '../taxmanager.dll/jumpto?nav_script=IV_USF1040X_Q1';
		}
	}
