// Event Delegation ------------------------------------[TN]
jQuery.delegate = function(Rules) {
	return function(e) {
		var Target = $(e.target);
		for (var Selector in Rules)
			if (Target.is(Selector)) return Rules[Selector].apply(this, $.makeArray(arguments));
	}
}
//------------------------------------------------------[TN]

// Form Message Class ----------------------------------[MN]
var FormMessage = function( Config ) {
	var This = {
		Prefix: Config.Prefix ? Config.Prefix : '',
		Display: function( JQueryParent, Messages ) {
			var HTML = '<div class="'+ This.Prefix +'Messages">';

			for( Type in Messages ){
				HTML += '<div class="'+ This.Prefix + Type +'">';
				for( Type in Messages ){
					for( i in Messages[Type] ){
						if( typeof( Messages[Type][i] == 'string' ) )
							HTML += '<div class="'+ This.Prefix +'Message">'+ Messages[Type][i] +'</div>';
					}

				}
				HTML += '</div>';
			}
			HTML += '</div>';

			JQueryParent.children( '.'+ This.Prefix +'Messages' ).remove();
			JQueryParent.prepend( HTML );
		}
	};
	return This;
};
//------------------------------------------------------[MN]

// ModalBox jQuery Plugin ------------------------------[MN]
( function( $ ) {
	var VPI_ModalBox = function() {
		function This( Config ) {
			This._Settings				= $.extend( This._Settings, Config );
			This._Settings.Content_Type	= This._Settings.Content_Type.toLowerCase()
			This.Show();

			$( window ).resize( This.AdjustDimensions );
		}

		This._Settings = {
			BG_Class: 'VPI_ModalBox_Background',
			Container_Class: 'VPI_ModalBox_Container',
			Box_Class: 'VPI_ModalBox',
			Img_BasePath: '/images',
			Width: false,
			Height: false,
			MinPadding: 20
		};

		This.AdjustDimensions = function() {
			// Resize Transparent BG -------------------------------[MN]
			$( '.'+ This._Settings.BG_Class ).css( {
				width: $( document ).width() +'px',
				height:	$( document ).height() +'px'
			} );
			//------------------------------------------------------[MN]

			// Resize Container ------------------------------------[MN]
			var Width_Max		= $( window ).width() - ( 2 * This._Settings.MinPadding );
			var Height_Max		= $( window ).height() - ( 2 * This._Settings.MinPadding );
			var Width_Content	= $( '.'+ This._Settings.Box_Class ).width();
			var Height_Content	= $( '.'+ This._Settings.Box_Class ).height();

			if( This._Settings.Content_Type == 'iframe' ) {
				var Body_IFrame = $( $( '.'+ This._Settings.Box_Class ).get( 0 ).contentWindow.document.body );

				if( Body_IFrame.attr( 'scrollWidth' ) )
					Width_Content = Body_IFrame.attr( 'scrollWidth' );
				if( Body_IFrame.attr( 'scrollHeight' ) )
					Height_Content = Body_IFrame.attr( 'scrollHeight' );
			} else {
				//------------------------------------------------------[TN]
				// Reset width and height in case it was changed by the 
				//	iframe being loaded
				//------------------------------------------------------[TN]
				This._Settings.Width = false;
				This._Settings.Height = false;
			}

			var Width	= This._Settings.Width ? ( This._Settings.Width <= Width_Max ? This._Settings.Width : Width_Max ) : Math.min( Width_Max, Width_Content );
			var Height	= This._Settings.Height ? ( This._Settings.Height <= Height_Max ? This._Settings.Height : Height_Max ) : Math.min( Height_Max, Height_Content );

			Height = Height_Content;

			if ( Height > Height_Max ) {
				var IFrameTop = '20px';
				$( 'html' ).css( 'overflow', 'auto' );
			} else {
				var IFrameTop = parseInt( Number( $( window ).height() / 2 ) - ( Height / 2 ) + $( window ).scrollTop() ) +'px';
				$( 'html' ).css( 'overflow', 'hidden' );
			}

			$( '.'+ This._Settings.Container_Class ).css( {
				width: Width +'px',
				height: Height +'px',
				position: 'absolute',
				left: parseInt( Number( $( window ).width() / 2 ) - ( Width / 2 ) + $( window ).scrollLeft() ) +'px',
				top: IFrameTop
			} );
			//------------------------------------------------------[MN]

			// Resize Box ------------------------------------------[MN]
			$( '.'+ This._Settings.Box_Class ).css( {
				width: Width +'px',
				height: Height +'px'
			} );
			//------------------------------------------------------[MN]

		};

		This.Close = function() {
			$( '.'+ This._Settings.Container_Class ).fadeOut( 500, function() {
				$( this ).remove();
				$( '.'+ This._Settings.BG_Class ).remove();
				$( 'html' ).css( 'overflow', This._Settings.HTML_Overflow );
			} );
		};

		This.Content_Loaded = function() {
			This.AdjustDimensions();
			$( '.VPI_ModalBox_Loading' ).fadeOut( 250, function() {
				$( this ).remove();
				$( '.'+ This._Settings.Container_Class ).css( { display: 'none', visibility: 'visible' } ).fadeIn( 500 );
			} );
		};

		This.Show = function() {
			// Remove Scrollbars -----------------------------------[MN]
			This._Settings.HTML_Overflow = $( 'html' ).css( 'overflow' );
			$( 'html' ).css( 'overflow', 'hidden' );
			//------------------------------------------------------[MN]

			// Attach Transparent BG -------------------------------[MN]
			var HTML = '<div class="'+ This._Settings.BG_Class +'"></div>';
				HTML += '<img class="VPI_ModalBox_Loading" style="left: '+ parseInt( Number( $( window ).width() / 2 ) - 48 + $( window ).scrollLeft() ) +'px; top: '+ parseInt( Number( $( window ).height() / 2 ) - 48 + $( window ).scrollTop() ) +'px;" src="'+ This._Settings.Img_BasePath +'/vpi_modalbox.loading.gif" />';
			$( document.body ).append( HTML );
			//------------------------------------------------------[MN]

			// Attach Box ------------------------------------------[MN]
			var HTML = '<div class="'+ This._Settings.Container_Class +'">';
//				HTML += '<img class="VPI_ModalBox_Close" src="'+ This._Settings.Img_BasePath +'/vpi_modalbox.close.gif" border="0" alt="X" />';


			switch( This._Settings.Content_Type ) {
				case 'html':	HTML += '<div class="'+ This._Settings.Box_Class +'">'+ This._Settings.Content +'</div>';								break;
				case 'iframe':	HTML += '<iframe frameborder="0" class="'+ This._Settings.Box_Class +'" src="'+ This._Settings.Content +'"></iframe>';	break;
			}
				HTML += '</div>';

			$( document.body ).append( HTML );
			//------------------------------------------------------[MN]

			// Bind Events -----------------------------------------[MN]
			$( '.VPI_ModalBox_Close' ).click( This.Close );
			if( This._Settings.Content_Type == 'iframe' ) {
				This.AdjustDimensions();
				$( '.'+ This._Settings.Box_Class ).load( This.Content_Loaded );
			} else {
				This.Content_Loaded()
			}
			//------------------------------------------------------[MN]
		};

		return This;
	}
	$.VPI_ModalBox = new VPI_ModalBox();
} ) ( jQuery );
//------------------------------------------------------[MN]

// Login -----------------------------------------------[TN]
var Login = function( Config ) {
	var This = {
		ShowLogin : function(Event) {
			if ( Event == 'PageLoad' ) {
				var Top = '30px';
				var Left= ( ( ( $(window).width() - 970 ) / 2 ) + 770 ) + 'px';
			} else {
				var Top	= Event.pageY - 20 + 'px';
				var Left= Event.pageX;
				if ( Left > 900 )
					Left = ( ( $(window).width() - 970 ) / 2 ) + 770;

				Left += 'px';
			}

			$('.LOG_LogInBox').css( { 'top': Top, 'left': Left } );
			$('.LOG_LogInBox').fadeIn('normal');
		},
		SubmitLogin : function() {
			$('.LOG_LogInBox .MSG_Messages').remove();
			$('.LOG_Submit :input').css('display','none');
			$('.LOG_Submit').append('<img src="' + PATH.IMG + '/ico.loader_bar.gif" class="LOG_Working" />');
			$.post( PATH.Public + '/ajax/login.process/', 
				{
					Username	: $('.LOG_LogInBox input[@name=Username]').val(), 
					Pass		: $('.LOG_LogInBox input[@name=Pass]').val(), 
					RememberMe	: (($('.LOG_LogInBox input[@name=RememberMe]:checked').length == 1) ? 'Yes' : '')
				},
				function(data) {
					if(data.Msg == 'Success') {
						window.location.href = ( window.location.href.indexOf( '/username_update/', 0 ) === -1 ) ? window.location.href : PATH.Public + '/';
					}else{
						$('.LOG_CloseLink').after('<div class="MSG_Messages" style="clear: right;"><div class="MSG_Error">' + data.Msg + '</div></div>');
						$('.LOG_Submit .LOG_Working').remove();
						$('.LOG_Submit :input').css('display', '');
					}
				},
				'json'
			);
		},
		CloseLogin : function() {
			$('.LOG_LogInBox').fadeOut('normal');
			$('.LOG_LogInBox .MSG_Messages').remove();
		}
	};
	return This;
}
//------------------------------------------------------[TN]

// Search ----------------------------------------------[TN]
var Search = function( Config ) {
	var This = {
		ShowSearch : function( Event, Type ) {
			$('.SRCH_Options select').css('display', 'none');
			$('.SCH_Wrapper').remove();
			var SearchContent	=	'<div class="SCH_Wrapper">' +
									'	<div class="SCH_Header' + ( ( Type == 'Editorials' ) ? ' Editorials' : '' ) + '"><a href="#" onclick="$(\'.SCH_Wrapper\').fadeOut(\'normal\'); $(\'.SRCH_Options select\').css(\'display\', \'\'); return(false);" class="SCH_Close"><span>close</span></a></div>' +
									'	<div class="SCH_Container">' + This.SearchContent(Type) + '<br style="clear: left;" /></div>' +
									'	<div class="SCH_Footer"></div>' +
									'</div>';
			$(document.body).append( SearchContent );

			if ( ( true || Event == 'DefaultPosition' ) && Type == 'Comics' ) {
				var Top = '220px';
				var Left= ( ( ( $(window).width() - 970 ) / 2 ) + 10 ) + 'px';
			} else if ( (true || Event == 'DefaultPosition' ) && Type == 'Editorials' ) {
				var Top = '220px';
				var Left= ( ( ( $(window).width() - 970 ) / 2 ) + 310 ) + 'px';
			} else {
				var Top	= Event.pageY + 10 + 'px';
				var Left= Event.pageX - 100 + 'px';
			}

			$('.SCH_Wrapper').css({ top: Top, left: Left }).fadeIn('normal');

			// Attach Hover to Thumbs ------------------------------[TN]
			This.AttachDescriptionHover(Type);
			//------------------------------------------------------[TN]
		},
		SearchContent : function( Type ) {
			var SearchThumbs	= '<div class="SCH_Column DescriptionRight">';
			var ComicCount		= 0;

			for( i in eval( 'CMC.' + Type ) )
				ComicCount++;

			var PerColumn		= Math.ceil( ComicCount / 3 );

			var ComicCount		= 0;
			for( i in eval( 'CMC.' + Type ) ) {
				if ( ComicCount && ComicCount % PerColumn == 0 )
					SearchThumbs +='</div><div class="SCH_Column">';
					
				SearchThumbs += '<a href="/' + eval('CMC.' + Type + '[i][0]["URL"]' ) + '/" class="SCH_Link" id="SCH_Link' + eval('CMC.' + Type + '[i][0]["ComicID"]') + '">' + 
					'<div class="SCH_Title">' + eval('CMC.' + Type + '[i][0]["Comic"]' ) + '</div></a>';

				ComicCount++;

			}
			SearchThumbs += '</div>';

			var SearchContent = '<div class="SCH_Links">' + SearchThumbs + '</div>';
			return SearchContent;
		},		
		AttachDescriptionHover : function(Type) {
			$('.SCH_Link').hover(
				function(Event) {
					var DescriptionText = eval('CMC.' + Type + '[' + $(this).attr('id').substr(8) + '][0][\'Description\']');
					DescriptionText = DescriptionText.split('.', 1) + '.';

					if( $('.SCH_Description').length == 0 ) {
						$(document.body).prepend('<div class="SCH_Description' + ( ($(this).parents('.SCH_Column').hasClass('DescriptionRight')) ? ' Right' : '') + '"><div class="SCH_Property"><div class="SCH_DescriptionText">' + DescriptionText + '</div></div></div>');
					} else {
						if ($(this).parents('.SCH_Column').hasClass('DescriptionRight'))
							$('.SCH_Description').addClass('Right');
						else
							$('.SCH_Description').removeClass('Right');

						$('.SCH_Description').css('display', 'block').find('.SCH_DescriptionText').html( DescriptionText );
					}

					$('.SCH_Property').css( { 'background': 'url("' + eval('CMC.' + Type + '[' + $(this).attr('id').substr(8) + '][0][\'Path_Desc\']') + '") no-repeat' } );

					var Top	= Event.pageY - 22 + 'px';
	
					if ($(this).parents('.SCH_Column').hasClass('DescriptionRight'))
						var Left= Event.pageX + 10 + 'px';
					else
						var Left= Event.pageX - 200 + 'px';

					$('.SCH_Description').css({'top': Top, 'left': Left});
				},
				function() {
					$('.SCH_Description').html();
					$('.SCH_Description').css('display', 'none');
				}
			);
		}
	};
	return This;
}
//------------------------------------------------------[TN]

// Favorites -------------------------------------------[TN]
var Favorites = function( Config ) {
	var This = {
		HideReminder : function() {
			$('.FAV_Reminder').animate({
				width: '145px',
				height: '103px',
				top: '155px',
				left: '10px'
			}, 1000 );

			$('.FAV_ReminderImage').animate({
				width: '145px',
				height: '103px',
				top: '148px',
				left: '10px'
			}, 1000 );

			$('.FAV_AddNow').animate({ width: '105px', height: '13px', top: '27px', left: '20px'  }, 1000);
			$('.FAV_NotNow').animate({ width: '105px', height: '13px', top: '52px', left: '20px'  }, 1000);
		},
		ShowReminder : function() {
			$('.FAV_Reminder').animate({
				width: '290px',
				height: '180px',
				top: '180px',
				left: '10px'
			}, 1000 );

			$('.FAV_ReminderImage').animate({
				width: '290px',
				height: '180px',
				top: '148px',
				left: '10px',
				opacity: 1.0
			}, 1000 );


 			$('.FAV_AddNow').animate({ width: '208px', height: '25px', top: '45px', left: '38px' });
			$('.FAV_NotNow').animate({ width: '208px', height: '25px', top: '90px', left: '38px'  });
			window.setTimeout(This.HideReminder, 5000);
		}
	}
	return This;
}
//------------------------------------------------------[TN]


// Account Editing -------------------------------------[MN]
var Account = function( ObjName ){ 
	var This = {
		ObjName: ObjName,
		AvatarID: 0,
		Avatars: null,

		Avatars_Load: function( Page ){
			var HTML		= '<div style="background: #FBF8E4; margin-bottom: -3px;"><div class="ACT_AvatarList_Top">&nbsp;</div><div class="ACT_AvatarList_Body"><div class="ACT_AvatarChoices">';
			for( var i = 0; i < this.Avatars.length; i++ ){
				if( this.Avatars[i] )
					HTML += '<div class="ACT_AvatarChoice'+ ( this.Avatars[i].AvatarID == this.AvatarID ? ' ACT_Selected' : '' ) +'"><img class="ACT_Avatar" onclick="javascript: '+ ObjName +'.Avatars_Select( '+ this.Avatars[i].AvatarID +', this.src );" src="'+ this.Avatars[i].ThumbPath +'" width="90" height="90" /></div>';
			}

			HTML += '<br style="clear: both;" /></div></div><div class="ACT_AvatarList_Bottom">&nbsp;</div></div>';

			$( '.ACT_AvatarList' ).html( HTML );
		},

		Avatars_Select: function( AvatarID, Src ){
			this.AvatarID = AvatarID;
			$( '.ACT_CurrentAvatar' ).attr( 'src', Src.replace('thumb', 'full') );
			this.Avatars_Toggle();
			$.post( PATH.Public +'/ajax/my_account.avatar.edit.process/', { AvatarID: AvatarID } );
		},

		Avatars_Toggle: function(){
			var Div_AvatarList	= $( '.ACT_AvatarList' );
			var Action			= Div_AvatarList.hasClass( 'ACT_Open' ) ? 'Close' : 'Open';

			switch( Action ){
				case 'Open':
					Div_AvatarList.addClass( 'ACT_Open' );
					this.Avatars_Load( 1 );
				break;

				case 'Close':
					Div_AvatarList.removeClass( 'ACT_Open' );
				break;
			}
		},

		Input_ToggleEdit: function( Event ){
			var MyInput = $( Event.target );

			var Action		= Event.data.Action;
			var PostPage	= (Event.data.PostPage) ? Event.data.PostPage : 'my_account.profile.edit.process';
			var ItemID		= (Event.data.ItemID) ? Event.data.ItemID : 0;

			switch( Action ){
				case 'Edit':
					MyInput.addClass( 'ACT_FieldEdit' );
				break;

				case 'Save':
					MyInput.removeClass( 'ACT_FieldEdit' );
					$.post( PATH.Public + '/' + PostPage + '/', { Field: MyInput.attr( 'name' ), Value: MyInput.val(), ItemID: ItemID }, This.Save_Callback, 'json' );
				break;
			}
		},

		Profile_CheckKey: function( Event ){
			if ( 13 == ( Event.keyCode || Event.which ) ){
				$( Event.target ).blur();
			}
		},

		Profile_Save_Callback: function( Response ) {
			MSG.Display( $('.ACT_ProfileMessages'), [Response.Messages] );
		},

		Profile_Refresh: function(){
			This.Section_Toggle( 'ACT_Section_Profile', 'Close' );
			$( '.ACT_Section_Profile .ACT_SectionContent' ).html( '' );
			This.Section_Toggle( 'ACT_Section_Profile', 'Open' );
		},

		Profile_ToggleEdit: function(){
			var ToggleLink = $( '.ACT_EditLink' );

			if( ToggleLink.hasClass( 'ACT_LinkDisabled' ) )
				return false;

			switch( $(ToggleLink).children('img').attr('alt') ) {
				case 'EDIT':
					$( '.ACT_RefreshLink' ) .css( 'display', 'inline' );
					$( '.ACT_FieldInput' ).addClass( 'ACT_FieldEdit' );
					$( '.ACT_FieldInput_Country' ).css( 'display', 'inline' );
					$( '.ACT_FieldValue_Country' ).css( 'display', 'none' );
					$( '.ACT_FieldInput_Password' ).css( 'display', 'inline' ).val( '' );
					$( '.ACT_FieldValue_Password' ).css( 'display', 'none' );
					$(ToggleLink).children('img').attr('alt', 'SAVE');
					$(ToggleLink).children('img').attr('src', PATH.IMG + '/btn.save_edits.gif');
				break;

				case 'SAVE EDITS':
					var ProfileForm = ToggleLink.parents( '.ACT_ProfileForm' );
					$.post(
						PATH.Public +'/ajax/'+ ProfileForm.attr( 'action' ) +'/',
						ProfileForm.serialize(),
						This.Profile_Save_Callback,
						'json'
					);
				break;
			}
		},

		Section_Toggle: function( Section ){
			var Div_Section	= $( '.'+ Section );
			var Action		= arguments[1] != null ? arguments[1] : ( Div_Section.hasClass( 'ACT_Open' ) ? 'Close' : 'Open' );
			var Div_Content	= Div_Section.children( '.ACT_SectionContent' );
				
			if ( Div_Section.hasClass( 'ACT_Open' ) ) {
				$( '.' + Section ).children('.ACT_SectionHeader').removeClass('ACT_Open');
				$( '.' + Section ).next( '.ACT_ContentFooter' ).remove();
			} else {
				$( '.' + Section ).children('.ACT_SectionHeader').addClass('ACT_Open');
				$( '<div class="ACT_ContentFooter"></div>' ).insertAfter( '.' + Section );
			}

			switch( Action ){
				case 'Close':
					Div_Section.removeClass( 'ACT_Open' );
				break;

				case 'Open':
					if( !Div_Section.hasClass( 'ACT_Open' ) )
						Div_Section.addClass( 'ACT_Open' );
				break;
			}
		}
	};

	return This; 
};
//------------------------------------------------------[MN]

// Strip Container -------------------------------------[TN]
var StripContainer = function() {
	This = {
		CachedDays : [],
		CachedMonths : [],
		GetStripDates : function(date, ComicID) {   
			var year_month = ""+ (date.getFullYear()) +"-"+ (date.getMonth()+1) +"";  
			var year_month_day = ""+ year_month+"-"+ date.getDate()+"";  
			var opts = "";  
			var i = 0;  
			var ret = false;  
			i = 0;  
			ret = false;  
			for (i in This.CachedMonths[ComicID]) {  
				if (This.CachedMonths[ComicID][i] == year_month){  
					ret = true;  
					break;  
				};  
			};  
			if (ret == false){  
				opts= "Month="+ (date.getMonth()+1);  
				opts+="&Year="+ (date.getFullYear());
				opts+="&ComicID=" + ComicID;

				$.ajax({  
					url: "/ajax/comic_dates/",  
					data: opts,  
					dataType: "json",  
					async: false,  
					success: function(data){  
						This.CachedMonths[ComicID][This.CachedMonths[ComicID].length]= year_month ;  
						$.each(data.days, function(i, day){  
							This.CachedDays[ComicID][This.CachedDays[ComicID].length]= year_month +"-"+ day.day +"";  
						});  
					}  
				});  
			};  
			i = 0;  
			ret = false;  
			for (i in This.CachedDays[ComicID]) {  
				if (year_month_day == This.CachedDays[ComicID][i]){  
					ret = true;  
				};  
			};  
			return [ret, ''];
		},
		Vote : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');

			$(e.target).parents('.STR_Container').find('.STR_MessagePanel').contents('.STR_Message').html('');

			$.post(PATH.Public + '/ajax/social.rate.process/', 
				{ TableID : Strip['StripID'], Type : 'strip', Rating : $(e.target).attr('rel') },
				function( Response ) {
					var Message = '<div style="padding: 5px;">';

					if ( Response.Success ) {
						var StripID = Strip['StripID'];
						$('.STR_Container').each( function() {
							var CurStrip = eval('(' + $(this).attr('rel') + ')');
							if ( CurStrip['StripID'] == StripID ) {
								$(this).children('.STR_Footer').find('.STR_VoteCount').html( $(this).children('.STR_Footer').find('.STR_VoteCount').html() * 1 + 1 );
								$(this).children('.STR_Footer').find('.STR_Stars').rating('',{maxvalue:5,increment:.5, curvalue:$(e.target).attr('rel')});
							}
						})

						for ( i in Response.Messages['Success'] )
							Message += Response.Messages['Success'][i] + '<br />';

					} else {
						for ( i in Response.Messages['Error'] )
							Message += Response.Messages['Error'][i] + '<br />';
					}

					BBL.ShowBubble( e, Message + '</div>', 'Right', 'CloseLink' );
				},
				'json'
			);
			return(false);
		},
		TagSubmit : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');

			$(e.target).parents('.STR_Container').find('.STR_TagPanel').children('.STR_Message').html('');

			$.post(PATH.Public + '/ajax/social.tag.process/', 
				{ StripID : Strip['StripID'], Tags : $(e.target).siblings('input[@name=StripTag]').val() },
				function( data ) {
					if ( data.Success ) {
						$(e.target).siblings('.STR_Message').html(data.Messages['Success'][0]);
					} else {
						var Message = '';
						for ( i in data.Messages['Error'] )
							Message += data.Messages['Error'][i] + '<br />';
	
						$(e.target).siblings('.STR_Message').html(Message);
					}
				},
				'json'
			);
			return(false);			
		},
		EmailSubmit : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			$(e.target).parent('.STR_EmailInputs').css('display', 'none');
			$(e.target).parents('.STR_EmailPanel').append('<div class="STR_Working">Sending message...<br /><br /><img src="' + PATH.IMG + '/ico.loader.gif" /></div>');
			$.post(PATH.Public + '/ajax/social.email.process/', 
				{ 
					StripID : Strip['StripID'], 
					Name	: $(e.target).siblings('input[@name=Name]').val(), 
					Email	: $(e.target).siblings('input[@name=Email]').val(),
					Message	: $(e.target).siblings('textarea[@name=Message]').val()

				},
				function( data ) {
					if ( data.Success ) {
						var HTML = data.Messages['Success'][0] + 
							'<div class="STR_EmailReturn">' + 
							'	<a href="#" onclick="return(false);" class="STR_EmailMore STR_EmailShowForm"><span>more, more!</span></a>' + 
							'	<a href="#" onclick="return(false);" class="STR_PanelClose STR_EmailDone"><span>I\'m done</span></a>' + 
							'</div>';
						$(e.target).parents('.STR_EmailPanel').find('.STR_Working').html( HTML );
					} else {
						var Message = '';
						for ( i in data.Messages['Error'] )
							Message += data.Messages['Error'][i] + '<br />';
	
						$(e.target).parents('.STR_EmailPanel').find('.STR_Working').html(Message + '<br /><input type="image" src="' + PATH.IMG + '/btn.strip.back.gif" class="STR_EmailShowForm">');

					}
				},
				'json'
			);
			return(false);					
		},
		ShowEmailForm : function(e) {
			// show email form, after submit, takes user back to form panel (back button)

			$(e.target).parents('.STR_EmailPanel').children('.STR_EmailInputs').css('display', '');
			$(e.target).parents('.STR_EmailPanel').children('.STR_Working').remove();
		},
		SaveFavorite : function(e) {
			if ( VPI.IsLoggedIn ) {
				var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
				$.post( PATH.Public + '/ajax/social.favorite.process/', { StripID: Strip['StripID'], Action: 'Favorite' },
					function( Response ){
						var Message = '<div style="padding: 5px;">';
						if ( Response.Success ) {
							for ( i in Response.Messages['Success'] )
								Message += Response.Messages['Success'][i] + '<br />';

							if ( $(e.target).parents('.STR_SaveList').children('select option:selected').val() == 0 )
								This.GetLists(e);

							$(e.target).siblings('input[@name=ListTitle]').val('');

						} else {
							for ( i in Response.Messages['Error'] )
								Message += Response.Messages['Error'][i] + '<br />';
						}

						BBL.ShowBubble( e, Message + '</div>', 'Left', 'CloseLink' );
					},
					'json'
				);
			} else {
				BBL.ShowBubble( e, '<div style="padding: 5px;">You must be logged in to save to favorites.</div>', 'left', 'CloseLink' );
			}
		},
		ShowListOptions : function(e) {
			if ( VPI.IsLoggedIn ) {
				$(e.target).parents('.STR_SavePanel').children('.STR_SaveOptions').fadeOut('fast', function() {
					$(e.target).parents('.STR_SavePanel').children('.STR_SaveList').fadeIn('fast');
				});
				STR.GetLists(e);
			} else {
				BBL.ShowBubble( e, '<div style="padding: 5px;">You must be logged in to save to lists.</div>', 'left', 'CloseLink' );
			}
		},
		HideListOptions : function(e) {
			$(e.target).parents('.STR_Container').find('.STR_SaveList').fadeOut('fast', function() {
				$(e.target).parents('.STR_Container').find('.STR_SaveOptions').fadeIn('fast');
			});
		},
		GetLists : function(e) {
			$(e.target).parents('.STR_SavePanel').children('.STR_SaveList').children('.STR_FavesList').empty();

			$.get(PATH.Public + "/xml/user_lists/",
				null,
				function(data) {
					$(e.target).parents('.STR_SavePanel').children('.STR_SaveList').children('.STR_FavesList').append('<option value="-1">select a list</option>');
					$(e.target).parents('.STR_SavePanel').children('.STR_SaveList').children('.STR_FavesList').append('<option value="0">New List</option>');
					$.each( 
						$(data).find("List"), 
						function(i, n) {
							$(e.target).parents('.STR_SavePanel').children('.STR_SaveList').children('.STR_FavesList').append('<option value="' + $(n).find('ListID').text() + '">' + $(n).find('Title').text() + '</option>');
						}
					);
				},
				'xml'	
			);
		},
		ListSelect : function(TheNode) {
			var ListID = $(TheNode).children('option:selected').val();
			if ( ListID >= 0 ) {
				$(TheNode).siblings('.STR_ListInputs').children('.STR_ListTitle').css('display', ( ( ListID == 0 ) ? 'block' : 'none' ) );
				$(TheNode).siblings('.STR_ListInputs').fadeIn('fast');
			} else {
				$(TheNode).siblings('.STR_XHMessage').html('Please select a list or add a new one.');
			}
		},
		ListSave : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			$.post(PATH.Public + '/ajax/social.favorite.process/', 
				{ 
					StripID		: Strip['StripID'],
					ListID		: $(e.target).parents('.STR_SaveList').children('select option:selected').val(),  
					ListTitle	: $(e.target).siblings('input[@name=ListTitle]').val(),
					Action		: 'List'
				},
				function( Response ){
					var Message = '<div style="padding: 5px;">';
					if ( Response.Success ) {
						for ( i in Response.Messages['Success'] )
							Message += Response.Messages['Success'][i] + '<br />';

						if ( $(e.target).parents('.STR_SaveList').children('select option:selected').val() == 0 )
							This.GetLists(e);

						$(e.target).siblings('input[@name=ListTitle]').val('');

					} else {
						for ( i in Response.Messages['Error'] )
							Message += Response.Messages['Error'][i] + '<br />';
					}

					BBL.ShowBubble( e, Message + '</div>', 'Left', 'CloseLink' );
				},
				'json'
			);
		},
		PrintStrip : function(e) {
			var ImgPath = $(e.target).parents('.STR_Container').find('.STR_StripImage').children('img').attr('src');
			$($('#PrintFrame').get(0).contentWindow.document.body).html('<img src="' + ImgPath + '" />');
			$('#PrintFrame' ).get( 0 ).contentWindow.focus(); 
			$( '#PrintFrame' ).get( 0 ).contentWindow.print();
		},
		GetRandom : function(e) {
			$(e.target).css('background', 'transparent url(' + PATH.IMG + '/bg.reload_working.gif) no-repeat scroll 0 0');
			$( $(e.target).parents('.STR_StripFrame') ).load( PATH.Public + '/ajax/strip.load/?Header=Main' );
			BBL.HideBubble();
			ADS.Load();
		},
		OpenPanel : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			This.ClosePanels(e);	

			// leave closed if already open ------------------------[TN]
			if ( $(e.target).parents('.STR_Container').find( '.' + $(e.target).attr('rel') ).css('display') != 'none' )
				return(false);
			//------------------------------------------------------[TN]




			$(e.target).parents('.STR_Container').find('.' + $(e.target).attr('rel')).fadeIn('fast');

			switch( $(e.target).attr('rel') ) {
				case 'STR_AboutPanel':
					$(e.target).parents('.STR_Container').find('.STR_AboutPanel').children('.STR_Title').html( eval( 'CMC.' + Strip['Type'] + 's[' + Strip['ComicID'] + '][0][\'Comic\']' ));
					$(e.target).parents('.STR_Container').find('.STR_AboutPanel').children('.STR_Description').html( eval( 'CMC.' + Strip['Type'] + 's[' + Strip['ComicID'] + '][0][\'Description\']' ) ).css('overflow', 'auto');
				break;
				
				case 'STR_SavePanel':
					This.HideListOptions(e);
				break;




			}
		},
		ClosePanels : function(e) {
			$(e.target).parents('.STR_Container').find('.STR_Panel').each( function() {
				$(this).fadeOut('fast');
			
				if ( $(this).hasClass('STR_AboutPanel') ) {
					$(this).children('.STR_Description').css('overflow', 'hidden');
				}
			});
		},
		RemoveStripConfirm : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			var Confirm =	'<div align="center">' +
							'	Are you sure you want to delete this comic from this page?<br /><br />' +
							'	<a href="#" onclick="STR.RemoveStrip(' + Strip['ComicID'] + '); BBL.HideBubble(); return(false);"><img src="' + PATH.IMG + '/btn.strip.yes.gif" border="0" /></a>' +
							'	<a href="#" onclick="BBL.HideBubble(); return(false);"><img src="' + PATH.IMG + '/btn.strip.cancel.gif" border="0" /></a>' +
							'</div>';
			BBL.ShowBubble( e, Confirm, 'Right' );
		},
		RemoveStrip : function(ComicID) {
			$.post( PATH.Public + '/ajax/strip.remove', { ComicID: ComicID }, 
				function( data ) {
					if ( data.Success ) {
						if ( $('.STR_Container').length == 1 ) {
							window.location.href=window.location.href;
							return(true);
						}
						
						$('.STR_Container').each( function() {
							var Strip = eval('(' + $(this).attr('rel') + ')');
							if ( Strip['ComicID'] == ComicID ) {
								if ( $(this).hasClass('FirstStrip') ) {
									if ( $('.STR_Container').length == 2 )
										$('.Ad_C:last').remove();

									$(this).parent('.STR_StripFrame').remove();

									$('.Ad_C:first').before( $('.STR_StripFrame:first') );

								} else if ( $(this).hasClass('LastStrip') && $('.STR_Container').length == 2 ) {
									$(this).parent('.STR_StripFrame').remove();

									$('.Ad_C:last').remove();
								} else {
									$(this).remove();
								}

								This.UpdateFirstLastClass();
							}
						});
					} else {
						var Message = '<div style="padding: 5px;">';
						for ( i in data.Messages['Error'] )
							Message += data.Messages['Error'][i] + '\n';

						BBL.ShowBubble( e, Message + '</div>', 'Left', 'CloseLink' );
					}
				}, 'json'
			);
			return(false);
		},
		UpdateFirstLastClass : function() {
			$('.STR_Container').each( function() {
				$(this).removeClass('FirstStrip').removeClass('LastStrip');
			} );

			$('.STR_Container:first').addClass('FirstStrip');
			$('.STR_Container:last').addClass('LastStrip');

			return(true);
		},
		MoveUp : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			$.post( PATH.Public + '/ajax/strip.move', { ComicID: Strip['ComicID'], Direction: 'up' }, 
				function( data ) {
					if ( data.Success ) {
						if ( $(e.target).parents('.STR_Container').hasClass('FirstStrip') ) {
							$('.STR_StripFrame:last').after( $(e.target).parents('.STR_StripFrame') );
							$('.Ad_C:first').before( $('.STR_StripFrame:first') );
						} else {
							$(e.target).parents('.STR_StripFrame').prevAll('.STR_StripFrame:first').before( $(e.target).parents('.STR_StripFrame') );
							$('.Ad_C:first').after( $('.STR_StripFrame:first').next('.STR_StripFrame') );
						}

						This.UpdateFirstLastClass();
					} else {
						var Message = '';
						for ( i in data.Messages['Error'] )
							Message += data.Messages['Error'][i] + '\n';

						alert( Message );
					}
				}, 'json'
			);
			return(false);
		},
		MoveDown : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			$.post( PATH.Public + '/ajax/strip.move', { ComicID: Strip['ComicID'], Direction: 'down' }, 
				function( data ) {
					if ( data.Success ) {
						if ( $(e.target).parents('.STR_Container').hasClass('LastStrip') ) {
							$('.STR_StripFrame:first').before( $(e.target).parents('.STR_StripFrame') );
							$('.Ad_C:first').after( $('.STR_StripFrame:first').next('.STR_StripFrame') );
						} else {
							$(e.target).parents('.STR_StripFrame').nextAll('.STR_StripFrame:first').after( $(e.target).parents('.STR_StripFrame') );
							$('.Ad_C:first').before( $('.STR_StripFrame:first') );
						}

						This.UpdateFirstLastClass();
					} else {
						var Message = '';
						for ( i in data.Messages['Error'] )
							Message += data.Messages['Error'][i] + '\n';

						alert( Message );
					}
				}, 'json'
			);
			return(false);
		},
		LoadStrip : function(e) {
			var Strip		= eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			var Direction	= ( $(e.target).hasClass('STR_Strip_Prev') ) ? 'Previous' : 'Next';
			var FirstStrip	= ( $(e.target).parents('.STR_Container').hasClass('FirstStrip') ) ? '&FirstStrip=1' : '';
			var LastStrip	= ( $(e.target).parents('.STR_Container').hasClass('LastStrip') ) ? '&LastStrip=1' : '';

			if ( $(e.target).parents('.STR_Container').find('.DefaultHeader' ).length ) {
				location.href = eval( 'Strip[\'Link_' + Direction + '\']' );
			} else {
				$( $(e.target).parents('.STR_StripFrame') ).load( PATH.Public + '/ajax/strip.load/?ComicID=' + Strip['ComicID'] + '&Header=Personalized&DateStrip=' + Strip['DateStrip'] + '&Direction=' + Direction + FirstStrip + LastStrip);
			}
			
			BBL.HideBubble();
			ADS.Load();
			return(false);
		},
		AddComic : function(e) {
			var Strip = eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			$.post( PATH.Public + '/ajax/strip.add_to_homepage/', { ComicID: Strip['ComicID'] },
				function( data ) {
					var Message = '<div style="padding: 5px;">';
					
					if ( data.Success ) {
						for ( i in data.Messages['Success'] )
							Message += data.Messages['Success'][i] + '<br />';
					} else {
						for ( i in data.Messages['Error'] )
							Message += data.Messages['Error'][i] + '<br />';
					}

					BBL.ShowBubble( e, Message + '</div>', 'Left', 'CloseLink' );

				}, 'json'
			);
		},
		ConfirmDeleteStrip : function(e) {
			var Strip	= eval('(' + $(e.target).parents('.STR_Container').attr('rel') + ')');
			var Data	=  eval('(' + $(e.target).parents('.FAV_Favorites').attr('rel') + ')');
			var Source	= $(e.target).attr('rel');
			var Confirm =	'<div align="center">' +
							'	Are you sure you want to delete this strip from your ' + Source + '?<br /><br />' +
							'	<a href="#" onclick="STR.DeleteStrip(event, ' + Strip['StripID'] + ', ' + Data['Page'] + ( ( Source == 'list' ) ? ', ' + Data['ListID'] : '' ) + '); return(false);"><img src="' + PATH.IMG + '/btn.strip.yes.gif" border="0" /></a>' +
							'	<a href="#" onclick="BBL.HideBubble(); return(false);"><img src="' + PATH.IMG + '/btn.strip.cancel.gif" border="0" /></a>' +
							'</div>';
			BBL.ShowBubble( e, Confirm, 'Left' );
		},
		DeleteStrip : function( event, StripID, Page ) {
			var PostVars = { StripID : StripID, Page : Page };
			if ( arguments[3] != null )
				PostVars['ListID'] = arguments[3];
			else if ( $('.STR_DeleteLinkThumb').length )
				PostVars['ThumbView'] = 1;


			$.post( PATH.Public + '/ajax/' + ( ( arguments[3] != null ) ? 'list.strip' : 'favorite' ) + '.delete.process/', PostVars, 
				function( Response ) {
					if ( Response.Success ) {
						location.href = Response.RedirectURL;
					} else {
						var Message = '<div style="padding: 5px;">';
						for ( i in Response.Messages['Error'] )
							Message += Response.Messages['Error'][i] + '\n';	
					}

					BBL.ShowBubble( event, Message + '<br /></div>', 'Right', 'CloseLink' );
				}, 'json'
			);
		},
		InitRating : function( RatingID, CurrentRating ) {
			$('.STR_Rating' + RatingID).rating('', {maxvalue:5,increment:.5, curvalue: CurrentRating});
		},
		AttachZoomHover : function(StripImage) {
			StripImage.parents('.STR_Comic').hover(
				function() {
					$(this).find('.STR_Zoom').fadeIn('normal');
				},
				function() {
					$(this).find('.STR_Zoom').css('display', 'none');
				}
			);

			StripImage.parents('.STR_Comic').find('.STR_Zoom').hover(
				function() {
					$(this).css('display', 'block');
				},
				function() { }
			);
		},
		HideMagnifier : function(e) {
			$(e.target).css('display', 'none');
		}
	};

	return This;
}
//------------------------------------------------------[TN]

// Ads -------------------------------------------------[MN]
var Ads = function() {
	var This = {
		AdList: [],

		Add: function( Selector, HTML ) {
			This.AdList.push( { Selector: Selector, HTML: HTML } );
		},

		Load: function() {
			for( var i=0; i<This.AdList.length; i++ ) {
				$( This.AdList[i].Selector ).html( This.AdList[i].HTML );

			}
		}
	};
	return This;
};
//------------------------------------------------------[MN]

// Message Bubble --------------------------------------[TN]
var MessageBubble = function() {
	var This = {
		ShowBubble: function( Event, Message ) {
			var Side = arguments[2] == 'Right' ? arguments[2] : '';

			var Top	= Event.pageY - 22 + 'px';
			if ( arguments[2] == 'Right' )
				var Left= Event.pageX  + 10 + 'px';
			else
				var Left= Event.pageX - 200 + 'px';

			This.HideBubble();
			var Close	= ( ( arguments[3] == 'CloseLink' ) ? ('<a href="#" onclick="BBL.HideBubble(); return(false);" class="BBL_Close' + Side + '"><span>close</span></a>') : '' );
			var HTML	=	'<div class="BBL_Container">' +
							'	<div class="BBL_Header' + Side + '">' +
							'		<div class="BBL_Message' + Side + '">' + Close + Message + '</div>' +
							'	</div>' +
							'	<div class="BBL_Footer' + Side + '"></div>' +
							'</div>';
			$( document.body ).append( HTML );

			$('.BBL_Container').css({'top': Top, 'left': Left}).fadeIn();

			return(false);
		},
		HideBubble: function() {
			$('.BBL_Container').fadeOut( 'normal', function() { $(this).remove(); } )
		}
	};
	return This;
}
//------------------------------------------------------[TN]

// Comments --------------------------------------------[TN]
var Comments = function(){ 
	var This = {
		Flag: function( e ) {
			var Comment		= eval('(' + $(e.target).parents('.CMT_Container').attr('rel') + ')');
			var HTML =	'<div class="CMT_FlagBubble">' +
						'	<form action="' + PATH.Public + '/ajax/comment.flag.process/" method="POST" onsubmit="$.post( $( this ).attr( \'action\' ), $( this ).serializeArray(), CMT.Flag_Callback ); return false;">'+
						'		<input type="hidden" name="CommentID" value="' + Comment['CommentID'] + '" />' +
						'		Reason:' +
						'		<textarea name="Reason" class="CMT_FlagReason"></textarea><br />' +
						'		<div align="center"><input type="image" src="' + PATH.IMG + '/btn.flag.gif" value="Flag" /></div>' +
						'	</form>' +
						'	<div class="CMT_FlagReturn"></div>' +
						'</div>';
				
				BBL.ShowBubble( e, HTML, 'Left', 'CloseLink' );

		},
		Flag_Callback: function( Response ) {
			eval( Response );
			var Message = '';
		
			if ( Response.Success ) {
				for ( i in Response.Messages['Success'] )
					Message += Response.Messages['Success'][i] + '<br />';

				$('.CMT_FlagReason').val('');

			} else {
				for ( i in Response.Messages['Error'] )
					Message += Response.Messages['Error'][i] + '<br />';
			}

			$('.CMT_FlagReturn').html( Message );
		},
		Rate : function( e ) {
			var Comment		= eval('(' + $(e.target).parents('.CMT_Container').attr('rel') + ')');
			var UserRating	= ( $(e.target).hasClass('CMT_ThumbUp') ) ? 1 : -1;
			$.post( PATH.Public + '/ajax/social.rate.process/', 
				{ TableID: Comment['CommentID'], Type: 'Comment', Rating: UserRating }, 
				function( Response ) { 
					var Message = '<div style="padding: 5px;">';
					
					if ( Response.Success ) {
						for ( i in Response.Messages['Success'] )
							Message += Response.Messages['Success'][i] + '<br />';

						BBL.ShowBubble( e, Message + '</div>', 'Right', 'CloseLink' );
						$(e.target).parents('.CMT_Rating').find('.CMT_Thumb' +  ( ( $(e.target).hasClass('CMT_ThumbUp') ) ? 'Down' : 'Up' ) ).remove();
						$(e.target).parents('.CMT_Rating').find('.CMT_CurrentRating').html( ( ( Response.Rating == 0 ) ? '' : ( ( Response.Rating < 0 ) ? '-' : '+' ) ) + Response.Rating );

					} else {
						for ( i in Response.Messages['Error'] )
							Message += Response.Messages['Error'][i] + '<br />';

						BBL.ShowBubble( e, Message + '</div>', 'Right', 'CloseLink' );
					}
				}, 
				'json' 
			);
			return(false);
		}
	};

	return This; 
};

//------------------------------------------------------[TN]

// Constructors ----------------------------------------[MN]
var MSG	= new FormMessage( { Prefix: 'MSG_' } );
var LOG	= new Login( { Prefix: 'LOG_' } );
var SCH	= new Search( { Prefix: 'SCH_' } );
var STR	= new StripContainer();
var ADS	= new Ads();
var BBL = new MessageBubble();
//------------------------------------------------------[MN]

// document ready --------------------------------------[TN]
$(document).ready( function() {
	// Login Form ------------------------------------------[TN]
	$(document.body).click( $.delegate({
		'.LoginLink' : function(Event) {
			LOG.ShowLogin(Event);
		}
	}));

	$('.LOG_CloseLink').click( function() {
		LOG.CloseLogin();
	});
	//------------------------------------------------------[TN]

	// Contact Us ------------------------------------------[TN]
	$('.ContactUsLink').click( function() {
		$.VPI_ModalBox( { Content_Type: 'iframe', Content: '/ajax/contact_us/' + ( ( $(this).html() == 'advertising' ) ? '?Subject=Advertising' : ''), Img_BasePath: PATH.IMG + '', Width: 800, BG_Class: 'VPI_ModalBox_Blank_Background' } );		
	});
	//------------------------------------------------------[TN]

	// Search Window ---------------------------------------[TN]
	$('.SearchLink').click( function( Event ) {
		SCH.ShowSearch( Event, $(this).attr('rel') );
	});
	//------------------------------------------------------[TN]

	// Header Nav ------------------------------------------[TN]
	$('.HDR_Nav').click( $.delegate({
		'.RSSLoggedIn' : function(e) {
			var Data = eval( '(' + $(e.target).attr('rel') + ')' );
			var UserID = Data['UserID'];

			var HTML = '<a href="#" class="HDR_RSSLink" onclick="javascript: $.VPI_ModalBox( { Content_Type: \'iframe\', Content: \'/ajax/user.subscription.edit/\', Img_BasePath: PATH.IMG + \'\', Width: 970, BG_Class: \'VPI_ModalBox_Background\' } ); return(false);" title="Click to Add/Edit Your RSS">Add/Edit RSS</a>';

			if ( !Data['EmptyFeed']  )
				HTML += '<br /><br /><a href="http://feeds.comics.com/comicsdaily?UserID=' + UserID + '" class="HDR_RSSLink" title="Click to View Your RSS"> View Your RSS</a>';

			BBL.ShowBubble( e, '<div style="' + ( (Data['EmptyFeed']) ? 'padding: 5px; ' : '' ) + 'text-align: center;">' + HTML + '</div>', 'Left', 'CloseLink' );
		},
		'.RSSNotLoggedIn' : function(e) {
			BBL.ShowBubble( e, '<div><a href="#" onclick="return(false);" class="LoginLink" title="Login">Login</a> or <a href="' + PATH.Public + '/register/" title="Register Now">register</a> now to personalize your RSS feed with all your favorite strips and editorial cartoons!</div>', 'Left', 'CloseLink' );
		},
		'.FAQLink' : function(e) {
			BBL.ShowBubble( e, '<div>Search by keyword, character name, title or tag</div>', 'Left', 'CloseLink' );
		}
	}));
	//------------------------------------------------------[TN]

	// Preferences -----------------------------------------[TN]
	$('.ShowPreferences').click( function( event ) {
		if ( VPI.IsLoggedIn )
			$.VPI_ModalBox( { Content_Type: 'iframe', Content: '/ajax/user.subscription.edit/', Img_BasePath: PATH.IMG + '', Width: 970, BG_Class: 'VPI_ModalBox_Background' } );
		else
			BBL.ShowBubble( event, '<div style="padding: 5px;">You must be logged in to perform this action.</div>', 'Left', 'CloseLink' );
	});
	//------------------------------------------------------[TN]

	// Fav Boxes -------------------------------------------[TN]
	$('.FAV_Boxes').click( $.delegate({
		'.MorePropertiesLink' : function(e) {
			var ComicIDs = eval( '(' + $(e.target).attr('rel') + ')' );

			var HTML = '';
			for ( i in ComicIDs )
				HTML += '<a href="' + ComicIDs[i]['URL'] + '" id="SCH_Link' + i + '" class="SCH_Link">' + ComicIDs[i]['Title'] + '</a><br />';

			BBL.ShowBubble( e, '<div>' + HTML + '</div>', 'Left', 'CloseLink' );
		}
	}));
	//------------------------------------------------------[TN]

	// Strip Container -------------------------------------[TN]
	$('.STR_StripFrame').click( $.delegate({
		'.STR_RatingStar' : function(e) {
			STR.Vote(e);
		},
		'.STR_PanelButton' : function(e) {
			STR.OpenPanel(e);
		},
		'.STR_PanelClose' : function(e) {
			STR.ClosePanels(e);
		},
		'.STR_TagSubmit' : function(e) {
			STR.TagSubmit(e);
		},
		'.STR_EmailSend' : function(e) {
			STR.EmailSubmit(e);
		},
		'.STR_EmailShowForm' : function(e) {
			STR.ShowEmailForm(e);	
		},
		'.STR_BtnPrint' : function(e) {
			STR.PrintStrip(e);
		},
		'.STR_SaveToFavorite' : function(e) {
			STR.SaveFavorite(e);
		},
		'.STR_SaveToList' : function(e) {
			STR.ShowListOptions(e);
		},
		'.STR_SaveListBack' : function(e) {
			STR.HideListOptions(e);
		},
		'.STR_ListSave' : function(e) {
			STR.ListSave(e);
		},
		'.STR_CopyEmbed' : function(e) {
			$.copy($(e.target).siblings('textarea[@name=EmbedCode]').val());
		},
		'.STR_RandomStripLink' : function(e) {
			STR.GetRandom(e);
		},
		'.STR_Remove' : function(e) {
			STR.RemoveStripConfirm(e);
		},
		'.STR_MoveUp' : function(e) {
			STR.MoveUp(e);
		},
		'.STR_MoveDown' : function(e) {
			STR.MoveDown(e);
		},
		'.STR_Strip_Prev' : function(e) {
			STR.LoadStrip(e);
		},
		'.STR_Strip_Next' : function(e) {
			STR.LoadStrip(e);
		},
		'.STR_AddComic' : function(e) {
			STR.AddComic(e);
		},
		'.STR_DeleteStrip' : function(e) {
			STR.ConfirmDeleteStrip(e);
		},
		'.STR_Zoom' : function(e) {
			STR.HideMagnifier(e);
		}
	}));
	//------------------------------------------------------[TN]
});
//------------------------------------------------------[TN]

