function show(which)
{
  window.scrollTo(0,0);
  document.getElementById("contactPopUp").style.display = "none";
  document.getElementById("newsletterPopUp").style.display = "none";
  
  document.getElementById(which).style.display = "block";
}

function closePopUp(which)
{
  document.getElementById(which).style.display = "none";
}

function signup(which)
{  
	id = which + "FName";
  var fname = document.getElementById(id).value;
  id = which + "LName";
  var lname = document.getElementById(id).value;
  id = which + "Email";
  var email = document.getElementById(id).value; 
  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email))
	{
    xmlHttpOp=GetXmlHttpObject();
  	if (xmlHttpOp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return
  	} 
  	
  	var url;
    if (which == "Signup")
    {
      document.getElementById("SignUpBtn").disabled = "disabled";
      document.getElementById("SignUpBtn").innerHTML = "Please Wait...";
      url = "ajax/newsletter.php";
      xmlHttpOp.onreadystatechange=ajaxSignup;
      url += "?category2="+fname+"%20"+lname+"&category3="+email;
      xmlHttpOp.open("GET", url, true);
      xmlHttpOp.send(null);
    }
    else
    {
      url="ajax/contact.php";
      var comments = document.getElementById("Comments").value;
      comments = escape(comments);
      url+="?fname="+fname+"&lname="+lname+"&email="+email+"&comments="+comments;
      xmlHttpOp.onreadystatechange=ajaxContact;
      xmlHttpOp.open("GET",url,true);
  	  xmlHttpOp.send(null);	
    }	
	}
	else 
  {
    alert("Incorrect email");
	}
  
}

function ajaxSignup()
{
  if (xmlHttpOp.readyState==4 || xmlHttpOp.readyState=="complete")
	{ 
	  //alert(xmlHttpOp.responseText);
	  if (xmlHttpOp.responseText == "1")
	  {
      document.getElementById("SignUpBtn").innerHTML = "Sign Up";
      show("newsletterPopUp");
    }
    else
    {    
      document.getElementById("SignUpBtn").innerHTML = "Error. Try later.";      
    }
  }
}

function ajaxContact()
{
  if (xmlHttpOp.readyState==4 || xmlHttpOp.readyState=="complete")
	{ 
    document.getElementById("contactcontent").innerHTML = "<span class='bold'>Contact received! We will respond to contacts where appropriate. You may now close this window.</span>";
  }
}

function download()
{
  location.href = "http://www.bestonlinebusinessresource.com/Secret_Strategies_for_Building_Wealth_ Independence.zip";
}

function clearMe(which)
{
  if (which == "Comments" && document.getElementById(which).innerHTML == "Comments")
    document.getElementById(which).innerHTML = "";
  else if ((which == "SignupFName" || which == "FName") && document.getElementById(which).value == "First Name")
    document.getElementById(which).value = "";
  else if ((which == "SignupLName" || which == "LName") && document.getElementById(which).value == "Last Name")
    document.getElementById(which).value = "";
  else if ((which == "SignupEmail" || which == "Email") && document.getElementById(which).value == "Email")
    document.getElementById(which).value = "";  
}

function fillMe(which)
{
  if (which == "Comments" && document.getElementById(which).innerHTML == "")
    document.getElementById(which).innerHTML = "Comments";
  else if ((which == "SignupFName" || which == "FName") && document.getElementById(which).value == "")
    document.getElementById(which).value = "First Name";
  else if ((which == "SignupLName" || which == "LName") && document.getElementById(which).value == "")
    document.getElementById(which).value = "Last Name";
  else if ((which == "SignupEmail" || which == "Email") && document.getElementById(which).value == "")
    document.getElementById(which).value = "Email";        
}

