function claim_open(person_id) {
	if(document.getElementById("claim_me").innerHTML == '') {
		document.getElementById("claim_me").innerHTML = '<br><div style="border:1px solid #ccc; padding:10px;"><b>How To Claim Your Profile:</b><br><br>If this profile is yours, please fill out the form below and we will respond with a username and login so you can start participating in the community. Please note that we are registering members individually, and though we\'re working as quick as we can, it might take some time to get back to you. <br><br>We prefer communicating with affiliated email addresses (@nytimes.com, etc) so that we can better assess the authenticity of your claim. Also, any other information you can provide or link to in the comments box will help us to verify your identity. <br><br>With time, we will implement a better mechanism to help us verify that you are who you say you are. <br><br><br><form style="margin-left:20px;" name="claim_me_form" id="claim_me_form" action="javascript:post_claim(document.getElementById(\'claim_me_form\'));">Name:&nbsp;<input class="textboxlong" type="text" name="name" ize="80">&nbsp;&nbsp;&nbsp;&nbsp;<br><br>Email:&nbsp;<input class="textboxlong" type="text" name="email" size="150"><input type="hidden" name="person_id" value="' + person_id + '"><br><br>Additional Comments:<br><textarea class="textbox" rows="3" cols="29" style="width:238px; height:60px;" name="comments"></textarea><br><br><input type="checkbox" name="join_mailing_list" value="yes"> Join the mailing list?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class="submitBtnSmall" type="submit" value="Submit" onclick=""></form></div><br>';
	} else {
		document.getElementById("claim_me").innerHTML = '';
	}
}

function mailing_list_open() {
	if(document.getElementById("mailing_list").innerHTML == ''){
	
		document.getElementById("mailing_list").innerHTML = '<form action="javascript:post_mailing(document.getElementById(\'mailing_list_form\'));" name="mailing_list_form" id="mailing_list_form">Email: <input class="textbox" type="text" name="email" value=""/>&nbsp;&nbsp;<input type="hidden" name="join_mailing_list" value="yes"><input class="submitBtnSmall" name="submitmailinglist" type="button" value="Submit" onclick="javascript:post_mailing(this.parentNode);"/></form>';
	
	}else{
		document.getElementById("mailing_list").innerHTML = '';
	
	}
}

var http_request = false;
function makeAjaxRequest(url, parameters, div) {
   http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
      	// set type accordingly to anticipated content type
         //http_request.overrideMimeType('text/xml');
         http_request.overrideMimeType('text/html');
      }
   } else if (window.ActiveXObject) { // IE
      try {
         http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
         try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (e) {}
      }
   }
   if (!http_request) {
      alert('Cannot create XMLHTTP instance');
      return false;
   }
   http_request.onreadystatechange = alertContents;
   full_request = url + parameters;
   http_request.open('POST', full_request, true);
   http_request.send(null);
   
   function alertContents() {
        try {
        if (http_request.status == 200) {
           if (http_request.readyState == 4) {
              //alert(http_request.responseText);
              result = http_request.responseText;
              if(document.getElementById(div) != null){
                document.getElementById(div).innerHTML = result; 
              }
           }
        } else {
           alert('There was a problem with the request.');
        }
        } catch(e){  }
        
	}
}

 function post_claim(obj) {

    var getstr = "?";
    for (i=0; i<obj.childNodes.length; i++) {
       if (obj.childNodes[i].tagName == "INPUT") {
          if (obj.childNodes[i].type == "text") {
             getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
          } else if (obj.childNodes[i].type == "hidden") {
             getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
          }
       }
       if (obj.childNodes[i].type == "checkbox") {
             if (obj.childNodes[i].checked) {
                getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
             } else {
                getstr += obj.childNodes[i].name + "=&";
             }
       }
       if (obj.childNodes[i].tagName == "TEXTAREA") {
		 getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
       }
       
    }
    //document.write(getstr);
    makeAjaxRequest('../scripts/claim_me.php', getstr, "claim_me");
 //   makeAjaxRequest('../scripts/mailing_list.php', getstr, "mailing_list");
     
 }
 
 
  function post_mailing(obj) {
    var getstr = "?";
    for (i=0; i<obj.childNodes.length; i++) {
       if (obj.childNodes[i].tagName == "INPUT") {
          if (obj.childNodes[i].type == "text") {
             getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value;
          }
       }
    }
    makeAjaxRequest('../scripts/mailing_list.php', getstr, "mailing_list");
 }
