var xmlHttp


function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
 } 
 setTimeout('history.go(0)',3000);
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function Validate_String(string, return_invalid_chars) {
  valid_chars = '1234567890-_.^~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  invalid_chars = '';
  if(string == null || string == '')
     return(true);

  //For every character on the string.   
  for(index = 0; index < string.length; index++) {
    char = string.substr(index, 1);                        
     
    //Is it a valid character?
    if(valid_chars.indexOf(char) == -1) {
      //If not, is it already on the list of invalid characters?
      if(invalid_chars.indexOf(char) == -1) {
        //If it's not, add it.
        if(invalid_chars == '')
          invalid_chars += char;
        else
          invalid_chars += ', ' + char;
      }
    }
  }
            
  //If the string does not contain invalid characters, the function will return true.
  //If it does, it will either return false or a list of the invalid characters used
  //in the string, depending on the value of the second parameter.
  if(return_invalid_chars == true && invalid_chars != '') {
    last_comma = invalid_chars.lastIndexOf(',');
    if(last_comma != -1)
      invalid_chars = invalid_chars.substr(0, $last_comma) + 
      ' and ' + invalid_chars.substr(last_comma + 1, invalid_chars.length);
    return(invalid_chars);
    }
  else
    return(invalid_chars == ''); 
}


function Validate_Email_Address(email_address){
  // Modified and tested by Thai Cao Phong, JavaScriptBank.com
  //Assumes that valid email addresses consist of user_name@domain.A
  
  at = email_address.indexOf('@');
  dot = email_address.indexOf('.');

  if(at == -1 || 
    dot == -1 || 
    dot <= at + 1 ||
    dot == 0 || 
    dot == email_address.length - 1)
  {
  	
    return(false);
  }
     
  user_name = email_address.substr(0, at);
  domain_name = email_address.substr(at + 1, email_address.length);                  

  if(Validate_String(user_name) === false || Validate_String(domain_name) === false)
  {
  	
    return(false);
  }

  return(true);
}



function  submitmailing(){  // This function does the AJAX request
divid="mailinglist";

 if(document.getElementById("email2").value&&Validate_Email_Address(document.getElementById("email2").value)&&(document.getElementById("newsletterlist").checked || document.getElementById("volunteerlist").checked || document.getElementById("eventslist").checked )){
	http.open("POST", "mailing_ajax.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
 var params = "email2="+document.getElementById("email2").value+"&events="+document.getElementById("eventslist").checked+"&news="+document.getElementById("newsletterlist").checked+"&volun="+document.getElementById("volunteerlist").checked;
	

  //Set our POST header correctly…
 http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 http.setRequestHeader("Content-length", params.length);
 http.setRequestHeader("Connection", "close");

  // Send the parms data…
 http.send(params);

 }
}


function  submitmailingheart(){  // This function does the AJAX request
divid="mailinglist";

 if(document.getElementById("email2").value&&Validate_Email_Address(document.getElementById("email2").value)&&document.getElementById("newsletterlist").checked ){
	http.open("POST", "mailing_ajaxheart.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
 var params = "email2="+document.getElementById("email2").value+"&news="+document.getElementById("newsletterlist").checked;
	

  //Set our POST header correctly…
 http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 http.setRequestHeader("Content-length", params.length);
 http.setRequestHeader("Connection", "close");

  // Send the parms data…
 http.send(params);

 }
}
function hidedetails(){
	document.getElementById('donationshidediv').style.display = 'none'; 
}

function monthlydonation() {  // This function does the AJAX request
divid="donationsajaxdiv";



 document.getElementById('donationshidediv').style.display = 'block'; 


 http.open("POST", "donations_ajax.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
 var params = "amount="+document.getElementById("amount").value;
	

  //Set our POST header correctly…
 http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 http.setRequestHeader("Content-length", params.length);
 http.setRequestHeader("Connection", "close");

  // Send the parms data…
 http.send(params);


}

function singledonation() {  // This function does the AJAX request
divid="donationsajaxdiv";



 document.getElementById('donationshidediv').style.display = 'block'; 




 http.open("POST", "donations_ajax.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
 var params = "amount=single";
	

  //Set our POST header correctly…
 http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 http.setRequestHeader("Content-length", params.length);
 http.setRequestHeader("Connection", "close");

  // Send the parms data…
 http.send(params);


}

//----------------ajax





function getHttpRes( ) {
  if (http.readyState == 4 && http.status == 200) { 
    res = http.responseText;  // These following lines get the response and update the page

	document.getElementById(divid).innerHTML = res;

	

  }
}

function getXHTTP( ) {
  var xhttp;
   try {   // The following "try" blocks get the XMLHTTP object for various browsers…
      xhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
 		 // This block handles Mozilla/Firefox browsers...
	    try {
	      xhttp = new XMLHttpRequest();
	    } catch (e3) {
	      xhttp = false;
	    }
      }
    }
  return xhttp; // Return the XMLHTTP object
}

var http = getXHTTP(); // This executes when the page first loads.
var divid="";


