	$(document).ready(function() {
						
		// new comment
		$('#add_new_comment').click(function(){
			v = $('#new_comment').val();
			if ( $('#new_comment').val() == '' )
				display_error( 'Please write a comment.' );
			else if ( v.length > 500 )
				display_error( 'Comment length must have MAXIMUM 500 chars.' );
			else{
				$('#comments_loader').show();
				no_history_server_post( { m : 'profile_comments', comment : $('#new_comment').val() , id : user_id, a:'add' } , add_comment );
				$('#comments_loader').hide();
			}
			return false;
		});
		
		$('#new_comment').keyup(function(){
			v = $(this).val(); x = v.length; 
			if ( x < 1 ) x = '0';
			$('#no_chars').html(x);
		});
		
	});

	// adds a comment to the comment section of the show, and refreshes the comments
	function add_comment( data )
	{
		if ( data['err'] )
			alert( data['err'] );
		else {
			profile_comments( 1 );
			$('#new_comment').val('');
		}
	}
	
	function profile_comments(lpage){ build_box_content( lpage , 'profile_comments' ) }
	function profile_vod(lpage){ build_box_content( lpage , 'profile_vod' ) }
	function profile_images(lpage){ build_box_content( lpage , 'profile_images' ) }
	function profile_friends(lpage){ build_box_content( lpage , 'profile_friends' ) }
	
	function build_box_content( lpage , type )
	{
		page = lpage;
		$('#' + type).empty().append( loader() );
		
		no_history_server_post( { m : type , page : lpage , user_id : user_id } , function( data ) {
			if ( data['err'] )
				display_error( data['err'] );
			else
				$('#' + type ).empty().append( data['content'] );
				
			$('a[rel*=lightbox]').lightBox();
			
			if ( typeof do_footer == 'function' )
				do_footer();
		} );
	}
	
	
	
	function delete_comment(id)
	{
		if ( confirm('Are you sure you want to delete this comment ? ') ) {
			no_history_server_post( { m:'profile_comments', id:id, a:'delete' },function() {
				profile_comments( page );
			});
		}
		return false;
	}
	
	
	

