(function ($) 
{
// INIT
$.fn.TCv_Dialog = function(options) 
{
	var settings = $.extend(
	{
		'confirm_action' : '',
		'message' : 'Message',
		'type' : 'notice'
	}, options || {});

	/**********************************************/
	/*										   	  */
	/*               PUBLIC METHODS               */
	/*										   	  */
	/**********************************************/
	
	/* 	FUNCTION	: 	showUsingLink
		DESCRIPTION	:	Shows the dialog
		PARAMS		:	link [string] = The link being used
					:	type [string] = The type of dialog
		RESULT		:	
		ADDED		:	
	 */
	this.showUsingLink = function(link, type) 
	{
		link = $(link);
		
		settings.confirm_action = link.attr('href');
		settings.message = link.attr('title');
		if(type)
		{
			settings.type = type;
		}
		// show the actual dialog
		this.show();
	}
	
	/* 	FUNCTION	: 	show
		DESCRIPTION	:	Shows the dialog
		PARAMS		:	
		RESULT		:	
		ADDED		:	
	 */
	this.show = function() 
	{
		this.setType(settings.type);
		this.setMessage(settings.message);
		$('#TCv_Dialog').show();
	}
	
	/* 	FUNCTION	: 	setType
		DESCRIPTION	:	Sets the type for this dialog
		PARAMS		:	type [string] = The type
		RESULT		:	
		ADDED		:	
	 */
	this.setType = function(type) 
	{
		$('#TCv_Dialog_content').removeClass();
		$('#TCv_Dialog_content').addClass(type);
		settings.type = type;
	}
	
	/* 	FUNCTION	: 	setMessage
		DESCRIPTION	:	Sets the message for this dialog
		PARAMS		:	message [string] = The message
		RESULT		:	
		ADDED		:	
	 */
	this.setMessage = function(message) 
	{
		$('#TCv_Dialog #message').html(message);
		settings.message = message;
	}
	
	/**********************************************/
	/*										   	  */
	/*               CANCEL BUTTON                */
	/*										   	  */
	/**********************************************/
	
	/* 	FUNCTION	: 	setCancelAction
		DESCRIPTION	:	Sets the action for the cancel button
		PARAMS		:	action [string] = The action
		RESULT		:	
		ADDED		:	
	 */
	this.setCancelAction = function(action) 
	{
		$('#TCv_Dialog #left_button').unbind('click').click(function() { eval(action); });
	
	}
	
	/* 	FUNCTION	: 	setCancelText
		DESCRIPTION	:	Sets the text for the cancel button
		PARAMS		:	text [string] = The text
		RESULT		:	
		ADDED		:	
	 */
	this.setCancelText = function(text) 
	{
		$('#TCv_Dialog #left_button').html(text);
	
	}
	
	/* 	FUNCTION	: 	cancel
		DESCRIPTION	:	Cancels the dialog box
		PARAMS		:	
		RESULT		:	
		ADDED		:	
	 */
	this.cancel = function() 
	{
		$('#TCv_Dialog').hide();
		this.reset();
	}
	
	
	/**********************************************/
	/*										   	  */
	/*               CONFIRM BUTTON               */
	/*										   	  */
	/**********************************************/
	
	/* 	FUNCTION	: 	setConfirmAction
		DESCRIPTION	:	Sets the action for the ok button
		PARAMS		:	action [string] = The action
		RESULT		:	
		ADDED		:	
	 */
	this.setConfirmAction = function(action) 
	{
		$('#TCv_Dialog #right_button').unbind('click').click(function() { eval(action); });
	}
	
	/* 	FUNCTION	: 	setConfirmText
		DESCRIPTION	:	Sets the text for the Confirm button
		PARAMS		:	text [string] = The text
		RESULT		:	
		ADDED		:	
	 */
	this.setConfirmText = function(text) 
	{
		$('#TCv_Dialog #right_button').html(text);
	
	}
	
	/* 	FUNCTION	: 	confirm
		DESCRIPTION	:	Confirms the dialog box
		PARAMS		:	
		RESULT		:	
		ADDED		:	
	 */
	this.confirm = function() 
	{
		window.location = settings.confirm_action;
		$('#TCv_Dialog').hide();
		this.reset();
	}
	
	
	/**********************************************/
	/*										   	  */
	/*                   RESET                    */
	/*										   	  */
	/**********************************************/
	
	
	/* 	FUNCTION	: 	reset
		DESCRIPTION	:	Resets the form back to all the default values
		PARAMS		:	
		RESULT		:	
		ADDED		:	
	 */
	this.reset = function() 
	{
		this.setCancelAction('window.TCv_Dialog.cancel();');
		this.setCancelText('Cancel');
		
		this.setConfirmAction('window.TCv_Dialog.confirm();');
		this.setConfirmText('OK');
		this.setMessage('This is a question?');
		this.setType('alert');
	
	}
	
	
	
	/**********************************************/
	/*										   	  */
	/*               PRIVATE METHODS              */
	/*										   	  */
	/**********************************************/
	
	
	/**********************************************/
	/*										   	  */
	/*                MAIN RETURN                 */
	/*										   	  */
	/**********************************************/
	this.reset();
	return this.each(function() 
	{ 
	}); 


};


// END THE WRAPPER
})(jQuery);


