// JavaScript Document
function MM_findObj(n, d) 
{
  //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() 
{
  //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj=MM_findObj(args[i]))!=null)
    {
      v=args[i+2];
      if (obj.style) 
  	  {
	    obj=obj.style;
	    v=(v=='show')?'visible':(v=='hide')?'hidden':v;
	  }
      obj.visibility=v;
    }
  }
}

function MM_showHideSendEmail() 
{
  var i,p,v,obj,args=MM_showHideSendEmail.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj=MM_findObj(args[i]))!=null)
    {
      v=args[i+2];
      if (obj.style) 
  	  {
	    obj=obj.style;
	  }
	  if (v=='show' || obj.display=='none')
	  {
	    obj.display='block';		  
	  }
	  else
	  {
	    obj.display='none';
	  }
    }
  }
}

function MM_showHidePositionLayers() 
{
  var x = 0;
  var y = 0;
  var i,p,v,obj,e,args=MM_showHidePositionLayers.arguments;
  for (i=0; i<(args.length-3); i+=4)
  {
    if ((obj=MM_findObj(args[i]))!=null)
    {
	  if (document.all)
	  {
		x = event.clientX + document.documentElement.scrollLeft - 200;
		y = event.clientY + document.documentElement.scrollTop;
	  }
	  else
	  {
		e = args[i+3];  
		x = e.pageX - 200;
		y = e.pageY;	  
	  }		
      v=args[i+2];
      if (obj.style) 
  	  {
	    obj=obj.style;
	  }
	  if (v=='show')
	  {
	    obj.visibility='visible';
		obj.top = y + 'px';
		obj.left = x + 'px';
	  }
	  else if (v=='hide')
	  {
	    obj.visibility='hidden';
	  }
    }
  }
}

function checkSendEmailForm(form)
{
  if (form.to_name.value == "")
  {
    alert("Please enter your friend's name.");
    form.to_name.focus();
    form.to_name.select();
    return false;
  }
  toHasDot = form.to_email.value.indexOf(".");
  toHasAt = form.to_email.value.indexOf("@");
  if (toHasDot == -1 || toHasAt == -1)
  {
	alert("Please enter a valid email address for your friend.");
	form.to_email.focus();
	form.to_email.select();
	return false;
  }
  if (form.from_name.value == "")
  {
    alert("Please enter your name.");
    form.from_name.focus();
    form.from_name.select();
    return false;
  }
  fromHasDot = form.from_email.value.indexOf(".");
  fromHasAt = form.from_email.value.indexOf("@");
  if (fromHasDot == -1 || fromHasAt == -1)
  {
	alert("Please enter a valid email address in the 'Your Email' box.");
	form.from_email.focus();
	form.from_email.select();
	return false;
  }
  alert("Thank you. Your email to " + form.to_name.value + " will be sent as soon as you press OK.");
  return true; 
}	

function clearTextField(field)
{
  field.value="";
}

function sf_log_out()
{
  ht = document.getElementsByTagName("html");
  ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
  if (confirm('Are you sure you want to log out?'))
  {
	return true;
  }
  else
  {
	ht[0].style.filter = "";
	return false;
  }
}

function CheckSS(form)
{
  hasDot = form.email.value.indexOf(".");
  hasAt = form.email.value.indexOf("@");
  if (hasDot == -1 || hasAt == -1)
	{
		alert("Please enter a valid email address.");
		form.email.focus();
		form.email.select();
		return false;
	}	
	return true;
}

function checkDonateForm(form)
{
  if (form.first_name.value == "")
  {
    alert("Please enter your first name.");
    form.first_name.focus();
    form.first_name.select();
	return false;
  }
  if (form.last_name.value == "")
  {
    alert("Please enter your last name.");
    form.last_name.focus();
    form.last_name.select();
	return false;
  }
  hasDot = form.email.value.indexOf(".");
  hasAt = form.email.value.indexOf("@");
  if (hasDot == -1 || hasAt == -1)
  {
    alert("Please enter a valid email address.");
	form.email.focus();
	form.email.select();
	return false;
  }   
  if (form.address.value == "")
  {
    alert("Please provide a street address.");
    form.address.focus();
    form.address.select();
	return false;
  }
  if (form.city.value == "")
  {
    alert("Please provide your city.");
    form.city.focus();
    form.city.select();
	return false;
  }
  if (form.state.value == "")
  {
    alert("Please provide your state.");
    form.state.focus();
    form.state.select();
    return false;
  }
  if (form.zip.value == "")
  {
    alert("Please provide your zip code.");
    form.zip.focus();
    form.zip.select();
    return false;
  }
  if (form.phone.value == "")
  {
    alert("Please provide a phone number in case we need to contact you regarding your donation.");
    form.phone.focus();
    form.phone.select();
	return false;
  }
  if (form.select_amount[0].checked == false &&
      form.select_amount[1].checked == false &&
      form.select_amount[2].checked == false &&
      form.select_amount[3].checked == false &&
      form.select_amount[4].checked == false &&
      form.select_amount[5].checked == false &&
      form.select_amount[6].checked == false &&
      form.select_amount[7].checked == false &&
      form.select_amount[8].checked == false &&
      form.select_amount[9].checked == false)
  {
    alert("Please specify an amount.");
	return false;
  }
  if (form.select_amount[9].checked == true &&
      form.other_amount.value == "")
  {
    alert("Please specify an amount.");
    return false;
  }
  if (form.select_amount[9].checked == true &&
      isCurrency(form.other_amount) == false)
  {
    alert("The amount you specified in 'Other Amount' is invalid. Please enter the amount using only the numerals 0-9 and a decimal point if needed. Commas and other characters are not valid.");
    return false;
  }	
  if (form.select_amount[9].checked == true &&
      isCurrency(form.other_amount) == true &&
      parseFloat(form.other_amount.value) < 10)
  {
    alert("We're sorry, but due to processing costs the minimum online credit card donation is $10. You can, however, send a check to the address listed on the bottom of this page.");
    return false;
  }		
  if (form.cc_number.value == "")
  {
    alert("Please provide your credit card number.");
    form.cc_number.focus();
    form.cc_number.select();
    return false;
  }	
  if (form.cc_type.value == "Visa")
  {
    validVisa = ((form.cc_number.value.length == 16 || form.cc_number.value.length == 13) && form.cc_number.value.substring(0,1) == 4);
    if (validVisa != true) 
	{
      alert("Please enter a valid Visa credit card number.");
      form.cc_number.focus();
      form.cc_number.select();
	  return false;
    }
  }
  if (form.cc_type.value == "MasterCard")
  {
    firstdig = form.cc_number.value.substring(0,1), seconddig=form.cc_number.value.substring(1,2);
	validMasterCard = (form.cc_number.value.length == 16 && firstdig == 5 && (seconddig >= 1 && seconddig <= 5));
	if (validMasterCard != true)
	{
      alert("Please enter a valid MasterCard credit card number.");
      form.cc_number.focus();
      form.cc_number.select();
	  return false;
    }
  }		
  document.donate.submit_donation.disabled = true;  
  return true; 
}

function clearOtherAmount()
{
    document.donate.other_amount.value = "";
}

<!-- Modified for this application on 3/22/05: Jamie McDaniel --> 
<!-- Original Credit Information-->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Derek J. Klingman (dklingman@quantumsoftware.net) -->
<!-- Web Site:  http://quantumsoftware.net -->
function isCurrency(input_text)
{
	var nNum = 0;			// Total numbers for currency value.
	var nDecimal = 0;		// Total times a decimal point occurs.
	var txtLen;				// Length of string passed.
	var xTxt;				// Assigned object passed.
	var decPos;				// Assigned value of numbers or positions after decimal point.
	var i;					// For forloop indexing.
	var x;					// Assigned each indivual character in string.

	// Set the xTxt variable to the object passed to this function.
	// Assign the length of the string to txtLen.
	xTxt = input_text;
	txtLen = xTxt.value.length

	for(i = 0; i < txtLen; i++)
	{
		// Assign charater in substring to x.
		x = xTxt.value.substr(i, 1);
		if(x == ".")
			nDecimal = nDecimal + 1; // Sum total times decimal point occurs.
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1; // If the character is a number sum total times a number occurs.
		else
		{
			// Error occurs if any other character value is in the string
			// othere then the valid characters.
			return false;
		} // end else
	} // end for

	if(nDecimal > 1)
	{
		return false;
	} // end if

	if(nDecimal == 1)
	{
		// Get the number of numbers after the decimal point in
		// the string if there is a decimal point present
		decPos = (txtLen - 1) - xTxt.value.indexOf(".");
		// Floating point cannot be more then two.
		// Valid format after decimal point.
		/**********************************/
		/*   $#.##, $#.#, $.#, $#., $.##  */
		/**********************************/
		if(decPos > 2)
		{
			return false;
		} // end if
	} // end if
	// Return true indicating that the value is a valid
	// currency.
	return true;
}

function checkOrderForm(form)
{
  if (form.first_name.value == "")
  {
    alert("Please enter your first name.");
    form.first_name.focus();
    form.first_name.select();
	return false;
  }
  if (form.last_name.value == "")
  {
    alert("Please enter your last name.");
    form.last_name.focus();
    form.last_name.select();
	return false;
  }
  hasDot = form.email.value.indexOf(".");
  hasAt = form.email.value.indexOf("@");
  if (hasDot == -1 || hasAt == -1)
  {
    alert("Please enter a valid email address.");
	form.email.focus();
	form.email.select();
	return false;
  }   
  if (form.address.value == "")
  {
    alert("Please provide a street address.");
    form.address.focus();
    form.address.select();
	return false;
  }
  if (form.city.value == "")
  {
    alert("Please provide your city.");
    form.city.focus();
    form.city.select();
	return false;
  }
  if (form.state.value == "")
  {
    alert("Please provide your state.");
    form.state.focus();
    form.state.select();
    return false;
  }
  if (form.zip.value == "")
  {
    alert("Please provide your zip code.");
    form.zip.focus();
    form.zip.select();
    return false;
  }
  if (form.phone.value == "")
  {
    alert("Please provide a phone number in case we need to contact you regarding your donation.");
    form.phone.focus();
    form.phone.select();
	return false;
  }
  if (form.cc_number.value == "")
  {
    alert("Please provide your credit card number.");
    form.cc_number.focus();
    form.cc_number.select();
    return false;
  }	
  if (form.cc_type.value == "Visa")
  {
    validVisa = ((form.cc_number.value.length == 16 || form.cc_number.value.length == 13) && form.cc_number.value.substring(0,1) == 4);
    if (validVisa != true) 
	{
      alert("Please enter a valid Visa credit card number.");
      form.cc_number.focus();
      form.cc_number.select();
	  return false;
    }
  }
  if (form.cc_type.value == "MasterCard")
  {
    firstdig = form.cc_number.value.substring(0,1), seconddig=form.cc_number.value.substring(1,2);
	validMasterCard = (form.cc_number.value.length == 16 && firstdig == 5 && (seconddig >= 1 && seconddig <= 5));
	if (validMasterCard != true)
	{
      alert("Please enter a valid MasterCard credit card number.");
      form.cc_number.focus();
      form.cc_number.select();
	  return false;
    }
  }	
  if (form.cc_amount.value == "0.00")
  {  
    alert("Your total amount is $0.00.  Please recheck you order.");
	return false;	
  }
  document.store.submit_order.disabled = true;  
  return true; 
}

function updateTotalPrice()
{
	var ta = 0;	
	var boxes = document.getElementsByName('qty[]').length;
	boxes = boxes * 4;  //This is 4 because there are 4 elements per product (3 inputs and 1 hidden)
	for (var i = 0; i < boxes; i=i+4)
	{
	  var q = parseInt(document.store.elements[i].value);
	  var q2 = parseFloat(document.store.elements[i].value);	
	  if (q < 0 || (q != q2) || isNaN(q)) //if an invalid quantity is entered, set it to zero
	  {
	    q = 0;
		document.store.elements[i].value = "0"
	  }
	  var p = document.store.elements[i+1].value;
	  p = p.substring(1); //strip the dollar sign
	  p = parseFloat(p);
	  var t = q * p;
	  document.store.elements[i+2].value = formatCurrency(t);	  
	  ta = ta + t;
	}
	ta = formatCurrency(ta);
	ta = ta.substring(1);
	document.store.cc_amount.value = ta;
}


<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

function formatCurrency(num)
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	{
	  num = "0";
	}
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	{
	  cents = "0" + cents;
	}
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	{
	  num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
	}
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function checkFreeBookletForm(form)
{
   if (form.first_name.value == "") {
     alert("Please fill out your First Name");
	 form.first_name.focus();
	 form.first_name.select();	 
	 return false;
   }
   if (form.last_name.value == "") {
     alert("Please fill out your Last Name");
	 form.last_name.focus();
	 form.last_name.select();		 
	 return false;
   }
   if (form.address.value == "") {
     alert("Please fill out your Street Address");
	 form.address.focus();
	 form.address.select();		 
	 return false;
   }
   if (form.city.value == "") {
     alert("Please fill out your City");
	 form.city.focus();
	 form.city.select();		 
	 return false;
   }
   if (form.zip.value == "") {
     alert("Please fill out your Zip");
	 form.zip.focus();
	 form.zip.select();		 
	 return false;
   }         
   toHasDot = form.email.value.indexOf(".");
   toHasAt = form.email.value.indexOf("@");
   if (toHasDot == -1 || toHasAt == -1)
   {
	   alert("Please enter a valid email address.");
	   form.email.focus();
	   form.email.select();
	   return false;
   }
  return true; 
}	

function checkOnlineReviewForm(form)
{
   tinyMCE.triggerSave(); 
   if (form.review_title.value == "") {
     alert("Please enter a title for your review");
	 form.review_title.focus();
	 form.review_title.select();	 
	 return false;
   }
   if (form.star_rating.value == "-") {
     alert("Please select a star rating for your review");
	 form.star_rating.focus();
	 return false;
   }  
   if (form.editor_content.value.length <= 20) {
     alert("The text of your review needs to be longer than 20 characters.");
	 return false;
   }
  document.review.submit_review.disabled = true;    
  return true; 
}	 

function checkPetitionForm(form)
{
   if (form.first_name.value == "") {
     alert("Please fill out your First Name");
	 form.first_name.focus();
	 form.first_name.select();	 
	 return false;
   }
   if (form.last_name.value == "") {
     alert("Please fill out your Last Name");
	 form.last_name.focus();
	 form.last_name.select();		 
	 return false;
   }
   if (form.address1.value == "" && form.address2.value == "") {
     alert("Please fill out your Street Address");
	 form.address1.focus();
	 form.address1.select();		 
	 return false;
   }
   if (form.city.value == "") {
     alert("Please fill out your City");
	 form.city.focus();
	 form.city.select();		 
	 return false;
   }
   if (form.state.value == "") {
     alert("Please fill out your State/Province. If you live in a country that does not use State/Province please type the word none.");
	 form.state.focus();
	 form.state.select();		 
	 return false;
   }
   if (form.zip.value == "") {
     alert("Please fill out your Zip/Postal code.  If you live in a country that does not use a Zip/Postal code, please type the word none.");
	 form.zip.focus();
	 form.zip.select();		 
	 return false;
   }         
   toHasDot = form.email.value.indexOf(".");
   toHasAt = form.email.value.indexOf("@");
   if (toHasDot == -1 || toHasAt == -1)
   {
	   alert("Please enter a valid email address.");
	   form.email.focus();
	   form.email.select();
	   return false;
   }
  document.petition.submit_petition.disabled = true;    
  return true; 
}	

function holidaycardUpdate(num)
{
	if (confirm("Refreshing the page to show " + num + " address boxes will erase the current addresses entered. Do you want to do this?"))
	{
	  location.href="http://www.soulforce.org/application.php?application=holidaycard&num_cards=" + num;
	}
	else
	{
	  document.donate.number_cards.value = document.donate.num_cards.value;
	}
}

function holidaycardAddressList(check)
{
	if (check == "yes")
	{
	  MM_showHideSendEmail('hc_mailing_list','','hide');
	}
	else
	{
	  MM_showHideSendEmail('hc_mailing_list','','show');
	}	
}

function checkHolidayCardForm(form)
{
  num = parseInt(form.num_cards.value) * 5 //This is 5 because there are 5 elements per card address;
  card_num = 1;
  if (form.email_list.checked == false)
  {	  
    for (var i = 3; i < num; i=i+5) //i starts at 3 because element[3] is the name for the first card, and that is where we want to start at. 
    {
      if (document.donate.elements[i].value == "")
      {
        alert("Please enter the Name for Card #" + card_num);
        document.donate.elements[i].focus();
        document.donate.elements[i].select();
	    return false;
      }
      if (document.donate.elements[i+1].value == "")
      {
        alert("Please enter the Address for Card #" + card_num);
        document.donate.elements[i+1].focus();
        document.donate.elements[i+1].select();
	    return false;
      }
      if (document.donate.elements[i+2].value == "")
      {
        alert("Please enter the City for Card #" + card_num);
        document.donate.elements[i+2].focus();
        document.donate.elements[i+2].select();
	    return false;
      }
      if (document.donate.elements[i+4].value == "")
      {
        alert("Please enter the Zip for Card #" + card_num);
        document.donate.elements[i+4].focus();
        document.donate.elements[i+4].select();
	    return false;
      }
	  card_num = card_num + 1;
    }
  }
  if (checkDonateForm(form))
  {
    return true;
  }
  return false;
}

function checkFamilyMarchForm(form)
{
   if (form.first_name.value == "") {
     alert("Please fill out your First Name");
	 form.first_name.focus();
	 form.first_name.select();	 
	 return false;
   }
   if (form.last_name.value == "") {
     alert("Please fill out your Last Name");
	 form.last_name.focus();
	 form.last_name.select();		 
	 return false;
   }
   if (form.address1.value == "" && form.address2.value == "") {
     alert("Please fill out your Street Address");
	 form.address1.focus();
	 form.address1.select();		 
	 return false;
   }
   if (form.city.value == "") {
     alert("Please fill out your City");
	 form.city.focus();
	 form.city.select();		 
	 return false;
   }
   if (form.state.value == "") {
     alert("Please fill out your State");
	 form.state.focus();
	 form.state.select();		 
	 return false;
   }
   if (form.zip.value == "") {
     alert("Please fill out your Zip");
	 form.zip.focus();
	 form.zip.select();		 
	 return false;
   }  
  if (form.phone.value == "")
  {
    alert("Please provide a phone number in case we need to contact you by phone regarding your application.");
    form.phone.focus();
    form.phone.select();
	return false;
  }   
   toHasDot = form.email.value.indexOf(".");
   toHasAt = form.email.value.indexOf("@");
   if (toHasDot == -1 || toHasAt == -1)
   {
	   alert("Please enter a valid email address.");
	   form.email.focus();
	   form.email.select();
	   return false;
   }
   if (form.question1.value == "" || form.question2.value == "" || form.question3.value == "" || form.question6.value == "") {
     alert("Please fill out answers to the questions in the section \"Tell Us More About Your Family.\" ");
	 return false;
   }   
  document.familymarch.submit_application.disabled = true;    
  return true; 
}

function checkNYMarriageRideForm(form)
{
   if (form.first_name.value == "") {
     alert("Please fill out your First Name");
	 form.first_name.focus();
	 form.first_name.select();	 
	 return false;
   }
   if (form.last_name.value == "") {
     alert("Please fill out your Last Name");
	 form.last_name.focus();
	 form.last_name.select();		 
	 return false;
   }
   if (form.address1.value == "" && form.address2.value == "") {
     alert("Please fill out your Street Address");
	 form.address1.focus();
	 form.address1.select();		 
	 return false;
   }
   if (form.city.value == "") {
     alert("Please fill out your City");
	 form.city.focus();
	 form.city.select();		 
	 return false;
   }
   if (form.state.value == "") {
     alert("Please fill out your State");
	 form.state.focus();
	 form.state.select();		 
	 return false;
   }
   if (form.zip.value == "") {
     alert("Please fill out your Zip");
	 form.zip.focus();
	 form.zip.select();		 
	 return false;
   }  
  if (form.phone.value == "")
  {
    alert("Please provide a phone number in case we need to contact you by phone regarding your application.");
    form.phone.focus();
    form.phone.select();
	return false;
  }   
   toHasDot = form.email.value.indexOf(".");
   toHasAt = form.email.value.indexOf("@");
   if (toHasDot == -1 || toHasAt == -1)
   {
	   alert("Please enter a valid email address.");
	   form.email.focus();
	   form.email.select();
	   return false;
   }
   if (form.question1.value == "" || form.question2.value == "" || form.question6.value == "" || form.question7.value == "" || form.question8.value == "") {
     alert("Please fill out answers to the questions in the section \"Questions\" ");
	 return false;
   }   
  document.nymarriageride.submit_application.disabled = true;    
  return true; 
}

function checkEqualityRideApplicationForm(form)
{
   if (form.first_name.value == "")
   {
     alert("Please fill out your First Name");
	 form.first_name.focus();
	 form.first_name.select();	 
	 return false;
   }
   if (form.last_name.value == "")
   {
     alert("Please fill out your Last Name");
	 form.last_name.focus();
	 form.last_name.select();		 
	 return false;
   }
   if (form.address1.value == "" && form.address2.value == "")
   {
     alert("Please fill out your Street Address");
	 form.address1.focus();
	 form.address1.select();		 
	 return false;
   }
   if (form.city.value == "")
   {
     alert("Please fill out your City");
	 form.city.focus();
	 form.city.select();		 
	 return false;
   }
   if (form.state.value == "")
   {
     alert("Please fill out your State");
	 form.state.focus();
	 form.state.select();		 
	 return false;
   }
   if (form.zip.value == "")
   {
     alert("Please fill out your Zip");
	 form.zip.focus();
	 form.zip.select();		 
	 return false;
   }  
  if (form.phone.value == "")
  {
    alert("Please provide a phone number in case we need to contact you by phone regarding your application.");
    form.phone.focus();
    form.phone.select();
	return false;
  }   
   toHasDot = form.email.value.indexOf(".");
   toHasAt = form.email.value.indexOf("@");
   if (toHasDot == -1 || toHasAt == -1)
   {
	   alert("Please enter a valid email address.");
	   form.email.focus();
	   form.email.select();
	   return false;
   }  
   if (form.birth_month.value == "" || form.birth_year.value == "")
   {
     alert("Please fill out your birth date");	 
	 return false;
   } 
   document.equalityride.submit_application.disabled = true;    
   return true; 
}

function checkAFOForm(form)
{
   if (form.first_name.value == "") {
     alert("Please fill out your First Name");
	 form.first_name.focus();
	 form.first_name.select();	 
	 return false;
   }
   if (form.last_name.value == "") {
     alert("Please fill out your Last Name");
	 form.last_name.focus();
	 form.last_name.select();		 
	 return false;
   }
   if (form.address1.value == "" && form.address2.value == "") {
     alert("Please fill out your Street Address");
	 form.address1.focus();
	 form.address1.select();		 
	 return false;
   }
   if (form.city.value == "") {
     alert("Please fill out your City");
	 form.city.focus();
	 form.city.select();		 
	 return false;
   }
   if (form.zip.value == "") {
     alert("Please fill out your Zip");
	 form.zip.focus();
	 form.zip.select();		 
	 return false;
   }  
  if (form.phone.value == "")
  {
    alert("Please provide a phone number in case we need to contact you by phone regarding your application.");
    form.phone.focus();
    form.phone.select();
	return false;
  }   
   toHasDot = form.email.value.indexOf(".");
   toHasAt = form.email.value.indexOf("@");
   if (toHasDot == -1 || toHasAt == -1)
   {
	   alert("Please enter a valid email address.");
	   form.email.focus();
	   form.email.select();
	   return false;
   }
   if (form.question4.value == "" || form.question5.value == "" || form.question6.value == "" || form.question9.value == "") {
     alert("Please fill out answers to the questions in the section \"Questions\". Questions 4, 5, 6, and 9 are required.");
	 return false;
   }   
  document.afo.submit_application.disabled = true;    
  return true; 
}

function checkRegistrationForm(form)
{
   if (form.first_name.value == "") {
     alert("Please fill out your First Name");
	 form.first_name.focus();
	 form.first_name.select();	 
	 return false;
   }
   if (form.last_name.value == "") {
     alert("Please fill out your Last Name");
	 form.last_name.focus();
	 form.last_name.select();		 
	 return false;
   }
   if (form.address1.value == "" && form.address2.value == "") {
     alert("Please fill out your Street Address");
	 form.address1.focus();
	 form.address1.select();		 
	 return false;
   }
   if (form.city.value == "") {
     alert("Please fill out your City");
	 form.city.focus();
	 form.city.select();		 
	 return false;
   }
   if (form.zip.value == "") {
     alert("Please fill out your Zip");
	 form.zip.focus();
	 form.zip.select();		 
	 return false;
   }  
   if (form.phone.value == "") {
     alert("Please fill out your Phone Number");
	 form.phone.focus();
	 form.phone.select();		 
	 return false;
   }    
   toHasDot = form.email.value.indexOf(".");
   toHasAt = form.email.value.indexOf("@");
   if (toHasDot == -1 || toHasAt == -1)
   {
	   alert("Please enter a valid email address.");
	   form.email.focus();
	   form.email.select();
	   return false;
   }
  document.registration.submit_registration.disabled = true;    
  return true; 
}	

function checkLetterCampaignForm(form)
{
   tinyMCE.triggerSave(); 
   if (form.first_name.value == "") {
     alert("Please fill out your First Name");
	 form.first_name.focus();
	 form.first_name.select();	 
	 return false;
   }
   if (form.last_name.value == "") {
     alert("Please fill out your Last Name");
	 form.last_name.focus();
	 form.last_name.select();		 
	 return false;
   }
   if (form.address1.value == "" && form.address2.value == "") {
     alert("Please fill out your Street Address");
	 form.address1.focus();
	 form.address1.select();		 
	 return false;
   }
   if (form.city.value == "") {
     alert("Please fill out your City");
	 form.city.focus();
	 form.city.select();		 
	 return false;
   }
   if (form.state.value == "") {
     alert("Please fill out your State");
	 form.state.focus();
	 form.state.select();		 
	 return false;
   }
   if (form.zip.value == "") {
     alert("Please fill out your Zip");
	 form.zip.focus();
	 form.zip.select();		 
	 return false;
   }  
   toHasDot = form.email.value.indexOf(".");
   toHasAt = form.email.value.indexOf("@");
   if (toHasDot == -1 || toHasAt == -1)
   {
	   alert("Please enter a valid email address.");
	   form.email.focus();
	   form.email.select();
	   return false;
   }
   if (form.picture_caption.value == "" && form.picture_file.value != "")
   {
      alert("Please enter a caption for the picture you are uploading.");
      form.picture_caption.focus();
      form.picture_caption.select();
	  return false;
   }
   if (form.editor_content.value.length <= 20)
   {
      alert("The text of your letter needs to be longer than 20 characters.");
	  return false;	   
   }
   //MM_showHideLayers('cover_ie_control','','show','upload_progress','','show');

   if (form.picture_file.value != "")
   {
     var progress_win;
     var editor_pos = findPos(document.getElementById('editor_wrapper'));
     var widget_x = editor_pos[0] + 30;
     var widget_y = editor_pos[1] + 200;   
     progress_win = new YAHOO.widget.Panel("progress_win", { width:"420px", x:widget_x, y:widget_y, fixedcenter:false, underlay:"shadow", close:false, draggable:false, modal:true, effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.3} } );
     progress_win.setHeader("Uploading "+document.getElementById('picture_file').value+" ...");
     progress_win.setBody('Do not close this window until upload is complete. Depending on the file size and your internet connection, uploading your file could take a few minutes.');
	 //progress_win.setBody('<div style="height: 1em; width: 400px; border:1px solid #000;"> <div id="pbar" style="background: #99e; height: 98%; width:0%; float:left;">&nbsp;</div> <div id="ppct" style="height: 90%; position: absolute; margin: 1 0 0 185;">0%</div></div><div id="ptxt" style="margin: 3 0 0 5">0 of 0 bytes</div>');
     progress_win.render(document.body);
   }
   document.lettercampaign.submit_letter.disabled = true;    
   return true; 
}

function findPos(obj)
{
  var curleft = curtop = 0;
  if (obj.offsetParent)
  {
    curleft = obj.offsetLeft
	curtop = obj.offsetTop
	while (obj = obj.offsetParent)
	{
	  curleft += obj.offsetLeft
	  curtop += obj.offsetTop
	}
  }
  return [curleft,curtop];
}

//v1.1
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
//These functions are for writing Flash and ActiveX content with Javascript in order to avoid the "Click to activate this control" problem in Internet Explorer
//source: www.adobe.com/devnet/activecontent/articles/devletter.html
function AC_AX_RunContent(){
  var ret = AC_AX_GetArgs(arguments);
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_YouTube_RunContent(){
  //This is a function created by Jamie McDaniel on 2/25/2007 specifically for YouTube and Google video. 
  var ret = AC_AX_GetArgs(arguments);
  AC_GenerateEmbed(ret.embedAttrs);
}

function AC_AX_GetArgs(args){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "pluginspage":
      case "type":
      case "src":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "data":
      case "codebase":
      case "classid":
      case "id":
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  return ret;
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_GenerateEmbed(embedAttrs) 
{ 
//This is a modified version of the AC_Generateobj function created by Adobe.  For YouTube and Google video files, I needed just the <embed> tag.  Otherwise
//if you wrap <embed> in the <object> tag (like the original AC_Generateobj function does) you get the "Click to Activate This Control" problem in Internet Explorer
  var str = '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
