function sendData_flag_item(item_id, item_type, item_title, objection_submitted_msg)
{
  module = document.getElementById("flag_comment_"+item_id);
  comment_var = escape(module.value);

//	alert("testing...\n" + item_id + "\n"+document.getElementById("hidden_current_objection"));
  current_objection = document.getElementById("hidden_current_objection_"+item_id);
  current_objection.value = item_id;

  // Show the "Please Wait.." Message...
	showWaitingMsg(item_id);

	try {
	  http.open('post', 'index.php', true);
	  http.onreadystatechange = function() {
	  	handlePostData_flag_item(item_id,  objection_submitted_msg);
	  }
	  http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  query="page_id=1003&mode=f&item_id="+item_id+"&item_type="+item_type+"&item_title="+escape(item_title)+"&item_comment="+comment_var;
	  //alert(query);
	  http.send(query);

	  module = document.getElementById("flag_form_"+item_id);
	  module.style.display = "none";
	}
	catch(e) {
		alert(e+'\n'+e.name + ': ' + e.description+'\n'+e.message );
	}
}

function showWaitingMsg(item_id)
{
	//alert("Please wait...");
	document.getElementById("waitMsgHolder_"+item_id).style.display="block";
}

function handlePostData_flag_item(item_id,  objection_submitted_msg)
{
//	alert(http.readyState);
	document.getElementById("waitMsgHolder_"+item_id).style.display = "none";
  if(http.readyState == 4)
  { //Finished loading the response
//	alert("readyState is 4...");

    if (http.status==200)
    {
//	alert("http.status is 200...");
      current_objection = document.getElementById("hidden_current_objection_"+item_id);
      module = document.getElementById("flag_form_"+current_objection.value);
      module.style.display = "block";
      module.innerHTML = "<div class=\"objection_response\">" + objection_submitted_msg  + "</div>";
      current_objection.value = null;
    }
    else
    {
      alert("Error Saving Infomation");
    }
  }
}

function sendData_publish_item(item_id, item_type, item_title)
{
  //alert("print_communities_"+item_id);
  community = document.getElementById("print_communities_"+item_id);
  interest = document.getElementById("print_interests_"+item_id);
  module = document.getElementById("rp_comment_"+item_id);
  comment_var = escape(module.value);

  http.open('post', 'index.php', true);
  http.onreadystatechange = handlePostData_publish_item;
  http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  query="page_id=1003&mode=p&item_id="+item_id+"&item_type="+item_type+"&item_title="+escape(item_title)+"&item_community="+community.value+"&item_interest="+interest.value+"&item_comment="+comment_var;

  //alert(query);
  http.send(query);

  module = document.getElementById("rp_form_"+item_id);
  module.style.display = "none";

}

function handlePostData_publish_item()
{
  if(http.readyState == 4)
  { //Finished loading the response
    if (http.status==200)
    {
      //module = document.getElementById("ajax_test");
      //module.innerHTML = http.responseText;
    }
    else
    {
      alert("Error Saving Infomation");
    }
  }
}

function sendData_subscribe(user_id)
{
  //alert("print_communities_"+item_id);
  module = document.getElementById("subscribe");

  http.open('post', 'index.php', true);
  http.onreadystatechange = handlePostData_subscribe;
  http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  query="page_id=84&target_user_id="+user_id;

  //alert(query);
  http.send(query);

  module.innerHTML = "adding subscription";

}

function handlePostData_subscribe()
{
  if(http.readyState == 4)
  { //Finished loading the response
    if (http.status==200)
    {
      module = document.getElementById("subscribe");
      module.innerHTML = http.responseText;
    }
    else
    {
      alert("Error Saving Infomation");
    }
  }
}


function toggle_display( section )
{
  section = document.getElementById(section);
  if ( section.style.display == "block" )
  {
    section.style.display = "none";
  }
  else
  {
    section.style.display = "block";
  }

}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=300');");
}

var cmodule;


