// JavaScript Document

function showEditAdd(link,id,hide_id)
{
		$(hide_id).hide();
		$("#profile_edit").attr("style","display:block;");
		$("#profile_edit").html("Loading....");
		$.get(link,{profile:id,content:hide_id},function(data){ $("#profile_edit").html(data);});
		return false;
}

function loadFacilityContent(_link,_content_id,_profile_id,_facility)
{
	$(_content_id).html('Loading...');
	$.get(_link,{profile:_profile_id,content:_content_id,facility:_facility},function(data){$(_content_id).html(data);});
	return false;
}

function addMemberArticle(_form_val,_content_id)
{
	$(_content_id).html('Adding Article....');
	$.get('member_article_action.php',_form_val,function(data){
		if(data=='y')
		{
			document.getElementById("article_title").value = '';
			document.getElementById("full_story").value = '';
			alert('Successfully added a Article');
		}
		else
		{
			alert('Article addition Failed!!');
		}
		
	});
	return false;
}

function addMemberOffer(_form_val,_content_id)
{
	$(_content_id).html('Adding Offer....');
	$.get('member_offer_action.php',_form_val,function(data){
		if(data=='y')
		{
			document.getElementById("offer_title").value = '';
			document.getElementById("event_date").value = '';
			document.getElementById("full_story").value = '';
			alert('Successfully added a Offer');
		}
		else
		{
			alert('Article addition Failed!!');
		}
		
	});
	return false;
}

function deleteMemberOffer(_article,_content_id)
{
	if(confirm("Are you sure you want to delete?"))
	{
		$(_content_id).html('Deleting Offer....');
	$.get('member_offer_action.php',{m_offer:_article,action:'delete'},function(data){
		if(data=='y')
		{
			alert('Successfully Deleted a Offer');
			$(_content_id).html('Please Click on the Offers Tab to see changes');
		}
		else
		{
			alert('Offer Delete Failed!!');
			$(_content_id).html('No Changes took place, Please Click on the Offers Tab');
		}
		
	});
	}
	return false;
}

function deleteMemberArticle(_article,_content_id)
{
	if(confirm("Are you sure you want to delete?"))
	{
		$(_content_id).html('Deleting Article....');
	$.get('member_article_action.php',{m_article:_article,action:'delete'},function(data){
		if(data=='y')
		{
			alert('Successfully Deleted a Article');
			$(_content_id).html('Please Click on the Articles Tab to see changes');
		}
		else
		{
			alert('Article Delete Failed!!');
			$(_content_id).html('No Changes took place, Please Click on the Articles Tab');
		}
		
	});
	}
	return false;
}

function updateOffer(_form_val,_content_id)
{
	$(_content_id).html('Updating Offer....');
	$.get('member_offer_action.php',_form_val,function(data){
		if(data=='y')
		{
			alert('Successfully Updated a Offer');
			$(_content_id).html('Please Click on the Offers Tab to see changes');
		}
		else
		{
			alert('Offer Update Failed!!');
			$(_content_id).html('No Changes took place, Please Click on the Offers Tab');
		}
		
	});
	return false;
}

function updateArticle(_form_val,_content_id)
{
	$(_content_id).html('Updating Article....');
	$.get('member_article_action.php',_form_val,function(data){
		if(data=='y')
		{
			alert('Successfully Updated a Article');
			$(_content_id).html('Please Click on the Articles Tab to see changes');
		}
		else
		{
			alert('Article Update Failed!!');
			$(_content_id).html('No Changes took place, Please Click on the Articles Tab');
		}
		
	});
	return false;
}

