
/**
*	Class : Bookmark
*
*	Creates a new Bookmark and handles the targetting of it to different platforms
*
*	@param	b - bookmark url
*	@param	t - bookmark title
*	@param	d - debug
*/
function Bookmark( b, t, d )
{
	if ( d )
		alert( "new bookmark created " + b + " : " + t );
	
	// define all props
	
	// @@ bookmark url
	this.bookmarkURL = b;
	
	// @@ bookmark title
	this.bookMarkTitle = t;
	
	// @@ bookMarkMode
	this.bookMarkDebugMode = d;
	
	// @@ bookmarks array
	// array to hold all bookmarf target URLs
	this.bookmarkTargets = new Array( "hello" );
	
	this.init = function()
	{
		// @@ myspace
		this.bookmarkTargets[ 'myspace' ] = { url: "http://www.myspace.com/Modules/PostTo/Pages/", varURL: "u", varTitle: "t" };
		// @@ facebook
		this.bookmarkTargets[ 'facebook' ] = { url: "http://www.facebook.com/sharer.php", varURL: "u", varTitle: "t" };
		// @@ delicious
		this.bookmarkTargets[ 'delicious' ] = { url: "http://del.icio.us/post", varURL: "url", varTitle: "title" };
		// @@ stumbleupon
		this.bookmarkTargets[ 'stumbleupon' ] = { url: "http://www.stumbleupon.com/submit", varURL: "url", varTitle: "title" };
		// @@ twitter
		this.bookmarkTargets[ 'twitter' ] = { url: "http://www.twitter.com/home", varURL: "status", varTitle: null };
	}/**/
	
	/**
	*	getBookmarkTargetURLString
	*
	*	Returns the bookmark URL from passed bookmark id
	*
	*	@param	s - target site name [ all lower case ]
	*/
	this.getBookmarkTargetURLString = function( s )
	{
		//alert( "getting URL string for " + s );
		
		var url = "";
		
		if ( this.bookmarkTargets[ s ].url ) 			url += this.bookmarkTargets[ s ].url;
		if ( this.bookmarkTargets[ s ].varURL )			url += (( url.indexOf( "?" ) != -1 ) ? "&" : "?") + this.bookmarkTargets[ s ].varURL + "=" + this.bookmarkURL;
		if ( this.bookmarkTargets[ s ].varTitle ) 		url += (( url.indexOf( "?" ) != -1 ) ? "&" : "?") + this.bookmarkTargets[ s ].varTitle + "=" + this.bookMarkTitle;
		
		return url;
	}/**/

	/**
	*	sendToTarget
	*
	*	Bookmarks a target
	*
	*	@param	s - target site name [ all lower case ]
	*/
	this.sendToTarget = function( s )
	{
		//alert( "Sending to target " + s );
		
		if ( !this.bookmarkTargets[ s ] ) {
			alert( "WARNING : No bookmark target defined for " + s );
			return;
		}
		
		// open the new window
		window.open(
			this.getBookmarkTargetURLString( s ), 'bookmark'
		);
	}/**/
	
	// initialise
	this.init();
}