var xmlhttp;

//function showUser(str)
function showUser()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }

//$(.error.hide());
//var email= document.getElementById("email");
var email = document.ajaxradioform.email.value; //gets email 
for (var i=0; i < document.ajaxradioform.myradio.length; i++)
   {
   if (document.ajaxradioform.myradio[i].checked)
      {
      var radiovalue = document.ajaxradioform.myradio[i].value; //gets radiovalue (either 'subscribe' or 'unsubscribe')
      }
   }


var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
//	if(elem.value.match(emailExp)){
//	if(email.match(emailExp)){
//	if (email=emailExp)
//		return true;
//alert("dfdf");
//	}else{
//		alert("email not valid");
//		email.focus();
//		return false;
//	}
//document.getElementById('mailerror').style.visibility = 'visible'; 

//var t=setTimeout("alert('5 seconds!')",5000);


if ((!email) || (!email.match(emailExp))){
//	alert("Please enter a valid email!");
document.getElementById('mailerror').style.visibility = 'visible'; 
return false;
}
	

else
	{
document.getElementById('mailerror').style.visibility = 'hidden'; //hide the error message
document.getElementById('button').disabled=true; //disable the button
var t=setTimeout("document.getElementById('button').disabled=false", 5000);// re-enable the button after 5 seconds
var url="getuser.php";
//url=url+"?q="+str;
//url=url+"?radiovalue=" +radiovalue +str;
//url=url+"?radiovalue=" +radiovalue +email;//no radio value is both
//url=url+"?radiovalue=" +radiovalue +"?email=" +email;//no radio value is both
//url=url+"?radiovalue=" +radiovalue;//no these 2 together -radio val is both
//url=url+"?email=" +email;

url=url + "?radiovalue=" + radiovalue +"&email=" +email ;
//url=url+"?radiovalue=" +"?email=";//this works??
//url=url + radiovalue + email; //no
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
	}
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}