<!--
function getElement(f,nme)
{
	for(x=0;x<f.length;x++)
	{
		var elem=f[x];
		if (elem.id.indexOf(nme) > -1)
		{
			return elem;
		}
	}
}

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 validateDropDownList(f,fld)
{
	var selectionMade=true;
	var fname;
	for (x=0;x<f.length;x++)
	{
		fname=f[x].name;
		if (f[x].type=="select-one")
		{
			if (fname.indexOf(fld)>0)
			{
				if (f[x].options[f[x].selectedIndex].value=="Select")
				{
					selectionMade=false;
					break;
				}
			}
		}
	}
	return selectionMade;
}

function validateRadioButtonSelection(f,fld)
{
	var selectionMade=false;
	var fname;
	for (x=0;x<f.length;x++)
	{
		fname=f[x].name;
		if (f[x].type=="radio")
		{
			if (fname.indexOf(fld)>0)
			{
				if (f[x].checked==true)
				{
					selectionMade=true;
					break;
				}
			}
		}
	}
	return selectionMade;
}

function checkContactUs(f, clientID){
	var formType=f.formType.value;
	switch(formType)
		{
		case "SpeakerSeries":
			return checkSpeakerSeries(f,clientID);
		case "StudentPress":
			return checkStudentPress(f,clientID);
		case "ContactUs":
			return checkContact(f,clientID);
		case "MovieBenefit":
			return checkMovieBenefit(f,clientID);
		default: return true;
		
		}
	}

function checkContact(f, clientID)
{
	var t = getElement(f, clientID, 'SubjectList');
	var x=getElement(f, clientID, 'OtherText');
	if (t.options[t.selectedIndex].value=="" && x.value=="")
	{
		alert("Please select or enter a subject.")
		return false;
	}
    if (checkWhitespace(f, clientID, "FirstNameTextBox", "First Name")){
        return false;
    }
    if (checkWhitespace(f, clientID, "LastNameTextBox", "Last Name")){
        return false;
    }
    if (checkWhitespace(f, clientID, "DaytimePhoneNumberTextBox", "Daytime Phone Number")){
        return false;
    }
    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; 
}

function checkStudentPress(f, clientID)
{
    if (checkWhitespace(f, clientID, "FirstNameTextBox", "First Name")){
        return false;
    }
    if (checkWhitespace(f, clientID, "LastNameTextBox", "Last Name")){
        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;
    }    
    if (checkWhitespace(f, clientID, "PhoneNumberTextBox", "Telephone")){
        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;
    }
    if (checkWhitespace(f, clientID, "FinishDateTextBox", "Date needed")){
        return false;
    }
	if (!validateDropDownList(f,"JobDescription"))
	{
		alert("Please select a description of the job.");
		return false;
	}
	t = getElement(f, clientID, 'JobDescription');
	if (t.options[t.selectedIndex].value=="Envelopes")
	{
		if (!validateDropDownList(f,"EnvelopeSize"))
		{
			alert("Please select an envelope size.");
			return false;
		}
	}
	
	if (!validateDropDownList(f,"Quantity"))
	{
		alert("Please select a quantity.");
		return false;
	}
	if (!validateDropDownList(f,"FinishedSize"))
	{
		alert("Please select a finished size.");
		return false;
	}
	if (!validateRadioButtonSelection(f,"OneOrTwoSided"))
	{
		alert("Please select one or two-sided.");
		return false;
	}
	if (!validateRadioButtonSelection(f,"FullorSpotColor"))
	{
		alert("Please select full or spot color.");
		return false;
	}
	t = getElement(f, clientID, 'FullorSpotColor');
	if (t[1].checked)
	{
		if (!validateDropDownList(f,"NumSpotColor"))
		{
			alert("Please select number of spot colors.");
			return false;
		}
	}

	return true;
}

function CheckSpeakerSeriesCheckBoxes(f, clientID)
{
	var ischecked=false;
	for (x=0;x<f.length;x++)
	{
		var e=f[x];
		if (e.type=="checkbox")
		{
			if (e.checked)
			{
				ischecked=true;
				break;
			}
		}
	}
	return ischecked;
}

function checkSpeakerSeries(f, clientID){ 
	if (!CheckSpeakerSeriesCheckBoxes(f, clientID))
	{
		alert("Please select a donor level and quantity of tickets.");
		return false;
	}
	var t=getElement(f,"FirstNameTextBox");
	if (isWhitespace(t.value)){
		alert("Please enter your first name.");
		t.focus();
        return false;
    }
    t=getElement(f,"LastNameTextBox");
	if (isWhitespace(t.value)){
		alert("Please enter your last name.");
		t.focus();
        return false;
    }
    t=getElement(f,"NameTagTextBox");
	if (isWhitespace(t.value)){
		alert("Please enter the text for your name tag.");
		t.focus();
        return false;
    }
    t = getElement(f, 'EMailTextBox');
    if (isWhitespace(t.value) || !isEmail(t.value)){
	    alert("Please provide a valid e-mail address");
        t.focus();
        return false;
    }    
    t = getElement(f, 'PhoneNumberTextBox');
	if (isWhitespace(t.value)){
	    alert("Please provide a daytime telephone number.");
        t.focus();
        return false;
    }    
    t = getElement(f, 'Address1TextBox');
	if (isWhitespace(t.value)){
	    alert("Please enter your address.");
        t.focus();
        return false;
    }  
    t = getElement(f, 'CityTextBox');
	if (isWhitespace(t.value)){
	    alert("Please enter your city.");
        t.focus();
        return false;
    }    
    t = getElement(f, 'ZipCodeTextBox');
	if (isWhitespace(t.value)){
	    alert("Please enter your zip code.");
        t.focus();
        return false;
    }  

    return true;
}

function checkMovieBenefit(f, clientID){   
	var t=getElement(f,"FirstNameTextBox");
	if (isWhitespace(t.value)){
		alert("Please enter your first name.");
		t.focus();
        return false;
    }
    t=getElement(f,"LastNameTextBox");
	if (isWhitespace(t.value)){
		alert("Please enter your last name.");
		t.focus();
        return false;
    }
    t = getElement(f, 'EMailTextBox');
    if (isWhitespace(t.value) || !isEmail(t.value)){
	    alert("Please provide a valid e-mail address");
        t.focus();
        return false;
    }    
    t = getElement(f, 'PhoneNumberTextBox');
	if (isWhitespace(t.value)){
	    alert("Please provide a daytime telephone number.");
        t.focus();
        return false;
    }    
    t = getElement(f, 'Address1TextBox');
	if (isWhitespace(t.value)){
	    alert("Please enter your address.");
        t.focus();
        return false;
    }  
    t = getElement(f, 'CityTextBox');
	if (isWhitespace(t.value)){
	    alert("Please enter your city.");
        t.focus();
        return false;
    }    
    t = getElement(f, 'ZipCodeTextBox');
	if (isWhitespace(t.value)){
	    alert("Please enter your zip code.");
        t.focus();
        return false;
    }  
    return true;
}
//-->
