function sendData_flag_item(item_id, item_type, item_title, objection_submitted_msg)
{
	if (item_type.startsWith('feedback_'))
	{
		module = $('flag_comment_form_comment_'+item_id);
	}
	else
	{
		module = $('flag_comment_form_'+item_id);
	}
	comment_var = escape(module.value);

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

	try {
		http.open('post', 'index.php', true);
		http.onreadystatechange = function() {
			handlePostData_flag_item(item_id, objection_submitted_msg, item_type);
		}
		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;
		http.send(query);

		if (item_type.startsWith('feedback_'))
		{
			module = $('flag_form_comment_'+item_id);
		}
		else
		{
			module = $('flag_form_'+item_id);
		}
		$(module).hide();
	}
	catch(e) {
		alert(e+'\n'+e.name + ': ' + e.description+'\n'+e.message );
	}
}

function showWaitingMsg(item_id, item_type)
{
	if (item_type.startsWith('feedback_'))
	{
		$('waitMsgHolder_form_comment_'+item_id).show();
	}
	else
	{
		$('waitMsgHolder_form_'+item_id).show();
	}
}

function handlePostData_flag_item(item_id, objection_submitted_msg, item_type)
{
	if (item_type.startsWith('feedback_'))
	{
		$('waitMsgHolder_form_comment_'+item_id).hide();
	}
	else
	{
		$('waitMsgHolder_form_'+item_id).hide();
	}

	//Finished loading the response
	if(http.readyState == 4)
	{
		if (http.status==200)
		{
			if (item_type.startsWith('feedback_'))
			{
				$('flag_form_comment_'+item_id).show();
				$('flag_form_comment_'+item_id).innerHTML = '<div class="objection_response">'+objection_submitted_msg+'</div>';
			}
			else
			{
				$('flag_form_'+item_id).show();
				$('flag_form_'+item_id).innerHTML = '<div class="objection_response">'+objection_submitted_msg+'</div>';
			}
			/*	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();
	pageid = "page" + id;
	pageid = window.open(URL, id, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=300');
}

var cmodule;


