/* All Functions and code below Copyright SportSites Inc.
   Do not use without explicit permission from SportSites Inc
   
   Version 1.0 - DAP - 07/31/2002
*/
function validateUnsubForm()
{
	var formIsValid = true;
	var alertText = "You must enter your email address to proceed.";
	
	if(document.unsub.email.value == "")
	{
		formIsValid = false;
	} // end if

	if(formIsValid == false)
	{
		alert(alertText);
	} // end if

	return formIsValid;
} // end validateUnsubForm()

function validateEmailForm()
{
	var formIsValid = true;
	var alertText = "There are problems with your submission:\n\n";
	var count = 0;
	
	if(document.add.name.value == "")
	{
		count++;
		alertText = alertText + count + ") You did not enter a name.\n";
		formIsValid = false;
	} // end if
	if(document.add.phone.value == "")
	{
		count++;
		alertText = alertText + count + ") You did not enter a phone number.\n";
		formIsValid = false;
	} // end if
	else
	{
		if(!isValidPhone(document.add.phone.value))
		{
			if(formIsValid)
			{
				count++;
				alertText = alertText + count + ") Phone number format is invalid.\n";
				formIsValid = false;
			} // end if
			else
			{
				count++;
				alertText = alertText + "\n" + count + ") Phone number format is invalid.\n";
				formIsValid = false;
			} // end else
		} // end if
	} // end else
	if(document.add.email.value == "")
	{
		count++;
		alertText = alertText + count + ") You did not enter an email address.\n";
		formIsValid = false;
	} // end if
	else
	{
		if(!isValidEmail(document.add.email.value))
		{
			if(formIsValid)
			{
				count++;
				alertText = alertText + count + ") Email address format is invalid.\n";
				formIsValid = false;
			} // end if
			else
			{
				count++;
				alertText = alertText + "\n" + count + ") Email address format is invalid.\n";
				formIsValid = false;
			} // end else
		} // end if
	} // end else
			
	
	if(formIsValid == false)
	{
		alert(alertText);
	} // end if
	return formIsValid;
} // end validateEmailForm()

function isValidEmail(emailText)
{
	var emailRegEx = /^\w(\.?\w)*@\w(\.?[-\w])*\.([a-z]{3,4}(\.[a-z]{2})?|[a-z]{2}(\.[a-z]{2})?)$/i;
	
	if(emailRegEx.test(emailText))
	{
		return true;
	} // end if
	else
	{
		return false;
	} // end else
} // end isValidEmail()

function isValidPhone(phoneText)
{
	var phoneRegEx = /\d\d\d-\d\d\d-\d\d\d\d/i;
	var phoneRegEx2 = /\d-\d\d\d-\d\d\d-\d\d\d\d/i;
	if(phoneRegEx.test(phoneText))
	{
		return true;
	} // end if
	else
	{
		if(phoneRegEx2.test(phoneText))
		{
			return true;
		} // end if
		else
		{
			return false;
		} // end else
	} // end else
} // end isValidPhone()


function openPicWindow(imageName, windowWidth, windowHeight)
{
	windowW = parseInt(windowWidth) + 25;
	windowH = parseInt(windowHeight) + 25;
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(imageName, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+windowW+",height="+windowH+",left=20,top=20');");
} // end openPicWindow()
