function parentEmail()
{
	
	var email = /^.+@.+\..{2,3}$/;
	var parentForm = document.getElementById("parent_email");
	var parentSubmit = document.getElementById("p_email");
	var checkAge = document.getElementById("under_thirteen");
	if(parentForm.className==="hide" && checkAge.checked)
	{
		parentForm.className="show";
	}
	else
	{
		parentForm.className="hide";
	}

}

function doValidate()
	{	
		var email = /^.+@.+\..{2,3}$/;
		//var current_date = new Date();
		
		if (!(FormValidationElementHasValue(document.subscribe.subscriber_name)) || document.subscribe.subscriber_name.value == "first name")
		{
			alert( "Please enter your first name" );
      		document.subscribe.subscriber_name.focus();
	        return false;
		}
		
		if (!(FormValidationElementHasValue(document.subscribe.last_name)) || document.subscribe.last_name.value == "last name")
		{
			alert( "Please enter your last name" );
      		document.subscribe.last_name.focus();
	        return false;
		}
		
		if (!(FormValidationElementHasValue(document.subscribe.subscriber_email)) || document.subscribe.subscriber_email.value == "my email")
		{
			alert( "Please enter your email address" );
      		document.subscribe.subscriber_email.focus();
	        return false;
		}
		
		if( !email.test(document.subscribe.subscriber_email.value ) )
		{
			 alert( "Invalid email address" );
			 document.subscribe.subscriber_email.focus();
			 return false;
		}
		
		
		if(document.getElementById("parent_email").className == "show")
		{
			if (!(FormValidationElementHasValue(document.subscribe.parent_email)) || document.subscribe.parent_email.value == "Parent Email Address")
			{
				alert( "Please enter your parent's email address" );
      			document.subscribe.parent_email.focus();
	    	    return false;
			}
		
			if( !email.test(document.subscribe.parent_email.value ) )
			{
				 alert( "Invalid email address" );
				 document.subscribe.parent_email.focus();
				 return false;
			}
		}
		
		
		if (!(FormValidationElementHasValue(document.subscribe.listId)))
		{
			alert( "Please select which mailing list you would like to be added to" );
	        return false;
		}
		
		
		
}

function doValidateContact()
	{	
		var email = /^.+@.+\..{2,3}$/;
		//var current_date = new Date();
		
		if (!(FormValidationElementHasValue(document.subscribe.subscriber_name)) || document.subscribe.subscriber_name.value == "first name")
		{
			alert( "Please enter your first name" );
      		document.subscribe.subscriber_name.focus();
	        return false;
		}
		
		if (!(FormValidationElementHasValue(document.subscribe.last_name)) || document.subscribe.last_name.value == "last name")
		{
			alert( "Please enter your last name" );
      		document.subscribe.last_name.focus();
	        return false;
		}
		
		if (!(FormValidationElementHasValue(document.subscribe.subscriber_email)) || document.subscribe.subscriber_email.value == "my email")
		{
			alert( "Please enter your email address" );
      		document.subscribe.subscriber_email.focus();
	        return false;
		}
		
		if( !email.test(document.subscribe.subscriber_email.value ) )
		{
			 alert( "Invalid email address" );
			 document.subscribe.subscriber_email.focus();
			 return false;
		}
}



function referralValidate()
	{	
		var email = /^.+@.+\..{2,3}$/;
		
		if (!(FormValidationElementHasValue(document.email_a_friend.realname)) || document.email_a_friend.realname.value == "your name")
		{
			alert( "Please enter your your name" );
      		document.email_a_friend.realname.focus();
	        return false;
		}
		
		if (!(FormValidationElementHasValue(document.email_a_friend.recipient)) || document.email_a_friend.recipient.value == "friend name")
		{
			alert( "Please enter the name of your friend" );
      		document.email_a_friend.recipient.focus();
	        return false;
		}
		
		if (!(FormValidationElementHasValue(document.email_a_friend.email)) || document.email_a_friend.email.value == "friend email")
		{
			alert( "Please enter your friend's email address" );
      		document.email_a_friend.email.focus();
	        return false;
		}
		
		if( !email.test(document.email_a_friend.email.value ) )
		{
			 alert( "Invalid email address" );
			 document.email_a_friend.email.focus();
			 return false;
		}		
}



function FormValidationElementHasValue(formElementObject)
{
  if (!(FormValidationCanValidateElement(formElementObject)))
  {
    return false;
  }
  if ((formElementObject.type == "file") ||
      (formElementObject.type == "text") ||
      (formElementObject.type == "textarea") ||
      (formElementObject.type == "password"))
  {
    return FormValidationIsStringEmpty(formElementObject.value) ? false : true;
  }
  else if ((formElementObject.type == "select-one") ||
           (formElementObject.type == "select-multiple"))
  {
    if (formElementObject.selectedIndex < 0)
    {
      return false;
    }
    if (FormValidationIsStringEmpty(formElementObject.options[formElementObject.selectedIndex].value))
    {
      return false;
    }
  }
  else if ((formElementObject.type == "checkbox") ||
           (formElementObject.type == "radio") ||
           (formElementObject.length))
  {
    if (formElementObject.length)
    {
      for (var i = 0; i < formElementObject.length; i++)
      {
        if (formElementObject[i].checked)
        {
          return true;
        }
      }
      return false;
    }
    else
    {
      return formElementObject.checked;
    }
  }
  return true;
}

function FormValidationCanValidateElement(formElementObject)
{
  if (formElementObject.length)
  {
    return true;
  }
  if (!(formElementObject.type))
  {
    return false;
  }
  if (formElementObject.type == "button")
  {
    return false;
  }
  if (formElementObject.type == "hidden")
  {
    return false;
  }
  if (formElementObject.type == "image")
  {
    return false;
  }
  if (formElementObject.type == "reset")
  {
    return false;
  }
  if (formElementObject.type == "submit")
  {
    return false;
  }
  return true;
}

function FormValidationIsStringEmpty(stringValue)
{
  if (stringValue == "")
  {
    return true;
  }
  if (/^\s+$/.test(stringValue))
  {
    return true;
  }
  return false;
}


function openPopWin(winURL, winWidth, winHeight, winScroll) {
        var winOptions = 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=' + winScroll + ',resizable=no,width=' + winWidth + ',height=' + winHeight;
        popup = window.open(winURL, 'popup', winOptions);
    }

    function openPopWinResizable(winURL, winWidth, winHeight, winScroll) {
        var winOptions = 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=' + winScroll + ',resizable=yes,width=' + winWidth + ',height=' + winHeight;
        popup = window.open(winURL, 'popup', winOptions);
    }

    function closePopWin() {
        if (popup && popup.open && ! popup.closed) popup.close();
    }
	
	
function showForm()	{
	var formVar = document.getElementById("notify_friend_fieldset");
		if (formVar.className == "hidden") {
			formVar.className = "show";
		}
		else if (formVar.className == "show") {
			formVar.className = "hidden";
		}
	}
	
	
function activeToc ()
{
	var divs = document.getElementsByTagName('div');
	var headers = document.getElementsByTagName('h1');
	for(i=0; i<headers.length; i++)
	{
		if (headers[i].className == "as_title")
		{
			var mainHeader = headers[i].innerHTML;
			var chars = mainHeader.length;
		}
	}
	
	for(i=0; i<divs.length; i++)
	{
		if (divs[i].className == "as_toc")
		{
			var links = divs[i].getElementsByTagName('li');
			for(j=0; j<links.length; j++)
			{
					links[j].className = "";
			}
			for(k=0; k<links.length; k++)
			{
				var marker = links[k].innerHTML.indexOf('>');
				var testerA = links[k].innerHTML.substr(marker + 1, chars);
				if(testerA == mainHeader)
				{
					links[k].className = "active";
					links[k].innerHTML = "<a>" + mainHeader + "</a>"
				}
			}
		}
	}			
}	


function expandFAQ()
{
	var paragraphs = document.getElementById("left_col").getElementsByTagName("p");
	var questions = document.getElementById("left_col").getElementsByTagName("strong");
	var answers = document.getElementById("left_col").getElementsByTagName("span");
	for(var i=0; i<answers.length; i++)
	{
		questions[i].style.cursor = "pointer";
		answers[i].style.display = "none";
	}
	for(var j=0; j<questions.length; j++)
	{
		paragraphs[j].firstChild.onclick = function()
		{
			this.style.color = "#5C5F0C";
			var currentAnswer = this.parentNode.getElementsByTagName("span");
			for(var k=0; k<currentAnswer.length; k++)
			{
				if(currentAnswer[k].style.display == "none")
				{
					currentAnswer[k].style.display = "inline";
				}
				else
				{
					currentAnswer[k].style.display = "none";
					this.style.color = "#999E11";
				}
			}
		}
	}
	activeToc();
}
