// JavaScript Document

function contact_industry(s){
  if(s=='Other'){
    document.getElementById('other_industry_div').style.display='block';
  }
}

function _ltrim(s){
	var w = " \n\t\f";
	// remove all beginning white space
	while( w.indexOf(s.charAt(0)) != -1 && s.length != 0 ) s = s.substring(1);
	return s;
}

function signup() {
myerror="blah";
var theval = document.getElementById('signupformemail').value;

if( _ltrim(theval).length == 0 ){
		myerror = "Please enter an email address.";
  } else if ( theval.indexOf(" ") != -1 ){
		myerror = "Invalid email address. An e-mail address should not contain a space.";
	} else if( theval.indexOf("@") == -1 ){
		myerror = "Invalid email address. An e-mail address must contain the @ symbol.";
	} else if( theval.indexOf("@") == 0 ){
		myerror = "Invalid email address. The @ symbol can not be the first character of an e-mail address.";
	} else if( theval.substring(theval.indexOf("@")+2).indexOf(".") == -1 ){
		myerror = "Invalid email address. An e-mail address must contain at least one period after the @ symbol.";
	} else if( theval.lastIndexOf("@") == theval.length-1 ){
		myerror = "Invalid email address. The @ symbol can not be the last character of an e-mail address.";
	} else if( theval.lastIndexOf(".") == theval.length-1 ){
		myerror = "Invalid email address. A period can not be the last character of an e-mail address.";

	}

if (myerror!=='blah'){
alert(myerror);
return false;
}
else
{

	
var xmlHttp;
try
  {  
  // Firefox, Opera 8.0+, Safari  
  xmlHttp=new XMLHttpRequest();  
  }
catch (e)
  {  
  // Internet Explorer  
  try
    {    
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
    }
  catch (e)
    {    
    try
      {      
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
      }
    catch (e)
      {      
      alert("Your browser does not support AJAX!");
      return false;      
      }    
    }  
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById('signupconfirm').innerHTML='Thank You!';
      document.getElementById('signupformcell').innerHTML="";
      }
    }
    
  var themailerURL = 'newsletter.php?e=' + theval;
  
  //alert(themailerURL);
  
  xmlHttp.open("GET",themailerURL,true);
  xmlHttp.send(null);  
  }
  
  
  
  }
