// JavaScript Document// JavaScript Document
function FrontPage_Form1_Validator(theForm)
{//-------The first	eight required fields are the same for each business form except training
	
    if (theForm.Full_Name.value == "")
  	{
	   	alert ("Please provide the contact name under Contact Information.");
		theForm.Full_Name.focus();
		return false;
  	}
	else if (theForm.phone.value == "")
	{
		alert ("Please provide the contact telephone number under Contact Information.");
		theForm.phone.focus();
		return false;
	}
	else if(theForm.email.value == "")//Is there a email?
	{
		alert ("Please provide your email under Contact Information.");
		theForm.email.focus(); 
		return false;
	}
	else if(theForm.Company_Name.value == "")//Is there a company name?
	{	
		alert ("Please provide your Company name.");
		theForm.Company_Name.focus();
		return false;
	}
	else if(theForm.Work_Type.value == "Other")
	{
		
	}
	else if(theForm.Work_Type.value == "Site Survey")
	{
		
	}
	
	else if(theForm.Street_Address.value == "")//Is there a Street Address?
	{
		alert ("Please provide your Companies Street Address under Billing information.");
		theForm.Street_Address.focus();
		return false;
	}
	else if(theForm.Town.value == "")//Is there a Town?
	{
		alert ("Please provide your Companies Town under Billing information.");
		theForm.Town.focus();
		return false;
	}
	else if(theForm.State.value == "")//Is there a State?
	{
		alert ("Please provide your Companies State under Billing information.");
		theForm.State.focus();
		return false;
	}
	else if(theForm.Zip_Code.value == "")//Is there a Zip Code?
	{
		alert ("Please provide your Companies Zip Code under Billing information.");
		theForm.Zip_Code.focus();
		return false;
	}
	
	//-------------After this point the required inputs are varied per form
	if(theForm.Work_Type.value == "110 - Telephone Line Programming Change")
	{
		if(theForm.Purchase_Phone.selectedIndex == 0)
		{
			alert("Please select yes or no.");
			theForm.Purchase_Phone.focus();
			return false;	
		}
		else if(theForm.Purchase_Phone.selectedIndex == 1 & theForm.Equipment.selectedIndex == 0)
		{
			alert("Please select the phone you wish to purchase.");
			theForm.Equipment.focus();
			return false;	
		}
		else if(theForm.Purchase_Phone.selectedIndex == 1 & theForm.Quantity.value == "")
		{
			alert("Please select quantity of the selected phone you wish to purchase.");
			theForm.Quantity.focus();
			return false;	
		}
		else if(theForm.Purchase_Phone.selectedIndex == 2)
		{
			theForm.Work_Type2.disabled = true;
		}
	}
	if(theForm.Work_Type.value == "300 - Data Install (Cable Needed)" ||
	   theForm.Work_Type.value == "106 - Telephone Line Disconnect" ||
	   theForm.Work_Type.value == "100 - Telephone Line Install (Existing)" ||
	   theForm.Work_Type.value == "210 - Speech Recognition Change" ||
	   theForm.Work_Type.value == "110 - Telephone Line Programming Change" ||
	   theForm.Work_Type.value == "600 - Telephone Line Repair" ||
	   theForm.Work_Type.value == "623 - Emergency Notification Speaker Repair")
	{
		if(theForm.Building_Name.selectedIndex == 0)
		{
			alert ("Please select the Building location.");
			theForm.Building_Name.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "300 - Data Install (Cable Needed)" ||
	   theForm.Work_Type.value == "106 - Telephone Line Disconnect" ||
	   theForm.Work_Type.value == "100 - Telephone Line Install (Existing)" ||
	   theForm.Work_Type.value == "210 - Speech Recognition Change" ||
	   theForm.Work_Type.value == "110 - Telephone Line Programming Change" ||
	   theForm.Work_Type.value == "600 - Telephone Line Repair")
	{
		if(theForm.Room.value == "")
		{
			alert ("Please Enter the Room Number location.");
			theForm.Room.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "300 - Data Install (Cable Needed)")
	{
		if(theForm.Number_Of_Drops.value == "")
		{
			alert ("Please Enter the Number of Connections to be installed.");
			theForm.Number_Of_Drops.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "201 - Add Voice Mailbox")
	{
		if(theForm.Change.selectedIndex == 0)
		{
			alert ("Please select the service needed under Voice Mailbox information.");
			theForm.Change.focus();
			return false;
		}

	}
	if(theForm.Work_Type.value == "201 - Add Voice Mailbox")
	{
		if(theForm.Voice_Mail_On.value == "")
		{
			alert ("Please enter the extension to add/change/delete under Voice Mailbox information.");
			theForm.Voice_Mail_On.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "106 - Telephone Line Disconnect")
	{
		if(theForm.Disconnect_Telephone.value == "")
		{
			alert ("Please enter the telephone number to be disconnected under Disconnect Information.");
			theForm.Disconnect_Telephone.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "106 - Telephone Line Disconnect")
	{
		if(theForm.Line_Has_Voice_Mail.selectedIndex == 0)
		{
			alert ("Please select (yes or no) for if this line has voicemail under Disconnect Information");
			theForm.Line_Has_Voice_Mail.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "Equipment Order")
	{
		if(theForm.Equipment_Extension.value == "")
		{
			alert ("Please enter the extension number of the line the new equipment will be connected to.");
			theForm.Equipment_Extension.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "Equipment Order")
	{
		if(theForm.Equipment.selectedIndex == 0)
		{
			alert ("Please select the new equipment you wish to purchase.");
			theForm.Equipment.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "100 - Telephone Line Install (Existing)")
	{
		if(theForm.Line_Type.selectedIndex == 0)
		{
			alert ("Please select Type of Telephone line to be installed.");
			theForm.Line_Type.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "100 - Telephone Line Install (Existing)")
	{
		if(theForm.Purchase_Telephone.selectedIndex == 0)
		{
			alert ("Please tell us if you purchased the phone from Telecom.");
			theForm.Purchase_Telephone.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "100 - Telephone Line Install (Existing)")
	{
		if(theForm.Telephone_Model.selectedIndex == 0)
		{
			alert ("Please select the phone that will be used on the line.");
			theForm.Telephone_Model.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "100 - Telephone Line Install (Existing)" ||
	   (theForm.Work_Type.value == "104 - Telephone Line Move (Cable needed)" && theForm.summary.value != "Contractor Computer Line Move") || theForm.Work_Type.value == "110 - Telephone Line Programming Change")
	{
		if(theForm.Caller_ID_Display_Name.value == "")
		{
			alert ("Please enter the name you want to display on caller id for this line.");
			theForm.Caller_ID_Display_Name.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "110 - Telephone Line Programming Change")
	{
		if(theForm.Restrictions.value == "")
		{
			alert ("Please select the restrictions for this line.");
			return false;
		}
		else
		{
			theForm.Restrictions.disabled = true;
		}
	}
	if(theForm.Work_Type.value == "100 - Telephone Line Install (Existing)")
	{
		if(theForm.Add_Voice_Mail.selectedIndex == 0)
		{
			alert ("Please tell us if you (yes or no) want voicemail on this line.");
			theForm.Add_Voice_Mail.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "104 - Telephone Line Move (Cable needed)" && theForm.summary.value != "Contractor Computer Line Move")
	{
		if(theForm.Move_Telephone.value == "")
		{
			alert ("Please enter the extension of the line being moved.");
			theForm.Move_Telephone.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "104 - Telephone Line Move (Cable needed)")
	{
		if(theForm.Current_Building_Name.selectedIndex == 0)
		{
			alert ("Please enter the Building where the line is currently located.");
			theForm.Current_Building_Name.focus();
			return false;
		}
		else if(theForm.Current_Building_Name.selectedIndex == 0)
		{
			if(theForm.Current_Other_Location.value = "")
			{
				alert ("Please specify the other location.");
				theForm.Current_Other_Location.focus();
				return false;
			}
		}
	}
	if(theForm.Work_Type.value == "104 - Telephone Line Move (Cable needed)")
	{
		if(theForm.New_Building_Name.selectedIndex == 0)
		{
			alert ("Please enter the building where the new line will be located.");
			theForm.New_Building_Name.focus();
			return false;
		}
		else if(theForm.New_Building_Name.selectedIndex == 0)
		{
			if(theForm.New_Other_Location.value = "")
			{
				alert ("Please specify the other location.");
				theForm.New_Other_Location.focus();
				return false;
			}
		}
	}
	if(theForm.Work_Type.value == "104 - Telephone Line Move (Cable needed)")
	{
		if(theForm.Current_Room.value == "")
		{
			alert ("Please enter the room where the line is currently located.");
			theForm.Current_Room.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value == "104 - Telephone Line Move (Cable needed)")
	{
		if(theForm.New_Room.value == "")
		{
			alert ("Please enter the room where the new line will be located.");
			theForm.New_Room.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value ==  "210 - Speech Recognition Change")
	{
		if(theForm.Name_of_Person_Assigned_to_Phone_Line.value == "")
		{
			alert ("Please enter the name of the person or company to be assigned to phone");
			theForm.Name_of_Person_Assigned_to_Phone_Line.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value ==  "210 - Speech Recognition Change")
	{
		if(theForm.Change_Name_On_Telephone_Line.value == "")
		{
			alert ("Please enter the telephone number that you want the name change to occur on.");
			theForm.Change_Name_On_Telephone_Line.focus();
			return false;
		}
	}
	if(theForm.Work_Type.value ==  "110 - Telephone Line Programming Change")
	{
		if(theForm.Changes_To_Telephone.value == "")
		{
			alert ("Please enter the telephone line extension to make programming changes to.");
			theForm.Changes_To_Telephone.focus();
			return false;
		}
	}
	
	if(theForm.Work_Type.value == "600 - Telephone Line Repair")
	{
		if(theForm.Time_Problem_Started.selectedIndex == 0)
		{
			alert ("Please select the time that the problem started.");
			theForm.Time_Problem_Started.focus();
			return false;
		}
	}
	
	
	return (true);
}

function ResetForm()
{
	
	num = document.FrontPage_Form1.elements.length;
	//Loop Through form elements enabling all of them
	//Loop Through form elements enabling all of them
	for(i = 0 ;i < num; i++)
	{
		document.FrontPage_Form1.elements[i].disabled = false;
		if(document.FrontPage_Form1.elements[i].name == "Account_Not_Listed" && document.FrontPage_Form1.Account_Billed.selectedIndex != 1)
		{
			document.FrontPage_Form1.elements[i].disabled = true;
		}
		if(document.FrontPage_Form1.elements[i].name == "Other_Location" && document.FrontPage_Form1.Building_Name.selectedIndex != 1)
		{
		
			document.FrontPage_Form1.elements[i].disabled = true;
		}
		if(document.FrontPage_Form1.elements[i].name == "Current_Other_Location" && document.FrontPage_Form1.Current_Building_Name.selectedIndex != 1) 
		{
			document.FrontPage_Form1.elements[i].disabled = true;
		}
		if(document.FrontPage_Form1.elements[i].name == "New_Other_Location" && document.FrontPage_Form1.New_Building_Name.selectedIndex != 1)
		{
			document.FrontPage_Form1.elements[i].disabled = true;
		}
	}

}
function otherLocations()
{
	if(document.FrontPage_Form1.Current_Building_Name.selectedIndex == 1)
		document.FrontPage_Form1.Current_Other_Location.disabled = false;
	else
		document.FrontPage_Form1.Current_Other_Location.disabled = true;

if(document.FrontPage_Form1.New_Building_Name.selectedIndex == 1)
		document.FrontPage_Form1.New_Other_Location.disabled = false;
	else
		document.FrontPage_Form1.New_Other_Location.disabled = true;

		
}


function Validate()
{
	
	var temp = document.FrontPage_Form1.ValidationCode.value;
	if(validateText(temp)==true)
	{
		if(FrontPage_Form1_Validator(document.FrontPage_Form1))
		{
			num = document.FrontPage_Form1.elements.length;
			//Loop Through form elements diabling any that are not filled out
			for(i = 0 ;i < num; i++)
			{
				if (document.FrontPage_Form1.elements[i].type == "text")
					if (document.FrontPage_Form1.elements[i].value == "")
						document.FrontPage_Form1.elements[i].disabled = true;
				if (document.FrontPage_Form1.elements[i].selectedIndex == 0)
					document.FrontPage_Form1.elements[i].disabled = true;
				
					
			
				if(document.FrontPage_Form1.elements[i].value == "on")
					document.FrontPage_Form1.elements[i].value = "";
			}
			if(document.FrontPage_Form1.Date_Month)
				document.FrontPage_Form1.Date_Month.disabled=true;
			document.FrontPage_Form1.ValidationCode.disabled=true;
				
			document.FrontPage_Form1.submit();
		}
	
	}
}

function otherLocation()
{
	if(document.FrontPage_Form1.Building_Name.selectedIndex == 1)
		document.FrontPage_Form1.Other_Location.disabled = false;
	else
		document.FrontPage_Form1.Other_Location.disabled = true;
		
}
function otherLocations()
{
	if(document.FrontPage_Form1.Current_Building_Name.selectedIndex == 1)
		document.FrontPage_Form1.Current_Other_Location.disabled = false;
	else
		document.FrontPage_Form1.Current_Other_Location.disabled = true;

	if(document.FrontPage_Form1.New_Building_Name.selectedIndex == 1)
		document.FrontPage_Form1.New_Other_Location.disabled = false;
	else
		document.FrontPage_Form1.New_Other_Location.disabled = true;

		
}
function otherAccount()
{
	if(document.FrontPage_Form1.Account_Billed.selectedIndex == 1)
		document.FrontPage_Form1.Account_Not_Listed.disabled = false;
	else
		document.FrontPage_Form1.Account_Not_Listed.disabled = true;
		
}

