// --------------------------------------------------------------------------------
// Remarks:
// This class implements a simple way to tweet, post to twitter via a URL
// http://twitter.com/home?source=ropemarks&status=%22bla die bla%22 - http%3A%2F%2Fropemarks.com%2Ftw%2F%3FXXX %23RopeMarks %23NSFW
// 


var SIMPLETWITTER_TWITTER_HOME		= "http://twitter.com/home";
var SIMPLETWITTER_URI_ARG_SOURCE	= "source";
var SIMPLETWITTER_URI_ARG_STATUS	= "status";

// --------------------------------------------------------------------------------
// Private section
// --------------------------------------------------------------------------------

//
// %22 = "
// %3A = :
// %2F = /
// %23 = #
// escape, url encode a string.
//
SimpleTwitter.prototype.__buildUri = function( /* string */ message, /* string */ uriToMedia )
{
	//alert( "__buildUri( '" + message + "', '" + uriToMedia + "' )" );
	var uri = 
		SIMPLETWITTER_TWITTER_HOME + 
		"?" + SIMPLETWITTER_URI_ARG_SOURCE	+"=" + "RopeMarks" + 
		"&" + SIMPLETWITTER_URI_ARG_STATUS	+ "=" + escape( message + " " +  uriToMedia + " #RopeMarks #NSFW" )
	;
	//alert( uri );
	return uri;
}


function SimpleTwitter()
{
}

// --------------------------------------------------------------------------------
// Public section
// --------------------------------------------------------------------------------

SimpleTwitter.prototype.tweetUri = function( /* string */ message, /* string */ uriToMedia)
{
	//alert( "tweetUri( '" + message + "', '" + uriToMedia + "' )" );
	return this.__buildUri( message, uriToMedia );
}
	
SimpleTwitter.prototype.tweetThis =  function( /* string */ uri )
{
	// Navigate to the URI in a new window
	window.open( uri, "Twitter" );		
}





// --------------------------------------------------------------------------------
// Support functions
// --------------------------------------------------------------------------------

function TweetThis( /* string */ message, /* string */ uriToMedia )
{
	//alert( "TweetThis( '" + message + "', '" + uriToMedia + "' )" );
	
	var twitter = new SimpleTwitter();
	var uri = twitter.tweetUri( message, uriToMedia );
	twitter.tweetThis( uri );
}

/* EOF */
