<!--
function checkWhitespace(f, clientID, name, text){
    var t = getElement(f, clientID, name);
    if (isWhitespace(t.value)){
        alert("Please complete the " + text + " field.");
        t.focus();
        return true;
    }    
    return false;
}

function isUpperCase(aCharacter)
{
   return (aCharacter >= 'A') && (aCharacter <= 'Z')
}

function isNumeric(aCharacter)
{
	return (aCharacter >= '0') && (aCharacter <= '9')
}


function checkDropDownSelected(fld)
{
	if (fld.options[fld.selectedIndex].value=="")
	{
		return false;
	}		
	return true;
}

function checkContractorCode(f,clientID,name)
{
    var t = getElement(f, clientID, name);
    var ar=t.value.split("-");
    if (ar.length !=2)
    {
		return false;
    }
    else
    {
		var a=ar[0];
		var b=ar[1];
		var s="";
		if (a.length !=4 || b.length !=2)
		{
			return false;		
		}
		else
		{
			for (x=0;x<a.length;x++)
			{
				s=a.substring(x,x+1);
				if (!isUpperCase(s))
				{
					return false;
				}
			}
			for (x=0;x<b.length;x++)
			{
				s=b.substring(x,x+1);
				if (!isNumeric(s))
				{
					return false;
				}
			}
		}
	}
	return true;
}

function checkContactUs(f, clientID){
	var formType=f.formType.value;
	switch(formType)
		{
		case "ContactForm":
			return checkContactForm(f,clientID);	
		case "BidBondResults":
			return checkBidBondResults(f,clientID);		
		case "BidBondRequest":
			return checkBidBondRequest(f,clientID);		
		}
	}

var isUploading=false;
function checkBidBondRequest(f,clientID)
{
	var t;
	if (!isUploading)
	{
		if (checkWhitespace(f, clientID, "ContractorCode", "Contractor Code")){
			return false;
		}
		else
		{
			if (!checkContractorCode(f,clientID,"ContractorCode"))
			{
				alert("Invalid Contractor Code. Please re-enter or contact your Thomas McGee Account Manager.");
				t=getElement(f, clientID, 'ContractorCode');
				t.focus();
				return false;
			}		
		}
		if (checkWhitespace(f, clientID, "ContractorNameTextBox", "Contractor")){
			return false;
		}
		if (checkWhitespace(f, clientID, "IndividualRequesting", "name and email of individual requesting")){
			return false;
		}
		if (checkWhitespace(f, clientID, "OwnerInfoTextBox", "Project Owner/Obligee")){
			return false;
		}
		t=getElement(f, clientID, 'BidDateTextBox');
		if (!checkStringDate(t,"Bid date"))
		{
			return false;
		}
		if (checkWhitespace(f, clientID, "BidSecurityTextBox", "Bid Security")){
			return false;
		}
		t=getElement(f, clientID, 'BidBondForm');
		if (!checkDropDownSelected(t)){
			alert("Please select the type of bid bond form.");
			t.focus();
			return false;
		}
		t=getElement(f, clientID, 'StateCodeList');
		if (t.options[t.selectedIndex].value=="0")
		{
			alert("Please select the location of work (state).");
			t.focus();
			return false;
		}
		if (checkWhitespace(f, clientID, "ProjectSolicitationTextBox", "Project/Solicitation number")){
		return false;
		}
		if (checkWhitespace(f, clientID, "ProjectTitleTextBox", "Project title")){
			return false;
		}
		if (checkWhitespace(f, clientID, "ProjectDescription", "Project description")){
			return false;
		}
		if (checkWhitespace(f, clientID, "EstimateTextBox", "Estimate")){
			return false;
		}
		if (checkWhitespace(f, clientID, "MaintenancePeriodTextBox", "Maintenance period")){
			return false;
		}
		if (checkWhitespace(f, clientID, "CompletionTimeTextBox", "Completion time")){
			return false;
		}
		if (checkWhitespace(f, clientID, "LiquidatedDamagesTextBox", "Liquidated damages")){
		return false;
		}
		if (checkWhitespace(f, clientID, "ArchitectEngineerTextBox", "Architect/Engineer")){
		return false;
		}
		if (checkWhitespace(f, clientID, "RetainageTextBox", "Retainage")){
			return false;
		}
		var t=getElement(f, clientID, 'FileUpload');
		var val=t.value;
		val=val.toLowerCase();
		if (val !="")
		{
			if (val.indexOf(".doc") == -1 && val.indexOf(".pdf")==-1 && val.indexOf(".jpg")==-1 && val.indexOf(".jpeg")==-1 && val.indexOf(".tif")==-1)
			{
				alert("Only Microsoft Word (.doc), Adobe PDF, .jpg and .tiff documents may be uploaded.");
				return false;
			}
			else
			{
				isUploading=true;
				alert("Depending on your document size and Internet connection, it may take up to several minutes to upload your document.  Please be patient.");
			}
		}
		return true;
	}
}

function checkBidBondResults(f,clientID)
{
	if (checkWhitespace(f, clientID, "ContractorCode", "Contractor Code")){
		return false;
	}
	else
	{
		if (!checkContractorCode(f,clientID,"ContractorCode"))
		{
			alert("Invalid Contractor Code. Please re-enter or contact your Thomas McGee Account Manager.");
			t=getElement(f, clientID, 'ContractorCode');
			t.focus();
			return false;
		}		
	}
    if (checkWhitespace(f, clientID, "ContractorNameTextBox", "Contractor")){
        return false;
    }
	if (checkWhitespace(f, clientID, "IndividualReporting", "name and mail of individual reporting")){
		return false;
	}
	if (checkWhitespace(f, clientID, "OwnerInfoTextBox", "Project Owner/Obligee")){
		return false;
	}
    if (checkWhitespace(f, clientID, "ProjectNameTextBox", "Project")){
        return false;
    }
    if (checkWhitespace(f, clientID, "BidDateTextBox", "Bid date")){
        return false;
    }
    var t=getElement(f, clientID, 'BidDateTextBox');
    if (!checkStringDate(t,"Bid date"))
    {
		return false;
    }
    if (checkWhitespace(f, clientID, "BidAmountTextBox", "Your bid amount")){
        return false;
    }

    if (checkWhitespace(f, clientID, "LowBidderName", "Low bidder\'s name")){
        return false;
    }
    if (checkWhitespace(f, clientID, "LowBidPrice", "Low bid price")){
        return false;
    }
    if (checkWhitespace(f, clientID, "SecondBidderName", "2nd bidder\'s name")){
        return false;
    }
    if (checkWhitespace(f, clientID, "SecondBidPrice", "2nd bid price")){
        return false;
    }
    if (checkWhitespace(f, clientID, "ThirdBidderName", "3rd bidder\'s name")){
        return false;
    }
    if (checkWhitespace(f, clientID, "ThirdBidPrice", "3rd bid price")){
        return false;
    }
	return true;
}

function checkContactForm(f, clientID){    
    if (checkWhitespace(f, clientID, "FirstNameTextBox", "First name")){
        return false;
    }
    if (checkWhitespace(f, clientID, "LastNameTextBox", "Last name")){
        return false;
    }
    if (checkWhitespace(f, clientID, "Address1TextBox", "Address")){
        return false;
    }
    if (checkWhitespace(f, clientID, "CityTextBox", "City")){
        return false;
    }
    if (checkWhitespace(f, clientID, "ZipCodeTextBox", "ZIP code")){
        return false;
    }
    var t = getElement(f, clientID, 'EMailTextBox');
    if (isWhitespace(t.value) || !isEmail(t.value)){
	    alert("Please provide a valid e-mail address.");
        t.focus();
        return false;
    }    
    return true;
}
//-->

