	$(document).ready(function() {
						
		$('#all_pics').click(function()	{
			$("a[name=imgHiddenClass]").show();
			$(this).toggle();
			$('#few_pics').toggle();
			return false;
		});
		$('#few_pics').click(function(){
			$("a[name=imgHiddenClass]").hide();
			$(this).toggle();
			$('#all_pics').toggle();
			return false;
		});
		
		$('#all_videos').click(function()	{
			$("a[name=videoHiddenClass]").show();
			$(this).toggle();
			$('#few_videos').toggle();
			return false;
		});
		$('#few_videos').click(function(){
			$("a[name=videoHiddenClass]").hide();
			$(this).toggle();
			$('#all_videos').toggle();
			return false;
		});
		
		$('#friends_view_all').click(function()	{
			$("#my_friends > div.hiddenClass").show();
			$(this).toggle();
			$('#friends_few_pics').toggle();
			return false;
		});
		$('#friends_few_pics').click(function(){
			$("#my_friends > div.hiddenClass").hide();
			$(this).toggle();
			$('#friends_view_all').toggle();
			return false;
		});
		
		// new comment
		$('#add_new_comment').click(function(){
			if ( $('#new_comment').val() == '' )
				display_error( 'Please write a comment.' );
			else{
				$('#comments_loader').show();
				no_history_server_post( { m : 'add_comment', comment : $('#new_comment').val() , id : user_id } , add_comment );
				$('#comments_loader').hide();
			}
			return false;
		});
		
		// show / hide videos
		$('#vid_hid_trigger').click(function(){
			$('[rel=vid_hid]').toggle();
			
			rel = $('#vid_hid_trigger').attr('rel');
			$('#vid_hid_trigger').attr( 'rel', $('#vid_hid_trigger').text() );
			$('#vid_hid_trigger').text( rel );
			
			return false;
		});
		
		$('#new_comment').keyup(function(){
			v = $(this).val(); l = v.length; x = parseInt(500 - l); if ( x < 1 ) x = '0';$('#chars_left').html(x);
			if ( l > 500 ) {
				$(this).val( v.substring(0,500) );
				return false;
			}
		});
	});

	// adds a comment to the comment section of the show, and refreshes the comments
	function add_comment( data )
	{
		if ( data['err'] )
			display_error( data['err'] );
		else {
			build_comments( 1 );
			$('#new_comment').val('');
		}
	}
	
	$(document).ready(function() {
		build_comments( page );
	});
	
	// build comments section
	function build_comments( lpage )
	{
		page = lpage;
		
		$('#comments').hide().empty().show().append( loader() );
		
		no_history_server_post( { m : 'build_comments' , page : lpage , user_id : user_id } , function( data ) {
			if ( data['err'] ) {
				display_error( data['err'] );
			}else if ( data['server'] &&  data['server']['comments'] ){
				
				$('#comments').hide().empty().append( data['server']['pagination'] );
				$('#comments').append( clearer(10) ).append( data['server']['comments'] ).append( data['server']['pagination'] ).show();
				
				
			}
		} );
		$('#comments_loader').hide();
	}
	
	
	function delete_comment(id)
	{
		if ( confirm('Are you sure you want to delete this comment ? ') ) {
			no_history_server_post( { m:'delete_comment', id:id },function() {
				build_comments( page );
			});
		}
		return false;
	}
	
	
	