
function show_volunteer_div()
{
if(document.getElementById('volunteer_formyes').style.display != 'block')
{
	document.getElementById('volunteer_formyes').style.display = "block";
	document.getElementById('vb').className = 'volunteer_bn_big_on';
}
	else 
	{
		document.getElementById('volunteer_formyes').style.display = "none";
		document.getElementById('vb').className = 'volunteer_bn_big';
	}
}


function show_topbar_div(target)
{
	document.getElementById('topbar').style.display = "block";
	eval("document.getElementById('"+target+"').style.display = 'none'");
	document.getElementById('email_thanks').style.display = 'none';
	 document.getElementById('email_error').style.display = 'none';
	 document.getElementById('sponsor_thanks').style.display = 'none';
	 document.getElementById('donation_thanks').style.display = 'none';
	 
}

function show_email_div(target)
{
    document.getElementById('topbar').style.display = "none";
    eval("document.getElementById('"+target+"').style.display = 'block'");
    
}

// services: newsletter, sponsor, donation
function email_submit(service)
{

target_email = document.forms['record_email'].target_email.value;
if(!echeck(target_email)){
     document.getElementById('email_error').style.display = 'block';
     document.getElementById('email_thanks').style.display = 'none';
     }
else {
if(service == 'newsletter'){  document.getElementById('emailtopbar').style.display = 'none'; document.getElementById('email_thanks').style.display = 'block';}
if(service == 'sponsor'){  document.getElementById('sponsortopbar').style.display = 'none'; document.getElementById('sponsor_thanks').style.display = 'block';}
if(service == 'donation'){  document.getElementById('donatetopbar').style.display = 'none'; document.getElementById('donation_thanks').style.display = 'block';}

    document.getElementById('email_error').style.display = 'none';

// turn off the other divs.    

  // call your xmladdemail.php and add the email accourding to service.
//  alert('good');
    loademail(target_email,service);
    }
}

function check_email(target_email)
{
document.forms['record_email'].target_email.value = target_email;
// alert(document.forms['record_email'].target_email.value);

}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		     
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		     
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false
		 }

 		 return true					
	}
 


var xmlhttp;

function loadXMLDoc(url)
{
  //alert('loadingXMLDoc:'+ url) good good... next check xml

xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for all new browsers
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5 and IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function loademail(target,service)
{
 
  // alert('in loademail:' + target  + 'service:' + service);

// it seems that httpxml can't send the '#' so lets strip them out. &#60; &lt;
// php filter won't see the variable until it is too late. || target.charAt(i) != '<' || target.charAt(i) != '&#60;'  || target.charAt(i) != '&lt;'

targetemail = 'xmladdemail.php?target_email=' + target + '&service=' + service;

loadXMLDoc(targetemail);
}



function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {
	// 200 = OK
 
 document.getElementById('emailresult').innerHTML=xmlhttp.responseText;
    }
  else
    {
 //   alert("Problem retrieving XML data");
    }
  }
}



loadXMLDoc('xmladdemail.php?target_email=$target_email&service=$service');