<!--
	var reValidExtension = /^\.(hqx|sit|sitx|zip|rar|png|gif|pdf|psd|tif|tiff|eps|ai|jpg)$/i
	var reValidExtensionMac = /^\.(hqx|sit|sitx|zip|rar)$/i
	var regExpPhone = /^\d{10}$/
	var regExpEmail = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|gov|biz|info|name|aero|biz|info|jobs|museum|travel|cat|asia|coop|mobi|pro|tel|mil|int)\b$/i
	
//==== enable_fields =================================================================================================
	
	function enable_fields()
	{
		for(var i=0;i<document.frmAdSubmission.elements.length;i++)
			if(document.frmAdSubmission.elements[i].disabled) 
				document.frmAdSubmission.elements[i].disabled = false;
	}
	
//==== movePhone =====================================================================================================
	//Checks the textboxes for the phone number and moves the cursor to the next textbox
	
	function movePhone()
	{
		if(frmAdSubmission.txtPhoneAC.value.length == 3 && frmAdSubmission.txtPhonePrefix.value.length <= 0)
		{
			frmAdSubmission.txtPhonePrefix.focus()			
		}
		else if(frmAdSubmission.txtPhoneAC.value.length == 3 && frmAdSubmission.txtPhonePrefix.value.length == 3)
		{
			frmAdSubmission.txtPhoneSuffix.focus()			
		}
	}

//==== showFileboxes =====================================================================================
	// Checks for the operating system. If mac, it shows 1 filebox. If windows, it shows 5 fileboxes.
	// For versions 1.1, 1.2, 1.3, 1.4
	
	function showFileboxes()
	{			
		frmAdSubmission.dflFile1.disabled = true;
		frmAdSubmission.dflFile2.disabled = true;
		frmAdSubmission.dflFile3.disabled = true;
		frmAdSubmission.dflFile4.disabled = true;
		frmAdSubmission.dflFile5.disabled = true;
		document.getElementById("divFile1").style.display = "none";
		document.getElementById("divFile2").style.display = "none";
		document.getElementById("divFile3").style.display = "none";
		document.getElementById("divFile4").style.display = "none";
		document.getElementById("divFile5").style.display = "none";
		//increase the size of the div
		switch(frmAdSubmission.cboFileNum.value)
		{
			case "5":
				document.getElementById("divFile5").style.display = "block";
				frmAdSubmission.dflFile5.disabled = false;
			case "4": 
				document.getElementById("divFile4").style.display = "block";
				frmAdSubmission.dflFile4.disabled = false;
			case "3": 
				document.getElementById("divFile3").style.display = "block";
				frmAdSubmission.dflFile3.disabled = false;
			case "2":
				document.getElementById("divFile2").style.display = "block";
				frmAdSubmission.dflFile2.disabled = false;
			case "1":
				document.getElementById("divFile1").style.display = "block";
				frmAdSubmission.dflFile1.disabled = false;
				break;
			default:
				break;
		}
	}
	
//==== clearForm ====================================================================================
	// This clears the form elements.
	// This may not have all of the elements from all versions listed below.
	// For versions 1.1, 1.2, 1.3, 1.4

	function clearForm()
	{
				
		frmAdSubmission.txtCompany.value = ""
		frmAdSubmission.txtContact.value = ""
		frmAdSubmission.txtAgency.value = ""
			
		frmAdSubmission.txtPhoneAC.value = ""
		frmAdSubmission.txtPhonePrefix.value = ""
		frmAdSubmission.txtPhoneSuffix.value = ""				
		frmAdSubmission.txtEmail.value = ""
										
		frmAdSubmission.txtChamber.value = ""
		frmAdSubmission.txtSalesRep.value = ""							
					
		frmAdSubmission.radPublicationType[0].checked = false
		frmAdSubmission.radPublicationType[1].checked = false		
		frmAdSubmission.radPublicationType[2].checked = false
		frmAdSubmission.radPublicationType[3].checked = false
								
		frmAdSubmission.cboFileNum.selectedIndex = 0												
		
		frmAdSubmission.dflWindowsFile1.value = ""
		frmAdSubmission.dflWindowsFile2.value = ""
		frmAdSubmission.dflWindowsFile3.value = ""
		frmAdSubmission.dflWindowsFile4.value = ""
		frmAdSubmission.dflWindowsFile5.value = ""
		
		frmAdSubmission.dflMacFile.value = ""
								
		showFileboxes();										
	}

//==== isEmpty ====================================================================================
	// Checks the values of the form elements to see if they are empty	
	// For versions 1.1, 1.2, 1.3, 1.4
	
	function isEmpty(str)
	{					
		//replace all spaces and newlines and see if it comes up empty		
		return (str.replace(/(\s|\n|\r)/gi, "") == "");
	}

//==== invalidText ============================================================================
	function invalidText(str)
	{
		var regexInvalidText = /[\*?"<>&\|\r\n\f]+/gi;
		//return whether it has bad text or not.
		return regexInvalidText.test(str);
	}
	
//==== validate ===================================================================================
	// Checks the required fields to make sure they have been filled out.
	// This may not check all of the required elements from all versions listed below.
	// For versions 1.1, 1.2, 1.3, 1.4
	
	function validate()
	{
		var oForm = document.frmAdSubmission;
		if(!oForm)
		{
			alert("There is no form! Please contact the webmaster (webnotify@lawtonprinting) if you feel this is in error.");
			return false;
		}
		
		if(isEmpty(oForm.txtCompany.value) || invalidText(oForm.txtCompany.value))
		{//checking company field
			alert("A valid company name is required  (without the characters:  \\/*?:\"<>|).");
			oForm.txtCompany.focus();
			return false;
		}
		
		if(isEmpty(oForm.txtContact.value) || invalidText(oForm.txtContact.value))
		{//checking company field
			alert("A valid contact name is required  (without the characters:  \\/*?:\"<>|).");
			oForm.txtContact.focus();
			return false;
		}
		
		if(invalidText(oForm.txtAgency.value))
		{//checking company field
			alert("Please use a valid agency name  (without the characters:  \\/*?:\"<>|).");
			oForm.txtAgency.focus();
			return false;
		}			

			
		if(isEmpty(oForm.txtEmail.value) || !regExpEmail.test(oForm.txtEmail.value))
		{
			alert("A valid contact email is required.");
			oForm.txtEmail.focus();
			return false;
		}
		
		//check for the phone number
		strPhone = oForm.txtPhoneAC.value + oForm.txtPhonePrefix.value + oForm.txtPhoneSuffix.value;
		if(isEmpty(strPhone) || !regExpPhone.test(strPhone))
		{
			alert("Please enter a valid telephone number.")
			if(isEmpty(oForm.txtPhoneAC.value))
				oForm.txtPhoneAC.focus();
			else if(isEmpty(oForm.txtPhonePrefix.value))
				oForm.txtPhonePrefix.focus();
			else if(isEmpty(oForm.txtPhoneSuffix.value))
				oForm.txtPhoneSuffix.focus();
			else oForm.txtPhoneAC.focus();
			return false;
		}
			
		if(!oForm.radPublicationType[0].checked && !oForm.radPublicationType[1].checked 
			&& !oForm.radPublicationType[2].checked && !oForm.radPublicationType[3].checked)
		{
			alert("Please indicate what type of publication the ad is for.") ;			
			oForm.radPublicationType[0].focus();
			return false;
		}
	
		if(isEmpty(oForm.txtChamber.value) || invalidText(oForm.txtChamber.value))
		{	
			alert("Please indicate a valid chamber or city name this is for (without the characters:  \\/*?:\"<>|).");
			oForm.txtChamber.focus();
			return false;			
		}

		if(invalidText(oForm.txtSalesRep.value))
		{	
			alert("Please enter a valid sales rep name (without the characters: \\/*?:\"<>|).");
			oForm.txtSalesRep.focus();
			return false;			
		}
		
		if(isMac)
		{
			if(isEmpty(oForm.dflFile1.value))
			{
				alert("Please choose a file to upload.");
				oForm.dflFile1.focus();
				return false;
			}
			
			strTemp = oForm.dflFile1.value ;				
			intStartIndex = strTemp.lastIndexOf(".");
			strFileExt = strTemp.substr(intStartIndex);						
			
			if(!reValidExtensionMac.test(strFileExt))
			{					
				alert("Your file must be compressed into one of the following archive types: .hqx, .sit, .sitx, .zip.")
				if(oForm.cboFileNum.selectedIndex > 0)
					oForm.dflFile1.focus();
				else oForm.cboFileNum.focus();
				return false;
			} else if(invalidText(strTemp)) {
				alert("You cannot upload a file with a filename containing the following characters: \\/*?:\"<>|.");
				oForm.dflFile1.focus();
				return false;
			}
		} else {
			switch(oForm.cboFileNum.options[oForm.cboFileNum.selectedIndex].value)
			{
				case "5":   
			        if(isEmpty(oForm.dflFile5.value))
					{
						//file is empty
						alert("Please choose your 5th file to upload.");
						oForm.dflFile5.focus();
						return false;
					}
					
					strTemp = oForm.dflFile5.value;				
					intStartIndex = strTemp.lastIndexOf(".");
					strFileExt = strTemp.substr(intStartIndex);
					if(!reValidExtension.test(strFileExt))
					{
						alert("You cannot upload a file with the " + strFileExt + " extention.\nPlease re-enter file 5.");
						oForm.dflFile5.focus();
						return false;
					} else if(invalidText(strTemp)) {
						alert("You cannot upload a file with a filename containing the following characters: \\/*?:\"<>|.");
						oForm.dflFile5.focus();
						return false;
					}
				case "4":				        
					if(isEmpty(oForm.dflFile4.value))
					{
						//file is empty
						alert("Please choose your 4th file to upload.");
						oForm.dflFile4.focus();
						return false;
					}
					
					strTemp = oForm.dflFile4.value;
					intStartIndex = strTemp.lastIndexOf(".");
					strFileExt = strTemp.substr(intStartIndex);
					if(!reValidExtension.test(strFileExt))
					{
						alert("You cannot upload a file with the " + strFileExt + " extention.\nPlease re-enter file 4.");
						oForm.dflFile4.focus();
						return false;
					} else if(invalidText(strTemp)) {
						alert("You cannot upload a file with a filename containing the following characters: \\/*?:\"<>|.");
						oForm.dflFile4.focus();
						return false;
					}
				case "3":				        
					if(isEmpty(oForm.dflFile3.value))
					{
						//file is empty
						alert("Please choose your 3rd file to upload.");
						oForm.dflFile3.focus();
						return false;
					}
					
					strTemp = oForm.dflFile3.value;
					intStartIndex = strTemp.lastIndexOf(".");
					strFileExt = strTemp.substr(intStartIndex);
					if(!reValidExtension.test(strFileExt))
					{
						alert("You cannot upload a file with the " + strFileExt + " extention.\nPlease re-enter file 3.");
						oForm.dflFile3.focus();
						return false;
					} else if(invalidText(strTemp)) {
						alert("You cannot upload a file with a filename containing the following characters: \\/*?:\"<>|.");
						oForm.dflFile3.focus();
						return false;
					}
				case "2":								
					if(isEmpty(oForm.dflFile2.value))
					{
						//file is empty
						alert("Please choose your 2nd file to upload.");
						oForm.dflFile2.focus();
						return false;
					}
					
					strTemp = oForm.dflFile2.value;				
					intStartIndex = strTemp.lastIndexOf(".");
					strFileExt = strTemp.substr(intStartIndex);
					if(!reValidExtension.test(strFileExt))
					{
						alert("You cannot upload a file with the " + strFileExt + " extention.\nPlease re-enter file 2.");
						oForm.dflFile2.focus();
						return false;
					} else if(invalidText(strTemp)) {
						alert("You cannot upload a file with a filename containing the following characters: \\/*?:\"<>|.");
						oForm.dflFile2.focus();
						return false;
					}
				case "1":
					if(isEmpty(oForm.dflFile1.value))
					{
						alert("Please choose your 1st file to upload.");
						//Causes IE to allow attempted upload.
						//If commented out, IE will not allow the attempt.
						oForm.dflFile1.focus();
						return false;
					}
					
					strTemp = oForm.dflFile1.value;
					intStartIndex = strTemp.lastIndexOf(".");
					strFileExt = strTemp.substr(intStartIndex);
					if(!reValidExtension.test(strFileExt))
					{
						alert("You cannot upload a file with the " + strFileExt + " extention.\nPlease re-enter file 1.");
						oForm.dflFile1.focus();
						return false;
					} else if(invalidText(strTemp)) {
						alert("You cannot upload a file with a filename containing the following characters: \\/*?:\"<>|.");
						oForm.dflFile1.focus();
						return false;
					}
					break;
				default: //0
					alert("Please select the number of files you wish to send.");
					oForm.cboFileNum.focus();
					return false;
					break;							
			}//end switch
		}//end else					
		
		document.getElementById("SubmissionForm").style.display = "none";
		document.getElementById("msg_box").style.display = "block";
		
//		setTimeout("", 2000);
		
//		return true;
		oForm.submit();
	}

//-->
