// JavaScript Document

function validateLogin() 
{ 
	if(document.theForm.Username.value == '')
	{
		alert('Username is required.');
		return false;
	}	
	if(document.theForm.Password.value == '')
	{
		alert('Password is required.');
		return false;
	}	
	return true;
}


function isblank(s)
{
	for(var i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if ((c != " ") && (c != '\n') && (c != '\t')) return false;
	}
	return true;	
}


function validateSelections() 
{ 
	var valid = true;
	alert(''); 
	return valid;
}


function validateContactInfo() 
{ 
	var valid = true;
	if(document.theForm.State.value.length > 2)
	{
		alert('State is invalid. Please use the two letter postal code.');
		valid = false;
	}	
	return valid;
}


function validateFCApp() 
{ 
	var missing = '' ;
	if( (document.theForm.First_Name.value == '') || isblank(document.theForm.First_Name.value))
	{
		missing+= 'Your First Name.\r\n' ;
	}	
	if( (document.theForm.Last_Name.value == '') || isblank(document.theForm.Last_Name.value))
	{
		missing+= 'Your Last Name.\r\n';
	}	
	if( (document.theForm.Email1.value == '') || isblank(document.theForm.Email1.value))
	{
		missing+= 'Your Primary Email Address.\r\n' ;
	}	
	if( (document.theForm.Street_Address_1.value == '') || isblank(document.theForm.Street_Address_1.value))
	{
		missing+= 'Your Home Street Address.\r\n' ;
	}	
	if( (document.theForm.City.value == '') || isblank(document.theForm.City.value))
	{
		missing+= 'Your City.\r\n' ;
	}	
	if(document.theForm.State.value.length != 2)
	{
		missing+= 'Your State.\r\n' ;
	}	
	if( (document.theForm.Zip.value == '') || isblank(document.theForm.Zip.value))
	{
		missing+= 'Your Zip/Postal Code.\r\n' ;
	}	
	if( (document.theForm.Country.value == '') || isblank(document.theForm.Country.value))
	{
		missing+= 'Your Country.\r\n' ;
	}		
	if( (document.theForm.Phone.value == '') || isblank(document.theForm.Phone.value))
	{
		missing+= 'Your Phone Number.\r\n' ;
	}	
//	if( (document.theForm.Biz_started.value == '') || isblank(document.theForm.Biz_started.value))
//	{
//		missing+= 'The Year your business started.\r\n' ;
//	}	
	if( (document.theForm.Company_Name.value == '') || isblank(document.theForm.Company_Name.value))
	{
		missing+= 'Your Business Name.\r\n' ;
	}	
	if(document.theForm.Legal_entity[0].checked == false && document.theForm.Legal_entity[1].checked == false && document.theForm.Legal_entity[2].checked == false && document.theForm.Legal_entity[3].checked == false )
	{
		missing+= 'Your Business Type.\r\n' ;
	}		
	if( (document.theForm.Biz_product_servs.value == '') || isblank(document.theForm.Biz_product_servs.value))
	{
		missing+= 'The Services/Products your business offers.\r\n' ;
	}	
	if( (document.theForm.Biz_sales_last_fiscal_year.value == '') || isblank(document.theForm.Biz_sales_last_fiscal_year.value))
	{
		missing+= 'Total Sales for Last Fiscal Year.\r\n' ;
	}	
	if( (document.theForm.Est_Monthly_Revenue.value == '') || isblank(document.theForm.Est_Monthly_Revenue.value))
	{
		missing+= 'Current Monthly Sales Volume.\r\n' ;
	}	
	if( (document.theForm.Biz_ytd_sls_vl.value == '') || isblank(document.theForm.Biz_ytd_sls_vl.value))
	{
		missing+= 'Year-to-Date Sales Volume.\r\n' ;
	}	
	if( (document.theForm.Biz_avg_inv_amt.value == '') || isblank(document.theForm.Biz_avg_inv_amt.value))
	{
		missing+= 'Your Average Invoice Dollar Amount.\r\n' ;
	}	
	if( (document.theForm.Est_Invoices_per_mo.value == '') || isblank(document.theForm.Est_Invoices_per_mo.value))
	{
		missing+= 'Average number of invoices planned.\r\n' ;
	}	
	if(document.theForm.third_party[0].checked == false && document.theForm.third_party[1].checked == false )
	{
		missing+= 'How you contract the company you invoice.\r\n' ;
	}		
	if( (document.theForm.Billing_time.value == '') || isblank(document.theForm.Billing_time.value))
	{
		missing+= 'When you bill for your work.\r\n' ;
	}	


	if( (document.theForm.is_company1.value == '') || isblank(document.theForm.is_company1.value))
	{
		missing+= 'The Client Name in Section 4.\r\n' ;
	}	
	if( (document.theForm.is_frequency1.value == '') || isblank(document.theForm.is_frequency1.value))
	{
		missing+= 'How often the Client is invoiced in Section 4.\r\n' ;
	}	
	if( (document.theForm.is_amount1.value == '') || isblank(document.theForm.is_amount1.value))
	{
		missing+= 'The Average Invoice Amount in Section 4.\r\n' ;
	}	
	if( (document.theForm.is_terms1.value == '') || isblank(document.theForm.is_terms1.value))
	{
		missing+= 'The Invoice Payment Terms in Section 4.\r\n' ;
	}	
//	if(document.theForm.credit_release.checked == false)
//	{
//		missing+= 'Please click the checkbox authorizing Aquent to review your credit.\r\n' ;
//	}

	if (missing == '' )
	{		
		return true;
	}
	else
	{
		missing = 'The following required fields are missing:\r\n\r\n' + missing ;
		alert (missing);
		return false;
	}

}


function validateNewClient() 
{ 
	var missing = '' ;
	if( (document.theForm.Client_Name.value == '') || isblank(document.theForm.Client_Name.value))
	{
		missing+= 'Client Name.\r\n' ;
	}	
	if( (document.theForm.Client_Address.value == '') || isblank(document.theForm.Client_Address.value))
	{
		missing+= 'Client Street Address.\r\n' ;
	}	
	if( (document.theForm.Client_City.value == '') || isblank(document.theForm.Client_City.value))
	{
		missing+= 'Client City.\r\n' ;
	}	
	if(document.theForm.Client_State.value.length != 2)
	{
		missing+= 'Client State.\r\n' ;
	}	
	if( (document.theForm.Client_Zip.value == '') || isblank(document.theForm.Client_Zip.value))
	{
		missing+= 'Client Zip Code.\r\n' ;
	}	
	if( (document.theForm.Client_Report_to_Contact.value == '') || isblank(document.theForm.Client_Report_to_Contact.value))
	{
		missing+= 'Main Contact.\r\n' ;
	}	
	if( (document.theForm.Client_phone.value == '') || isblank(document.theForm.Client_phone.value))
	{
		missing+= 'Client Phone Number.\r\n' ;
	}	
	if(document.theForm.Billing_First_Time[0].checked == false && document.theForm.Billing_First_Time[1].checked == false )
	{
		missing+= 'Please select if this is your first time billing with this client.\r\n' ;
	}	
	if( (document.theForm.EstBilling.value == '') || isblank(document.theForm.EstBilling.value))
	{
		missing+= 'Monthly Billings.\r\n' ;
	}	
	if(document.theForm.TypeofBilling.selectedIndex == 0)
	{
		missing+= 'Type of Billing.\r\n' ;
	}	
	if(document.theForm.BillingFrequency[0].checked == false && document.theForm.BillingFrequency[1].checked == false )
	{
		missing+= 'Please select if this is One time billing, or Ongoing.\r\n' ;
	}	
	if(document.theForm.Contract[0].checked == false && document.theForm.Contract[1].checked == false )
	{
		missing+= 'Please select if you have a contract with this client.\r\n' ;
	}	
	
	if (missing == '' )
	{		
		return true;
	}
	else
	{
		missing = 'The following required fields are missing:\r\n\r\n' + missing ;
		alert (missing);
		return false;
	}

}

function validateITF() 
{ 

	var missing = '' ;
	if( (document.theForm.Billto_Contact.value == '') || isblank(document.theForm.Billto_Contact.value))
	{
		missing+= 'Bill attention to.\r\n' ;
	}	
	if( (document.theForm.IP_Invoice.value == '') || isblank(document.theForm.IP_Invoice.value))
	{
		missing+= 'Your invoice number.\r\n' ;
	}	
	if(document.theForm.Terms[0].checked == false && document.theForm.Terms[1].checked == false && document.theForm.Terms[2].checked == false && document.theForm.Terms[3].checked == false && document.theForm.Terms[4].checked == false && document.theForm.Terms[5].checked == false && document.theForm.Terms[6].checked == false )
	{
		missing+= 'Invoice payment terms selection.\r\n' ;
	}	
	if( (document.theForm.Terms[6].checked == true) && (isblank(document.theForm.Terms_Other.value) ) )
	{
		missing+= 'Payment terms.\r\n' ;
	}	
	if( (document.theForm.InvoiceDate.value == '') || isblank(document.theForm.InvoiceDate.value))
	{
		missing+= 'An invoice date.\r\n' ;
	}	
	if( (document.theForm.Web_Invoice_Amount.value == '') || isblank(document.theForm.Web_Invoice_Amount.value))
	{
		missing+= 'An invoice amount.\r\n' ;
	}	
	if( (document.theForm.ClientReportToContact.value == '') || isblank(document.theForm.ClientReportToContact.value))
	{
		missing+= 'Part 2 Verification contact.\r\n' ;
	}	
	if( (document.theForm.ClientPhone.value == '') || isblank(document.theForm.ClientPhone.value))
	{
		missing+= 'Part 2 Phone Number.\r\n' ;
	}	
	if( (document.theForm.ClientEmail.value == '') || isblank(document.theForm.ClientEmail.value))
	{
		missing+= 'Part 2 Email address.\r\n' ;
	}	
	if( (document.theForm.Web_Invoice_Text.value == '') || isblank(document.theForm.Web_Invoice_Text.value))
	{
		missing+= 'Part 3 Description.\r\n' ;
	}	
	
	if (missing == '' )
	{		
		return true;
	}
	else
	{
		missing = 'The following required fields are missing:\r\n\r\n' + missing ;
		alert (missing);
		return false;
	}
}

