
function store_fb_user() {
	jQuery.post(
		MyAjax.ajaxurl,
		{ action : 'store_fb_user'},
		function( response ) {
			window.location.reload();
		}
	);
}

jQuery('#updateBtn').live('click', function(event) {
	event.preventDefault();
	update_status_users_behaf();
});

function update_status_users_behaf() {
	var updateBtn = jQuery('#updateBtn');
	var status_to_update = jQuery('#status_to_update').val();
	var link_to_update = jQuery('#link_to_update').val();
	var picture_to_update = jQuery('#picture_to_update').val();
	var name_to_update = jQuery('#name_to_update').val();
	var caption_to_update = jQuery('#caption_to_update').val();
	var description_to_update = jQuery('#description_to_update').val();
	//var source_to_update = jQuery('#source_to_update').val();
	link_to_update = escape(link_to_update);
	picture_to_update = escape(picture_to_update);
	name_to_update = escape(name_to_update);
	caption_to_update = escape(caption_to_update);
	description_to_update = escape(description_to_update);
	//source_to_update = escape(source_to_update);
	
	//alert(status_to_update + ' - ' + link_to_update);
	
	if(status_to_update=='') {
		alert('Please type a status first.');
	}
	else {
		jQuery('#status_to_update').attr('disabled','disabled');
		jQuery('#link_to_update').attr('disabled','disabled');
		jQuery('#picture_to_update').attr('disabled','disabled');
		jQuery('#name_to_update').attr('disabled','disabled');
		jQuery('#caption_to_update').attr('disabled','disabled');
		jQuery('#description_to_update').attr('disabled','disabled');
		jQuery('#source_to_update').attr('disabled','disabled');
		jQuery('#updateBtn').attr('disabled','disabled');
		
		jQuery.post(
			MyAjax.ajaxurl,
			{ action : 'update_status_users_behaf', status: status_to_update, link: link_to_update, picture: picture_to_update, name: name_to_update, caption: caption_to_update, description: description_to_update },
			function( response ) {
				//alert(response);
				if(response!='0') {
					alert('The updates have been published.');
				}
				jQuery('#status_to_update').removeAttr('disabled');
				jQuery('#link_to_update').removeAttr('disabled');
				jQuery('#picture_to_update').removeAttr('disabled');
				jQuery('#name_to_update').removeAttr('disabled');
				jQuery('#caption_to_update').removeAttr('disabled');
				jQuery('#description_to_update').removeAttr('disabled');
				//jQuery('#source_to_update').removeAttr('disabled');
				jQuery('#updateBtn').removeAttr('disabled');
				jQuery('#status_to_update').val('');
				jQuery('#link_to_update').val('');
				jQuery('#picture_to_update').val('');
				jQuery('#name_to_update').val('');
				jQuery('#caption_to_update').val('');
				jQuery('#description_to_update').val('');
				//jQuery('#source_to_update').val('');
			}
		);
	}
}
