
function twitterInitializeSettings ()
	{
	if ($('#twitter-info').html() == '')
		{
		$('#twitter-info').hide();
		}
	$('.twitter-authorize').live
		(
		'click',
		function ()
			{
			twitterAuthorize();
			}
		);
	$('.twitter-remove').live
		(
		'click',
		function ()
			{
			twitterRemove();
			}
		);
	}

function twitterLink (account, token, token_secret)
	{
	$.post
		(
		'ajax.php?do=twitter-link',
		{'account': account, 'token': token, 'token_secret': token_secret},
		function (xml)
			{
			$('#twitter-info').html($(xml).find('info').text()).animate({'height': 'show', 'opacity': 'show'});
			showStatus({'head': $(xml).find('resultHead').text(), 'body': $(xml).find('resultBody').text()});
			twitterUpdateManageOptions($(xml).find('manageOptions'));
			},
		'xml'
		);
	//alert("account: "+account+" | token: "+token+" | token_secret: "+token_secret);
	}

function twitterAuthorize ()
	{
	$.post
		(
		'ajax.php?do=twitter-authorize',
		null,
		function (xml)
			{
			window.location.href = $(xml).find('authorizationURL').text();
			},
		'xml'
		);
	}

function twitterRemove ()
	{
	$.post
		(
		'ajax.php?do=twitter-remove',
		null,
		function (xml)
			{
			$('#twitter-info').animate({'height': 'hide', 'opacity': 'hide'});
			showStatus({'head': $(xml).find('resultHead').text(), 'body': $(xml).find('resultBody').text()});
			twitterUpdateManageOptions($(xml).find('manageOptions'));

			},
		'xml'
		);
	}

function twitterUpdateManageOptions (options)
	{
	var numOptions = options.children().size();
	var i = 0;
	var opts = "";
	options.children().each
		(
		function ()
			{
			
			opts += "<span class='"+$(this).attr('class')+"'>"+$(this).attr('label')+"</span>";
			i++;
			if (i < numOptions)
				{
				opts += " | ";
				}
			}
		);
	$('.twitter-tbl_rc2').html(opts);
	}

function twitterGetTimeline (user, cb)
	{
	if (typeof(cb) != 'function')
		{
		cb = function () {};
		}
	$.post
		(
		'ajax.php?do=twitter-get_timeline',
		{'user': user},
		cb,
		'xml'
		);
	}

