//Setup a PlanetTagger namespace
var PT = PT || {};

PT.invite = function( e, options ){
	
	//show the user that this target is loading
	SDNA.loading(options.target);
	
	if( options.url.indexOf('.htm') > -1 ){
		
		Window.pop( 
			options.url,
			{
				close: function(){
					SDNA.loaded(options.target);
				}
			} 
		);
		
	}else{
	
		//TODO: Add JSON requests for inviting individual users
		//Not needed as of this version
		
	}
}


//Handles a DOM click event on links with a class of invite
//and triggers the invite action with this link|radio as the target
PT.invite.click = function( e ){	              
	
	//keep this link from functioning
	e.preventDefault();
	
	//Trigger the global follow action
	SDNA.Event.trigger(
		'invite',  
		{ 
			url: $j(this).attr('href'), 
			target: this 
		}
	);

};

//Binds any link with a class of "invite" to the dom handler
PT.invite.bind = function(){

	$j('a.invite').live('click.invite', PT.invite.click );
	
};

SDNA.Event.create('invite', PT.invite );
