
var FAQWindow;
var FormsListWindow;
var HelpWindow;	
var LearnMoreWindow;
var OfxWindow;
var PrintWindow;
var ReportWindow;
var SiteMapWindow;
var SummaryWindow;
var SupportWindow;
var TaxPayerSupportWindow;
var LogoutWindow;
var HelpCenterWindow;
var ReturnStatusWindow;
var MyAccountWindow;
var AdminToolsWindow;
var PrintCenterWindow;
var EFCenterWindow;
var EFStatusWindow;
var EmailPrefWindow;
var	UpdateAccountWindow;
var	ChangeEmailRequestWindow;
var ReferAFriendWindow;
var SearchTopicFeedbackWindow;
var DASWindow;
var CalculatorWindow;
var LoanCalculatorWindow;
var SavingsCalculatorWindow;
var FormCalculatorWindow;
var arrWindows = new Array("FAQWindow","FormsListWindow","HelpWindow","LearnMoreWindow","OfxWindow","PrintWindow","ReportWindow","SiteMapWindow","SummaryWindow","SupportWindow","TaxPayerSupportWindow","LogoutWindow","HelpCenterWindow","ReturnStatusWindow","MyAccountWindow","AdminToolsWindow","PrintCenterWindow","EFCenterWindow","EFStatusWindow","EmailPrefWindow","UpdateAccountWindow","ChangeEmailRequestWindow","ReferAFriendWindow","SearchTopicFeedbackWindow","DASWindow","CalculatorWindow","FormCalculatorWindow");

var ie = document.all ? 1 : 0;
var ns = document.layers ? 1 : 0;
var ns6 = document.getElementById&&!document.all ? 1 : 0;
var bInSubmit = false;
var cLast2TaxYear = 2007	// BUGBUG - Update each year
var cLastTaxYear = 2008	// BUGBUG - Update each year
var cTaxYear = 2009
var cNextTaxYear = 2010
var cPreviewVersion = "PREVIEW";
var cFINALVersion = "FINAL";
var cVersion = "FINAL"; // BUGBUG - Update for PREVIEW/FINAL
var bPrintLY = false;	// BUGBUG - Update for PrintLY
var	cImagesDir = "images/final/"; //	BUGBUG - Update for PREVIEW/FINAL
var cFreeSourceCode = "0950302"; // BUGBUG - Update for new tax year
var cFreeSourceCode2 = "0950305"; // BUGBUG - Update for new tax year
var registrationPromptTimer, registrationPromptTimeout = 4 * 60 * 1000;

//------ IE openurl ----------------------------------

function showPDF(url, closeCode) {
    if (this.parent.mainbody_frame)
	    this.parent.mainbody_frame.showPDF(url, closeCode);
	else if (window.opener) {
	    if (window.opener.opener) {
		    if (window.opener.opener.parent.mainbody_frame)
		        window.opener.opener.parent.mainbody_frame.showPDF(url, closeCode);
	    } else if (window.opener.parent.mainbody_frame)
	        window.opener.parent.mainbody_frame.showPDF(url, closeCode);
    }
}

function stockAssistant() {
  if (this.parent.mainbody_frame)
    this.parent.mainbody_frame.stockAssistant();
  else if (window.opener) {
	if (window.opener.parent.mainbody_frame)
	    window.opener.parent.mainbody_frame.stockAssistant();
  }
}

function showFmvCalculator(field, max, descr) {
  if (this.parent.mainbody_frame)
    this.parent.mainbody_frame.showFmvCalculator(field, max, descr);
  else if (window.opener) {
	if (window.opener.parent.mainbody_frame)
	    window.opener.parent.mainbody_frame.showFmvCalculator(field, max, descr);
  }
}

function showCalculator(){
    if (CheckSessionTimeout () != false)
		return;
	ResetLogoutTimer();
	
	if (CalculatorWindow && !CalculatorWindow.closed){
		CalculatorWindow.close();
	}

    var url = "../taxmanager.dll/Calculator" + 
              "?t=" + new Date().getTime();
              
	CalculatorWindow = window.open(url,'TaxACTCalculator','resizable,scrollbars,height=310,width=360');
	CalculatorWindow.opener = self;
	CalculatorWindow.focus();
	
	if (parent.myLightWindow){
	    parent.myLightWindow.deactivate();
	}
	else if (NavToolsWindow && !NavToolsWindow.closed) {
		NavToolsWindow.close();
	}
}

function csvStockImport(action) {
  if (this.parent.mainbody_frame)
    this.parent.mainbody_frame.csvStockImport(action);
  else if (window.opener) {
    if (window.opener.parent.mainbody_frame)
      window.opener.parent.mainbody_frame.csvStockImport(action);
  }
}

function showLoanCalculator(){
  if (this.parent.mainbody_frame)
    this.parent.mainbody_frame.showLoanCalculator();
  else if (window.opener) {
	if (window.opener.parent.mainbody_frame)
	    window.opener.parent.mainbody_frame.showLoanCalculator();
  }
}

function showSavingsCalculator(){
  if (this.parent.mainbody_frame)
    this.parent.mainbody_frame.showSavingsCalculator();
  else if (window.opener) {
	if (window.opener.parent.mainbody_frame)
	    window.opener.parent.mainbody_frame.showSavingsCalculator();
  }
}

function showFormCalculator(module, type, id, index, continueButton) {
  if (this.parent.mainbody_frame)
    this.parent.mainbody_frame.showFormCalculator(module, type, id, index, continueButton);
  else if (window.opener) {
	if (window.opener.parent.mainbody_frame) {
	  ResetLogoutTimer();
	
	  var nEdition = window.opener.parent.mainbody_frame.document.TAForm.hidedition.value;
	  if (nEdition == "1") {
	    OnShowInfo('topic:show info/TAXCALC');
	    window.close();
	  }
	  else {
	    if (FormCalculatorWindow && !FormCalculatorWindow.closed){
		    FormCalculatorWindow.close();
	    }
    	
	    if (parent.myLightWindow){
	        parent.myLightWindow.deactivate();
	    }
	
	    var strDate = new Date().getTime();
		var url = "../introduction/VisualForms.asp?FormCalculator&type="+type+(continueButton?("&continueButton="+continueButton):"")+'&width='+screen.width+'&height='+screen.height+'&deviceXDPI='+screen.deviceXDPI+'&deviceYDPI='+screen.deviceYDPI+'&logicalXDPI='+screen.logicalXDPI+'&logicalYDPI='+screen.logicalYDPI+'&id='+id+'&index='+index+'&module='+module+'&appTimeout='+window.opener.parent.mainbody_frame.nAppTimeout+'&appWarning='+window.opener.parent.mainbody_frame.nAppWarning+'&userAgent='+navigator.userAgent+'&time='+strDate;
		FormCalculatorWindow = window.open(url,'TaxACTCalculator','resizable,scrollbars,height=310,width=360');
	    FormCalculatorWindow.opener = self;
	    FormCalculatorWindow.focus();
	  }
	}
  }
}

function onReload(inUrl) {
  onRefresh();
  this.parent.mainbody_frame.HeaderNavTools(inUrl);
}

function setCookie(name, value, expire) {   
	document.cookie = name + "=" + escape(value)   
		+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}
function getCookie(Name) {   
	var search = Name + "=";
	if (document.cookie.length > 0) {
		var offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			var end = document.cookie.indexOf(";", offset);
			if (end == -1)             
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}    
	}
}

function stopRegistrationPrompting() {
	window.clearInterval(registrationPromptTimer);
}

function startRegistrationPrompting() {
	stopRegistrationPrompting();
	registrationPromptTimer = window.setInterval('promptForRegistration(1, false, true)', registrationPromptTimeout);
}

function promptForRegistration(actionOnNo, siginingOut, timedPrompt) {
  stopRegistrationPrompting();
  if (parent && parent.mainbody_frame) {
    parent.mainbody_frame.doRegistrationPrompt(actionOnNo, siginingOut, timedPrompt);
  }
  else if (mainbody_frame) {
    mainbody_frame.doRegistrationPrompt(actionOnNo, siginingOut, timedPrompt);
  }
}

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(){
	var navFrame = parent.document.getElementById('navframe');
	if (navFrame && -1 != navFrame.src.toUpperCase().indexOf("HELP_HEADER.ASP")) {
		if (top.opener && top.opener.parent) {
			top.opener.parent.ResetLogoutTimer();
		}
	}
	else 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)
			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(){
    if (document.TAForm.FLD_MODIFIED)
	    document.TAForm.FLD_MODIFIED.value = "1";
}

function calcSetFieldModified(fld){
    if (fld != undefined)
	    fld.value = "1";
	calcSetModified();
}

//	These 2 functions are used by Details functions from pop-up window
function calcSetModified_2(){
    if (parent && parent.mainbody_frame && parent.mainbody_frame.document.getElementById("TAForm") && parent.mainbody_frame.document.getElementById("TAForm").FLD_MODIFIED)
	    parent.mainbody_frame.document.getElementById("TAForm").FLD_MODIFIED.value = "1";
}

function calcSetFieldModified_2(fld){
    if (fld != undefined)
	    fld.value = "1";
	parent.mainbody_frame.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;
	}
	if (bPrintLY)
	{
		if (btn.value.indexOf("File Federal Extension",0) != -1 ||
			btn.value.indexOf("File Electronically",0) != -1)
		{
			OnNotAvailForPrintLY()	
			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){
	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 calcGetCaretPosition(fld) {
	var caretPos = 0;
	if (IsMicrosoft()) {
		fld.focus ();
		var sel = document.selection.createRange();
		sel.moveStart ('character', -fld.value.length);
		caretPos = sel.text.length;
	} else if (fld.selectionStart || fld.selectionStart == '0') {
		caretPos = fld.selectionStart;
	}
	return (caretPos);
}

function calcSetCaretPosition(fld,pos) {
	if(fld.setSelectionRange)
	{
		fld.focus();
		fld.setSelectionRange(pos,pos);
	}
	else if (fld.createTextRange) {
		var range = fld.createTextRange();
		range.collapse(true);
		range.moveEnd('character', pos);
		range.moveStart('character', pos);
		range.select();
	}
}

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 c;
	var i;
	var j;
	var dollarval;
	var centval;
	var newval;

	i = currval;
	if (i < 0){
		i *= -1;
	}
	
	j = (i % 100);
	if (j < 10){
		centval = "0";
		centval += j.toString();
	}else{
		centval = j.toString();
	}
	if (currval < 0){
		newval = "-";
	}else{
		newval = "";
	}
	
	i = ((i - (i % 100)) / 100);
	j = i.toString();
	dollarval = "0";
	for (var s = j.length, count = 1; s > 0; s--, count++) {
		if (s == j.length) { dollarval = ""; }
		
		c = j.charAt(s-1);
		if (count > 3) {
			dollarval = c + "," + dollarval;
			count = 1;
		}
		else {
			dollarval = c + dollarval;
		}
	}
	
	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,c,pos,selected;
	
	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 != 'v') && (c != 'V')){ return false; }
		
		if ((c != 'v') && (c != 'V')) { 
			pos = calcGetCaretPosition(txt)
			if (((pos == 0) && ((c == ')') || (c == '-')))
				|| ((pos == 4) && ((c == '(') || (c == '-')))
				|| ((pos == 8) && ((c == '(') || (c == ')')))
				|| ((pos != 0) && (pos != 4) && (pos != 8) && ((c == '(') || (c == ')') || (c == '-')))) { return false; }
			
			if (IsMicrosoft()) {
				var textRange = document.selection.createRange();
				selected = textRange.text.length;
			} else {
				selected = txt.selectionEnd - txt.selectionStart;
			}
			
			if ((pos == 0) && (c != '(')) {
				if (selected == txt.value.length) {
					txt.value = '(';
					calcSetCaretPosition(txt,pos + 1);
				} else if (selected < 2) {
					if (txt.value.indexOf('(') == - 1) {
						txt.value = '(' + txt.value;
					}
				}
			} else if ((selected < 2) && (txt.value.indexOf('(') != -1)) {
				if ((pos == 4) && (c != ')')) {
					if (txt.value.indexOf(')') == -1) {
						txt.value = txt.value.substr(0, pos) + ')' + txt.value.substr(pos);
						calcSetCaretPosition(txt,pos + 1);
					}
				} else if ((pos == 8) && (c != '-')) {
					if ((txt.value.indexOf('-') == -1) && (txt.value.indexOf(')') != -1)) {
						txt.value = txt.value.substr(0, pos) + '-' + txt.value.substr(pos);
						calcSetCaretPosition(txt,pos + 1);
					}
				}
			}
		}
	}
}

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,sMinDate,sMaxDate){
	var i,c,currval,newval,isday,ismonth,issep,isinvalid,dayval,monthval,yearval,dayint,monthint,yearint,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{
		    var sTmpYr = cTaxYear.toString();
		    var sTmp = sTmpYr.substr(2,2);
		    sTmpYr = parseInt(sTmp,10);
			yearint = parseInt(yearval,10);
			
			if (yearint < (sTmpYr + 9)){ // current year + 9
				yearint += 2000;
			}else if (yearint < 100){
				yearint += 1900;
			}
		}
	}
	if ((yearint < 1900) || (yearint > 2099)){
		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;
	}
	else 
	{
		var sYear = '0000' + yearint.toString();
		var sMonth = '0000' + monthint.toString();
		var sDay = '00' + dayint.toString();
		var sCurrDate = sYear.substr(sYear.length-4, 4) + sMonth.substr(sMonth.length-2,2) + sDay.substr(sDay.length-2,2);
	    if (sCurrDate < sMinDate || sCurrDate > sMaxDate)
	    {
			msg = "Please enter a date between " + sMinDate + " and " + sMaxDate + ".";
			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.user_id);
	else
		var bValidUserID = ValidSigninUserID(inForm.user_id);

	if (!bValidUserID){
		//inWindow.location = "err_signin.asp";
	}else if (!ValidSigninPassword(inForm.user_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.user_id)){
		//return(false);
	}else if (!ValidPassword(inForm.user_password,inForm.user_id)){
		//return(false);
	}else if (!CheckPassword(inForm.user_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.user_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 < 6 || inField.value.length > 25) {
		bValid = false;
		szError = "User name must contain at least 6 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 < 6){
		bValid = false;
		szError = "The Password entered is less than 6 characters.\r\n\r\nPlease enter a Password between 6 and 16 characters.";
	}
	else {
		var regex = /^[a-zA-Z0-9_`~!@#$%^&*()_+-={}|\[\]\\:;<>?.]{6,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 < 6 || inField.value.length > 16){
		bValid = false;
		szError = "The Password entered is less than 6 characters.\r\n\r\nPlease enter a Password between 6 and 16 characters.";
	}
	else {
		var regex = /^[a-zA-Z0-9_`~!@#$%^&*()_+-={}|\[\]\\:;<>?.]{6,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 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){}

//------------------------------------------------------------------
//--------------------- Script Functions ---------------------------
//------------------------------------------------------------------
function OnSubmitIS(inURL){
	doDate = new Date();
	strDate = doDate.getTime();
	inURL += "time="+strDate;
	document.location.href = inURL;
}

function OnPopupRegistrationComplete(){
	top.browserNavigationDialog=false;
	if (parent.myLightWindow &&
	    (parent.myLightWindow.closingUrl &&
	    -1 != parent.myLightWindow.closingUrl.toUpperCase().indexOf("PRINT_SIGNIN.ASP")) ||
		-1 != document.location.href.toUpperCase().indexOf("PRINT_SIGNIN.ASP")) {
		var strURL = "taxactonline.asp?d=1";
		var doDate = new Date();
		var strDate = doDate.getTime();
		
		if (bInSubmit)
			return;
		if (CheckSessionTimeout () != false)
			return;
		
		bInSubmit = true;
		
		if (strURL.indexOf('?') == -1)
		  strURL = strURL  + "?time=" + strDate;
		else
		  strURL = strURL  + "&time=" + strDate;
	    
		this.parent.mainbody_frame.allowThrough = true;    
		this.parent.location = strURL;
	}
	else if(parent.myLightWindow){
		var myTaxAct=top.document.getElementById("myTaxact");
		//parent.myLightWindow.deactivate();
		if (myTaxAct && -1 != myTaxAct.innerHTML.toUpperCase().indexOf("REGISTER NOW")){
			startRegistrationPrompting();
		}
		else {
			stopRegistrationPrompting();
		}
	}
	else {
	  var myTaxAct = document.getElementById("myTaxact");
		if (myTaxAct && -1 != myTaxAct.innerHTML.toUpperCase().indexOf("REGISTER NOW")){
			startRegistrationPrompting();
		}
		else {
			stopRegistrationPrompting();
		}
	}
}

function OnLogout() {
	try {  // gk - guard against invalid opener, (e.g. launched from Outlook Express)
	if (opener && opener.top && opener.top.browserNavigationDialog)
		opener.top.browserNavigationDialog = false;
	else
		top.browserNavigationDialog = false;
	}
	catch (e) {
		opener = null;
		OnLogout();
	}
		
	doDate = new Date();
	strDate = doDate.getTime();
	var sURL = "../taxmanager.dll/logoff?time=" + strDate;
	if (this.parent.mainbody_frame){
		this.parent.mainbody_frame.allowThrough = true;
		this.parent.mainbody_frame.document.location = sURL;
	}else if (opener.parent.mainbody_frame){
		opener.parent.mainbody_frame.allowThrough = true;
		opener.parent.mainbody_frame.document.location = sURL;
	}
}

function CheckSessionTimeout () {
	var bTimedOut = false;
  
	try { // gk - guard against invalid opener, (e.g. launched from Outlook Express)
    if (window.opener) {
	    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 && window.opener.open && !window.opener.closed) || (window.opener.top.frames.length == 0))
		    if (!(window.opener && window.opener.open && !window.opener.closed))
			    bTimedOut = true
			}
		}
	}
	catch(e) {
		window.opener = null;
		CheckSessionTimeout();
	}
		
	
	//	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();
			if (window.CalculatorWindow && !window.CalculatorWindow.closed())
				window.CalculatorWindow.close();
		    if (window.LoanCalculatorWindow && !window.LoanCalculatorWindow.closed())
				window.LoanCalculatorWindow.close();
			if (window.SavingsCalculatorWindow && !window.SavingsCalculatorWindow.closed())
				window.SavingsCalculatorWindow.close();
			if (window.FormCalculatorWindow && !window.FormCalculatorWindow.closed())
				window.FormCalculatorWindow.close();
		}
    
		bTimedOut = true;
		window.close();
	}
	
	return (bTimedOut);
}

function CloseWindows() {
  var i;
  for (i = 0; i < arrWindows.length; i++){
    eval("if (parent.mainbody_frame." + arrWindows[i] + ") {parent.mainbody_frame." + arrWindows[i] + ".close();}");
  }
}

function isIE5()
{
  var index = -1, sVer = "", sUserAgent = "", retVal = false;
  if (navigator.userAgent) {sUserAgent = navigator.userAgent;}

  index = sUserAgent.search("MSIE");
  if (index > -1) {
    sVer = sUserAgent.substr(index+5,5);
    sVer = sVer.replace(";","0");

    if (sVer.search("5.") > -1){
      retVal = true;
    }
  }
  
  return retVal;
}

function OnFormInstrHelp(inURL){
    if (!isIE5())
    {
        // ie5 has issues clicking links with this code enabled
	    if (CheckSessionTimeout () != false)
		    return;

	    ResetLogoutTimer();
	}
	
	var sFormInstrHelpTopic = 'Default';
	var sFullTopicName;
	if (sFormInstrHelpTopic == '' || sFormInstrHelpTopic.length < 0)
		sFormInstrHelpTopic = 'Default';
	sFullTopicName = 'topic:' + parent.mainbody_frame.document.TAForm.hidmod.value + ' INSTRUCTIONS/' + sFormInstrHelpTopic;
	resizeDraggable('guidance','490');
	var oWrap = parent.document.getElementById('guidanceWrap');
	if (oWrap.style.left == '')
	    oWrap.style.left = '475px';
	OnHelp (inURL, sFullTopicName);
}

function resizeDraggable(sName, sSize){
    var sNewSize = '438';
    if (sSize)
        sNewSize = sSize;
    eval("var oWrap = parent.document.getElementById('" + sName + "Wrap');");
	eval("var oInnerWrap = parent.document.getElementById('" + sName + "InnerWrap');");
	eval("var oFrame = parent.document.getElementById('" + sName + "Frame');");
	if (oWrap)
	    oWrap.style.width = sNewSize + "px";
	if (oInnerWrap)
	    oInnerWrap.style.width = sNewSize + "px";
	if (oFrame)
	    oFrame.style.width = sNewSize + "px";
}

function OnHelp(inURL,HelpTopic){
	var EncodedTopic,TopicURL;
	EncodedTopic = escape(HelpTopic);
	EncodedTopic = EncodedTopic.replace ('+', '***AND***')
 
	var navFrame = parent.document.getElementById('navframe');
	if (navFrame && -1 != navFrame.src.toUpperCase().indexOf("HELP_HEADER.ASP")) {
		var topOpener = top.opener;
		var topOpenerParent = top.opener.parent;
		// If we were opened by a light window, we need to get the parent of the parent...
		if (top.opener && top.opener.parent && top.opener.parent.parent && top.opener.parent.parent.mainbody_frame) {
			topOpener = top.opener.parent;
			topOpenerParent = top.opener.parent.parent;
		}
		if (topOpener && topOpenerParent && topOpenerParent.mainbody_frame) {
			if (!isIE5()) {
				// ie5 has issues clicking links with this code enabled
				if (CheckSessionTimeout () != false)
					return;
				topOpenerParent.ResetLogoutTimer();
			}
			var nEdition = topOpenerParent.mainbody_frame.document.TAForm.hidedition.value;
			if (HelpTopic.toUpperCase().indexOf("TOPIC:EXPERT HELP") >= 0 && nEdition == "1") {
				// This case is for when we choose Form Instructions from a Visual Form, and then
				// click on the TaxTutor tab
				if (-1 != top.opener.document.location.href.toUpperCase().indexOf("VISUALFORMS.ASP")) {
					top.opener.frames[0].visualForm.onTaxTutor();
				}
				else {
					topOpenerParent.OnNavClick('../taxmanager.dll/JumpTo?nav_script=IV_USMarketing_JKLDLXInfo&nav_index=0&show_topics=0');
					top.close();
					topOpenerParent.ClearInSubmit();
				}
			}
			else {
				TopicURL = inURL + EncodedTopic;
				TopicURL = TopicURL + '&hidmod=' + topOpenerParent.mainbody_frame.document.TAForm.hidmod.value;
				doDate = new Date();
				strDate = doDate.getTime();
				TopicURL += "&time="+strDate;
				top.document.getElementById('mainbody_frame').src=TopicURL;
			}
		}
	}
	else {
	    if (!isIE5()) {
		    // ie5 has issues clicking links with this code enabled
		    if (CheckSessionTimeout () != false)
  		    return;
  		    
		    ResetLogoutTimer();
	    }

        var frmTA = null;
        if (parent && parent.mainbody_frame) {
            frmTA = parent.mainbody_frame.document.TAForm;
        } else if (top && top.opener && top.opener.parent && top.opener.parent.mainbody_frame) {
            frmTA = top.opener.parent.mainbody_frame.document.TAForm;
        }
        
        if (frmTA != null) {
	        var nEdition = frmTA.hidedition.value;
	        if (HelpTopic.toUpperCase().indexOf("topic:EXPERT HELP") >= 0 && nEdition == "1"){
		        parent.document.getElementById('guidanceFrame').src='../taxmanager.dll/JumpTo?nav_script=IV_USMarketing_JKLDLXInfo&nav_index=0';
	        }else{
	            TopicURL = inURL + EncodedTopic;
	            TopicURL = TopicURL + '&hidmod=' + frmTA.hidmod.value;
		           
		        if (frmTA.hidden_cur_script.value.toUpperCase() != "IV_USINTERVIEW_HOMEPAGE" && 
		           frmTA.hidden_cur_script.value.toUpperCase() != "IV_USINTERVIEW_WELCOMEBACK" &&
		           frmTA.hidden_cur_script.value.toUpperCase() != "IV_USSTEP1_IMPORT" &&
		           frmTA.hidden_cur_script.value.toUpperCase() != "IV_USSTEP1_IMPORT_SUCCESS") {
			        TopicURL = TopicURL + '&hidCurFieldName=' + frmTA.hidCurFieldName.value +
			         '&hidden_cur_form=' + frmTA.hidden_cur_form.value +
			         '&hidNumFields=' + frmTA.hidNumFields.value;
                }
                
	            doDate = new Date();
	            strDate = doDate.getTime();
	            TopicURL += "&time="+strDate;
	            
	            if (parent) {
	                if (parent.opener) {
	                    if (top) {
	                        top.document.location.href = TopicURL;
	                    }
	                } else {
	                    if ((parent.myLightWindow) && (parent.myLightWindow.isOpen()))
	                        eval("parent.myLightWindow.activateWindow({href:'" + TopicURL + "',title:'',width:600,height:500});");
	                    else
	                        parent.document.getElementById('guidanceFrame').src=TopicURL;
	               }   
	            }
	        }
	    }
    }
}

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=728");
		SiteMapWindow.opener = self;
	 }
	 else{
		SiteMapWindow.document.location = newURL;
	}
	SiteMapWindow.focus();
}

function validateImportSummary(txt, type, minval, maxval) {
    if (type == "SSN") {
        return calcSSNValidate(txt, true);
    } else if (type == "CURRENCY") {
        return calcCurrencyValidate(txt, minval, maxval, true);
    } else if (type == "PHONE") {
        return calcPhoneValidate(txt, true);
    } else if (type == "NUMBER") {
        return calcNumberValidate(txt, minval, maxval, true);
    }
    return true;
}

function OnLearnMore(inURL,LearnMore){
  if (CheckSessionTimeout () != false)
		return;
		
	ResetLogoutTimer();
	var EncodedTopic,TopicURL,bPop;
	EncodedTopic = escape(LearnMore);
	EncodedTopic = EncodedTopic.replace ('+', '***AND***')
	
	bExisting = false;
	var frmTA = null;
	if (top && top.opener && top.opener.parent && top.opener.parent.mainbody_frame) {
        frmTA = top.opener.parent.mainbody_frame.document.TAForm;
        bExisting = true;
    } else if (parent && parent.mainbody_frame) {
        frmTA = parent.mainbody_frame.document.TAForm;
    }
	
	if (frmTA != null) {
	    var nEdition = frmTA.hidedition.value;
    	
	    TopicURL = inURL + EncodedTopic;
	    TopicURL = TopicURL + '&hidmod=' + frmTA.hidmod.value;
	    if (frmTA.hidden_cur_script.value.toUpperCase() != "IV_USINTERVIEW_HOMEPAGE" && 
	       frmTA.hidden_cur_script.value.toUpperCase() != "IV_USINTERVIEW_WELCOMEBACK" &&
	       frmTA.hidden_cur_script.value.toUpperCase() != "IV_USSTEP1_IMPORT" &&
	       frmTA.hidden_cur_script.value.toUpperCase() != "IV_USSTEP1_IMPORT_SUCCESS")
		    TopicURL = TopicURL + '&hidCurFieldName=' + frmTA.hidCurFieldName.value +
		     '&hidden_cur_form=' + frmTA.hidden_cur_form.value +
		     '&hidNumFields=' + frmTA.hidNumFields.value;
    		
	    doDate = new Date();
	    strDate = doDate.getTime();
	    TopicURL += "&time="+strDate;
    	
	    if (navigator.userAgent.toUpperCase().indexOf('OPERA') != -1) {
		    if (LearnMoreWindow && !LearnMoreWindow.closed){LearnMoreWindow.close();}
		    LearnMoreWindow = window.open(TopicURL,"LearnMoreWindow","resizable,scrollbars,height=400,width=600");
		    LearnMoreWindow.opener = self;
		    LearnMoreWindow.focus();
    		
		    var operaOnly = null;
		    var startTime = doDate.getTime();
		    while (!operaOnly){
			    operaOnly = LearnMoreWindow.parent.document.getElementById('OperaOnly');
			    if (new Date().getTime()-startTime > 10000){
				    break;
			    }
		    }		
		    if (operaOnly){
			    operaOnly.style.display='inline';
		    }
	    } else if (bExisting) {
	        document.location.href = TopicURL;
	    } else {
		    var guidanceWrap = parent.document.getElementById('guidanceWrap');
		    var guidanceIndex = parent.document.getElementById('guidanceIndex');
		    var guidanceTitle = parent.document.getElementById('guidanceTitle');
		    var guidanceFrame = parent.document.getElementById('guidanceFrame');

		    if (guidanceTitle){
			    guidanceTitle.innerHTML = "Learn More";
		    }

		    if (guidanceIndex){
			    guidanceIndex.style.display='none';
		    }

		    if (guidanceFrame){
			    guidanceFrame.src=TopicURL;
		    }

		    if (guidanceWrap){	
			    guidanceWrap.style.display='block';			
		    }
	    }
	}
}

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 ((navigator.userAgent.toUpperCase().indexOf('OPERA') != -1) ||
	    (navigator.userAgent.toUpperCase().indexOf('NETSCAPE/8') != -1)){
	    if (!SummaryWindow || SummaryWindow.closed){
		    SummaryWindow = window.open(newURL,"TaxSummary","status,resizable,scrollbars,height=460,width=700");
		    SummaryWindow.opener = self;
	     }
	     else{
		    SummaryWindow.document.location = newURL;
	    }
	    SummaryWindow.focus();
	}
	else {
		if (parent.myLightWindow){
			parent.myLightWindow.activateWindow({href:newURL,title:'',width:728,height:600});
		}
	}
}

function OnHelpCenter(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL;
	if (newURL.indexOf("?") > 0)
		newURL += "&t=" + strDate;
	else
		newURL += "?t=" + strDate;
	var navFrame = parent.document.getElementById('navframe');
	if (navFrame && -1 != navFrame.src.toUpperCase().indexOf("HELP_HEADER.ASP")) {
		// This is the new Help Center, just set the new location
		document.location=newURL;
	}
	else {
		// This is the old (?) help, or not sure - ToDo: gk - Can this be removed?
		if (!HelpCenterWindow || HelpCenterWindow.closed){
			HelpCenterWindow = window.open(newURL,"Help","height=500,width=700,toolbar=1,location=1,directories=1,status=1,menuBar=1,scrollBars=1,resizable=1");
			HelpCenterWindow.opener = self;
		 }
		 else{
			 HelpCenterWindow = window.open(newURL,"Help","height=500,width=700,toolbar=1,location=1,directories=1,status=1,menuBar=1,scrollBars=1,resizable=1");
			//HelpCenterWindow.document.location = newURL;
		}
		HelpCenterWindow.focus();
	}
}
function OnReturnStatus(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!ReturnStatusWindow || ReturnStatusWindow.closed){
		ReturnStatusWindow = window.open(newURL,"ReturnStatus","status,resizable,scrollbars,height=550, width=600");
	 	ReturnStatusWindow.opener = self;
	 }
	 else{
		ReturnStatusWindow.document.location = newURL;
	}
}

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 OnAdminTools(inURL){
	ResetLogoutTimer();
	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!AdminToolsWindow || AdminToolsWindow.closed){
		AdminToolsWindow = window.open(newURL,"AdminTools","status,resizable,scrollbars,height=600, width=800");
	 	AdminToolsWindow.opener = self;
	}else{
		AdminToolsWindow.document.location = newURL;
	}
	AdminToolsWindow.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=1000");
		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=450, width=725");
		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=0,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 OnChangeEmailRequest(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!ChangeEmailRequestWindow || ChangeEmailRequestWindow.closed){
		ChangeEmailRequestWindow = window.open(newURL,"ChangeEmailRequest","toolbar=1,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1,height=600, width=800");
		ChangeEmailRequestWindow.opener = self;
	 }
	 else{
		ChangeEmailRequestWindow.document.location = newURL;
	}
	ChangeEmailRequestWindow.focus();
}
function OnReferAFriend(inURL){
	var newURL = inURL;
	doDate = new Date();
	strDate = doDate.getTime();
	newURL = newURL + "&time=" + strDate;
	if (!ReferAFriendWindow || ReferAFriendWindow.closed){
		ReferAFriendWindow = window.open(newURL,"ReferAFriend","status,resizable,scrollbars,height=650,width=800");
		ReferAFriendWindow.opener = self;
	 }
	 else{
		ReferAFriendWindow.document.location = newURL;
	}
	ReferAFriendWindow.focus();
}
function OnSearchTopicFeedback(inURL){
	var newURL = inURL;
	doDate = new Date();
	strDate = doDate.getTime();
	var strTopic = document.getElementById('txtSearch').value;
	if (strTopic != ''){
	    newURL = newURL + "?tp=" + escape(strTopic) + "&t=" + strDate;
	}else{
	    newURL = newURL + "?t=" + strDate;    
	}
	
	if (!SearchTopicFeedbackWindow || SearchTopicFeedbackWindow.closed){
		SearchTopicFeedbackWindow = window.open(newURL,"SearchTopicFeedback","status,resizable,scrollbars,height=525,width=1000");
		SearchTopicFeedbackWindow.opener = self;
	 }
	 else{
		SearchTopicFeedbackWindow.document.location = newURL;
	}
    SearchTopicFeedbackWindow.focus();
}
function OnDAS(inURL){
	ResetLogoutTimer();
	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!DASWindow || DASWindow.closed){
		DASWindow = window.open(newURL,"DAS","status,resizable,scrollbars,height=550, width=600");
	 	DASWindow.opener = self;
	 }else{
		DASWindow.document.location = newURL;
		DASWindow.focus();
	}
}
function OnPrintCenter(inURL){
	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	var newURL = inURL + "?t=" + strDate;
	if (!PrintCenterWindow || PrintCenterWindow.closed) {
		if (inURL.toLowerCase().indexOf('mytaxactfees.asp') != -1) {
		    PrintCenterWindow = window.open(newURL,"PrintCenter","status,resizable,scrollbars,height=600, width=753");
			PrintCenterWindow.opener = top;
		} else {
		    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){
    if (bInSubmit)
        return;

	ResetLogoutTimer();

	if (ReportWindow && !ReportWindow.closed){
		ReportWindow.close();
	}

	var newURL = inURL + ReportType;
	doDate = new Date();
	strDate = doDate.getTime();
	newURL = newURL  + "&time=" + strDate;
	if (parent.myLightWindow){
	    bInSubmit = true;
	    if ((navigator.userAgent.toLowerCase().indexOf('opera') != -1) && (parent.myLightWindow.isOpen())) {
	        ReportWindow = window.open(newURL,'TaxACTReportWindow','toolbar,resizable,scrollbars,height=500,width=800');
	        ReportWindow.opener = self;
	        ReportWindow.focus();
	    } else {
		    parent.myLightWindow.activateWindow({href:newURL,title:'',width:800,height:500});
		}
	}else{
	    bInSubmit = true;
		ReportWindow = window.open(newURL,'TaxACTReportWindow','toolbar,resizable,scrollbars,height=500,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;
	
	if (parent.myLightWindow){
		parent.myLightWindow.activateWindow({href:newURL,title:'',width:600,height:525});
	}
	else{
	    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 (divObject){
	    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 (divObject){
	    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 updateQuestion() {
  parent.mainbody_frame.document.TAForm.action = "../taxmanager.dll/OnRefresh?time=" + new Date().getTime();
  parent.mainbody_frame.hideSelects();
  parent.mainbody_frame.OnUpdateSplash();
  if (parent.mainbody_frame.allowThrough != undefined) {
    parent.mainbody_frame.allowThrough = true;
  }
  parent.mainbody_frame.document.TAForm.submit();	
}

function openFormWin( inURL, windowName){ 
	if (CheckSessionTimeout () != false)
		return;

	ResetLogoutTimer();

	doDate = new Date();
	strDate = doDate.getTime();
	inURL = inURL  + "time=" + strDate;

	if (parent.myLightWindow){
			var szModule = parent.mainbody_frame.document.TAForm.hidmod.value;
			inURL = inURL + "&hidmod=" + szModule;

		/* gk: With the new min supported version of Opera being 9.5, I don't believe we need code like
		       this anymore.  In anycase, this doesn't work in Opera 10.0 on the Mac, and works properly
		       on the PC
			if ((navigator.userAgent.toLowerCase().indexOf('opera') != -1) && (parent.myLightWindow.isOpen())) {
			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 (-1 != inURL.indexOf("updateQuestion")) {
				parent.myLightWindow.activateWindow({href:inURL, title:'', onclose:'updateQuestion()', width:728, height:600});
			}
			else {
				parent.myLightWindow.activateWindow({href:inURL,title:'',width:728,height:600});
			}
		}
	}
	else 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=780,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 openTaxPayerSupportWin(inURL, windowName){ 
	ResetLogoutTimer();

  var strEdition = "0";
  if (window.opener) {
		if (window.opener.parent.mainbody_frame) {
			if (window.opener.parent.mainbody_frame.document.TAForm) {
			  strEdition = window.opener.parent.mainbody_frame.document.TAForm.hidedition.value;
			}
		}
	} else if (this.parent.mainbody_frame) {
	  if (this.parent.mainbody_frame.document.TAForm) {
	    strEdition = this.parent.mainbody_frame.document.TAForm.hidedition.value;
	  }
  }
  
	var	strParam = "?"
	if (inURL.indexOf("?") >= 0)
		strParam = "&";
		
	if (strEdition == "1") {
		strParam += "ed=1";
	} else if (strEdition == "2") {
		strParam += "ed=2";
	}
	inURL += strParam;
	
	if (TaxPayerSupportWindow && !TaxPayerSupportWindow.closed){
		TaxPayerSupportWindow.close();
	}
	TaxPayerSupportWindow = window.open( inURL, windowName, 'width=780,height=480,toolbar=1,location=1,directories=1,status=1,menuBar=1,scrollBars=1,resizable=1'); 
	TaxPayerSupportWindow.opener = self;
	TaxPayerSupportWindow.focus();
} 

function OnFirstQuestion(szURL){
	ResetLogoutTimer();

	if (CheckSessionTimeout () != false)
		return;

	doDate = new Date();
	strDate = doDate.getTime();
	inURL = szURL + "time="+strDate;
	document.location.href = inURL;
}

function OnNotAvailForPrintLY(){
	window.alert ('This feature is no longer available for ' + cTaxYear + ' tax returns.\r\n\r\nPlease see "Filing->Mail Paper Return" to print and mail a paper return.'); 
}

function payPdfFormView() {
    top.browserNavigationDialog = false;
    if (bInSubmit) { 
		return;
	}
    if (CheckSessionTimeout () != false){return;}
    ResetLogoutTimer();

    if (parent && parent.mainbody_frame && parent.mainbody_frame.document.TAForm) {
        if (parent.mainbody_frame.document.TAForm.hidden_Button.value != "") {
            bInSubmit = true;
            parent.mainbody_frame.allowThrough = true;
            calcSetModified_2();
            parent.mainbody_frame.document.TAForm.action = "../taxmanager.dll/PayPdfFormView?t=" + new Date().getTime();
            parent.mainbody_frame.hideSelects();
            parent.mainbody_frame.OnUpdateSplash();
            parent.mainbody_frame.document.TAForm.submit();	
        }
    }
}

function OnShowInfo(topic){
    var EncodedTopic,TopicURL;
    var nWidth = 676;
    var nHeight = 400;

    if (topic.toUpperCase().indexOf("OPTIONS") > -1){
        nHeight = 513;
    } else if (topic.toUpperCase().indexOf("IMPORT") > -1){
        nHeight = 420;
    } else if (topic.toUpperCase().indexOf("DAS") > -1) {
        nWidth = 679;
        nHeight = 405;
    }
	EncodedTopic = escape(topic);
	EncodedTopic = EncodedTopic.replace ('+', '***AND***');
	doDate = new Date();
	strDate = doDate.getTime();
	var sURL = "../taxmanager.dll/ShowInfo?topic=" + EncodedTopic + "&time=" + strDate;
	if (parent.myLightWindow){
		parent.myLightWindow.activateWindow({href:sURL,title:'',onclose:'onRefresh()',width:nWidth,height:nHeight});
	}
	else
	{
	    eval("window.open(sURL,'Info','toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=0,scrollbars=1,width=" + nWidth + ",height=" + nHeight + "');");
	}
}

function OnShowTour(){
    var v = 1;
    if (IsFreeIRSReturn())
        v = 2;
    
	if (parent.myLightWindow) {
		parent.myLightWindow.activateWindow({href:'../introduction/tour-video.asp?v='+v,title:'',width:641,height:512});
	}else{
		eval("window.open('../introduction/tour-video.asp?v=" + v + "','Tour','toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=0,scrollbars=1,width=661,height=532');");
	}
}

function onRefresh(){
  if (parent.mainbody_frame.document.TAForm){
    if ((parent.mainbody_frame.document.TAForm.hidupgraded.value == '1') && (parent.mainbody_frame.document.TAForm.hidedition.value == '1')){
      var doDate = new Date();
      var strDate = doDate.getTime();
      parent.mainbody_frame.document.TAForm.action = "../taxmanager.dll/OnRefresh?time="+strDate;
      parent.mainbody_frame.hideSelects();
      parent.mainbody_frame.OnUpdateSplash();
      if (parent.mainbody_frame.allowThrough != undefined) {
        parent.mainbody_frame.allowThrough = true;
      }
      parent.mainbody_frame.document.TAForm.submit();	
    }
  }
}

function OnNavClick(inURL, force){
	var closeLightWindow = false;
	if (top.mainbody_frame && top.mainbody_frame.taxInterface) {
		top.mainbody_frame.taxInterface.closeVisualForm();
	}
	top.browserNavigationDialog = false;
	if (force) {
		if (parent.myLightWindow && parent.myLightWindow.isOpen()) {
			closeLightWindow = true;
		}
	}
	else if (bInSubmit)
		return;

	if (CheckSessionTimeout () != false)
		return;

	var sURL = inURL.toUpperCase();
	if (bPrintLY && (sURL.search('IV_USSTEP6_REFUND') != -1 || sURL.search('IV_USF4868_Q1') != -1))
	{
		OnNotAvailForPrintLY();
		return;
	}

	doDate = new Date();
	strDate = doDate.getTime();
	inURL = inURL  + "&time=" + strDate;
	var urlString = inURL.toUpperCase();
	
	var navFrame = null;
	if (parent)
	    navFrame = parent.document.getElementById('navframe');
	if (navFrame && (-1 != navFrame.src.toUpperCase().indexOf("HELP_HEADER.ASP")) && (-1 != urlString.indexOf("JUMPTO"))) {
		// This is the new Help Center...
		if (top.opener.parent.mainbody_frame.document.TAForm){
			bInSubmit = true;
			top.opener.parent.mainbody_frame.allowThrough = true;
			top.opener.parent.mainbody_frame.location = inURL;
		}
	}
    else {
        if (parent && parent.mainbody_frame){
		    bInSubmit = true;
		    parent.mainbody_frame.allowThrough = true;
		    parent.mainbody_frame.location = inURL;
	    } else if (top && top.opener && top.opener.parent && top.opener.parent.mainbody_frame) {
		    bInSubmit = true;
		    top.opener.parent.mainbody_frame.allowThrough = true;
		    top.opener.parent.mainbody_frame.location = inURL;
	    }
	}
	if (closeLightWindow) {
		parent.myLightWindow.deactivate();
	}
}

function calcTabSubNav(inParams){
    top.browserNavigationDialog = false;
    if (bInSubmit) { 
		return;
	}
	ResetLogoutTimer();
	var tmpParams = inParams.toUpperCase();
	if (bPrintLY && (tmpParams.search('IV_USSTEP6_REFUND') != -1 || tmpParams.search('IV_USF4868_Q1') != -1))
	{
		OnNotAvailForPrintLY();
		return;
	}
	if (CheckSessionTimeout () != false){return;}
	if (inParams != "") {
	    if (parent && parent.mainbody_frame && parent.mainbody_frame.document.TAForm) {
            parent.mainbody_frame.allowThrough = true;
            calcSetModified_2();
            parent.mainbody_frame.document.TAForm.hidden_Button.value = "tsnav";
            parent.mainbody_frame.document.TAForm.hidTSN.value = inParams;
            
            if (parent.mainbody_frame.OnSubmitForm(document.TAForm) == true) {
                bInSubmit = true;
                parent.mainbody_frame.hideSelects();
                parent.mainbody_frame.delayedSubmit("");
            } else {
                bInSubmit = false;
            }
        } else if (top && top.opener && top.opener.parent && top.opener.parent.mainbody_frame) {
            top.opener.parent.mainbody_frame.allowThrough = true;
            calcSetModified();
            top.opener.parent.mainbody_frame.document.TAForm.hidden_Button.value = "tsnav";
            top.opener.parent.mainbody_frame.document.TAForm.hidTSN.value = inParams;
            
            if (top.opener.parent.mainbody_frame.OnSubmitForm(document.TAForm) == true) {
                bInSubmit = true;
                top.opener.parent.mainbody_frame.hideSelects();
                top.opener.parent.mainbody_frame.delayedSubmit("");
            } else {
                bInSubmit = false;
            }
        
        }
    }
}

function closeWindow(){
    if (parent.myLightWindow && parent.myLightWindow.isOpen()) {
        parent.myLightWindow.deactivate();
    } else if (top && top.opener && top.opener.parent && top.opener.parent.myLightWindow) {
        top.opener.parent.myLightWindow.deactivate();
        window.close();
    } 
}



//------------------------------------------------------------------
//The following functions are used by the SiteMap window
//------------------------------------------------------------------
function HeaderInstructions(inURL, sType){
	if (CheckSessionTimeout () != false)
		return;

	ResetLogoutTimer();

    if (this.parent.mainbody_frame.document.forms[0] != null && this.parent.mainbody_frame.document.forms[0].name == "TAForm"){
		DoReport(inURL,sType);
	}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 () {
	var operaOnly = window.document.getElementById('OperaOnly')
	if (operaOnly){
		operaOnly.style.display='none';
	}
	window.print();
	if (operaOnly){
		operaOnly.style.display='inline';
	}
}

function printHelpWin () {
	parent.guidanceFrame.focus();
	parent.guidanceFrame.print();
}

//------------------------------------------------------------------
//-- Functions to Set/Reset the background color of current field --
//------------------------------------------------------------------
	function setFieldBGColor (Field) 
	{
		if (ie)
			Field.style.backgroundColor='#E7F3FB'; 
		else if (ns)
			Field.backgroundColor='#E7F3FB';
		else if (ns6)
			Field.style.backgroundColor='#E7F3FB';
	}

	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='#E7F3FB';
		else if (ns)
			Field.backgroundColor='#E7F3FB';
		else if (ns6)
			Field.style.backgroundColor='#E7F3FB';
			
		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 = parent.mainbody_frame.document.getElementById('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 onValidDetails () {
		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, true) != 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 onSubmitDetails (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 (onValidDetails() == 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 (parent.mainbody_frame && parent.mainbody_frame.document.getElementById("TAForm")) {
					if (bDetailsDataExists == true)
						sHidDetailsStatus = setDetailsStatus (nFieldIndex, '2');
					else
						sHidDetailsStatus = setDetailsStatus (nFieldIndex, '1');

					if (eval ('parent.mainbody_frame.document.getElementById("TAForm").' + sFieldName)) {
						//	if FLDTYPE_CURRENCY update value in parent field of Details Window
						if (nFieldType == 1) {
							eval ('parent.mainbody_frame.document.getElementById("TAForm").' + sFieldName + '.value="' + nValue + '"');
						}

						//	Update Details Status
						parent.mainbody_frame.document.getElementById("TAForm").hidDetailsStatus.value = sHidDetailsStatus;

						//	Update Field Modified
						var sModFieldName = 'FFMOD' + sFieldName.substring (sFieldName.indexOf("_"), sFieldName.length);
						calcSetFieldModified_2 (eval ('parent.mainbody_frame.document.getElementById("TAForm").' + sModFieldName));
					}

					document.frmDetails.cmdAction.value = 'Save';
					document.frmDetails.submit();
				}
				else {
					// Opened from a lightwindow as a popup window (visual form)
					if (top.opener &&
					    top.opener.top &&
					    top.opener.top.parent &&
					    top.opener.top.parent.myLightWindow) {
						var fieldId = document.frmDetails.hidCurFieldId.value;
						var field = top.opener.document.getElementById(fieldId);
						if (field && 1 == nFieldType) {
							field.value = nValue;
							top.opener.visualForm.detailsChanged(fieldId, bDetailsDataExists);
							top.opener.visualForm.onCalcFieldChanged(fieldId);
						}
						document.frmDetails.cmdAction.value = 'Save';
						document.frmDetails.submit();
						return;
					}
					else if (!parent.myLightWindow) {
						if (opener.top.mainbody_frame) {
							var fieldId = document.frmDetails.hidCurFieldId.value;
							var field = opener.top.mainbody_frame.document.getElementById(fieldId);
							if (field && 1 == nFieldType) {
								field.value = nValue;
								opener.top.mainbody_frame.visualForm.detailsChanged(fieldId, bDetailsDataExists);
								opener.top.mainbody_frame.visualForm.onCalcFieldChanged(fieldId);
							}
						}
					}
					else if (top.mainbody_frame) {
						var fieldId = document.frmDetails.hidCurFieldId.value;
						var field = top.mainbody_frame.document.getElementById(fieldId);
						if (field && 1 == nFieldType) {
							field.value = nValue;
							top.mainbody_frame.visualForm.detailsChanged(fieldId, bDetailsDataExists);
							top.mainbody_frame.visualForm.onCalcFieldChanged(fieldId);
						}
					}
					document.frmDetails.cmdAction.value = 'Save';
					document.frmDetails.submit();
					bCloseWindow = true;
				}
			}
		}
		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) {
			// Opened from a lightwindow as a popup window (visual form)
			if (top.opener &&
			    top.opener.top &&
			    top.opener.top.parent &&
			    top.opener.top.parent.myLightWindow) {
				close();
			}
			else if (parent.mainbody_frame && parent.mainbody_frame.document.getElementById("TAForm")) {
				if (parent.myLightWindow) {
					parent.myLightWindow.deactivate();
				}
				else {
					close();
				}
				if (parent.mainbody_frame && parent.mainbody_frame.document.TAForm) {
					if (eval ('parent.mainbody_frame.document.TAForm.' + sFieldName + '.value'))
						eval ('parent.mainbody_frame.document.TAForm.' + sFieldName + '.focus()');
				}
			}
			else if (top.myLightWindow) {
				top.myLightWindow.deactivate();
			}
		}
	}

	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 (" ", "");
			while (strValue.search(",") != -1) {
				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() {
		try {
			if (window.document.frmDetails.cmdAction.value == 'CloseNoSave' || (parent.mainbody_frame && parent.mainbody_frame.document.getElementById("TAForm").hidDetailsStatus.value == 'XXX') || !parent.myLightWindow.isOpen())
				var bResult = true;
			else
				var bResult = false;
			return (bResult);
		}
		catch(e) {
			return false;
		}
	}
	
	function onUnloadDetailsWin () {
    // Opened from a lightwindow as a popup window (visual form)
    if (top.opener &&
      top.opener.top &&
      top.opener.top.parent &&
      top.opener.top.parent.myLightWindow) {
      close();
    }
		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 () {
	    var doDate = new Date();
		var strDate = doDate.getTime();
		var sURL = '';

        if (parent.mainbody_frame.document.TAForm.hidedition.value != '2') {
		    sURL = '../taxmanager.dll/JumpTo?nav_script=IV_USMARKETING_DLXFORMS';
		}
		else {
			sURL = '../taxmanager.dll/JumpTo?nav_script=IV_USF1040X_Q1&time=' + strDate;
		}

        parent.mainbody_frame.location.href = sURL;
	}
	
function CheckAgreement(){
	if(document.getElementById('license').checked){
		return true;
	}else{
		eval ("document.getElementById('license_wrap').style.backgroundImage = 'url(../"+ cImagesDir +"alert-license.gif)';");
		return false;
	}
}

function testCFO(svr) {
	var doDate = new Date();
	var strDate = doDate.getTime();
	document.location.href = '../admin/TestJSResults.asp?t='+strDate+'&s='+svr+'&m=3';
}
// *****NOTE: Keep testCFO as last function - add new functions above testCFO
