function autoSelectInquiry()
{
	showDiv(0);
	var iType
	iType=document.location.search;
	iType=iType.substring(7,iType.length)
	if ((iType>0)&&(iType<(document.forms['EmailForm'].InquiryTypeDropDown.length)))
	{
		document.forms['EmailForm'].InquiryTypeDropDown.options[iType].selected=true;
		for (var i=0; i < document.forms['EmailForm'].InquiryTypeDropDown.length;i++)
		{
			if((document.forms['EmailForm'].InquiryTypeDropDown.options[i].value)==iType)
			{
				document.forms['EmailForm'].InquiryTypeDropDown.options[iType].selected=true;
				showDiv(iType);
			}
		}
	}
	document.EmailForm.InquiryTypeDropDown.selectedIndex=0;
}

function resetStyle(fldName)
{
	fldName = "lbl" + fldName;
	document.getElementById(fldName).style.color = "black";
	document.getElementById(fldName).style.fontWeight = "normal";	
}

function resetStyles()
{
	//Reset Styles
	resetStyle("FirstName");
	resetStyle("LastName");
	resetStyle("EmailAddress");
	resetStyle("PhoneNumber");
	resetStyle("AccountNumber")
	resetStyle("InquiryOther");
	resetStyle("InvoiceNumber");
	resetStyle("InquiryDescription");
	resetStyle("ProductLine");
	resetStyle("Product");
	resetStyle("Version");
	resetStyle("WorkAreaName");
	resetStyle("EntityName");
	resetStyle("BinderTaxYear");
	resetStyle("TrustNumber");
	resetStyle("TrustTaxYear");
	resetStyle("ElectronicFiling");
	resetStyle("DescriptionOfRequest");
	resetStyle("Attachment")
}

function requireField(fldName)
{
	fldName = "lbl" + fldName;
	document.getElementById(fldName).style.color = "red";
	document.getElementById(fldName).style.fontWeight = "bold";
	flag = false;
}

function displayAttachmentInput()
{
	document.getElementById("dependent-upload-link").style.display = 'none';
	document.getElementById("dependent-upload").style.display = 'block';
}

function showDiv(optionValue)
{
	resetStyles();

	// first hide all dependent divs
	document.getElementById("dependent-inquiry-other").style.display = 'none';
	document.getElementById("dependent-inquiry-other").style.display = 'none';
	document.getElementById("Inquiry-Details-Fieldset").style.display = 'none';
	document.getElementById("dependent-inquiry-description").style.display = 'none';
	document.getElementById("dependent-invoice-number").style.display = 'none';
	document.getElementById("dependent-product-line").style.display = 'none';
	document.getElementById("dependent-product").style.display = 'none';
	document.getElementById("dependent-version").style.display = 'none';
	document.getElementById("dependent-work-area-name").style.display = 'none';
	document.getElementById("dependent-entity-name").style.display = 'none';
	document.getElementById("dependent-binder-number").style.display = 'none';
	document.getElementById("dependent-binder-tax-year").style.display = 'none';
	document.getElementById("dependent-binder-tax-year-required").style.visibility="hidden";
	document.getElementById("dependent-trust-number").style.display = 'none';
	document.getElementById("dependent-trust-tax-year").style.display = 'none';
	document.getElementById("dependent-electronic-filing").style.display = 'none';
	document.getElementById("dependent-upload-help").style.display = 'none';
	document.getElementById("dependent-upload-link").style.display = 'none';
	document.getElementById("dependent-upload").style.display = 'none';

	document.getElementById("Contact-Method-Fieldset").style.display = 'none';
	document.getElementById("dependent-response-optional").style.display = 'none';
	document.getElementById("Submit-Buttons").style.display = 'none';
	document.EmailForm.ProductLineDropDown.selectedIndex=0;
	document.EmailForm.ProductDropDown.selectedIndex=0;
	
	switch (optionValue)
	{
		//Account Management
		case "1":
			window.document.EmailForm.FormType.value="1";

			document.getElementById("Inquiry-Details-Fieldset").style.display = 'block';
			document.getElementById("dependent-inquiry-description").style.display = 'block';
			document.getElementById("dependent-invoice-number").style.display = 'block';
			document.getElementById("dependent-upload-link").style.display = 'block';

			document.getElementById("Contact-Method-Fieldset").style.display = 'block';

			document.getElementById("Submit-Buttons").style.display = 'block';
			break;

		//Product Support
		case "2":
			window.document.EmailForm.FormType.value="2";

			AddAllProductLines();
			
			document.getElementById("Inquiry-Details-Fieldset").style.display = 'block';
			document.getElementById("dependent-product-line").style.display = 'block';
			document.getElementById("dependent-upload-help").style.display = 'block';
			document.getElementById("dependent-upload-link").style.display = 'block';

			document.getElementById("Contact-Method-Fieldset").style.display = 'block';

			document.getElementById("Submit-Buttons").style.display = 'block';
			break;

		//Systems Support
		case "3":
			window.document.EmailForm.FormType.value="3";

			AddSystemProductLines();
			
			document.getElementById("Inquiry-Details-Fieldset").style.display = 'block';
			document.getElementById("dependent-product-line").style.display = 'block';
			document.getElementById("dependent-upload-help").style.display = 'block';
			document.getElementById("dependent-upload-link").style.display = 'block';

			document.getElementById("Contact-Method-Fieldset").style.display = 'block';

			document.getElementById("Submit-Buttons").style.display = 'block';
			break;

		//Gadget Support
		case "5":
			window.document.EmailForm.FormType.value="5";
			
			document.getElementById("Inquiry-Details-Fieldset").style.display = 'block';
			document.getElementById("dependent-upload-link").style.display = 'block';

			document.getElementById("Contact-Method-Fieldset").style.display = 'block';

			document.getElementById("Submit-Buttons").style.display = 'block';
			break;

		//Other
		case "4":
			window.document.EmailForm.FormType.value="4";
			
			document.getElementById("dependent-inquiry-other").style.display = 'block';

			document.getElementById("Inquiry-Details-Fieldset").style.display = 'block';
			document.getElementById("dependent-upload-link").style.display = 'block';

			document.getElementById("Contact-Method-Fieldset").style.display = 'block';

			document.getElementById("Submit-Buttons").style.display = 'block';
			break;
	} //switch
	
	if (document.getElementById("dependent-product-line").style.display == 'block')
	{
		var prodlinebox = document.EmailForm.ProductLineDropDown;
		var prodlinetext = document.EmailForm.ProductLineTextBox.value;
		
		for(index = 0; index < prodlinebox.length; index++) {
		if(prodlinebox[index].value == prodlinetext)
			prodlinebox.selectedIndex = index;
		}
		changeProductLine(EmailForm.FormType.value);
	}
} //showDiv

function AddDomesticVersion()
{
	var selbox = document.EmailForm.VersionDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Version -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE RS','ONESOURCE RS');
	selbox.options[selbox.options.length] = new Option('ONESOURCE CS','ONESOURCE CS');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Express RS','ONESOURCE Express RS');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Express CD','ONESOURCE Express CD');
}

function AddInternationalVersion()
{
	var selbox = document.EmailForm.VersionDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Version -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE RS','ONESOURCE RS');
	selbox.options[selbox.options.length] = new Option('ONESOURCE CS','ONESOURCE CS');
}

function AddTrustEstateProducts()
{
	var selbox = document.EmailForm.ProductDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Product -','00');

	selbox.options[selbox.options.length] = new Option('1041 & Related State Fiduciary Returns','1041 & Related State Fiduciary Returns');
	selbox.options[selbox.options.length] = new Option('706 & Related State Death & Insurance Tax Returns','706 & Related State Death & Insurance Tax Returns');
	selbox.options[selbox.options.length] = new Option('709','709');
	selbox.options[selbox.options.length] = new Option('FAS','FAS');
	selbox.options[selbox.options.length] = new Option('ZCALC','ZCALC');
}

function AddIncomeTaxProducts()
{
	var selbox = document.EmailForm.ProductDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Product -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE Domestic','ONESOURCE Domestic');
	selbox.options[selbox.options.length] = new Option('ONESOURCE International','ONESOURCE International');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Exchange','ONESOURCE Exchange');
	selbox.options[selbox.options.length] = new Option('ONESOURCE 1099','ONESOURCE 1099');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Fixed Assets/Corporate Tax Analyzer','ONESOURCE Fixed Assets/Corporate Tax Analyzer');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Transfer Pricing','ONESOURCE Transfer Pricing');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Tax Calendar (formerly ITC)','ONESOURCE Tax Calendar (formerly ITC)');
	selbox.options[selbox.options.length] = new Option('ONESOURCE State Analytics/State Apportionment','ONESOURCE State Analytics/State Apportionment');
	selbox.options[selbox.options.length] = new Option('Other','Other');
}

function AddPlatformProducts()
{
	var selbox = document.EmailForm.ProductDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Product -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE Workstation','ONESOURCE Workstation');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Workflow Manager','ONESOURCE Workflow Manager');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Tax Calendar','ONESOURCE Tax Calander');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Entity Manager','ONESOURCE Entity Manager');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Data Flow','ONESOURCE Data Flow');
}

function AddProvisionsProducts()
{
	var selbox = document.EmailForm.ProductDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Product -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE Provision Application (formerly InSource Provisions)','ONESOURCE Provision Application (formerly InSource Provisions)');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Tax Stream Provision','ONESOURCE Tax Stream Provision');
	selbox.options[selbox.options.length] = new Option('ONESOURCE FIN48','ONESOURCE FIN48');
	selbox.options[selbox.options.length] = new Option('ONESOURCE FasTrac 109','ONESOURCE FasTrac 109');
}

function AddPropertyTaxProducts()
{
	var selbox = document.EmailForm.ProductDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Product -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE Property Tax Software','ONESOURCE Property Tax Software');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Compliance Services','ONESOURCE Compliance Services');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Consulting for Real Estate and Complex Properties','ONESOURCE Consulting for Real Estate and Complex Properties');
}

function AddSalesTaxProducts()
{
	var selbox = document.EmailForm.ProductDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Product -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE Sales & Use Tax Software','ONESOURCE Sales & Use Tax Software');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Sales & Use Tax Outsourcing Services','ONESOURCE Sales & Use Tax Outsourcing Services');
}

function AddOneSourceProducts()
{
	var selbox = document.EmailForm.ProductDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Product -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE Domestic','ONESOURCE Domestic');
	selbox.options[selbox.options.length] = new Option('ONESOURCE International','ONESOURCE International');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Exchange','ONESOURCE Exchange');
	selbox.options[selbox.options.length] = new Option('ONESOURCE 1099','ONESOURCE 1099');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Fixed Assets/Corporate Tax Analyzer','ONESOURCE Fixed Assets/Corporate Tax Analyzer');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Transfer Pricing','ONESOURCE Transfer Pricing');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Tax Calendar (Formerly ITC)','ONESOURCE Tax Calendar (Formerly ITC)');
	selbox.options[selbox.options.length] = new Option('ONESOURCE State Analytics/State Appointment','ONESOURCE State Analytics/State Appointment');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Workstation','ONESOURCE Workstation');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Workflow Manager','ONESOURCE Workflow Manager');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Tax Calendar','ONESOURCE Tax Calendar');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Entity Manager','ONESOURCE Entity Manager');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Data Flow','ONESOURCE Data Flow');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Sales & Use Tax Software','ONESOURCE Sales & Use Tax Software');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Property Tax Software','ONESOURCE Property Tax Software');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Tax Stream Provision','ONESOURCE Tax Stream Provision');
	selbox.options[selbox.options.length] = new Option('ONESOURCE FIN48','ONESOURCE FIN48');
	selbox.options[selbox.options.length] = new Option('ONESOURCE FasTrac 109','ONESOURCE FasTrac 109');
}

function AddTrustTaxProducts()
{
	var selbox = document.EmailForm.ProductDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select Product -','00');

	selbox.options[selbox.options.length] = new Option('ONESOURCE Trust Tax','ONESOURCE Trust Tax');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Trust & Estate Administration','ONESOURCE Trust & Estate Administration');
}

function AddAllProductLines()
{
	var selbox = document.EmailForm.ProductLineDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select One -','');

	selbox.options[selbox.options.length] = new Option('ONESOURCE 1099','ONESOURCE 1099');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Trust & Estate Administration','ONESOURCE Trust & Estate Administration');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Income Tax','ONESOURCE Income Tax');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Workstation','ONESOURCE Workstation');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Provisions','ONESOURCE Provisions');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Trust Tax','ONESOURCE Trust Tax');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Property Tax','ONESOURCE Property Tax');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Sales & Use Tax','ONESOURCE Sales & Use Tax');
	selbox.options[selbox.options.length] = new Option('Other','Other');
}

function AddSystemProductLines()
{
	var selbox = document.EmailForm.ProductLineDropDown;
	selbox.length=1;
	selbox.options[0] = new Option('- Select One -','');

	selbox.options[selbox.options.length] = new Option('ONESOURCE','ONESOURCE');
	selbox.options[selbox.options.length] = new Option('ONESOURCE Trust Tax','ONESOURCE Trust Tax');
}

function changeProductLine(FormType)
{
	switch (document.EmailForm.ProductLineDropDown.value)
	{
		case "ONESOURCE Trust & Estate Administration":
			document.getElementById("dependent-product").style.display = 'block';
			AddTrustEstateProducts();
			break;
		case "ONESOURCE Income Tax":
			document.getElementById("dependent-product").style.display = 'block';
			AddIncomeTaxProducts();
			break;
		case "ONESOURCE Workstation":
			document.getElementById("dependent-product").style.display = 'block';
			AddPlatformProducts();
			break;
		case "ONESOURCE Provisions":
			document.getElementById("dependent-product").style.display = 'block';
			AddProvisionsProducts();
			break;
		case "ONESOURCE Property Tax":
			document.getElementById("dependent-product").style.display = 'block';
			AddPropertyTaxProducts();
			break;
		case "ONESOURCE Sales & Use Tax":
			document.getElementById("dependent-product").style.display = 'block';
			AddSalesTaxProducts();
			break;
		case "ONESOURCE Trust Tax":
			document.getElementById("dependent-product").style.display = 'block';
			AddTrustTaxProducts();
			break;
		case "ONESOURCE":
			document.getElementById("dependent-product").style.display = 'block';
			AddOneSourceProducts();
			break;
		default:
			document.getElementById("dependent-product").style.display = 'block';
			document.getElementById("dependent-product").style.display = 'none';
			break;
	}

	switch (document.EmailForm.ProductLineDropDown.value)
	{
		case "ONESOURCE Income Tax":
		case "ONESOURCE":
			document.getElementById("dependent-binder-number").style.display = 'block';
			document.getElementById("dependent-binder-tax-year").style.display = 'block';
			break;
		default:
			document.getElementById("dependent-binder-number").style.display = 'none';
			document.getElementById("dependent-binder-tax-year").style.display = 'none';
			document.getElementById("dependent-electronic-filing").style.display = 'none';
			break;
	}

	if (FormType=="2")
	{
		switch (document.EmailForm.ProductLineDropDown.value)
		{
			case "ONESOURCE Trust Tax":
				document.getElementById("dependent-trust-number").style.display = 'block';
				document.getElementById("dependent-trust-tax-year").style.display = 'block';
				break;
			default:
				document.getElementById("dependent-trust-number").style.display = 'none';
				document.getElementById("dependent-trust-tax-year").style.display = 'none';
				break;
		}
	}
	else
	{
		document.getElementById("dependent-trust-number").style.display = 'none';
		document.getElementById("dependent-trust-tax-year").style.display = 'none';
	}
}

function changeProduct(Product)
{
	switch (Product)
	{
		case "ONESOURCE Domestic":
			document.getElementById("dependent-version").style.display = 'block';
			document.getElementById("dependent-work-area-name").style.display = 'block';
			document.getElementById("dependent-entity-name").style.display = 'block';
			document.getElementById("dependent-electronic-filing").style.display = 'block';
			AddDomesticVersion();
			break;
        case "ONESOURCE International":
			document.getElementById("dependent-version").style.display = 'block';
			document.getElementById("dependent-work-area-name").style.display = 'block';
			document.getElementById("dependent-entity-name").style.display = 'block';
			document.getElementById("dependent-electronic-filing").style.display = 'block';
			AddInternationalVersion();
			break;
		case "Other":
			document.getElementById("dependent-version").style.display = 'none';
			document.getElementById("dependent-work-area-name").style.display = 'none';
			document.getElementById("dependent-entity-name").style.display = 'none';
			document.getElementById("dependent-electronic-filing").style.display = 'block';
			break;
		default:
			document.getElementById("dependent-version").style.display = 'none';
			document.getElementById("dependent-work-area-name").style.display = 'none';
			document.getElementById("dependent-entity-name").style.display = 'none';
			document.getElementById("dependent-electronic-filing").style.display = 'none';
			break;
	}
}

function changeBinderNumber(FormType)
{
	if (document.EmailForm.BinderNumberTextBox.value!="")
	{
		document.getElementById("dependent-binder-tax-year-required").style.visibility="visible";
	}
	else
	{
		document.getElementById("dependent-binder-tax-year-required").style.visibility="hidden";
	}
}

function SubmitForm()
{
	strFormType = document.EmailForm.FormType.value;

	strErr = ""; //clear error label
	flag = true; //unset flag

	resetStyles();
	
	validateForm();
	
	if (flag)
	{
		document.EmailForm.action="SendEmail.asp";
		document.EmailForm.submit();
	}
	else
	{
		alert(strErr);
	}
}

function validateForm()
{
	validRequired("FirstName");
	validRequired("LastName");
	validRequired("EmailAddress");
	validRequired("PhoneNumber");
	validRequired("AccountNumber");
	validRequired("DescriptionOfRequest");

	if(strFormType=="1")
	{
		validRequired("InquiryDescription");
		validRequired("InvoiceNumber");
	}

	if(strFormType=="2" || strFormType=="3")
	{
		validRequired("ProductLine");
		switch (document.EmailForm.ProductLineDropDown.value)
		{
			case "ONESOURCE Trust & Estate Administration":
			case "ONESOURCE Income Tax":
			case "ONESOURCE Workstation":
			case "ONESOURCE Provisions":
			case "ONESOURCE Property Tax":
			case "ONESOURCE Sales & Use Tax":
			case "ONESOURCE Trust Tax":
			case "ONESOURCE":
				validRequired("Product");
				break;
			default:
				break;
		}

		if (strFormType=="2")
		{
			switch (document.EmailForm.ProductLineDropDown.value)
			{
				case "ONESOURCE Trust Tax":
					validRequired("TrustNumber");
					validRequired("TrustTaxYear");
					break;
				default:
					break;
			}
		}

		switch (document.EmailForm.ProductLineDropDown.value)
		{
			case "ONESOURCE Income Tax":
			case "ONESOURCE":
				validRequired("BinderTaxYear");
				switch (document.EmailForm.ProductDropDown.value)
				{
					case "ONESOURCE Domestic":
						validRequired("Version");
						validRequired("WorkAreaName");
						validRequired("EntityName");
						validRequired("ElectronicFiling");
						break;
					case "ONESOURCE International":
						validRequired("Version");
						validRequired("WorkAreaName");
						validRequired("EntityName");
						validRequired("ElectronicFiling");
						break;
					case "Other":
						validRequired("ElectronicFiling");
						break;
				}
				break;
			default:
				break;
		}
	}
	
	if(strFormType=="4")
	{
		validRequired("InquiryOther");
	}

	if(!flag){strErr = strErr + "Please complete all required fields (shown in bold red)";}
}

function validRequired(fldName)
{
	// First Name Validation
	if((fldName=="FirstName") && (document.EmailForm.FirstNameTextBox.value==""))
	{
		requireField(fldName);
	}

	// Last Name Validation
	if((fldName=="LastName") && (document.EmailForm.LastNameTextBox.value==""))
	{
		requireField(fldName);
	}

	// Email Validation
	if((fldName=="EmailAddress") && (document.EmailForm.EmailAddressTextBox.value==""))
	{
		requireField(fldName);
	}
	if((fldName=="EmailAddress") && (document.EmailForm.EmailAddressTextBox.value!=""))
	{
		str=document.EmailForm.EmailAddressTextBox.value;
		if (str.indexOf("@") == -1){
			requireField(fldName);
			alert("Please enter a valid email address.");
		}
		if (str.indexOf(".") == -1)
		{
			requireField(fldName);
			alert("Please enter a valid email address.");
		}
		else
		{
			var atPos = str.indexOf("@")
			if (str.indexOf(".",atPos) == -1)
			{
				requireField(fldName);
				alert("Please enter a valid email address.");
			}
		}
	}

	// Phone Validation
	if(fldName=="PhoneNumber"){
		if (document.EmailForm.PhoneNumberTextBox.value=="")
		{
			requireField(fldName);
		}
		else
		{
			if (document.EmailForm.PhoneNumberTextBox.value!="")
			{
				if (document.EmailForm.PhoneNumberTextBox.value.length < 10) 
				{ 
					requireField(fldName);
					alert('Phone numbers should include at least 10 digits.')
				}
				else
				{	
					x=0
					for (j=0; j<document.EmailForm.PhoneNumberTextBox.value.length; j++) 
					{
						x=x+1 
						if ((document.EmailForm.PhoneNumberTextBox.value.charAt(j) < "0") || (document.EmailForm.PhoneNumberTextBox.value.charAt(j) > "9")) 
						{ 
							x=x-1
						}
					}
					if (x<10)
					{
						requireField(fldName);
						alert('Phone numbers should include at least 10 digits.')
					}
			 	}
			}
		}
	}

	// Account Number Validation
	if((fldName=="AccountNumber") && (document.EmailForm.AccountNumberTextBox.value==""))
	{
		requireField(fldName);
	}
	if((fldName=="AccountNumber") && (document.EmailForm.AccountNumberTextBox.value!=""))
	{
		if (document.EmailForm.AccountNumberTextBox.value!="")
		{
			var acctNumRegEx = new RegExp("^[A-Za-z0-9]{1,20}$");
			if (!acctNumRegEx.test(document.EmailForm.AccountNumberTextBox.value))
			{ 
				requireField(fldName);
				alert('Please review your account number for accuracy and resubmit.')
			}
		}
	}

	// Inquiry Other Validation
	if((fldName=="InquiryOther") && (document.EmailForm.InquiryOtherTextBox.value==""))
	{
		requireField(fldName);
	}

	// Inquiry Description
	if(fldName=="InquiryDescription")
	{
		selectedButton = -1;
		for (i=document.EmailForm.InquiryDescRadio.length-1; i > -1; i--)
		{
			if (document.EmailForm.InquiryDescRadio[i].checked)
			{
				selectedButton = i; i = -1;
			}
		}
		if (selectedButton == -1)
		{
			requireField(fldName);
		}
	}

	// Invoice Number Validation
	if((fldName=="InvoiceNumber") && (document.EmailForm.InvoiceNumberTextBox.value!=""))
	{
		if (document.EmailForm.InvoiceNumberTextBox.value!="")
		{
			var acctNumRegEx = new RegExp("^[A-Za-z0-9]{7,14}$");
			if (!acctNumRegEx.test(document.EmailForm.InvoiceNumberTextBox.value))
			{ 
				requireField(fldName);
				alert('Please review your invoice number for accuracy and resubmit.')
			}
		}
	}

	// Product Line Validation
	if (fldName=="ProductLine")
	{
		if (document.EmailForm.ProductLineDropDown.selectedIndex==0)
		{
			requireField(fldName);
		}
	}

	// Product Validation
	if (fldName=="Product")
	{
		if (document.EmailForm.ProductDropDown.selectedIndex==0)
		{
			requireField(fldName);
		}
	}

	// Version Validation
	if (fldName=="Version")
	{
		if (document.EmailForm.VersionDropDown.selectedIndex==0)
		{
			requireField(fldName);
		}
	}

	// Work Area Name Validation
	if(fldName=="WorkAreaName")
	{
		if(document.EmailForm.WorkAreaNameTextBox.value=="")
		{
			requireField(fldName);
		}
	}

	// Entity Name Validation
	if(fldName=="EntityName")
	{
		if(document.EmailForm.EntityNameTextBox.value=="")
		{
			requireField(fldName);
		}
	}

	// Binder Tax Year Validation
	if((fldName=="BinderTaxYear") && (document.EmailForm.BinderNumberTextBox.value!=""))
	{
		if (document.EmailForm.BinderTaxYearTextBox.value=="")
		{
			requireField(fldName);
			alert('Please provide a Tax Year and resubmit.')
		}
		else
		{
			var binTaxYearRegEx = new RegExp("^[0-9]{4}$");
			if (!binTaxYearRegEx.test(document.EmailForm.BinderTaxYearTextBox.value))
			{ 
				requireField(fldName);
				alert('Please provide a 4 digit tax year and resubmit.')
			}
		}
	}

	// Trust Number Validation
	if(fldName=="TrustNumber")
	{
		if(document.EmailForm.TrustNumberTextBox.value=="")
		{
			requireField(fldName);
		}
	}

	if((fldName=="TrustNumber") && (document.EmailForm.TrustNumberTextBox.value!=""))
	{
		if (document.EmailForm.TrustNumberTextBox.value!="")
		{
			var acctNumRegEx = new RegExp("^[A-Za-z0-9]{1,20}$");
			if (!acctNumRegEx.test(document.EmailForm.TrustNumberTextBox.value))
			{ 
				requireField(fldName);
				alert('Please review your trust number for accuracy and resubmit.')
			}
		}
	}

	// Trust Tax Year Validation
	if(fldName=="TrustTaxYear")
	{
		if(document.EmailForm.TrustTaxYearTextBox.value=="")
		{
			requireField(fldName);
		}
	}

	if((fldName=="TrustTaxYear") && (document.EmailForm.TrustNumberTextBox.value!=""))
	{
		if (document.EmailForm.TrustTaxYearTextBox.value=="")
		{
			requireField(fldName);
			alert('Please provide a Tax Year and resubmit.')
		}
		else
		{
			var truTaxYearRegEx = new RegExp("^[0-9]{4}$");
			if (!truTaxYearRegEx.test(document.EmailForm.TrustTaxYearTextBox.value))
			{ 
				requireField(fldName);
				alert('Please provide a 4 digit tax year and resubmit.')
			}
		}
	}

	// Who is impacted?
	if(fldName=="ElectronicFiling")
	{
		switch (document.EmailForm.ProductLineDropDown.value)
		{
			case "ONESOURCE Income Tax":
			case "ONESOURCE":
				selectedButton = -1;
				for (i=document.EmailForm.ElectronicFilingRadio.length-1; i > -1; i--)
				{
					if (document.EmailForm.ElectronicFilingRadio[i].checked)
					{
						selectedButton = i; i = -1;
					}
				}
				if (selectedButton == -1)
				{
						requireField(fldName);
						alert('Please indicate whether or not this is an electronic filing question and resubmit.')
				}
				break;
			default:
				break;
		}
	}

	// How would you like us to respond
	if(fldName==8)
	{
		selectedButton = -1;
		for (i=document.EmailForm.ResponseRadio.length-1; i > -1; i--)
		{
			if (document.EmailForm.ResponseRadio[i].checked)
			{
				selectedButton = i; i = -1;
			}
		}
		if (selectedButton == -1)
		{
			requireField(fldName);
		}
	}
	
	// Requests/Comments
	if((fldName=="DescriptionOfRequest") && (document.EmailForm.DescrptionOfRequestTextArea.value==""))
	{
		requireField(fldName);
	}

	if((fldName=="Attachment") && (document.EmailForm.FilAttach.value!=""))
	{
		var ext = document.EmailForm.FilAttach.value;
		ext = ext.substring(ext.length-3,ext.length);
		ext = ext.toLowerCase();
		if ((ext == 'exe')||(ext=='.js')||(ext=='.vb')||(ext=='asp')||(ext=='dll')||(ext=='scr')||(ext=='bat')||(ext=='reg')||(ext=='cab')||(ext=='mp3'))
		{
			alert('You selected a .'+ext+
			' file; Please select a text-based file.');
			flag = false;;
		}
	}
}
