$(document).ready(function() {
	$("#tab-head li a").click(function() {
		$("#tab-head li.active").removeClass("active");
		$(this).parent().addClass("active");

		var tablename0 = $(this).attr("href");
		var tablename = tablename0.substring(1, tablename0.length);
		$("#comments-list table:visible").hide();
		$("#comments-list table#"+tablename).show();
		return false;
	});
			
	$("#photos-comment a[title]").tooltip({
		track: true, 
    	delay: 0, 
    	showURL: false, 
    	showBody: " - ", 
    	fade: 250 
	});
			
	$("#users-comment a[title]").tooltip({
		track: true, 
    	delay: 0, 
    	showURL: false, 
    	showBody: " - ", 
    	fade: 250 
	});
			
	$("#photolist a[title]").tooltip({
		track: true, 
    	delay: 0, 
    	showURL: false, 
    	showBody: " - ", 
    	fade: 250 
	});
			
	$("#albumlist a[title]").tooltip({
		track: true, 
    	delay: 0, 
    	showURL: false, 
    	showBody: " - ", 
    	fade: 250 
	});
			
	$("#minilist a[title]").tooltip({
		track: true, 
    	delay: 0, 
    	showURL: false, 
    	showBody: " - ", 
    	fade: 250 
	});
			
	$("#user-watch a[title]").tooltip({
		track: true, 
    	delay: 0, 
    	showURL: false, 
    	showBody: " - ", 
    	fade: 250 
	});
			
	$("#users-watch a[title]").tooltip({
		track: true, 
    	delay: 0, 
    	showURL: false, 
    	showBody: " - ", 
    	fade: 250 
	});
	
	if ($('#user-watch > .options img:gt(4)').css('display') == 'none' || hiddenWatchPersons.length > 0) {
			$('#user-watch').append("<p class=\"more\"><a href=\"#\">Zobacz wszystkich</a></p>");
		}
	showWatchPersons();
		
		if ($('#users-watch > .options img:gt(4)').css('display') == 'none' || hiddenWatchUser.length > 0) {
			$('#users-watch').append("<p class=\"more\"><a href=\"#\">Zobacz wszystkich</a></p>");
		}
	showWatchUser();
			
});
		
		
	function showWatchPersons() {
		$('#user-watch  .more a').click(function() {
			if (hiddenWatchPersons.length > 0) {
				$(this).text("Zwiń");
				addHiddenImagesWatchPersons(hiddenWatchPersons);
				hiddenWatchPersons = new Array();
				
			} else if ($('#user-watch .options img:gt(4)').css('display') == 'none') {
				$('#user-watch .options img:gt(4)').show();
				$(this).text("Zwiń");
			} else {
				$('#user-watch .options img:gt(4)').hide();
				$(this).text("Zobacz wszystkich");
			} 
			return false;
		});
	}
	
	function showWatchUser() {
		$('#users-watch .more a').click(function() {
			if (hiddenWatchUser.length > 0) {
				$(this).text("Zwiń");
				addHiddenImagesWatchUser(hiddenWatchUser);
				hiddenWatchUser = new Array();
			} else if ($('#users-watch .options img:gt(4)').css('display') == 'none') {
				$('#users-watch .options img:gt(4)').show();
				$(this).text("Zwiń");
			} else {
				$('#users-watch .options img:gt(4)').hide();
				$(this).text("Zobacz wszystkich");
			} 
			return false;
		});
	}
	
	function addHiddenImagesWatchPersons(infoAr) {
		for (var i=0;i<infoAr.length;i++) {
			$('#user-watch .options').append('<a href="'+infoAr[i][0]+'" title="&lt;strong&gt;'+infoAr[i][2]+'&lt;/strong&gt;"><img class="avatar" src="'+infoAr[i][1]+'" alt="" title="'+infoAr[i][2]+'" /></a>');
		}
		return 1;
	}
	
	function addHiddenImagesWatchUser(infoAr) {
		for (var i=0;i<infoAr.length;i++) {
			$('#users-watch .options').append('<a href="'+infoAr[i][0]+'" title="&lt;strong&gt;'+infoAr[i][2]+'&lt;/strong&gt;"><img class="avatar" src="'+infoAr[i][1]+'" alt="" title="'+infoAr[i][2]+'" /></a>');
		}
		return 1;
	} 
